diff --git a/.gitignore b/.gitignore index 2d6b5c906e652e652cc7d411e24f013daa96d230..a501e07a142b357502f5b77c1e05a1be57f7480f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +################### +# Custom ignore rules snippets/ binarycpython_snippets core @@ -13,6 +15,9 @@ binarycpython_snippets -1.log reports/ docs/examples/ +custom_logging.dwo + +################################ # Standard template *.org~ *.so @@ -24,8 +29,6 @@ output/* *.swp .python-version \#* - - __pycache__/ .ipynb_checkpoints/ @@ -161,3 +164,5 @@ media/ db.sqlite3 *.swp + +*~ diff --git a/CHANGELOG b/CHANGELOG index d8c9186dee06429c74c35f9d4804a4ef4bec0912..8bb534010dc9926abc53832402573f77e4a7f3e4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,3 +29,14 @@ https://keepachangelog.com/en/0.3.0/ - dictionary utility functions put into dicts.py - some new functions to parse recursively dict keys and/or values that are faster than David's, but probably not as flexible. When these are all you need, they're more efficient. - added a few new Jupyter notebooks + +* 0.9.3: +- Changed the python version requirement to be 3.9+ (using 3.9.9) +- Restructured the population grid object by splitting off functions that belong in the same category and storing them in a mixin-class within the population_extensions/ dir. +- Made the Population object available via "from binarycpython import Population" +- merged the HPC branch: + - added Condor support + - added Slurm support + - Fixed JSON load(s) to not convert to ASCII hence preserve UTF-8 and hopefully be faster. + - Made sure file loads/saves use UTF-8 + - Fixed version dict to include units section and cleaned up a few other unit handlers diff --git a/HOW_TO_CONTRIBUTE b/HOW_TO_CONTRIBUTE index d9f7329c6704825e4c7ae154b9a89d628a84a7bb..99efb7a61ea29a64ea61ff0e8ca0243f74af482d 100644 --- a/HOW_TO_CONTRIBUTE +++ b/HOW_TO_CONTRIBUTE @@ -1,6 +1,4 @@ -You can contribute by contacting me (David) or Rob and asking what needs to be done, +You can contribute by contacting Rob Izzard (r.izzard@surrey.ac.uk) or David Hendriks (davidhendriks93@gmail.com) and asking what needs to be done, -Or resolve one of the many TODOs that are scattered throughout the code. - -Probably best to discuss with us first before making pull requests though. +There are many TODO items scattered throughout the codebase, but its probably best to discuss with us first before making pull requests though. diff --git a/MANIFEST.in b/MANIFEST.in index eb758555d885b8927ad5c098b9f21de402620523..325950da7de08249697a3960ba06d1ec480bb0ea 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,3 +3,4 @@ include src/*.c include include/*.h include README.md include VERSION +include requirements.txt \ No newline at end of file diff --git a/README.md b/README.md index 4d0dc5b92ef07bdad8ee37fd78372c5f4c512691..c2d27fc9281a6e8edec4d243e3972f349cfd5c6c 100644 --- a/README.md +++ b/README.md @@ -4,28 +4,27 @@ Docstring coverage: Test coverage:  -Binary population synthesis code that interfaces with binary_c. Based on a original work by Jeff Andrews (can be found in old_solution/ directory). Updated and extended for Python3 by David Hendriks, Robert Izzard. +Powered by: + -The current release is version [version](VERSION), make sure to use that version number when installing! +We present our package [binary-c-python](https://ri0005.pages.surrey.ac.uk/binary_c-python/), a population synthesis code which is aimed to provide a convenient and easy-to-use interface to the [binary_c](http://personal.ph.surrey.ac.uk/~ri0005/doc/binary_c/binary_c.html) framework, allowing the user to rapidly evolve single stellar systems and populations of star systems. Based on a early work by Jeff Andrews. Updated and extended for Python3 by David Hendriks, Robert Izzard. -## Requirements -To run this code you need to at least have installations of: +binary_c-python is developed for students and scientists in the field of stellar astrophysics, who want to study the evolution of individual or populations of single and binary star systems (see the example use-case notebooks in the [online documentation](https://ri0005.pages.surrey.ac.uk/binary_c-python/example_notebooks.html). + +The current release is version [version](VERSION), and is designed and tested to work with binary_c version 2.2.1 (for older or newer versions we can't guarantee correct behaviour). + +## Installation +To install binary_c-python we need to make sure we meet the requirements of installation, and -- Python 3.6 or higher -- binary_c version 2.1.7 or higher +### Python requirements +To run this code you need to at least have installations of: -And the following python packages (which will get installed automatically when installing with pip): +- Python 3.7 or higher (3.6 is EOL, and we are using 3.9 for development) +- binary_c version 2.2.0 or higher -- numpy -- pytest -- h5py -- pathos -- pandas -- astropy -- matplotlib -- py_rinterpolate +The packages that are required for this code to run are listed in the requirements.txt, which automatically gets read out by setup.py -## Environment variables +### Environment variables Before compilation you need to have certain environment variables: Required: @@ -35,8 +34,8 @@ Required: - `LIBRARY_PATH` should include whatever directories are required to build binary_c (e.g. locations of libgsl, libmemoize, librinterpolate, etc.) - `GSL_DIR` should point to the root location where you installed GSL to. This root dir should contain `bin/`, `lib/` etc -## Build instructions -First, make sure you have built binary_c (See `$BINARY_C/doc/binary_c2.pdf` section: installation for all the installation instructions for `binary_c`)) and that it functions correctly. +### Build instructions +First, make sure you have built binary_c (See `$BINARY_C/doc/binary_c2.pdf` section: installation for all the installation instructions for `binary_c`)) and that it functions correctly. ### Installation via PIP: To install this package via pip: @@ -44,32 +43,35 @@ To install this package via pip: ``` pip install binarycpython ``` -This will install the latest stable installation that is available on pip. + +This will install the latest stable installation that is available on Pip. The version on the master branch should be the same version as the latest stable version on Pip ### Installation from source: -We can also install the package from source, which is useful for development versions and when you want to modify the code. It is recommended that you install this into a virtual environment. From within the root directory, run +We can also install the package from source, which is useful for development versions and when you want to modify the code. It is recommended that you install this into a virtual environment. From within the `commands/` directory, run + ``` ./install.sh ``` -This will install the package, along with all the dependencies. -If this is not the first time you install the package, but rather rebuild it because you made changes in either binary_c or binarycpython, you can run -``` -./install_without_dependencies.sh -``` -to reinstall just binarycpython. +This will install the package, along with all the dependencies, into the current active (virtual) python environment. -#### After installation +#### After installation from source After installing the code via source it is useful to run the test suite before doing any programming with it. The test suite is stored in `binarycpython/tests` and running `python main.py` in there will run all the tests. -## Examples +### Use of code without installation +Because installing `binary_c-python` requires a working installation of `binary_c`, installing via pip or from source without this working installation of `binary_c` won't work. To still make use of some of the functions provided by `binary_c-python`, you can add the path to the code-base to your `PYTHONPATH`: +- Download `binary_c-python`, via e.g. `git clone https://gitlab.com/binary_c/binary_c-python.git` +- Add the path to the downloaded repo to your `$PYTHONPATH`, via e.g. `export PYTHONPATH="~/binary_c-python:$PYTHONPATH"` + +## Usage +### Examples See the examples/ directory for example scripts and notebooks. The documentation contains example pages as well. -## Usage notes +### Usage notes Make sure that with every change/recompilation you make in `binary_c`, you also rebuild this package. Whenever you change the sourcecode of this package, you need to reinstall it into your virtualenvironment as well -## Documentation -Look in the docs/ directory. Within the build/html/ there is the html version of the documentation. The +### Documentation +Look in the docs/ directory. Within the build/html/ there is the html version of the documentation. The documentation is also hosted on http://personal.ph.surrey.ac.uk/~ri0005/doc/binary_c/binary_c.html but only for the most recent stable release. ## Development: If you want to contribute to the code, then it is recommended that you install the packages in `development_requirements.txt`: @@ -78,7 +80,32 @@ If you want to contribute to the code, then it is recommended that you install t pip install -r development_requirements.txt ``` +Please do not hesitate to contact us to discuss any developments. + +### Generating documentation +To build the documentation manually, run + +``` +./generate_docs.sh +``` + +from within the `commands/` directory + +### Generating docstring and test coverage report +To generate the unit test and docstring coverage report, run + +``` +./generate_reports.sh +``` + +from within the `commands/` directory + +### Running unit tests +There are two versions of the general unit tests. The first includes only the actual code of the project, and is located at `binarycpython/test/main.py`. The second includes the tutorial notebooks, and is located at `binarycpython/test/main_with_notebooks.py`. To run just the notebook tests run `python binarycpython/tests/test_notebooks.py` + ## FAQ/Issues: +Here we provide a non-exhaustive list of some issues we encountered and solutions for these: + Building issues with binary_c itself: - see the documentation of binary_c (in doc/). - If you have MESA installed, make sure that the `$MESASDK_ROOT/bin/mesasdk_init.sh` is not sourced. It comes with its own version of some programs, and those can interfere with installing. diff --git a/badges/test_coverage.svg b/badges/test_coverage.svg index dfb99a19bbb554f31bc566f509dce7df5d8bb40d..a4262d340358b7051e60330569727e5a2d1695f9 100644 --- a/badges/test_coverage.svg +++ b/badges/test_coverage.svg @@ -15,7 +15,7 @@ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text> <text x="31.5" y="14">coverage</text> - <text x="80" y="15" fill="#010101" fill-opacity=".3">67%</text> - <text x="80" y="14">67%</text> + <text x="80" y="15" fill="#010101" fill-opacity=".3">69%</text> + <text x="80" y="14">69%</text> </g> </svg> diff --git a/binarycpython/__init__.py b/binarycpython/__init__.py index d0b3153d7a6216136e5f039ba80ae6f964549f0a..5d82f47b270e7d0a3e133c27d941ba69ae8ce0fa 100644 --- a/binarycpython/__init__.py +++ b/binarycpython/__init__.py @@ -1,3 +1,7 @@ """ Init function for binarycpython module + +Make population accessible here """ + +from binarycpython.utils.grid import Population diff --git a/binarycpython/tests/__init__.py b/binarycpython/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/binarycpython/tests/example.ipynb b/binarycpython/tests/example.ipynb deleted file mode 100644 index 57ce0148138a19e0c9cffd6872673c3f44d627d7..0000000000000000000000000000000000000000 --- a/binarycpython/tests/example.ipynb +++ /dev/null @@ -1,95 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "fd5b1a83-7212-4aca-b317-991bf289fba8", - "metadata": {}, - "outputs": [], - "source": [ - "def add(a, b):\n", - " return a + b" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "4d842395-3e17-48e8-b613-9856365e9796", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "11" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "add(5, 6)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "f2afc967-a66a-4a47-bfc5-0d6c17826794", - "metadata": {}, - "outputs": [ - { - "ename": "ZeroDivisionError", - "evalue": "division by zero", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-3-bc757c3fda29>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;36m1\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" - ] - } - ], - "source": [ - "1 / 0" - ] - }, - { - "cell_type": "markdown", - "id": "8491b29d-375d-458f-8a46-fc822422d8f3", - "metadata": {}, - "source": [ - "hello" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "601a89e6-5ca6-4725-8834-5e975ba76726", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.4" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/binarycpython/tests/main.py b/binarycpython/tests/main.py index 9725fd0f2a7681ba9b031a6eab582e20b6b2d453..a5d43085c7b52e905c25c0f9fdcd8f619db012a3 100755 --- a/binarycpython/tests/main.py +++ b/binarycpython/tests/main.py @@ -1,22 +1,178 @@ # /usr/bin/env python """ -Main file for the tests. This file imports all the combined_test functions from all files. +Main file for the tests. This file imports all the unit test functions from all modules except for the notebooks and for the HPC functions """ +# pylint: disable=W0611 + import unittest -from binarycpython.tests.test_c_bindings import * -from binarycpython.tests.test_custom_logging import * -from binarycpython.tests.test_distributions import * -from binarycpython.tests.test_functions import * -from binarycpython.tests.test_grid import * -from binarycpython.tests.test_hpc_functions import * -from binarycpython.tests.test_plot_functions import * +from binarycpython.tests.test_c_bindings import ( + test_run_system, + test_return_store_memaddr, + test_ensemble_functions, +) +from binarycpython.tests.test_custom_logging import ( + test_autogen_C_logging_code, + test_binary_c_log_code, + test_binary_c_write_log_code, + test_from_binary_c_config, + test_return_compilation_dict, + test_create_and_load_logging_function, +) +from binarycpython.tests.test_dicts import ( + test_merge_dicts, + test_setopts, + test_AutoVivicationDict, + test_inspect_dict, + test_custom_sort_dict, + test_filter_dict, + test_filter_dict_through_values, + test_prepare_dict, + test_normalize_dict, + test_multiply_values_dict, + test_count_keys_recursive, + test_keys_to_floats, + test_recursive_change_key_to_float, + test_recursive_change_key_to_string, + test_multiply_float_values, + test_subtract_dicts, + test_update_dicts, + test__nested_get, +) +from binarycpython.tests.test_ensemble import ( + test_binaryc_json_serializer, + test_handle_ensemble_string_to_json, + test_BinarycEncoder, + test_BinarycDecoder, + test_extract_ensemble_json_from_string, + test_load_ensemble, + test_ensemble_file_type, + test_open_ensemble, +) +from binarycpython.tests.test_functions import ( + test_verbose_print, + test_temp_dir, + test_remove_file, + test_create_hdf5, + test_output_lines, + test_example_parse_output, + test_get_defaults, + test_get_arg_keys, + test_create_arg_string, + test_get_help, + test_get_help_all, + test_get_help_super, + test_make_build_text, + test_write_binary_c_parameter_descriptions_to_rst_file, + test_bin_data, +) +from binarycpython.tests.test_grid import ( + test__setup, + test_set, + test_cmdline, + test__return_argline, + test_return_population_settings, + test_return_binary_c_defaults, + test_return_all_info, + test_export_all_info, + test__cleanup_defaults, + test__increment_probtot, + test__increment_count, + test__dict_from_line_source_file, + test_evolve_single, + test_grid_evolve, + test_resultdict, +) +from binarycpython.tests.test_plot_functions import ( + test_color_by_index, + test_plot_system, +) from binarycpython.tests.test_run_system_wrapper import * -from binarycpython.tests.test_spacing_functions import * -from binarycpython.tests.test_useful_funcs import * -from binarycpython.tests.test_grid_options_defaults import * + +from binarycpython.tests.tests_population_extensions.test_distribution_functions import ( + test_flat, + test_number, + test_const_distribution, + test_powerlaw, + test_three_part_power_law, + test_Kroupa2001, + test_ktg93, + test_imf_tinsley1980, + test_imf_scalo1986, + test_imf_scalo1998, + test_imf_chabrier2003, + test_duquennoy1991, + test_gaussian, + test_Arenou2010_binary_fraction, + test_raghavan2010_binary_fraction, + test_Izzard2012_period_distribution, + test_flatsections, + test_sana12, +) +from binarycpython.tests.tests_population_extensions.test_grid_options_defaults import ( + test_grid_options_help, + test_grid_options_description_checker, + test_write_grid_options_to_rst_file, +) + +from binarycpython.tests.tests_population_extensions.test_version_info import ( + test_return_binary_c_version_info, + test_parse_binary_c_version_info, +) +from binarycpython.tests.tests_population_extensions.test_gridcode import ( + test_add_grid_variable, +) + +from binarycpython.tests.tests_population_extensions.test_HPC import ( + test_HPC_njobs, + test_HPC_job, + test_HPC_job_type, + test_HPC_jobID, + test_HPC_jobID_tuple, + test_HPC_dirs, + test_HPC_id_filename, + test_HPC_check_requirements, + test_HPC_set_status, + test_HPC_get_status, + test_HPC_job_task, + test_HPC_dir, + test_HPC_id_from_dir, +) +from binarycpython.tests.tests_population_extensions.test_condor import ( + test_condorID, + test_condor_dirs, + test_condor_check_requirements, + test_set_condor_status, + test_get_condor_status, + test_condor_outfile, + test_make_condor_dirs, +) +from binarycpython.tests.tests_population_extensions.test_slurm import ( + test_slurmID, + test_slurm_dirs, + test_slurm_check_requirements, + test_set_slurm_status, + test_get_slurm_status, + test_slurm_outfile, + test_make_slurm_dirs, +) + from binarycpython.tests.test_stellar_types import * +from binarycpython.tests.test_useful_funcs import ( + test_calc_period_from_sep, + test_calc_sep_from_period, + test_roche_lobe, + test_ragb, + test_rzams, + test_zams_collission, +) + + +# from binarycpython.tests.test_spacing_functions import * +# from binarycpython.tests.test_grid_options_defaults import * +# from binarycpython.tests.test_hpc_functions import * + if __name__ == "__main__": unittest.main() diff --git a/binarycpython/tests/test_c_bindings.py b/binarycpython/tests/test_c_bindings.py index 2fc163d8700d259e405cbe735ed3f1320ceb4759..65ddd3252142ea891717704ff1ad8d416b91b247 100644 --- a/binarycpython/tests/test_c_bindings.py +++ b/binarycpython/tests/test_c_bindings.py @@ -19,7 +19,7 @@ from binarycpython.utils.functions import ( Capturing, ) from binarycpython.utils.ensemble import ( - binarycDecoder, + BinarycDecoder, handle_ensemble_string_to_json, extract_ensemble_json_from_string, ) @@ -119,8 +119,6 @@ class test_run_system(unittest.TestCase): ### memaddr test ####################################################################################################################################################### -# TODO: Make some assertion tests in c - class test_return_store_memaddr(unittest.TestCase): """ @@ -156,7 +154,7 @@ class test_return_store_memaddr(unittest.TestCase): ####################################################################################################################################################### -class TestEnsemble(unittest.TestCase): +class test_ensemble_functions(unittest.TestCase): """ Unittests for handling the ensemble outputs and adding those """ @@ -165,7 +163,7 @@ class TestEnsemble(unittest.TestCase): """ init function """ - super(TestEnsemble, self).__init__(*args, **kwargs) + super(test_ensemble_functions, self).__init__(*args, **kwargs) def test_return_persistent_data_memaddr(self): with Capturing() as output: @@ -180,9 +178,6 @@ class TestEnsemble(unittest.TestCase): output = _binary_c_bindings.return_persistent_data_memaddr() self.assertTrue(is_capsule(output), msg="Object must be a capsule") - # self.assertNotEqual( - # output, 0, "memory adress seems not to have a correct value" - # ) def test_minimal_ensemble_output(self): with Capturing() as output: @@ -442,14 +437,13 @@ class TestEnsemble(unittest.TestCase): ############# - # def test_full_ensemble_output(self): - # with Capturing() as output: - # self._test_full_ensemble_output() + def test_full_ensemble_output(self): + with Capturing() as output: + self._test_full_ensemble_output() def _test_full_ensemble_output(self): """ Function to just output the whole ensemble - TODO: put this one back """ print(self.id()) @@ -466,13 +460,12 @@ class TestEnsemble(unittest.TestCase): # output_json_1 = extract_ensemble_json_from_string(output_1) - keys = json_1.keys() + keys = output_json_1.keys() # assert statements: self.assertIn("number_counts", keys) self.assertIn("HRD", keys) self.assertIn("HRD(t)", keys) - self.assertIn("Xyield", keys) self.assertIn("distributions", keys) self.assertIn("scalars", keys) diff --git a/binarycpython/tests/test_custom_logging.py b/binarycpython/tests/test_custom_logging.py index d5068984929c1666560afaf9592900ad9d75b770..4b30ae48d0889c2ea371b4812f19ba9d9dc090d5 100644 --- a/binarycpython/tests/test_custom_logging.py +++ b/binarycpython/tests/test_custom_logging.py @@ -10,9 +10,9 @@ from binarycpython.utils.functions import Capturing TMP_DIR = temp_dir("tests", "test_custom_logging") -class test_custom_logging(unittest.TestCase): +class test_autogen_C_logging_code(unittest.TestCase): """ - Unit test for the custom_logging module + Unit test class for autogen_C_logging_code """ def test_autogen_C_logging_code(self): @@ -48,6 +48,12 @@ class test_custom_logging(unittest.TestCase): output_3 = autogen_C_logging_code(input_dict_3, verbosity=1) self.assertEqual(output_3, None, msg="Output should be None") + +class test_binary_c_log_code(unittest.TestCase): + """ + Unit test for binary_c_log_code + """ + def test_binary_c_log_code(self): with Capturing() as output: self._test_binary_c_log_code() @@ -72,6 +78,12 @@ class test_custom_logging(unittest.TestCase): msg="Output does not match what it should be: {}".format(test_value_2), ) + +class test_binary_c_write_log_code(unittest.TestCase): + """ + Unit test for binary_c_write_log_code + """ + def test_binary_c_write_log_code(self): with Capturing() as output: self._test_binary_c_write_log_code() @@ -98,6 +110,12 @@ class test_custom_logging(unittest.TestCase): content_file = repr(f.read()) self.assertEqual(repr(input_1), content_file, msg="Contents are not similar") + +class test_from_binary_c_config(unittest.TestCase): + """ + Unit test for from_binary_c_config + """ + def test_from_binary_c_config(self): with Capturing() as output: self._test_from_binary_c_config() @@ -131,6 +149,12 @@ class test_custom_logging(unittest.TestCase): msg="binary_c version doesnt match", ) + +class test_return_compilation_dict(unittest.TestCase): + """ + Unit test for return_compilation_dict + """ + def test_return_compilation_dict(self): with Capturing() as output: self._test_return_compilation_dict() @@ -152,6 +176,12 @@ class test_custom_logging(unittest.TestCase): self.assertTrue("libs" in output) self.assertTrue("inc" in output) + +class test_create_and_load_logging_function(unittest.TestCase): + """ + Unit test for return_compilation_dict + """ + def test_create_and_load_logging_function(self): with Capturing() as output: self._test_create_and_load_logging_function() diff --git a/binarycpython/tests/test_dicts.py b/binarycpython/tests/test_dicts.py new file mode 100644 index 0000000000000000000000000000000000000000..8d12b7caa0f00e6173033ba032ce58e9b9fa9fd8 --- /dev/null +++ b/binarycpython/tests/test_dicts.py @@ -0,0 +1,769 @@ +""" +Unittests for dicts module + +TODO: _nested_set +""" + +import os +import unittest +from collections import OrderedDict + +from binarycpython.utils.functions import ( + temp_dir, + Capturing, +) +from binarycpython.utils.dicts import ( + merge_dicts, + set_opts, + AutoVivificationDict, + inspect_dict, + normalize_dict, + filter_dict, + filter_dict_through_values, + prepare_dict, + custom_sort_dict, + multiply_values_dict, + keys_to_floats, + count_keys_recursive, + recursive_change_key_to_float, + recursive_change_key_to_string, + multiply_float_values, + subtract_dicts, + update_dicts, + _nested_get, + _nested_set, +) + +TMP_DIR = temp_dir("tests", "test_dicts") + + +class dummy: + """ + Dummy class to be used in the merge_dicts + """ + + def __init__(self, name): + """ + init + """ + self.name = name + + def __str__(self): + """ + str returns self.name + """ + return self.name + + +class test_merge_dicts(unittest.TestCase): + """ + Unittests for function merge_dicts + """ + + def test_empty(self): + with Capturing() as output: + self._test_empty() + + def _test_empty(self): + """ + Test merging an empty dict + """ + + input_dict = { + "int": 1, + "float": 1.2, + "list": [1, 2, 3], + "function": os.path.isfile, + "dict": {"int": 1, "float": 1.2}, + } + dict_2 = {} + output_dict = merge_dicts(input_dict, dict_2) + self.assertTrue(output_dict == input_dict) + + def test_unequal_types(self): + with Capturing() as output: + self._test_unequal_types() + + def _test_unequal_types(self): + """ + Test merging unequal types: should raise valueError + """ + + dict_1 = {"input": 10} + dict_2 = {"input": "hello"} + + self.assertRaises(ValueError, merge_dicts, dict_1, dict_2) + + def test_bools(self): + with Capturing() as output: + self._test_bools() + + def _test_bools(self): + """ + Test merging dict with booleans + """ + + dict_1 = {"bool": True} + dict_2 = {"bool": False} + output_dict = merge_dicts(dict_1, dict_2) + + self.assertTrue(isinstance(output_dict["bool"], bool)) + self.assertTrue(output_dict["bool"]) + + def test_ints(self): + with Capturing() as _: + self._test_ints() + + def _test_ints(self): + """ + Test merging dict with ints + """ + + dict_1 = {"int": 2} + dict_2 = {"int": 1} + output_dict = merge_dicts(dict_1, dict_2) + + self.assertTrue(isinstance(output_dict["int"], int)) + self.assertEqual(output_dict["int"], 3) + + def test_floats(self): + with Capturing() as output: + self._test_floats() + + def _test_floats(self): + """ + Test merging dict with floats + """ + + dict_1 = {"float": 4.5} + dict_2 = {"float": 4.6} + output_dict = merge_dicts(dict_1, dict_2) + + self.assertTrue(isinstance(output_dict["float"], float)) + self.assertEqual(output_dict["float"], 9.1) + + def test_lists(self): + with Capturing() as output: + self._test_lists() + + def _test_lists(self): + """ + Test merging dict with lists + """ + + dict_1 = {"list": [1, 2]} + dict_2 = {"list": [3, 4]} + output_dict = merge_dicts(dict_1, dict_2) + + self.assertTrue(isinstance(output_dict["list"], list)) + self.assertEqual(output_dict["list"], [1, 2, 3, 4]) + + def test_dicts(self): + with Capturing() as _: + self._test_dicts() + + def _test_dicts(self): + """ + Test merging dict with dicts + """ + + dict_1 = {"dict": {"same": 1, "other_1": 2.0}} + dict_2 = {"dict": {"same": 2, "other_2": [4.0]}} + output_dict = merge_dicts(dict_1, dict_2) + + self.assertTrue(isinstance(output_dict["dict"], dict)) + self.assertEqual( + output_dict["dict"], {"same": 3, "other_1": 2.0, "other_2": [4.0]} + ) + + def test_unsupported(self): + with Capturing() as output: + self._test_unsupported() + + def _test_unsupported(self): + """ + Test merging dict with unsupported types. should raise ValueError + """ + + dict_1 = {"new": dummy("david")} + dict_2 = {"new": dummy("gio")} + + # output_dict = merge_dicts(dict_1, dict_2) + self.assertRaises(ValueError, merge_dicts, dict_1, dict_2) + + +class test_setopts(unittest.TestCase): + """ + Unit test class for setopts + """ + + def test_setopts(self): + with Capturing() as output: + self._test_setopts() + + def _test_setopts(self): + """ + Unittest for function set_opts + """ + + default_dict = {"m1": 2, "m2": 3} + output_dict_1 = set_opts(default_dict, {}) + self.assertTrue(output_dict_1 == default_dict) + + new_opts = {"m1": 10} + output_dict_2 = set_opts(default_dict, new_opts) + updated_dict = default_dict.copy() + updated_dict["m1"] = 10 + + self.assertTrue(output_dict_2 == updated_dict) + + +class test_AutoVivicationDict(unittest.TestCase): + """ + Unittests for AutoVivicationDict + """ + + def test_add(self): + """ + Tests to see if the adding is done correctly + """ + + result_dict = AutoVivificationDict() + + result_dict["a"]["b"]["c"] += 10 + + self.assertEqual(result_dict["a"]["b"]["c"], 10) + result_dict["a"]["b"]["c"] += 10 + self.assertEqual(result_dict["a"]["b"]["c"], 20) + + +class test_inspect_dict(unittest.TestCase): + """ + Unittests for function inspect_dict + """ + + def test_compare_dict(self): + with Capturing() as output: + self._test_compare_dict() + + def _test_compare_dict(self): + """ + Test checking if inspect_dict returns the correct structure by comparing it to known value + """ + + input_dict = { + "int": 1, + "float": 1.2, + "list": [1, 2, 3], + "function": os.path.isfile, + "dict": {"int": 1, "float": 1.2}, + } + output_dict = inspect_dict(input_dict) + compare_dict = { + "int": int, + "float": float, + "list": list, + "function": os.path.isfile.__class__, + "dict": {"int": int, "float": float}, + } + self.assertTrue(compare_dict == output_dict) + + def test_compare_dict_with_print(self): + with Capturing() as output: + self._test_compare_dict_with_print() + + def _test_compare_dict_with_print(self): + """ + Test checking output is printed + """ + + input_dict = { + "int": 1, + "float": 1.2, + "list": [1, 2, 3], + "function": os.path.isfile, + "dict": {"int": 1, "float": 1.2}, + } + _ = inspect_dict(input_dict, print_structure=True) + + +class test_custom_sort_dict(unittest.TestCase): + """ + Unittests for function custom_sort_dict + """ + + def test_custom_sort_dict(self): + with Capturing() as output: + self._test_custom_sort_dict() + + def _test_custom_sort_dict(self): + """ + Test custom_sort_dict + """ + + input_dict = {"2": 1, "1": {2: 1, 1: 10}, -1: 20, 4: -1} + + # + output_1 = custom_sort_dict(input_dict) + + desired_output_1 = OrderedDict( + [(-1, 20), (4, -1), ("1", OrderedDict([(1, 10), (2, 1)])), ("2", 1)] + ) + + # + self.assertEqual(output_1, desired_output_1) + + +class test_filter_dict(unittest.TestCase): + """ + Unittests for function filter_dict + """ + + def test_filter_dict(self): + with Capturing() as output: + self._test_filter_dict() + + def _test_filter_dict(self): + """ + Test filter_dict + """ + + dict_1 = {"a": 10} + input_1 = ["a"] + + res_1 = filter_dict(dict_1, input_1) + + self.assertIsInstance(res_1, dict) + self.assertFalse(res_1) + + +class test_filter_dict_through_values(unittest.TestCase): + """ + Unittests for function filter_dict_through_values + """ + + def test_filter_dict_through_values(self): + with Capturing() as output: + self._test_filter_dict_through_values() + + def _test_filter_dict_through_values(self): + """ + Test filter_dict_through_values + """ + + dict_1 = {"a": 10} + input_1 = [10] + + res_1 = filter_dict_through_values(dict_1, input_1) + + self.assertIsInstance(res_1, dict) + self.assertFalse(res_1) + + +class test_prepare_dict(unittest.TestCase): + """ + Unittests for function prepare_dict + """ + + def test_prepare_dict(self): + with Capturing() as output: + self._test_prepare_dict() + + def _test_prepare_dict(self): + """ + Test prepare_dict + """ + + global_dict = {} + + # Call function to make sure the nested key contains an empty dict to store stuff in + input_1 = ["a", "b"] + prepare_dict(global_dict, input_1) + + # + self.assertIsNotNone(global_dict.get("a", None)) + self.assertIsNotNone(global_dict["a"].get("b", None)) + self.assertIsInstance(global_dict["a"]["b"], dict) + self.assertFalse(global_dict["a"]["b"]) + + +class test_normalize_dict(unittest.TestCase): + """ + Unittests for function normalize_dict + """ + + def test_normalize_dict(self): + with Capturing() as output: + self._test_normalize_dict() + + def _test_normalize_dict(self): + """ + Test normalize_dict + """ + + input_1 = {"a": 10, "b": 20, "c": 4} + + res_1 = normalize_dict(input_1) + + self.assertEqual(sum(list(res_1.values())), 1.0) + + +class test_multiply_values_dict(unittest.TestCase): + """ + Unittests for function multiply_values_dict + """ + + def test_multiply_values_dict(self): + with Capturing() as output: + self._test_multiply_values_dict() + + def _test_multiply_values_dict(self): + """ + Test multiply_values_dict + """ + + input_1 = {"a": 1, "b": {"c": 10}} + desired_output_1 = {"a": 2, "b": {"c": 20}} + + output_1 = multiply_values_dict(input_1, 2) + + # + self.assertEqual(output_1, desired_output_1) + + +class test_count_keys_recursive(unittest.TestCase): + """ + Unittests for function count_keys_recursive + """ + + def test_count_keys_recursive(self): + with Capturing() as output: + self._test_count_keys_recursive() + + def _test_count_keys_recursive(self): + """ + Test count_keys_recursive + """ + + # + input_1 = {"a": 2, "b": {"c": 20, "d": {"aa": 1, "bb": 2}}} + output_1 = count_keys_recursive(input_1) + + # + self.assertEqual(output_1, 6) + + +class test_keys_to_floats(unittest.TestCase): + """ + Unittests for function keys_to_floats + """ + + def test_keys_to_floats(self): + with Capturing() as output: + self._test_keys_to_floats() + + def _test_keys_to_floats(self): + """ + Test keys_to_floats + """ + + input_1 = {"a": 1, "1": 2, "1.0": 3, "b": {4: 10, "5": 1}} + output_1 = keys_to_floats(input_1) + + desired_output_1 = {"a": 1, 1.0: 3, "b": {4.0: 10, 5.0: 1}} + + self.assertEqual(output_1, desired_output_1) + + +class test_recursive_change_key_to_float(unittest.TestCase): + """ + Unittests for function recursive_change_key_to_float + """ + + def test_recursive_change_key_to_float(self): + with Capturing() as output: + self._test_recursive_change_key_to_float() + + def _test_recursive_change_key_to_float(self): + """ + Test recursive_change_key_to_float + """ + + input_1 = {"a": 1, "1": 2, "1.0": 3, "b": {4: 10, "5": 1}} + output_1 = recursive_change_key_to_float(input_1) + + desired_output_1 = OrderedDict( + [("a", 1), (1.0, 3), ("b", OrderedDict([(4.0, 10), (5.0, 1)]))] + ) + + self.assertEqual(output_1, desired_output_1) + + +class test_recursive_change_key_to_string(unittest.TestCase): + """ + Unittests for function recursive_change_key_to_string + """ + + def test_recursive_change_key_to_string(self): + with Capturing() as output: + self._test_recursive_change_key_to_string() + + def _test_recursive_change_key_to_string(self): + """ + Test recursive_change_key_to_string + """ + + input_1 = {"a": 1, "1": 2, "1.0": 3, "b": {4: 10, "5": 1, 6: 10}} + output_1 = recursive_change_key_to_string(input_1, "{:.2E}") + + desired_output_1 = OrderedDict( + [ + ("a", 1), + ("1.00E+00", 3), + ( + "b", + OrderedDict([("4.00E+00", 10), ("5.00E+00", 1), ("6.00E+00", 10)]), + ), + ] + ) + + self.assertEqual(output_1, desired_output_1) + + +class test_multiply_float_values(unittest.TestCase): + """ + Unittests for function multiply_float_values + """ + + def test_multiply_float_values(self): + with Capturing() as output: + self._test_multiply_float_values() + + def _test_multiply_float_values(self): + """ + Test multiply_float_values + """ + + # Test with all valid input + input_1 = {1: 2.2, "2": {"a": 2, "b": 10, "c": 0.5}} + multiply_float_values(input_1, 2) + desired_output_1 = {1: 4.4, "2": {"a": 2, "b": 10, "c": 1.0}} + + # + self.assertEqual(input_1, desired_output_1) + + # Test with unrecognised input: + input_2 = {1: 2.2, "2": {"a": 2, "b": 10, "c": 0.5, "d": dummy("david")}} + _ = multiply_float_values(input_2, 2) + + +class test_subtract_dicts(unittest.TestCase): + """ + Unittests for function subtract_dicts + """ + + def test_empty(self): + with Capturing() as output: + self._test_empty() + + def _test_empty(self): + """ + Test subtract_dicts with an empty dict + """ + + input_dict = { + "int": 1, + "float": 1.2, + "dict": {"int": 1, "float": 1.2}, + } + dict_2 = {} + output_dict = subtract_dicts(input_dict, dict_2) + self.assertTrue(output_dict == input_dict) + + def test_unequal_types(self): + with Capturing() as output: + self._test_unequal_types() + + def _test_unequal_types(self): + """ + Test subtract_dicts with unequal types: should raise valueError + """ + + dict_1 = {"input": 10} + dict_2 = {"input": "hello"} + + self.assertRaises(ValueError, subtract_dicts, dict_1, dict_2) + + def test_ints(self): + with Capturing() as _: + self._test_ints() + + def _test_ints(self): + """ + Test subtract_dicts with ints + """ + + dict_1 = {"int": 2} + dict_2 = {"int": 1} + output_dict = subtract_dicts(dict_1, dict_2) + + self.assertTrue(isinstance(output_dict["int"], int)) + self.assertEqual(output_dict["int"], 1) + + def test_floats(self): + with Capturing() as output: + self._test_floats() + + def _test_floats(self): + """ + Test subtract_dicts with floats + """ + + dict_1 = {"float": 4.5} + dict_2 = {"float": 4.6} + output_dict = subtract_dicts(dict_1, dict_2) + + self.assertTrue(isinstance(output_dict["float"], float)) + self.assertAlmostEqual(output_dict["float"], -0.1, 2) + + def test_zero_result(self): + with Capturing() as output: + self._test_zero_result() + + def _test_zero_result(self): + """ + Test subtract_dicts resulting in a 0 value. which should be removed + """ + + dict_1 = {"a": 4, "b": 0, "d": 1.0} + dict_2 = {"a": 4, "c": 0, "d": 1} + output_dict = subtract_dicts(dict_1, dict_2) + + self.assertIsInstance(output_dict, dict) + self.assertFalse(output_dict) + + def test_unsupported(self): + with Capturing() as output: + self._test_unsupported() + + def _test_unsupported(self): + """ + Test merging dict with lists + """ + + dict_1 = {"list": [1, 2], "b": [1]} + dict_2 = {"list": [3, 4], "c": [1]} + + self.assertRaises(ValueError, subtract_dicts, dict_1, dict_2) + + def test_dicts(self): + with Capturing() as _: + self._test_dicts() + + def _test_dicts(self): + """ + Test merging dict with dicts + """ + + dict_1 = {"dict": {"a": 1, "b": 1}} + dict_2 = {"dict": {"a": 2, "c": 2}} + output_dict = subtract_dicts(dict_1, dict_2) + + self.assertTrue(isinstance(output_dict["dict"], dict)) + self.assertEqual(output_dict["dict"], {"a": -1, "b": 1, "c": -2}) + + +class test_update_dicts(unittest.TestCase): + """ + Unittests for function update_dicts + """ + + def test_dicts(self): + with Capturing() as _: + self._test_dicts() + + def _test_dicts(self): + """ + Test update_dicts with dicts + """ + + dict_1 = {"dict": {"a": 1, "b": 1}} + dict_2 = {"dict": {"a": 2, "c": 2}} + output_dict = update_dicts(dict_1, dict_2) + + self.assertTrue(isinstance(output_dict["dict"], dict)) + self.assertEqual(output_dict["dict"], {"a": 2, "b": 1, "c": 2}) + + def test_unsupported(self): + with Capturing() as output: + self._test_unsupported() + + def _test_unsupported(self): + """ + Test update_dicts with unsupported types + """ + + dict_1 = {"list": 2, "b": [1]} + dict_2 = {"list": [3, 4], "c": [1]} + + self.assertRaises(ValueError, update_dicts, dict_1, dict_2) + + +class test__nested_get(unittest.TestCase): + """ + Unittests for function _nested_get + """ + + def test__nested_get(self): + with Capturing() as output: + self._test__nested_get() + + def _test__nested_get(self): + """ + Test _nested_get + """ + + input_1 = {"a": {"b": 2}} + + output_1 = _nested_get(input_1, ["a"]) + output_2 = _nested_get(input_1, ["a", "b"]) + + self.assertEqual(output_1, {"b": 2}) + self.assertEqual(output_2, 2) + + +class test__nested_set(unittest.TestCase): + """ + Unittests for function _nested_set + """ + + def test__nested_set(self): + with Capturing() as output: + self._test__nested_set() + + def _test__nested_set(self): + """ + Test _nested_set + """ + + # + input_1 = {"a": 0} + desired_output_1 = {"a": 2} + _nested_set(input_1, ["a"], 2) + self.assertEqual(input_1, desired_output_1) + + # + input_2 = {"a": {"b": 0}} + desired_output_2 = {"a": {"b": 2}} + _nested_set(input_2, ["a", "b"], 2) + self.assertEqual(input_2, desired_output_2) + + # + input_3 = {"a": {"b": 0}} + desired_output_3 = {"a": {"b": 0, "d": {"c": 10}}} + _nested_set(input_3, ["a", "d", "c"], 10) + self.assertEqual(input_3, desired_output_3) + + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/test_ensemble.py b/binarycpython/tests/test_ensemble.py new file mode 100644 index 0000000000000000000000000000000000000000..3fe789a7cd98db85099b1d8cd827a8248b87ad36 --- /dev/null +++ b/binarycpython/tests/test_ensemble.py @@ -0,0 +1,501 @@ +""" +Unit tests for the ensemble module +""" + +import os +import sys +import json +import unittest + +import io +from io import StringIO + +from binarycpython.utils.functions import ( + temp_dir, + Capturing, +) +from binarycpython.utils.ensemble import ( + binaryc_json_serializer, + handle_ensemble_string_to_json, + BinarycEncoder, + BinarycDecoder, + extract_ensemble_json_from_string, + load_ensemble, + ensemble_file_type, + open_ensemble, +) +from binarycpython.utils.grid import Population + +TMP_DIR = temp_dir("tests", "test_ensemble") +TEST_VERBOSITY = 1 + + +class test_binaryc_json_serializer(unittest.TestCase): + """ + Unittests for function binaryc_json_serializer + """ + + def test_not_function(self): + with Capturing() as output: + self._test_not_function() + + def _test_not_function(self): + """ + Test passing an object that doesnt get turned in to a string + """ + + stringo = "hello" + output = binaryc_json_serializer(stringo) + self.assertTrue(stringo == output) + + def test_function(self): + with Capturing() as output: + self._test_function() + + def _test_function(self): + """ + Test passing an object that gets turned in to a string: a function + """ + + string_of_function = str(os.path.isfile) + output = binaryc_json_serializer(os.path.isfile) + self.assertTrue(string_of_function == output) + + +class test_handle_ensemble_string_to_json(unittest.TestCase): + """ + Unittests for function handle_ensemble_string_to_json + """ + + def test_1(self): + with Capturing() as _: + self._test_1() + + def _test_1(self): + """ + Test passing string representation of a dictionary. + """ + + _ = str(os.path.isfile) + input_string = '{"ding": 10, "list_example": [1,2,3]}' + output_dict = handle_ensemble_string_to_json(input_string) + + self.assertTrue(isinstance(output_dict, dict)) + self.assertTrue(output_dict["ding"] == 10) + self.assertTrue(output_dict["list_example"] == [1, 2, 3]) + + +class test_BinarycEncoder(unittest.TestCase): + """ + Unittests for class BinarycEncoder + """ + + def test_1(self): + with Capturing() as _: + self._test_1() + + def _test_1(self): + """ + Test that the object is converted to strings + """ + + input_1 = {"a": BinarycEncoder} + output_1 = json.dumps(input_1, cls=BinarycEncoder) + self.assertTrue(isinstance(output_1, str)) + + dict_output_1 = json.loads(output_1) + self.assertTrue(isinstance(dict_output_1["a"], str)) + + +class test_BinarycDecoder(unittest.TestCase): + """ + Unittests for class BinarycDecoder + """ + + def test_1(self): + with Capturing() as _: + self._test_1() + + def _test_1(self): + """ + Test that the object is converted to floats + """ + + input_1 = '{"a": "10.0"}' + output_1 = json.loads(input_1) + output_2 = json.loads(input_1, cls=BinarycDecoder) + + self.assertTrue(isinstance(output_1["a"], str)) + self.assertTrue(isinstance(output_2["a"], float)) + + +class test_extract_ensemble_json_from_string(unittest.TestCase): + """ + Unittests for class extract_ensemble_json_from_string + """ + + def test_1(self): + with Capturing() as _: + self._test_1() + + def _test_1(self): + """ + Simple test without errors + """ + + input_1 = 'ENSEMBLE_JSON {"a": 10}' + output_1 = extract_ensemble_json_from_string(input_1) + + self.assertTrue(isinstance(output_1, dict)) + self.assertEqual(output_1, {"a": 10}) + + def test_2(self): + with Capturing() as _: + self._test_2() + + def _test_2(self): + """ + Simple test with 2 lines + """ + + input_1 = 'ENSEMBLE_JSON {"a": 10}\nENSEMBLE_JSON {"b": 20}' + + capturedOutput = StringIO() # Create StringIO object + sys.stdout = capturedOutput # and redirect stdout. + _ = extract_ensemble_json_from_string(input_1) + sys.stdout = sys.__stdout__ # Reset redirect. + + self.assertTrue(capturedOutput.getvalue().startswith("Warning:")) + + def test_3(self): + with Capturing() as _: + self._test_3() + + def _test_3(self): + """ + Simple test with empty input + """ + + input_1 = "" + output_1 = extract_ensemble_json_from_string(input_1) + + self.assertTrue(isinstance(output_1, dict)) + self.assertEqual(output_1, {}) + + def test_4(self): + with Capturing() as _: + self._test_4() + + def test_4(self): + """ + Simple test with missing starting string + """ + + input_1 = ' {"a": 10}' + + # + capturedOutput = StringIO() # Create StringIO object + sys.stdout = capturedOutput # and redirect stdout. + _ = extract_ensemble_json_from_string(input_1) + sys.stdout = sys.__stdout__ # Reset redirect. + + self.assertTrue(capturedOutput.getvalue().startswith("Error:")) + + +class test_load_ensemble(unittest.TestCase): + """ + Unittests for class extract_ensemble_json_from_string + """ + + def __init__(self, *args, **kwargs): + """ + init function + """ + super(test_load_ensemble, self).__init__(*args, **kwargs) + + # + self.run_population() + + def run_population(self): + with Capturing() as _: + self._run_population() + + def _run_population(self): + """ + Function to run the population to create the ensemble files + """ + + # First + test_pop_1 = Population() + test_pop_1.set( + num_cores=2, + verbosity=TEST_VERBOSITY, + M_2=1, + orbital_period=100000, + ensemble=1, + ensemble_defer=1, + ensemble_filters_off=1, + ensemble_filter_STELLAR_TYPE_COUNTS=1, + ensemble_dt=1000, + ) + test_pop_1.set( + data_dir=TMP_DIR, + combine_ensemble_with_thread_joining=True, + ) + + resolution = {"M_1": 10} + + test_pop_1.add_grid_variable( + name="lnm1", + longname="Primary mass", + valuerange=[1, 100], + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( + resolution["M_1"] + ), + precode="M_1=math.exp(lnm1)", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + dphasevol="dlnm1", + parameter_name="M_1", + condition="", # Impose a condition on this grid variable. Mostly for a check for yourself + ) + + _ = test_pop_1.evolve() + ensemble_output_1 = test_pop_1.grid_ensemble_results + + self.normal_ensemble_output_name = os.path.join( + TMP_DIR, "test_load_ensemble_ensemble_output.json" + ) + self.bzip2_ensemble_output_name = os.path.join( + TMP_DIR, "test_load_ensemble_ensemble_output.json.bz2" + ) + self.no_extension_ensemble_output_name = os.path.join( + TMP_DIR, "test_load_ensemble_ensemble_output" + ) + + # Write ensemble to json with normal write + test_pop_1.write_ensemble(self.normal_ensemble_output_name) + + # Write ensemble to bzip + test_pop_1.write_ensemble(self.bzip2_ensemble_output_name) + + # Write ensemble without extension + with open(self.no_extension_ensemble_output_name, "w") as f: + f.write(json.dumps(ensemble_output_1)) + + def test_1(self): + with Capturing() as _: + self._test_1() + + def _test_1(self): + """ + Simple test to load ensemble with normal filetype + """ + + # load data + loaded_data_1 = load_ensemble(self.normal_ensemble_output_name) + + self.assertTrue(isinstance(loaded_data_1, dict)) + + def test_2(self): + with Capturing() as _: + self._test_2() + + def _test_2(self): + """ + Simple test to load ensemble with msgpack type + """ + + # load data + loaded_data_1 = load_ensemble(self.bzip2_ensemble_output_name) + + self.assertTrue(isinstance(loaded_data_1, dict)) + + def test_3(self): + with Capturing() as _: + self._test_3() + + def _test_3(self): + """ + Simple test to load ensemble with timing output + """ + + # + capturedOutput = StringIO() # Create StringIO object + sys.stdout = capturedOutput # and redirect stdout. + _ = load_ensemble(self.normal_ensemble_output_name, timing=True) + sys.stdout = sys.__stdout__ # Reset redirect. + + self.assertTrue("Took" in capturedOutput.getvalue()) + + def test_4(self): + with Capturing() as _: + self._test_4() + + def _test_4(self): + """ + Simple test to load ensemble conveting to floats and timing + """ + + # + capturedOutput = StringIO() # Create StringIO object + sys.stdout = capturedOutput # and redirect stdout. + loaded_data_1 = load_ensemble( + self.normal_ensemble_output_name, timing=True, convert_float_keys=True + ) + sys.stdout = sys.__stdout__ # Reset redirect. + + self.assertTrue("Took" in capturedOutput.getvalue()) + + +class test_ensemble_file_type(unittest.TestCase): + """ + Unittests for class ensemble_file_type + """ + + def test_1(self): + with Capturing() as _: + self._test_1() + + def _test_1(self): + """ + filetype tests + """ + + # Json test + input_1 = "/tmp/test.json" + output_1 = ensemble_file_type(input_1) + + self.assertEqual(output_1, "JSON") + + # Msgpack + input_2 = "/tmp/test.msgpack" + output_2 = ensemble_file_type(input_2) + + self.assertEqual(output_2, "msgpack") + + # None + input_3 = "/tmp/test" + output_3 = ensemble_file_type(input_3) + + self.assertIsNone(output_3) + + +class test_open_ensemble(unittest.TestCase): + """ + Unittests for class open_ensemble: + """ + + def __init__(self, *args, **kwargs): + """ + init function + """ + super(test_open_ensemble, self).__init__(*args, **kwargs) + + # + self.run_population() + + def run_population(self): + with Capturing() as _: + self._run_population() + + def _run_population(self): + """ + Function to run the population to create the ensemble files + """ + + # First + test_pop_1 = Population() + test_pop_1.set( + num_cores=2, + verbosity=TEST_VERBOSITY, + M_2=1, + orbital_period=100000, + ensemble=1, + ensemble_defer=1, + ensemble_filters_off=1, + ensemble_filter_STELLAR_TYPE_COUNTS=1, + ensemble_dt=1000, + ) + test_pop_1.set( + data_dir=TMP_DIR, + combine_ensemble_with_thread_joining=True, + ) + + resolution = {"M_1": 10} + + test_pop_1.add_grid_variable( + name="lnm1", + longname="Primary mass", + valuerange=[1, 100], + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( + resolution["M_1"] + ), + precode="M_1=math.exp(lnm1)", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + dphasevol="dlnm1", + parameter_name="M_1", + condition="", # Impose a condition on this grid variable. Mostly for a check for yourself + ) + + _ = test_pop_1.evolve() + ensemble_output_1 = test_pop_1.grid_ensemble_results + + self.normal_ensemble_output_name = os.path.join( + TMP_DIR, "test_open_ensemble_ensemble_output.json" + ) + self.bzip2_ensemble_output_name = os.path.join( + TMP_DIR, "test_open_ensemble_ensemble_output.json.bz2" + ) + self.gzip_ensemble_output_name = os.path.join( + TMP_DIR, "test_open_ensemble_ensemble_output.json.gz" + ) + # self.msgpack_ensemble_output_name = os.path.join(TMP_DIR, 'test_open_ensemble_ensemble_output.msgpack') + + # Write ensemble to json with normal write + test_pop_1.write_ensemble(self.normal_ensemble_output_name) + + # Write ensemble to bzip + test_pop_1.write_ensemble(self.bzip2_ensemble_output_name) + + # gzip + test_pop_1.write_ensemble(self.gzip_ensemble_output_name) + + # # Msgpack + # test_pop_1.write_ensemble(self.msgpack_ensemble_output_name) + + def test_1(self): + with Capturing() as _: + self._test_1() + + def _test_1(self): + """ + filetype tests + """ + + self.msgpack_ensemble_output_name = os.path.join( + TMP_DIR, "test_open_ensemble_ensemble_output.msgpack.gz" + ) + + # + handle_1 = open_ensemble(self.normal_ensemble_output_name) + self.assertTrue(isinstance(handle_1, io._io.TextIOWrapper)) + handle_1.close() + + # + handle_2 = open_ensemble(self.bzip2_ensemble_output_name) + self.assertTrue(isinstance(handle_2, io._io.TextIOWrapper)) + handle_2.close() + + # + handle_3 = open_ensemble(self.gzip_ensemble_output_name) + self.assertTrue(isinstance(handle_3, io._io.TextIOWrapper)) + handle_3.close() + + # # TODO: implement this again + # handle_4 = open_ensemble(self.msgpack_ensemble_output_name) + # self.assertTrue(isinstance(handle_4, io._io.TextIOWrapper)) + # handle_4.close() + + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/test_functions.py b/binarycpython/tests/test_functions.py index d4ad330ec5b5412989c52f1d9004b00c5fb5d3ca..364ce9b4724b0236cee9e07ef08dab462b185eeb 100644 --- a/binarycpython/tests/test_functions.py +++ b/binarycpython/tests/test_functions.py @@ -1,5 +1,26 @@ """ Unittests for the functions module + +TODO: format_number +TODO: now +TODO: check_if_in_shell +TODO: timedelta +TODO: get_ANSI_colours +TODO: mem_use +TODO: trem +TODO: conv_time_units +TODO: convert_bytes +TODO: get_size +TODO: imports +TODO: isfloat +TODO: isint +TODO: convfloat +TODO: datalinedict +TODO: pad_output_distribution +TODO: catchtime +TODO: is_capsule +TODO: Capturing +TODO: call_binary_c_config """ import os @@ -12,53 +33,28 @@ import h5py from binarycpython.utils.custom_logging_functions import binary_c_log_code from binarycpython.utils.run_system_wrapper import run_system from binarycpython.utils.functions import ( + verbose_print, temp_dir, Capturing, - verbose_print, remove_file, - get_username, - bin_data, create_hdf5, - return_binary_c_version_info, - parse_binary_c_version_info, output_lines, - get_defaults, example_parse_output, - create_arg_string, + get_defaults, get_arg_keys, + create_arg_string, get_help, get_help_all, get_help_super, - write_binary_c_parameter_descriptions_to_rst_file, make_build_text, -) -from binarycpython.utils.dicts import AutoVivificationDict, inspect_dict, merge_dicts -from binarycpython.utils.ensemble import ( - binaryc_json_serializer, - handle_ensemble_string_to_json, + write_binary_c_parameter_descriptions_to_rst_file, + get_username, + bin_data, ) TMP_DIR = temp_dir("tests", "test_functions") -class dummy: - """ - Dummy class to be used in the merge_dicts - """ - - def __init__(self, name): - """ - init - """ - self.name = name - - def __str__(self): - """ - str returns self.name - """ - return self.name - - class test_verbose_print(unittest.TestCase): """ Unittests for verbose_print @@ -86,39 +82,6 @@ class test_verbose_print(unittest.TestCase): verbose_print("test1", 0, 1) -class test_remove_file(unittest.TestCase): - """ - Unittests for remove_file - """ - - def test_remove_file(self): - with Capturing() as output: - self._test_remove_file() - - def _test_remove_file(self): - """ - Test to remove a file - """ - - with open(os.path.join(TMP_DIR, "test_remove_file_file.txt"), "w") as f: - f.write("test") - - remove_file(os.path.join(TMP_DIR, "test_remove_file_file.txt")) - - def test_remove_nonexisting_file(self): - with Capturing() as output: - self._test_remove_nonexisting_file() - - def _test_remove_nonexisting_file(self): - """ - Test to try to remove a nonexistant file - """ - - file = os.path.join(TMP_DIR, "test_remove_nonexistingfile_file.txt") - - remove_file(file) - - class test_temp_dir(unittest.TestCase): """ Unittests for temp_dir @@ -153,6 +116,39 @@ class test_temp_dir(unittest.TestCase): ) == binary_c_temp_dir +class test_remove_file(unittest.TestCase): + """ + Unittests for remove_file + """ + + def test_remove_file(self): + with Capturing() as output: + self._test_remove_file() + + def _test_remove_file(self): + """ + Test to remove a file + """ + + with open(os.path.join(TMP_DIR, "test_remove_file_file.txt"), "w") as f: + f.write("test") + + remove_file(os.path.join(TMP_DIR, "test_remove_file_file.txt")) + + def test_remove_nonexisting_file(self): + with Capturing() as output: + self._test_remove_nonexisting_file() + + def _test_remove_nonexisting_file(self): + """ + Test to try to remove a nonexistant file + """ + + file = os.path.join(TMP_DIR, "test_remove_nonexistingfile_file.txt") + + remove_file(file) + + class test_create_hdf5(unittest.TestCase): """ Unittests for create_hdf5 @@ -190,89 +186,6 @@ class test_create_hdf5(unittest.TestCase): self.assertIn("settings_2", json.loads(file.get("settings/used_settings")[()])) -class test_return_binary_c_version_info(unittest.TestCase): - """ - Unittests for return_binary_c_version_info - """ - - def test_not_parsed(self): - with Capturing() as output: - self._test_not_parsed() - - def _test_not_parsed(self): - """ - Test for the raw version_info output - """ - - version_info = return_binary_c_version_info(parsed=False) - - self.assertTrue(isinstance(version_info, str)) - self.assertIn("Build", version_info) - self.assertIn("REIMERS_ETA_DEFAULT", version_info) - self.assertIn("SIGMA_THOMPSON", version_info) - - def test_parsed(self): - with Capturing() as output: - self._test_parsed() - - def _test_parsed(self): - """ - Test for the parssed version_info - """ - - # also tests the parse_version_info indirectly - version_info_parsed = return_binary_c_version_info(parsed=True) - - self.assertTrue(isinstance(version_info_parsed, dict)) - self.assertIn("isotopes", version_info_parsed.keys()) - self.assertIn("argpairs", version_info_parsed.keys()) - self.assertIn("ensembles", version_info_parsed.keys()) - self.assertIn("macros", version_info_parsed.keys()) - self.assertIn("elements", version_info_parsed.keys()) - self.assertIn("dt_limits", version_info_parsed.keys()) - self.assertIn("nucleosynthesis_sources", version_info_parsed.keys()) - self.assertIn("miscellaneous", version_info_parsed.keys()) - - -class test_parse_binary_c_version_info(unittest.TestCase): - """ - Unittests for function parse_binary_c_version_info - """ - - def test_1(self): - with Capturing() as output: - self._test_1() - - def _test_1(self): - """ - Test for the parsed versio info, more detailed - """ - - info = return_binary_c_version_info(parsed=False) - parsed_info = parse_binary_c_version_info(info) - - self.assertIn("isotopes", parsed_info.keys()) - self.assertIn("argpairs", parsed_info.keys()) - self.assertIn("ensembles", parsed_info.keys()) - self.assertIn("macros", parsed_info.keys()) - self.assertIn("elements", parsed_info.keys()) - self.assertIn("dt_limits", parsed_info.keys()) - self.assertIn("nucleosynthesis_sources", parsed_info.keys()) - self.assertIn("miscellaneous", parsed_info.keys()) - - self.assertIsNotNone(parsed_info["argpairs"]) - self.assertIsNotNone(parsed_info["ensembles"]) - self.assertIsNotNone(parsed_info["macros"]) - self.assertIsNotNone(parsed_info["dt_limits"]) - self.assertIsNotNone(parsed_info["miscellaneous"]) - - if parsed_info["macros"]["NUCSYN"] == "on": - self.assertIsNotNone(parsed_info["isotopes"]) - - if parsed_info["macros"]["NUCSYN_ID_SOURCES"] == "on": - self.assertIsNotNone(parsed_info["nucleosynthesis_sources"]) - - class test_output_lines(unittest.TestCase): """ Unittests for function output_lines @@ -515,10 +428,7 @@ class test_get_help(unittest.TestCase): """ output = get_help("kaasblokjes") - self.assertIsNone(output) - - # def test_print(self): - # output = get_help("M_1", print_help=True) + self.assertDictEqual(output, {}) class test_get_help_all(unittest.TestCase): @@ -629,8 +539,9 @@ class test_write_binary_c_parameter_descriptions_to_rst_file(unittest.TestCase): TMP_DIR, "test_write_binary_c_parameter_descriptions_to_rst_file_test_1.txt", ) - output_1 = write_binary_c_parameter_descriptions_to_rst_file(output_name) - self.assertIsNone(output_1) + self.assertRaises( + ValueError, write_binary_c_parameter_descriptions_to_rst_file, output_name + ) def test_checkfile(self): with Capturing() as output: @@ -649,267 +560,6 @@ class test_write_binary_c_parameter_descriptions_to_rst_file(unittest.TestCase): self.assertTrue(os.path.isfile(output_name)) -class test_inspect_dict(unittest.TestCase): - """ - Unittests for function inspect_dict - """ - - def test_compare_dict(self): - with Capturing() as output: - self._test_compare_dict() - - def _test_compare_dict(self): - """ - Test checking if inspect_dict returns the correct structure by comparing it to known value - """ - - input_dict = { - "int": 1, - "float": 1.2, - "list": [1, 2, 3], - "function": os.path.isfile, - "dict": {"int": 1, "float": 1.2}, - } - output_dict = inspect_dict(input_dict) - compare_dict = { - "int": int, - "float": float, - "list": list, - "function": os.path.isfile.__class__, - "dict": {"int": int, "float": float}, - } - self.assertTrue(compare_dict == output_dict) - - def test_compare_dict_with_print(self): - with Capturing() as output: - self._test_compare_dict_with_print() - - def _test_compare_dict_with_print(self): - """ - Test checking output is printed - """ - - input_dict = { - "int": 1, - "float": 1.2, - "list": [1, 2, 3], - "function": os.path.isfile, - "dict": {"int": 1, "float": 1.2}, - } - output_dict = inspect_dict(input_dict, print_structure=True) - - -class test_merge_dicts(unittest.TestCase): - """ - Unittests for function merge_dicts - """ - - def test_empty(self): - with Capturing() as output: - self._test_empty() - - def _test_empty(self): - """ - Test merging an empty dict - """ - - input_dict = { - "int": 1, - "float": 1.2, - "list": [1, 2, 3], - "function": os.path.isfile, - "dict": {"int": 1, "float": 1.2}, - } - dict_2 = {} - output_dict = merge_dicts(input_dict, dict_2) - self.assertTrue(output_dict == input_dict) - - def test_unequal_types(self): - with Capturing() as output: - self._test_unequal_types() - - def _test_unequal_types(self): - """ - Test merging unequal types: should raise valueError - """ - - dict_1 = {"input": 10} - dict_2 = {"input": "hello"} - - self.assertRaises(ValueError, merge_dicts, dict_1, dict_2) - - def test_bools(self): - with Capturing() as output: - self._test_bools() - - def _test_bools(self): - """ - Test merging dict with booleans - """ - - dict_1 = {"bool": True} - dict_2 = {"bool": False} - output_dict = merge_dicts(dict_1, dict_2) - - self.assertTrue(isinstance(output_dict["bool"], bool)) - self.assertTrue(output_dict["bool"]) - - def test_ints(self): - with Capturing() as _: - self._test_ints() - - def _test_ints(self): - """ - Test merging dict with ints - """ - - dict_1 = {"int": 2} - dict_2 = {"int": 1} - output_dict = merge_dicts(dict_1, dict_2) - - self.assertTrue(isinstance(output_dict["int"], int)) - self.assertEqual(output_dict["int"], 3) - - def test_floats(self): - with Capturing() as output: - self._test_floats() - - def _test_floats(self): - """ - Test merging dict with floats - """ - - dict_1 = {"float": 4.5} - dict_2 = {"float": 4.6} - output_dict = merge_dicts(dict_1, dict_2) - - self.assertTrue(isinstance(output_dict["float"], float)) - self.assertEqual(output_dict["float"], 9.1) - - def test_lists(self): - with Capturing() as output: - self._test_lists() - - def _test_lists(self): - """ - Test merging dict with lists - """ - - dict_1 = {"list": [1, 2]} - dict_2 = {"list": [3, 4]} - output_dict = merge_dicts(dict_1, dict_2) - - self.assertTrue(isinstance(output_dict["list"], list)) - self.assertEqual(output_dict["list"], [1, 2, 3, 4]) - - def test_dicts(self): - with Capturing() as _: - self._test_dicts() - - def _test_dicts(self): - """ - Test merging dict with dicts - """ - - dict_1 = {"dict": {"same": 1, "other_1": 2.0}} - dict_2 = {"dict": {"same": 2, "other_2": [4.0]}} - output_dict = merge_dicts(dict_1, dict_2) - - self.assertTrue(isinstance(output_dict["dict"], dict)) - self.assertEqual( - output_dict["dict"], {"same": 3, "other_1": 2.0, "other_2": [4.0]} - ) - - def test_unsupported(self): - with Capturing() as output: - self._test_unsupported() - - def _test_unsupported(self): - """ - Test merging dict with unsupported types. should raise ValueError - """ - - dict_1 = {"new": dummy("david")} - dict_2 = {"new": dummy("gio")} - - # output_dict = merge_dicts(dict_1, dict_2) - self.assertRaises(ValueError, merge_dicts, dict_1, dict_2) - - -class test_binaryc_json_serializer(unittest.TestCase): - """ - Unittests for function binaryc_json_serializer - """ - - def test_not_function(self): - with Capturing() as output: - self._test_not_function() - - def _test_not_function(self): - """ - Test passing an object that doesnt get turned in to a string - """ - - stringo = "hello" - output = binaryc_json_serializer(stringo) - self.assertTrue(stringo == output) - - def test_function(self): - with Capturing() as output: - self._test_function() - - def _test_function(self): - """ - Test passing an object that gets turned in to a string: a function - """ - - string_of_function = str(os.path.isfile) - output = binaryc_json_serializer(os.path.isfile) - self.assertTrue(string_of_function == output) - - -class test_handle_ensemble_string_to_json(unittest.TestCase): - """ - Unittests for function handle_ensemble_string_to_json - """ - - def test_1(self): - with Capturing() as _: - self._test_1() - - def _test_1(self): - """ - Test passing string representation of a dictionary. - """ - - _ = str(os.path.isfile) - input_string = '{"ding": 10, "list_example": [1,2,3]}' - output_dict = handle_ensemble_string_to_json(input_string) - - self.assertTrue(isinstance(output_dict, dict)) - self.assertTrue(output_dict["ding"] == 10) - self.assertTrue(output_dict["list_example"] == [1, 2, 3]) - - -class test_AutoVivicationDict(unittest.TestCase): - """ - Unittests for AutoVivicationDict - """ - - def test_add(self): - """ - Tests to see if the adding is done correctly - """ - - result_dict = AutoVivificationDict() - - result_dict["a"]["b"]["c"] += 10 - - self.assertEqual(result_dict["a"]["b"]["c"], 10) - result_dict["a"]["b"]["c"] += 10 - self.assertEqual(result_dict["a"]["b"]["c"], 20) - - class test_bin_data(unittest.TestCase): """ Unittests for bin_data diff --git a/binarycpython/tests/test_grid.py b/binarycpython/tests/test_grid.py index 6bfb9272b5a9db3e16e0c061e667a2ca0b21e28f..09b429dd1ef55c978d265243f7e1c9803d53b499 100644 --- a/binarycpython/tests/test_grid.py +++ b/binarycpython/tests/test_grid.py @@ -1,39 +1,51 @@ """ -Test cases for the grid - -Tasks: - TODO: write tests for load_from_sourcefile +Unit tests for the grid module + +TODO: jobID +TODO: exit +TODO: _set_nprocesses +TODO: _pre_run_setup +TODO: clean +TODO: _evolve_population +TODO: _system_queue_filler +TODO: _evolve_population_grid +TODO: _evolve_system_mp +TODO: _parent_signal_handler +TODO: _child_signal_handler +TODO: _process_run_population_grid +TODO: _cleanup +TODO: _dry_run +TODO: _dry_run_source_file +TODO: _load_source_file +TODO: was_killed +TODO: _check_binary_c_error + +TODO: Before running the non-unit tests to cover functions like evolve, we need to run the unit tests """ import os import sys import json +import gzip +import shutil import unittest import numpy as np -from binarycpython.utils.grid import Population - -from binarycpython.utils.functions import ( - temp_dir, - remove_file, - Capturing, - bin_data, -) - -from binarycpython.utils.ensemble import ( - extract_ensemble_json_from_string, -) +from binarycpython.utils.functions import temp_dir, Capturing, remove_file, bin_data from binarycpython.utils.dicts import ( merge_dicts, ) -from binarycpython.utils.custom_logging_functions import binary_c_log_code +from binarycpython.utils.grid import Population TMP_DIR = temp_dir("tests", "test_grid") +shutil.rmtree(TMP_DIR) +os.makedirs(TMP_DIR, exist_ok=True) + TEST_VERBOSITY = 1 -def parse_function_test_grid_evolve_2_threads_with_custom_logging(self, output): +def parse_function_test_grid_evolve_2_threads_with_custom_logging(self, output): # pragma: no cover """ Simple parse function that directly appends all the output to a file """ @@ -60,34 +72,53 @@ def parse_function_test_grid_evolve_2_threads_with_custom_logging(self, output): first_f.write(output + "\n") -# class test_(unittest.TestCase): -# """ -# Unittests for function -# """ +def parse_function_adding_results(self, output): # pragma: no cover + """ + Example parse function + """ + + seperator = " " + + parameters = ["time", "mass", "zams_mass", "probability", "stellar_type"] + + self.grid_results["example"]["count"] += 1 + + # Go over the output. + for line in output.splitlines(): + headerline = line.split()[0] + + # CHeck the header and act accordingly + if headerline == "EXAMPLE_OUTPUT": + values = line.split()[1:] + + # Bin the mass probability + self.grid_results["example"]["mass"][ + bin_data(float(values[2]), binwidth=0.5) + ] += float(values[3]) -# def test_1(self): -# pass + # + if not len(parameters) == len(values): + print("Number of column names isnt equal to number of columns") + raise ValueError -# def test_(self): -# """ -# Unittests for the function -# """ + # record the probability of this line (Beware, this is meant to only be run once for each system. its a controls quantity) + self.grid_results["example"]["probability"] += float(values[3]) -class test_Population(unittest.TestCase): +class test__setup(unittest.TestCase): """ - Unittests for function + Unittests for _setup function """ def test_setup(self): - with Capturing() as output: + with Capturing() as _: self._test_setup() def _test_setup(self): """ Unittests for function _setup """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) self.assertTrue("orbital_period" in test_pop.defaults) self.assertTrue("metallicity" in test_pop.defaults) @@ -96,11 +127,17 @@ class test_Population(unittest.TestCase): self.assertEqual(test_pop.custom_options, {}) self.assertEqual(test_pop.argline_dict, {}) self.assertEqual(test_pop.persistent_data_memory_dict, {}) - self.assertTrue(test_pop.grid_options["parse_function"] == None) + self.assertTrue(test_pop.grid_options["parse_function"] is None) self.assertTrue(isinstance(test_pop.grid_options["_main_pid"], int)) + +class test_set(unittest.TestCase): + """ + Unittests for _setup function + """ + def test_set(self): - with Capturing() as output: + with Capturing() as _: self._test_set() def _test_set(self): @@ -108,7 +145,7 @@ class test_Population(unittest.TestCase): Unittests for function set """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set(num_cores=2, verbosity=TEST_VERBOSITY) test_pop.set(M_1=10) test_pop.set(data_dir="/tmp/binary_c_python") @@ -124,8 +161,14 @@ class test_Population(unittest.TestCase): # self.assertTrue(test_pop.grid_options["num_cores"] == 2) + +class test_cmdline(unittest.TestCase): + """ + Unittests for cmdline function + """ + def test_cmdline(self): - with Capturing() as output: + with Capturing() as _: self._test_cmdline() def _test_cmdline(self): @@ -145,7 +188,7 @@ class test_Population(unittest.TestCase): ] # Set up population - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set(data_dir="/tmp", verbosity=TEST_VERBOSITY) # parse arguments @@ -166,8 +209,14 @@ class test_Population(unittest.TestCase): # put back the other args if they exist sys.argv = prev_sysargv.copy() + +class test__return_argline(unittest.TestCase): + """ + Unittests for _return_argline function + """ + def test__return_argline(self): - with Capturing() as output: + with Capturing() as _: self._test__return_argline() def _test__return_argline(self): @@ -176,7 +225,7 @@ class test_Population(unittest.TestCase): """ # Set up population - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set(metallicity=0.02, verbosity=TEST_VERBOSITY) test_pop.set(M_1=10) @@ -191,53 +240,14 @@ class test_Population(unittest.TestCase): argline2 == "binary_c example_parameter1 10 example_parameter2 hello" ) - def test_add_grid_variable(self): - with Capturing() as output: - self._test_add_grid_variable() - - def _test_add_grid_variable(self): - """ - Unittests for the function add_grid_variable - - TODO: Should I test more here? - """ - - test_pop = Population() - - resolution = {"M_1": 10, "q": 10} - test_pop.add_grid_variable( - name="lnm1", - longname="Primary mass", - valuerange=[1, 100], - samplerfunc="const(math.log(1), math.log(100), {})".format( - resolution["M_1"] - ), - precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", - dphasevol="dlnm1", - parameter_name="M_1", - condition="", # Impose a condition on this grid variable. Mostly for a check for yourself - ) - - test_pop.add_grid_variable( - name="q", - longname="Mass ratio", - valuerange=["0.1/M_1", 1], - samplerfunc="const(0.1/M_1, 1, {})".format(resolution["q"]), - probdist="flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])", - dphasevol="dq", - precode="M_2 = q * M_1", - parameter_name="M_2", - condition="", # Impose a condition on this grid variable. Mostly for a check for yourself - ) - - self.assertIn("q", test_pop.grid_options["_grid_variables"]) - self.assertIn("lnm1", test_pop.grid_options["_grid_variables"]) - self.assertEqual(len(test_pop.grid_options["_grid_variables"]), 2) +class test_return_population_settings(unittest.TestCase): + """ + Unittests for return_population_settings function + """ def test_return_population_settings(self): - with Capturing() as output: + with Capturing() as _: self._test_return_population_settings() def _test_return_population_settings(self): @@ -245,7 +255,7 @@ class test_Population(unittest.TestCase): Unittests for the function return_population_settings """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set(metallicity=0.02, verbosity=TEST_VERBOSITY) test_pop.set(M_1=10) test_pop.set(num_cores=2) @@ -263,41 +273,14 @@ class test_Population(unittest.TestCase): self.assertIn("custom_options", population_settings) self.assertTrue(population_settings["custom_options"]["data_dir"] == "/tmp") - def test_return_binary_c_version_info(self): - with Capturing() as output: - self._test_return_binary_c_version_info() - - def _test_return_binary_c_version_info(self): - """ - Unittests for the function return_binary_c_version_info - """ - - test_pop = Population() - binary_c_version_info = test_pop.return_binary_c_version_info(parsed=True) - - self.assertTrue(isinstance(binary_c_version_info, dict)) - self.assertIn("isotopes", binary_c_version_info) - self.assertIn("argpairs", binary_c_version_info) - self.assertIn("ensembles", binary_c_version_info) - self.assertIn("macros", binary_c_version_info) - self.assertIn("dt_limits", binary_c_version_info) - self.assertIn("nucleosynthesis_sources", binary_c_version_info) - self.assertIn("miscellaneous", binary_c_version_info) - self.assertIsNotNone(binary_c_version_info["argpairs"]) - self.assertIsNotNone(binary_c_version_info["ensembles"]) - self.assertIsNotNone(binary_c_version_info["macros"]) - self.assertIsNotNone(binary_c_version_info["dt_limits"]) - self.assertIsNotNone(binary_c_version_info["miscellaneous"]) - - if binary_c_version_info["macros"]["NUCSYN"] == "on": - self.assertIsNotNone(binary_c_version_info["isotopes"]) - - if binary_c_version_info["macros"]["NUCSYN_ID_SOURCES"] == "on": - self.assertIsNotNone(binary_c_version_info["nucleosynthesis_sources"]) +class test_return_binary_c_defaults(unittest.TestCase): + """ + Unittests for return_binary_c_defaults function + """ def test_return_binary_c_defaults(self): - with Capturing() as output: + with Capturing() as _: self._test_return_binary_c_defaults() def _test_return_binary_c_defaults(self): @@ -305,14 +288,20 @@ class test_Population(unittest.TestCase): Unittests for the function return_binary_c_defaults """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) binary_c_defaults = test_pop.return_binary_c_defaults() self.assertIn("probability", binary_c_defaults) self.assertIn("phasevol", binary_c_defaults) self.assertIn("metallicity", binary_c_defaults) + +class test_return_all_info(unittest.TestCase): + """ + Unittests for return_all_info function + """ + def test_return_all_info(self): - with Capturing() as output: + with Capturing() as _: self._test_return_all_info() def _test_return_all_info(self): @@ -321,7 +310,7 @@ class test_Population(unittest.TestCase): Not going to do too much tests here, just check if they are not empty """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) all_info = test_pop.return_all_info() self.assertIn("population_settings", all_info) @@ -334,8 +323,14 @@ class test_Population(unittest.TestCase): self.assertNotEqual(all_info["binary_c_version_info"], {}) self.assertNotEqual(all_info["binary_c_help_all"], {}) + +class test_export_all_info(unittest.TestCase): + """ + Unittests for export_all_info function + """ + def test_export_all_info(self): - with Capturing() as output: + with Capturing() as _: self._test_export_all_info() def _test_export_all_info(self): @@ -343,7 +338,7 @@ class test_Population(unittest.TestCase): Unittests for the function export_all_info """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set(metallicity=0.02, verbosity=TEST_VERBOSITY) test_pop.set(M_1=10) @@ -353,7 +348,9 @@ class test_Population(unittest.TestCase): # datadir settings_filename = test_pop.export_all_info(use_datadir=True) self.assertTrue(os.path.isfile(settings_filename)) - with open(settings_filename, "r") as f: + + # We currently export the file as a gzip file so we need to take that into accoutn + with gzip.open(settings_filename, "rb") as f: all_info = json.loads(f.read()) # @@ -398,8 +395,14 @@ class test_Population(unittest.TestCase): outfile=os.path.join(TMP_DIR, "example_settings.txt"), ) + +class test__cleanup_defaults(unittest.TestCase): + """ + Unittests for _cleanup_defaults function + """ + def test__cleanup_defaults(self): - with Capturing() as output: + with Capturing() as _: self._test__cleanup_defaults() def _test__cleanup_defaults(self): @@ -407,12 +410,18 @@ class test_Population(unittest.TestCase): Unittests for the function _cleanup_defaults """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) cleaned_up_defaults = test_pop._cleanup_defaults() self.assertNotIn("help_all", cleaned_up_defaults) + +class test__increment_probtot(unittest.TestCase): + """ + Unittests for _increment_probtot function + """ + def test__increment_probtot(self): - with Capturing() as output: + with Capturing() as _: self._test__increment_probtot() def _test__increment_probtot(self): @@ -420,25 +429,37 @@ class test_Population(unittest.TestCase): Unittests for the function _increment_probtot """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop._increment_probtot(0.5) self.assertEqual(test_pop.grid_options["_probtot"], 0.5) + +class test__increment_count(unittest.TestCase): + """ + Unittests for _increment_count function + """ + def test__increment_count(self): - with Capturing() as output: + with Capturing() as _: self._test__increment_count() def _test__increment_count(self): """ - Unittests for the function _increment_probtot + Unittests for the function _increment_count """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop._increment_count() self.assertEqual(test_pop.grid_options["_count"], 1) + +class test__dict_from_line_source_file(unittest.TestCase): + """ + Unittests for _dict_from_line_source_file function + """ + def test__dict_from_line_source_file(self): - with Capturing() as output: + with Capturing() as _: self._test__dict_from_line_source_file() def _test__dict_from_line_source_file(self): @@ -452,7 +473,7 @@ class test_Population(unittest.TestCase): with open(source_file, "w") as f: f.write("binary_c M_1 10 metallicity 0.02\n") - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) # readout with open(source_file, "r") as f: @@ -462,8 +483,14 @@ class test_Population(unittest.TestCase): self.assertTrue(argdict["M_1"] == 10) self.assertTrue(argdict["metallicity"] == 0.02) + +class test_evolve_single(unittest.TestCase): + """ + Unittests for evolve_single function + """ + def test_evolve_single(self): - with Capturing() as output: + with Capturing() as _: self._test_evolve_single() def _test_evolve_single(self): @@ -485,7 +512,7 @@ class test_Population(unittest.TestCase): ); """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set( M_1=10, M_2=5, @@ -505,7 +532,7 @@ class test_Population(unittest.TestCase): # custom_logging_dict = {"TEST_CUSTOM_LOGGING_2": ["star[0].mass", "model.time"]} - test_pop_2 = Population() + test_pop_2 = Population(tmp_dir=TMP_DIR) test_pop_2.set( M_1=10, M_2=5, @@ -524,13 +551,127 @@ class test_Population(unittest.TestCase): self.assertIn("TEST_CUSTOM_LOGGING_2", output_2) +######## +# Some tests that are not really -unit- tests +class test_resultdict(unittest.TestCase): + """ + Unittests for bin_data + """ + + def test_adding_results(self): + with Capturing() as _: + self._test_adding_results() + + def _test_adding_results(self): + """ + Function to test whether the results are properly added and combined + """ + + # Create custom logging statement + custom_logging_statement = """ + if (stardata->model.time < stardata->model.max_evolution_time) + { + Printf("EXAMPLE_OUTPUT %30.16e %g %g %30.12e %d\\n", + // + stardata->model.time, // 1 + stardata->star[0].mass, // 2 + stardata->common.zero_age.mass[0], // 3 + stardata->model.probability, // 4 + stardata->star[0].stellar_type // 5 + ); + }; + /* Kill the simulation to save time */ + stardata->model.max_evolution_time = stardata->model.time - stardata->model.dtm; + """ + + example_pop = Population(tmp_dir=TMP_DIR) + example_pop.set(verbosity=0) + example_pop.set( + max_evolution_time=15000, # bse_options + # grid_options + num_cores=3, + tmp_dir=TMP_DIR, + # Custom options + data_dir=os.path.join(TMP_DIR, "test_resultdict"), # custom_options + C_logging_code=custom_logging_statement, + parse_function=parse_function_adding_results, + ) + + # Add grid variables + resolution = {"M_1": 10} + + # Mass + example_pop.add_grid_variable( + name="lnm1", + longname="Primary mass", + valuerange=[2, 150], + samplerfunc="self.const_linear(math.log(2), math.log(150), {})".format( + resolution["M_1"] + ), + precode="M_1=math.exp(lnm1)", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1", + dphasevol="dlnm1", + parameter_name="M_1", + condition="", # Impose a condition on this grid variable. Mostly for a check for yourself + ) + + ## Executing a population + ## This uses the values generated by the grid_variables + analytics = example_pop.evolve() + + # + grid_prob = analytics["total_probability"] + result_dict_prob = example_pop.grid_results["example"]["probability"] + + # amt systems + grid_count = analytics["total_count"] + result_dict_count = example_pop.grid_results["example"]["count"] + + # Check if the total probability matches + self.assertAlmostEqual( + grid_prob, + result_dict_prob, + places=12, + msg="Total probability from grid {} and from result dict {} are not equal".format( + grid_prob, result_dict_prob + ), + ) + + # Check if the total count matches + self.assertEqual( + grid_count, + result_dict_count, + msg="Total count from grid {} and from result dict {} are not equal".format( + grid_count, result_dict_count + ), + ) + + # Check if the structure is what we expect. Note: this depends on the probability calculation. if that changes we need to recalibrate this + test_case_dict = { + 2.25: 0.01895481306515, + 3.75: 0.01081338190204, + 5.75: 0.006168841009268, + 9.25: 0.003519213484031, + 13.75: 0.002007648361756, + 21.25: 0.001145327489437, + 33.25: 0.0006533888518775, + 50.75: 0.0003727466560393, + 78.25: 0.000212645301782, + 120.75: 0.0001213103421247, + } + + self.assertEqual( + test_case_dict, dict(example_pop.grid_results["example"]["mass"]) + ) + + class test_grid_evolve(unittest.TestCase): """ Unittests for function Population.evolve() """ def test_grid_evolve_1_thread(self): - with Capturing() as output: + with Capturing() as _: self._test_grid_evolve_1_thread() def _test_grid_evolve_1_thread(self): @@ -538,7 +679,7 @@ class test_grid_evolve(unittest.TestCase): Unittests to see if 1 thread does all the systems """ - test_pop_evolve_1_thread = Population() + test_pop_evolve_1_thread = Population(tmp_dir=TMP_DIR) test_pop_evolve_1_thread.set( num_cores=1, M_2=1, orbital_period=100000, verbosity=TEST_VERBOSITY ) @@ -549,11 +690,11 @@ class test_grid_evolve(unittest.TestCase): name="lnm1", longname="Primary mass", valuerange=[1, 100], - samplerfunc="const(math.log(1), math.log(100), {})".format( + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( resolution["M_1"] ), precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", dphasevol="dlnm1", parameter_name="M_1", condition="", # Impose a condition on this grid variable. Mostly for a check for yourself @@ -568,7 +709,7 @@ class test_grid_evolve(unittest.TestCase): self.assertTrue(analytics["total_count"] == 10) def test_grid_evolve_2_threads(self): - with Capturing() as output: + with Capturing() as _: self._test_grid_evolve_2_threads() def _test_grid_evolve_2_threads(self): @@ -576,7 +717,7 @@ class test_grid_evolve(unittest.TestCase): Unittests to see if multiple threads handle the all the systems correctly """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set( num_cores=2, M_2=1, orbital_period=100000, verbosity=TEST_VERBOSITY ) @@ -587,11 +728,11 @@ class test_grid_evolve(unittest.TestCase): name="lnm1", longname="Primary mass", valuerange=[1, 100], - samplerfunc="const(math.log(1), math.log(100), {})".format( + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( resolution["M_1"] ), precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", dphasevol="dlnm1", parameter_name="M_1", condition="", # Impose a condition on this grid variable. Mostly for a check for yourself @@ -606,7 +747,7 @@ class test_grid_evolve(unittest.TestCase): self.assertTrue(analytics["total_count"] == 10) def test_grid_evolve_2_threads_with_custom_logging(self): - with Capturing() as output: + with Capturing() as _: self._test_grid_evolve_2_threads_with_custom_logging() def _test_grid_evolve_2_threads_with_custom_logging(self): @@ -618,7 +759,7 @@ class test_grid_evolve(unittest.TestCase): num_cores_value = 2 custom_logging_string = 'Printf("MY_STELLAR_DATA_TEST_EXAMPLE %g %g %g %g\\n",((double)stardata->model.time),((double)stardata->star[0].mass),((double)stardata->model.probability),((double)stardata->model.dt));' - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set( num_cores=num_cores_value, @@ -636,11 +777,11 @@ class test_grid_evolve(unittest.TestCase): name="lnm1", longname="Primary mass", valuerange=[1, 100], - samplerfunc="const(math.log(1), math.log(100), {})".format( + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( resolution["M_1"] ), precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", dphasevol="dlnm1", parameter_name="M_1", condition="", # Impose a condition on this grid variable. Mostly for a check for yourself @@ -651,7 +792,7 @@ class test_grid_evolve(unittest.TestCase): os.path.join( data_dir_value, "test_grid_evolve_2_threads_with_custom_logging_outputfile_population_{}_thread_{}.dat".format( - analytics["population_name"], thread_id + analytics["population_id"], thread_id ), ) for thread_id in range(num_cores_value) @@ -668,7 +809,7 @@ class test_grid_evolve(unittest.TestCase): remove_file(output_name) def test_grid_evolve_with_condition_error(self): - with Capturing() as output: + with Capturing() as _: self._test_grid_evolve_with_condition_error() def _test_grid_evolve_with_condition_error(self): @@ -676,7 +817,7 @@ class test_grid_evolve(unittest.TestCase): Unittests to see if the threads catch the errors correctly. """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set( num_cores=2, M_2=1, orbital_period=100000, verbosity=TEST_VERBOSITY ) @@ -706,11 +847,11 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", name="lnm1", longname="Primary mass", valuerange=[1, 100], - samplerfunc="const(math.log(1), math.log(100), {})".format( + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( resolution["M_1"] ), precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", dphasevol="dlnm1", parameter_name="M_1", condition="", # Impose a condition on this grid variable. Mostly for a check for yourself @@ -725,12 +866,12 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", self.assertEqual(analytics["failed_systems_error_codes"], [0]) self.assertTrue(analytics["total_count"] == 10) self.assertTrue(analytics["failed_count"] == 10) - self.assertTrue(analytics["errors_found"] == True) - self.assertTrue(analytics["errors_exceeded"] == True) + self.assertTrue(analytics["errors_found"] is True) + self.assertTrue(analytics["errors_exceeded"] is True) # test to see if 1 thread does all the systems - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set( num_cores=2, M_2=1, orbital_period=100000, verbosity=TEST_VERBOSITY ) @@ -743,11 +884,11 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", name="lnm1", longname="Primary mass", valuerange=[1, 100], - samplerfunc="const(math.log(1), math.log(100), {})".format( + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( resolution["M_1"] ), precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", dphasevol="dlnm1", parameter_name="M_1", condition="", # Impose a condition on this grid variable. Mostly for a check for yourself @@ -757,8 +898,8 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", name="q", longname="Mass ratio", valuerange=["0.1/M_1", 1], - samplerfunc="const(0.1/M_1, 1, {})".format(resolution["q"]), - probdist="flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])", + samplerfunc="self.const_linear(0.1/M_1, 1, {})".format(resolution["q"]), + probdist="self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])", dphasevol="dq", precode="M_2 = q * M_1", parameter_name="M_2", @@ -774,7 +915,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", # self.assertRaises(ValueError, test_pop.evolve) def test_grid_evolve_no_grid_variables(self): - with Capturing() as output: + with Capturing() as _: self._test_grid_evolve_no_grid_variables() def _test_grid_evolve_no_grid_variables(self): @@ -782,7 +923,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", Unittests to see if errors are raised if there are no grid variables """ - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set( num_cores=1, M_2=1, orbital_period=100000, verbosity=TEST_VERBOSITY ) @@ -791,7 +932,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", self.assertRaises(ValueError, test_pop.evolve) def test_grid_evolve_2_threads_with_ensemble_direct_output(self): - with Capturing() as output: + with Capturing() as _: self._test_grid_evolve_2_threads_with_ensemble_direct_output() def _test_grid_evolve_2_threads_with_ensemble_direct_output(self): @@ -802,7 +943,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", data_dir_value = TMP_DIR num_cores_value = 2 - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set( num_cores=num_cores_value, verbosity=TEST_VERBOSITY, @@ -816,7 +957,6 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", ) test_pop.set( data_dir=TMP_DIR, - ensemble_output_name="ensemble_output.json", combine_ensemble_with_thread_joining=False, ) @@ -826,11 +966,11 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", name="lnm1", longname="Primary mass", valuerange=[1, 100], - samplerfunc="const(math.log(1), math.log(100), {})".format( + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( resolution["M_1"] ), precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", dphasevol="dlnm1", parameter_name="M_1", condition="", # Impose a condition on this grid variable. Mostly for a check for yourself @@ -841,7 +981,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", os.path.join( data_dir_value, "ensemble_output_{}_{}.json".format( - analytics["population_name"], thread_id + analytics["population_id"], thread_id ), ) for thread_id in range(num_cores_value) @@ -862,7 +1002,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", self.assertNotEqual(ensemble_json["number_counts"], {}) def test_grid_evolve_2_threads_with_ensemble_combining(self): - with Capturing() as output: + with Capturing() as _: self._test_grid_evolve_2_threads_with_ensemble_combining() def _test_grid_evolve_2_threads_with_ensemble_combining(self): @@ -873,7 +1013,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", data_dir_value = TMP_DIR num_cores_value = 2 - test_pop = Population() + test_pop = Population(tmp_dir=TMP_DIR) test_pop.set( num_cores=num_cores_value, verbosity=TEST_VERBOSITY, @@ -888,7 +1028,6 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", test_pop.set( data_dir=TMP_DIR, combine_ensemble_with_thread_joining=True, - ensemble_output_name="ensemble_output.json", ) resolution = {"M_1": 10} @@ -897,11 +1036,11 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", name="lnm1", longname="Primary mass", valuerange=[1, 100], - samplerfunc="const(math.log(1), math.log(100), {})".format( + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( resolution["M_1"] ), precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", dphasevol="dlnm1", parameter_name="M_1", condition="", # Impose a condition on this grid variable. Mostly for a check for yourself @@ -918,7 +1057,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", ) def test_grid_evolve_2_threads_with_ensemble_comparing_two_methods(self): - with Capturing() as output: + with Capturing() as _: self._test_grid_evolve_2_threads_with_ensemble_comparing_two_methods() def _test_grid_evolve_2_threads_with_ensemble_comparing_two_methods(self): @@ -930,7 +1069,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", num_cores_value = 2 # First - test_pop_1 = Population() + test_pop_1 = Population(tmp_dir=TMP_DIR) test_pop_1.set( num_cores=num_cores_value, verbosity=TEST_VERBOSITY, @@ -945,7 +1084,6 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", test_pop_1.set( data_dir=TMP_DIR, combine_ensemble_with_thread_joining=True, - ensemble_output_name="ensemble_output.json", ) resolution = {"M_1": 10} @@ -954,11 +1092,11 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", name="lnm1", longname="Primary mass", valuerange=[1, 100], - samplerfunc="const(math.log(1), math.log(100), {})".format( + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( resolution["M_1"] ), precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", dphasevol="dlnm1", parameter_name="M_1", condition="", # Impose a condition on this grid variable. Mostly for a check for yourself @@ -968,7 +1106,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", ensemble_output_1 = test_pop_1.grid_ensemble_results # second - test_pop_2 = Population() + test_pop_2 = Population(tmp_dir=TMP_DIR) test_pop_2.set( num_cores=num_cores_value, verbosity=TEST_VERBOSITY, @@ -982,7 +1120,6 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", ) test_pop_2.set( data_dir=TMP_DIR, - ensemble_output_name="ensemble_output.json", combine_ensemble_with_thread_joining=False, ) @@ -992,11 +1129,11 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", name="lnm1", longname="Primary mass", valuerange=[1, 100], - samplerfunc="const(math.log(1), math.log(100), {})".format( + samplerfunc="self.const_linear(math.log(1), math.log(100), {})".format( resolution["M_1"] ), precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + probdist="self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", dphasevol="dlnm1", parameter_name="M_1", condition="", # Impose a condition on this grid variable. Mostly for a check for yourself @@ -1007,7 +1144,7 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", os.path.join( data_dir_value, "ensemble_output_{}_{}.json".format( - analytics_2["population_name"], thread_id + analytics_2["population_id"], thread_id ), ) for thread_id in range(num_cores_value) @@ -1039,146 +1176,5 @@ Printf("TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g\\n", ) -def parse_function_adding_results(self, output): - """ - Example parse function - """ - - seperator = " " - - parameters = ["time", "mass", "zams_mass", "probability", "stellar_type"] - - self.grid_results["example"]["count"] += 1 - - # Go over the output. - for line in output.splitlines(): - headerline = line.split()[0] - - # CHeck the header and act accordingly - if headerline == "EXAMPLE_OUTPUT": - values = line.split()[1:] - - # Bin the mass probability - self.grid_results["example"]["mass"][ - bin_data(float(values[2]), binwidth=0.5) - ] += float(values[3]) - - # - if not len(parameters) == len(values): - print("Number of column names isnt equal to number of columns") - raise ValueError - - # record the probability of this line (Beware, this is meant to only be run once for each system. its a controls quantity) - self.grid_results["example"]["probability"] += float(values[3]) - - -class test_resultdict(unittest.TestCase): - """ - Unittests for bin_data - """ - - def test_adding_results(self): - """ - Function to test whether the results are properly added and combined - """ - - # Create custom logging statement - custom_logging_statement = """ - if (stardata->model.time < stardata->model.max_evolution_time) - { - Printf("EXAMPLE_OUTPUT %30.16e %g %g %30.12e %d\\n", - // - stardata->model.time, // 1 - stardata->star[0].mass, // 2 - stardata->common.zero_age.mass[0], // 3 - stardata->model.probability, // 4 - stardata->star[0].stellar_type // 5 - ); - }; - /* Kill the simulation to save time */ - stardata->model.max_evolution_time = stardata->model.time - stardata->model.dtm; - """ - - example_pop = Population() - example_pop.set(verbosity=0) - example_pop.set( - max_evolution_time=15000, # bse_options - # grid_options - num_cores=3, - tmp_dir=TMP_DIR, - # Custom options - data_dir=os.path.join(TMP_DIR, "test_resultdict"), # custom_options - C_logging_code=custom_logging_statement, - parse_function=parse_function_adding_results, - ) - - # Add grid variables - resolution = {"M_1": 10} - - # Mass - example_pop.add_grid_variable( - name="lnm1", - longname="Primary mass", - valuerange=[2, 150], - samplerfunc="const(math.log(2), math.log(150), {})".format( - resolution["M_1"] - ), - precode="M_1=math.exp(lnm1)", - probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1", - dphasevol="dlnm1", - parameter_name="M_1", - condition="", # Impose a condition on this grid variable. Mostly for a check for yourself - ) - - ## Executing a population - ## This uses the values generated by the grid_variables - analytics = example_pop.evolve() - - # - grid_prob = analytics["total_probability"] - result_dict_prob = example_pop.grid_results["example"]["probability"] - - # amt systems - grid_count = analytics["total_count"] - result_dict_count = example_pop.grid_results["example"]["count"] - - # Check if the total probability matches - self.assertAlmostEqual( - grid_prob, - result_dict_prob, - places=12, - msg="Total probability from grid {} and from result dict {} are not equal".format( - grid_prob, result_dict_prob - ), - ) - - # Check if the total count matches - self.assertEqual( - grid_count, - result_dict_count, - msg="Total count from grid {} and from result dict {} are not equal".format( - grid_count, result_dict_count - ), - ) - - # Check if the structure is what we expect. Note: this depends on the probability calculation. if that changes we need to recalibrate this - test_case_dict = { - 2.25: 0.01895481306515, - 3.75: 0.01081338190204, - 5.75: 0.006168841009268, - 9.25: 0.003519213484031, - 13.75: 0.002007648361756, - 21.25: 0.001145327489437, - 33.25: 0.0006533888518775, - 50.75: 0.0003727466560393, - 78.25: 0.000212645301782, - 120.75: 0.0001213103421247, - } - - self.assertEqual( - test_case_dict, dict(example_pop.grid_results["example"]["mass"]) - ) - - if __name__ == "__main__": unittest.main() diff --git a/binarycpython/tests/test_hpc_functions.py b/binarycpython/tests/test_hpc_functions.py deleted file mode 100644 index e5fe16c34ea86965592827255a6649a54de2c149..0000000000000000000000000000000000000000 --- a/binarycpython/tests/test_hpc_functions.py +++ /dev/null @@ -1,7 +0,0 @@ -""" -Unittests for hpc_functions module -""" - -from binarycpython.utils.hpc_functions import * - -# TODO: write tests for hpc functions diff --git a/binarycpython/tests/test_run_system_wrapper.py b/binarycpython/tests/test_run_system_wrapper.py index ef4cc754d43de33d02c0cf748caa16f2e9147a30..66bfbc41ab68baae3ea9bbf3ba662d7fd885134c 100644 --- a/binarycpython/tests/test_run_system_wrapper.py +++ b/binarycpython/tests/test_run_system_wrapper.py @@ -3,3 +3,10 @@ Unittests for run_system_wrapper """ # TODO: write tests for run_system_wrapper + +import unittest + +from binarycpython.utils.run_system_wrapper import run_system + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/test_stellar_types.py b/binarycpython/tests/test_stellar_types.py index 84d3e5ee35edc912fdccadaf4c5c03956a54a1de..9f2f9adbf182a36765a8c8b9642b462bed57cabd 100644 --- a/binarycpython/tests/test_stellar_types.py +++ b/binarycpython/tests/test_stellar_types.py @@ -1,3 +1,10 @@ """ Unittests for stellar_types module """ + +import unittest + +from binarycpython.utils.stellar_types import STELLAR_TYPE_DICT, STELLAR_TYPE_DICT_SHORT + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/test_useful_funcs.py b/binarycpython/tests/test_useful_funcs.py index bbab35f7a292118dcf06e6f081cc04777265e111..1c1ed570951cfca8872beeb18e8e36f881ac6569 100644 --- a/binarycpython/tests/test_useful_funcs.py +++ b/binarycpython/tests/test_useful_funcs.py @@ -18,14 +18,6 @@ from binarycpython.utils.useful_funcs import ( calc_period_from_sep, ) -# class test_(unittest.TestCase): -# """ -# Unittests for function -# """ - -# def test_1(self): -# pass - class test_calc_period_from_sep(unittest.TestCase): """ @@ -105,7 +97,7 @@ class test_ragb(unittest.TestCase): """ m = 20 - output = ragb(m, 0.02) + output = ragb(m) self.assertEqual(output, 820) diff --git a/binarycpython/tests/tests_population_extensions/__init__.py b/binarycpython/tests/tests_population_extensions/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/binarycpython/tests/tests_population_extensions/test_HPC.py b/binarycpython/tests/tests_population_extensions/test_HPC.py new file mode 100644 index 0000000000000000000000000000000000000000..7bb35a2f4f2e4a4fbc784c1dca9b9f8f25447640 --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_HPC.py @@ -0,0 +1,738 @@ +""" +Unit tests for the HPC module + +TODO: HPC_make_joiningfile +TODO: HPC_joinlist +TODO: HPC_load_joinfiles_list +TODO: HPC_join_from_files +TODO: HPC_can_join +TODO: HPC_job_task +TODO: HPC_grid +TODO: HPC_id_from_dir +TODO: HPC_restore +TODO: HPC_join_previous +TODO: HPC_path +TODO: HPC_snapshot_filename +TODO: HPC_dir +TODO: HPC_touch +TODO: HPC_status +TODO: HPC_dump_status +TODO: HPC_queue_stats +""" + +import os +import shutil +import unittest +from binarycpython.utils.functions import Capturing, temp_dir +from binarycpython.utils.grid import Population + +TMP_DIR = temp_dir("tests", "test_HPC") +shutil.rmtree(TMP_DIR) +os.makedirs(TMP_DIR, exist_ok=True) + + +class test_HPC_njobs(unittest.TestCase): + """ + Unittests for function HPC_njobs + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_nJobs for condor + """ + + condor_pop = Population() + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_njobs"] = 10 + + result_condor = condor_pop.HPC_njobs() + + self.assertEqual(result_condor, 10) + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_nJobs for slurm + """ + + slurm_pop = Population() + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_njobs"] = 11 + + result_slurm = slurm_pop.HPC_njobs() + + self.assertEqual(result_slurm, 11) + + def test_none(self): + with Capturing() as output: + self._test_none() + + def _test_none(self): + """ + Unit test for HPC_nJobs when nothing is set + """ + + none_pop = Population() + self.assertRaises(TypeError, none_pop.HPC_njobs) + + +class test_HPC_job(unittest.TestCase): + """ + Unittests for function HPC_job + """ + + def test_HPC_job(self): + with Capturing() as output: + self._test_HPC_job() + + def _test_HPC_job(self): + """ + Test to see if its busy with a job + """ + + slurm_pop = Population() + slurm_pop.grid_options["slurm"] = 1 + + self.assertTrue(slurm_pop.HPC_job()) + + +class test_HPC_job_type(unittest.TestCase): + """ + Unittests for function HPC_job_type + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_nJobs for condor + """ + + condor_pop = Population() + condor_pop.grid_options["condor"] = 1 + result_condor = condor_pop.HPC_job_type() + + self.assertEqual(result_condor, "condor") + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_nJobs for slurm + """ + + slurm_pop = Population() + slurm_pop.grid_options["slurm"] = 1 + result_slurm = slurm_pop.HPC_job_type() + + self.assertEqual(result_slurm, "slurm") + + def test_none(self): + with Capturing() as output: + self._test_none() + + def _test_none(self): + """ + Unit test for HPC_nJobs when nothing is set + """ + + none_pop = Population() + result_none = none_pop.HPC_job_type() + self.assertEqual(result_none, "None") + + +class test_HPC_jobID(unittest.TestCase): + """ + Unittests for function HPC_jobID + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_jobID for condor + """ + + condor_pop = Population() + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + + self.assertEqual( + condor_pop.HPC_jobID(), + "{ClusterID}.{Process}".format(ClusterID=2, Process=3), + ) + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_jobID for slurm + """ + + slurm_pop = Population() + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + + self.assertEqual( + slurm_pop.HPC_jobID(), + "{jobid}.{jobarrayindex}".format(jobid=4, jobarrayindex=5), + ) + + def test_none(self): + with Capturing() as output: + self._test_none() + + def _test_none(self): + """ + Unit test for HPC_nJobs when nothing is set + """ + + none_pop = Population() + result_none = none_pop.HPC_jobID() + self.assertEqual(result_none, None) + + +class test_HPC_jobID_tuple(unittest.TestCase): + """ + Unittests for function HPC_jobID_tuple + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_jobID_tuple for condor + """ + + condor_pop = Population() + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + + self.assertEqual(condor_pop.HPC_jobID_tuple(), ("2", "3")) + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_jobID for slurm + """ + + slurm_pop = Population() + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + + self.assertEqual(slurm_pop.HPC_jobID_tuple(), ("4", "5")) + + def test_none(self): + with Capturing() as output: + self._test_none() + + def _test_none(self): + """ + Unit test for HPC_nJobs when nothing is set + """ + + none_pop = Population() + self.assertEqual(none_pop.HPC_jobID_tuple(), (None, None)) + + +class test_HPC_dirs(unittest.TestCase): + """ + Unittests for function HPC_jobID_tuple + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_dirs for condor + """ + + condor_pop = Population() + condor_pop.grid_options["condor"] = 1 + self.assertEqual(condor_pop.HPC_dirs(), ["condor_dir"]) + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_jobID for slurm + """ + + slurm_pop = Population() + slurm_pop.grid_options["slurm"] = 1 + self.assertEqual(slurm_pop.HPC_dirs(), ["slurm_dir"]) + + def test_none(self): + with Capturing() as output: + self._test_none() + + def _test_none(self): + """ + Unit test for HPC_nJobs when nothing is set + """ + + none_pop = Population() + self.assertEqual(none_pop.HPC_dirs(), []) + + +class test_HPC_id_filename(unittest.TestCase): + """ + Unittests for function HPC_id_filename + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_id_filename for condor + """ + + condor_pop = Population() + condor_pop.grid_options["condor"] = 1 + self.assertEqual(condor_pop.HPC_id_filename(), "ClusterID") + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_id_filename for slurm + """ + + slurm_pop = Population() + slurm_pop.grid_options["slurm"] = 1 + self.assertEqual(slurm_pop.HPC_id_filename(), "jobid") + + def test_none(self): + with Capturing() as output: + self._test_none() + + def _test_none(self): + """ + Unit test for HPC_id_filename when nothing is set + """ + + none_pop = Population() + self.assertEqual(none_pop.HPC_id_filename(), None) + + +class test_HPC_check_requirements(unittest.TestCase): + """ + Unittests for function HPC_check_requirements + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_check_requirements for condor + """ + + condor_pop = Population() + condor_pop.grid_options["condor"] = 1 + self.assertEqual(condor_pop.HPC_id_filename(), "ClusterID") + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + + # First the False test + result_1 = condor_pop.HPC_check_requirements() + self.assertFalse(result_1[0]) + self.assertTrue(len(result_1[1]) > 0) + + # First the True test + condor_pop.grid_options["condor_dir"] = TMP_DIR + result_2 = condor_pop.HPC_check_requirements() + self.assertTrue(result_2[0]) + self.assertTrue(len(result_2[1]) == 0) + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_check_requirements for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + + # First the False test + result_1 = slurm_pop.HPC_check_requirements() + self.assertFalse(result_1[0]) + self.assertTrue(len(result_1[1]) > 0) + + # First the True test + slurm_pop.grid_options["slurm_dir"] = TMP_DIR + result_2 = slurm_pop.HPC_check_requirements() + self.assertTrue(result_2[0]) + self.assertTrue(len(result_2[1]) == 0) + + def test_none(self): + with Capturing() as output: + self._test_none() + + def _test_none(self): + """ + Unit test for HPC_check_requirements when nothing is set + """ + + none_pop = Population(tmp_dir=TMP_DIR) + result_none = none_pop.HPC_check_requirements() + self.assertTrue(result_none[0]) + self.assertTrue(len(result_none[1]) == 0) + + +class test_HPC_set_status(unittest.TestCase): + """ + Unittests for function HPC_set_status + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_set_status for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + condor_pop.grid_options["condor_dir"] = TMP_DIR + + # + os.makedirs( + os.path.dirname( + condor_pop.condor_status_file( + condor_dir=condor_pop.grid_options["condor_dir"] + ) + ), + exist_ok=True, + ) + condor_pop.HPC_set_status("test_set_condor_status") + + # Check if ID file exists + self.assertTrue( + os.path.isfile( + os.path.join(condor_pop.grid_options["condor_dir"], "ClusterID") + ) + ) + + # Check if status file exists + self.assertTrue( + os.path.isfile( + condor_pop.condor_status_file( + condor_dir=condor_pop.grid_options["condor_dir"] + ) + ) + ) + + with open( + condor_pop.condor_status_file( + condor_dir=condor_pop.grid_options["condor_dir"] + ), + "r", + ) as f: + content_file = f.read() + self.assertTrue(content_file == "test_set_condor_status") + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_set_status for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + slurm_pop.grid_options["slurm_dir"] = TMP_DIR + + # + os.makedirs( + os.path.dirname( + slurm_pop.slurm_status_file( + slurm_dir=slurm_pop.grid_options["slurm_dir"] + ) + ), + exist_ok=True, + ) + slurm_pop.HPC_set_status("test_set_slurm_status") + + # Check if ID file exists + self.assertTrue( + os.path.isfile(os.path.join(slurm_pop.grid_options["slurm_dir"], "jobid")) + ) + + # Check if status file exists + self.assertTrue( + os.path.isfile( + slurm_pop.slurm_status_file( + slurm_dir=slurm_pop.grid_options["slurm_dir"] + ) + ) + ) + + with open( + slurm_pop.slurm_status_file(slurm_dir=slurm_pop.grid_options["slurm_dir"]), + "r", + ) as f: + content_file = f.read() + self.assertTrue(content_file == "test_set_slurm_status") + + +class test_HPC_get_status(unittest.TestCase): + """ + Unittests for function HPC_get_status + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_get_status for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + condor_pop.grid_options["condor_dir"] = TMP_DIR + + # + os.makedirs( + os.path.dirname( + condor_pop.condor_status_file( + condor_dir=condor_pop.grid_options["condor_dir"] + ) + ), + exist_ok=True, + ) + condor_pop.HPC_set_status("test_get_condor_status") + + # + status = condor_pop.HPC_get_status() + self.assertEqual(status, "test_get_condor_status") + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_set_status for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + slurm_pop.grid_options["slurm_dir"] = TMP_DIR + + # + os.makedirs( + os.path.dirname( + slurm_pop.slurm_status_file( + slurm_dir=slurm_pop.grid_options["slurm_dir"] + ) + ), + exist_ok=True, + ) + slurm_pop.HPC_set_status("test_set_slurm_status") + + status = slurm_pop.HPC_get_status() + self.assertEqual(status, "test_set_slurm_status") + + +class test_HPC_job_task(unittest.TestCase): + """ + Unittests for function HPC_get_status + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_job_task for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + condor_pop.grid_options["condor_dir"] = TMP_DIR + + # + job_task = condor_pop.HPC_job_task() + self.assertEqual(job_task, 1) + + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_set_status for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + slurm_pop.grid_options["slurm_dir"] = TMP_DIR + + # + job_task = slurm_pop.HPC_job_task() + self.assertEqual(job_task, 1) + + +class test_HPC_dir(unittest.TestCase): + """ + Unittests for function HPC_dir + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_dir for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + condor_pop.grid_options["condor_dir"] = os.path.join(TMP_DIR, "condor") + + # + self.assertEqual(condor_pop.HPC_dir(), os.path.join(TMP_DIR, "condor")) + + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_dir for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + slurm_pop.grid_options["slurm_dir"] = os.path.join(TMP_DIR, "slurm") + + # + self.assertEqual(slurm_pop.HPC_dir(), os.path.join(TMP_DIR, "slurm")) + + def test_none(self): + with Capturing() as output: + self._test_slurm() + + def _test_none(self): + """ + Unit test for HPC_dir for none + """ + + none_pop = Population(tmp_dir=TMP_DIR) + + # + self.assertEqual(none_pop.HPC_dir(), None) + + +class test_HPC_id_from_dir(unittest.TestCase): + """ + Unittests for function HPC_id_from_dir + """ + + def test_condor(self): + with Capturing() as output: + self._test_condor() + + def _test_condor(self): + """ + Unit test for HPC_id_from_dir for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + condor_pop.grid_options["condor_dir"] = TMP_DIR + + # id + id_from_dir = condor_pop.HPC_id_from_dir(condor_pop.HPC_dir()) + + self.assertEqual(id_from_dir.strip(), str(2)) + + def test_slurm(self): + with Capturing() as output: + self._test_slurm() + + def _test_slurm(self): + """ + Unit test for HPC_id_from_dir for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + slurm_pop.grid_options["slurm_dir"] = os.path.join(TMP_DIR) + + # id + id_from_dir = slurm_pop.HPC_id_from_dir(slurm_pop.HPC_dir()) + + self.assertEqual(id_from_dir.strip(), str(4)) + + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/tests_population_extensions/test_Moe_di_Stefano_2017.py b/binarycpython/tests/tests_population_extensions/test_Moe_di_Stefano_2017.py new file mode 100644 index 0000000000000000000000000000000000000000..69a9f26d91eb739a220658b86cf2bc2a6296c6e5 --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_Moe_di_Stefano_2017.py @@ -0,0 +1,18 @@ +""" +Unit tests for the _Moe_di_Stefano_2017 module + +TODO: set_moe_di_stefano_settings +TODO: _load_moe_di_stefano_data +TODO: _set_moe_di_stefano_distributions +TODO: Moe_di_Stefano_2017 +TODO: _clean_interpolators +TODO: _calculate_multiplicity_fraction +TODO: get_moe_di_stefano_dataset +TODO: get_Moe_di_Stefano_2017_default_options +TODO: get_Moe_di_Stefano_2017_default_options_description +""" + +import unittest + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/tests_population_extensions/test_analytics.py b/binarycpython/tests/tests_population_extensions/test_analytics.py new file mode 100644 index 0000000000000000000000000000000000000000..81ba30315aa45c169763df9f6997e9964c66eec4 --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_analytics.py @@ -0,0 +1,13 @@ +""" +Unit classes for the _analytics module population extension + +TODO: make_analytics_dict +TODO: set_time +TODO: time_elapsed +TODO: CPU_time +""" + +import unittest + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/tests_population_extensions/test_cache.py b/binarycpython/tests/tests_population_extensions/test_cache.py new file mode 100644 index 0000000000000000000000000000000000000000..4f3de7284d84d176484f733c57caa70b30e68494 --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_cache.py @@ -0,0 +1,13 @@ +""" +Unit classes for the _cache module population extension + +TODO: default_cache_dir +TODO: NullCache +TODO: setup_function_cache +TODO: test_caches +""" + +import unittest + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/tests_population_extensions/test_condor.py b/binarycpython/tests/tests_population_extensions/test_condor.py new file mode 100644 index 0000000000000000000000000000000000000000..a3a85a3fd118d4e80462b1a9993e18c07d56aaee --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_condor.py @@ -0,0 +1,249 @@ +""" +Unit classes for the _condor module population extension + +TODO: condorpath +TODO: condor_status_file +TODO: condor_grid +TODO: condor_queue_stats +""" + +import os +import shutil +import unittest +from binarycpython.utils.functions import Capturing, temp_dir +from binarycpython.utils.grid import Population + +TMP_DIR = temp_dir("tests", "test_condor") +shutil.rmtree(TMP_DIR) +os.makedirs(TMP_DIR, exist_ok=True) + + +class test_condorID(unittest.TestCase): + """ + Unittests for function HPC_jobID + """ + + def test_condorID(self): + with Capturing() as output: + self._test_condorID() + + def _test_condorID(self): + """ + Unit test for condorID for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + + self.assertEqual( + condor_pop.condorID(), + "{ClusterID}.{Process}".format(ClusterID=2, Process=3), + ) + + +class test_condor_dirs(unittest.TestCase): + """ + Unittests for function condor_dirs + """ + + def test_condor_dirs(self): + with Capturing() as output: + self._test_condor_dirs() + + def _test_condor_dirs(self): + """ + Unit test for condor_dirs for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + self.assertEqual(condor_pop.condor_dirs(), ["condor_dir"]) + + +class test_condor_check_requirements(unittest.TestCase): + """ + Unittests for function condor_check_requirements + """ + + def test_condor_check_requirements(self): + with Capturing() as output: + self._test_condor_check_requirements() + + def _test_condor_check_requirements(self): + """ + Unit test for condor_check_requirements for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + + # First the False test + result_1 = condor_pop.condor_check_requirements() + self.assertFalse(result_1[0]) + self.assertTrue(len(result_1[1]) > 0) + + # First the True test + condor_pop.grid_options["condor_dir"] = TMP_DIR + result_2 = condor_pop.condor_check_requirements() + self.assertTrue(result_2[0]) + self.assertTrue(len(result_2[1]) == 0) + + +class test_set_condor_status(unittest.TestCase): + """ + Unittests for function HPC_jobID + """ + + def test_set_condor_status(self): + with Capturing() as output: + self._test_set_condor_status() + + def _test_set_condor_status(self): + """ + Unit test for set_condor_status for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + condor_pop.grid_options["condor_dir"] = TMP_DIR + + id_filename = os.path.isfile( + os.path.join(condor_pop.grid_options["condor_dir"], "ClusterID") + ) + if os.path.isfile(id_filename): + os.remove(id_filename) + + # + os.makedirs( + os.path.dirname( + condor_pop.condor_status_file( + condor_dir=condor_pop.grid_options["condor_dir"] + ) + ), + exist_ok=True, + ) + condor_pop.set_condor_status("test_set_condor_status") + + # Check if ID file exists + self.assertTrue(os.path.exists(id_filename)) + + # Check if status file exists + self.assertTrue( + os.path.isfile( + condor_pop.condor_status_file( + condor_dir=condor_pop.grid_options["condor_dir"] + ) + ) + ) + + with open( + condor_pop.condor_status_file( + condor_dir=condor_pop.grid_options["condor_dir"] + ), + "r", + ) as f: + content_file = f.read() + self.assertTrue(content_file == "test_set_condor_status") + + +class test_get_condor_status(unittest.TestCase): + """ + Unittests for function get_condor_status + """ + + def test_get_condor_status(self): + with Capturing() as output: + self._test_get_condor_status() + + def _test_get_condor_status(self): + """ + Unit test for get_condor_status for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + condor_pop.grid_options["condor_dir"] = TMP_DIR + + # + os.makedirs( + os.path.dirname( + condor_pop.condor_status_file( + condor_dir=condor_pop.grid_options["condor_dir"] + ) + ), + exist_ok=True, + ) + condor_pop.set_condor_status("test_get_condor_status") + + # + status = condor_pop.get_condor_status() + self.assertEqual(status, "test_get_condor_status") + + +class test_condor_outfile(unittest.TestCase): + """ + Unittests for function condor_outfile + """ + + def test_condor_outfile(self): + with Capturing() as output: + self._test_condor_outfile() + + def _test_condor_outfile(self): + """ + Unit test for condor_outfile for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + condor_pop.grid_options["condor_dir"] = TMP_DIR + + outfile = condor_pop.condor_outfile() + condor_id = condor_pop.condorID() + self.assertEqual(outfile, os.path.abspath(os.path.join(condor_pop.grid_options["condor_dir"], "results", "{}.gz".format(condor_id)))) + + +class test_make_condor_dirs(unittest.TestCase): + """ + Unittests for function make_condor_dirs + """ + + def test_make_condor_dirs(self): + with Capturing() as output: + self._test_make_condor_dirs() + + def _test_make_condor_dirs(self): + """ + Unit test for make_condor_dirs for condor + """ + + condor_pop = Population(tmp_dir=TMP_DIR) + condor_pop.grid_options["condor"] = 1 + condor_pop.grid_options["condor_ClusterID"] = 2 + condor_pop.grid_options["condor_Process"] = 3 + condor_pop.grid_options["condor_dir"] = TMP_DIR + + shutil.rmtree(TMP_DIR) + os.makedirs(TMP_DIR) + + # + condor_pop.make_condor_dirs() + + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "stdout"))) + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "stderr"))) + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "log"))) + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "results"))) + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "status"))) + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "snapshots"))) + + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/tests_population_extensions/test_dataIO.py b/binarycpython/tests/tests_population_extensions/test_dataIO.py new file mode 100644 index 0000000000000000000000000000000000000000..bfe30739e4f7a44ca539461e4bc7ea092fdfe6cc --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_dataIO.py @@ -0,0 +1,27 @@ +""" +Unit classes for the _condor module population extension + +TODO: dir_ok +TODO: save_population_object +TODO: load_population_object +TODO: merge_populations +TODO: merge_populations_from_file +TODO: snapshot_filename +TODO: load_snapshot +TODO: save_snapshot +TODO: write_ensemble +TODO: write_binary_c_calls_to_file +TODO: set_status +TODO: locked_close +TODO: wait_for_unlock +TODO: locked_open_for_write +TODO: NFS_flush_hack +TODO: compression_type +TODO: open +TODO: NFSpath +""" + +import unittest + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/test_distributions.py b/binarycpython/tests/tests_population_extensions/test_distribution_functions.py similarity index 70% rename from binarycpython/tests/test_distributions.py rename to binarycpython/tests/tests_population_extensions/test_distribution_functions.py index 85d08e3465294da39b18baf22ed6605f08e87afd..fcf4699e8d10ec00d4307a7459889f1391bbca95 100644 --- a/binarycpython/tests/test_distributions.py +++ b/binarycpython/tests/tests_population_extensions/test_distribution_functions.py @@ -1,55 +1,52 @@ """ Module containing the unittests for the distribution functions. + +TODO: powerlaw_constant_nocache +TODO: powerlaw_constant +TODO: calculate_constants_three_part_powerlaw +TODO: gaussian_normalizing_const +TODO: gaussian_func +TODO: sana12 +TODO: interpolate_in_mass_izzard2012 +TODO: cosmic_SFH_madau_dickinson2014 +TODO: poisson +TODO: _poisson + +TODO: get_max_multiplicity +TODO: merge_multiplicities +TODO: Moe_di_Stefano_2017_multiplicity_fractions +TODO: build_q_table +TODO: powerlaw_extrapolation_q +TODO: linear_extrapolation_q +TODO: get_integration_constant_q +TODO: fill_data +TODO: calc_e_integral +TODO: calc_P_integral +TODO: calc_total_probdens +TODO: Moe_di_Stefano_2017_pdf """ import unittest +import numpy as np -from binarycpython.utils.distribution_functions import * from binarycpython.utils.useful_funcs import calc_sep_from_period from binarycpython.utils.functions import Capturing, temp_dir +from binarycpython.utils.grid import Population + TMP_DIR = temp_dir("tests", "test_distributions") +MASS_LIST = [0.1, 0.2, 1, 10, 15, 50] +LOGPER_LIST = [-2, -0.5, 1.6, 2.5, 5.3, 10] +Q_LIST = [0.01, 0.2, 0.4, 0.652, 0.823, 1] +PER_LIST = [10 ** logper for logper in LOGPER_LIST] +TOLERANCE = 1e-5 -class TestDistributions(unittest.TestCase): - """ - Unittest class - # https://stackoverflow.com/questions/17353213/init-for-unittest-testcase +class test_flat(unittest.TestCase): + """ + Class for unit test of flat """ - - def __init__(self, *args, **kwargs): - """ - init - """ - super(TestDistributions, self).__init__(*args, **kwargs) - - self.mass_list = [0.1, 0.2, 1, 10, 15, 50] - self.logper_list = [-2, -0.5, 1.6, 2.5, 5.3, 10] - self.q_list = [0.01, 0.2, 0.4, 0.652, 0.823, 1] - self.per_list = [10 ** logper for logper in self.logper_list] - - self.tolerance = 1e-5 - - def test_setopts(self): - with Capturing() as output: - self._test_setopts() - - def _test_setopts(self): - """ - Unittest for function set_opts - """ - - default_dict = {"m1": 2, "m2": 3} - output_dict_1 = set_opts(default_dict, {}) - self.assertTrue(output_dict_1 == default_dict) - - new_opts = {"m1": 10} - output_dict_2 = set_opts(default_dict, new_opts) - updated_dict = default_dict.copy() - updated_dict["m1"] = 10 - - self.assertTrue(output_dict_2 == updated_dict) def test_flat(self): with Capturing() as output: @@ -60,11 +57,19 @@ class TestDistributions(unittest.TestCase): Unittest for the function flat """ - output_1 = flat() + distribution_functions_pop = Population() + + output_1 = distribution_functions_pop.flat() self.assertTrue(isinstance(output_1, float)) self.assertEqual(output_1, 1.0) + +class test_number(unittest.TestCase): + """ + Class for unit test of number + """ + def test_number(self): with Capturing() as output: self._test_number() @@ -74,30 +79,50 @@ class TestDistributions(unittest.TestCase): Unittest for function number """ + distribution_functions_pop = Population() + input_1 = 1.0 - output_1 = number(input_1) + output_1 = distribution_functions_pop.number(input_1) self.assertEqual(input_1, output_1) - def test_const(self): + +class test_const_distribution(unittest.TestCase): + """ + Class for unit test of number + """ + + def test_const_distribution(self): with Capturing() as output: - self._test_const() + self._test_const_distribution() - def _test_const(self): + def _test_const_distribution(self): """ Unittest for function const """ - output_1 = const(min_bound=0, max_bound=2) + distribution_functions_pop = Population() + + output_1 = distribution_functions_pop.const_distribution( + min_bound=0, max_bound=2 + ) self.assertEqual( output_1, 0.5, msg="Value should be 0.5, but is {}".format(output_1) ) - output_2 = const(min_bound=0, max_bound=2, val=3) + output_2 = distribution_functions_pop.const_distribution( + min_bound=0, max_bound=2, val=3 + ) self.assertEqual( output_2, 0, msg="Value should be 0, but is {}".format(output_2) ) + +class test_powerlaw(unittest.TestCase): + """ + Class for unit test of powerlaw + """ + def test_powerlaw(self): with Capturing() as output: self._test_powerlaw() @@ -107,6 +132,8 @@ class TestDistributions(unittest.TestCase): unittest for the powerlaw test """ + distribution_functions_pop = Population() + perl_results = [ 0, 0, @@ -118,19 +145,29 @@ class TestDistributions(unittest.TestCase): python_results = [] input_lists = [] - for mass in self.mass_list: + for mass in MASS_LIST: input_lists.append(mass) - python_results.append(powerlaw(1, 100, -2.3, mass)) + python_results.append( + distribution_functions_pop.powerlaw(1, 100, -2.3, mass) + ) # GO over the results and check whether they are equal (within tolerance) for i in range(len(python_results)): msg = "Error: Value perl: {} Value python: {} for mass, per: {}".format( perl_results[i], python_results[i], str(input_lists[i]) ) - self.assertLess(np.abs(python_results[i] - perl_results[i]), self.tolerance) + self.assertLess(np.abs(python_results[i] - perl_results[i]), TOLERANCE) # extra test for k = -1 - self.assertRaises(ValueError, powerlaw, 1, 100, -1, 10) + self.assertRaises( + ValueError, distribution_functions_pop.powerlaw, 1, 100, -1, 10 + ) + + +class test_three_part_power_law(unittest.TestCase): + """ + Class for unit test of three_part_power_law + """ def test_three_part_power_law(self): with Capturing() as output: @@ -141,6 +178,8 @@ class TestDistributions(unittest.TestCase): unittest for three_part_power_law """ + distribution_functions_pop = Population() + perl_results = [ 10.0001044752901, 2.03065220596677, @@ -152,10 +191,12 @@ class TestDistributions(unittest.TestCase): python_results = [] input_lists = [] - for mass in self.mass_list: + for mass in MASS_LIST: input_lists.append(mass) python_results.append( - three_part_powerlaw(mass, 0.08, 0.1, 1, 300, -1.3, -2.3, -2.3) + distribution_functions_pop.three_part_powerlaw( + mass, 0.08, 0.1, 1, 300, -1.3, -2.3, -2.3 + ) ) # GO over the results and check whether they are equal (within tolerance) @@ -164,16 +205,25 @@ class TestDistributions(unittest.TestCase): perl_results[i], python_results[i], str(input_lists[i]) ) self.assertLess( - np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg ) # Extra test: # M < M0 self.assertTrue( - three_part_powerlaw(0.05, 0.08, 0.1, 1, 300, -1.3, -2.3, -2.3) == 0, + distribution_functions_pop.three_part_powerlaw( + 0.05, 0.08, 0.1, 1, 300, -1.3, -2.3, -2.3 + ) + == 0, msg="Probability should be zero as M < M0", ) + +class test_Kroupa2001(unittest.TestCase): + """ + Class for unit test of Kroupa2001 + """ + def test_Kroupa2001(self): with Capturing() as output: self._test_Kroupa2001() @@ -183,6 +233,8 @@ class TestDistributions(unittest.TestCase): unittest for three_part_power_law """ + distribution_functions_pop = Population() + perl_results = [ 0, # perl value is actually 5.71196495365248 2.31977861075353, @@ -194,9 +246,9 @@ class TestDistributions(unittest.TestCase): python_results = [] input_lists = [] - for mass in self.mass_list: + for mass in MASS_LIST: input_lists.append(mass) - python_results.append(Kroupa2001(mass)) + python_results.append(distribution_functions_pop.Kroupa2001(mass)) # GO over the results and check whether they are equal (within tolerance) for i in range(len(python_results)): @@ -204,15 +256,23 @@ class TestDistributions(unittest.TestCase): perl_results[i], python_results[i], str(input_lists[i]) ) self.assertLess( - np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg ) # Extra tests: self.assertEqual( - Kroupa2001(10, newopts={"mmax": 300}), - three_part_powerlaw(10, 0.1, 0.5, 1, 300, -1.3, -2.3, -2.3), + distribution_functions_pop.Kroupa2001(10, newopts={"mmax": 300}), + distribution_functions_pop.three_part_powerlaw( + 10, 0.1, 0.5, 1, 300, -1.3, -2.3, -2.3 + ), ) + +class test_ktg93(unittest.TestCase): + """ + Class for unit test of ktg93 + """ + def test_ktg93(self): with Capturing() as output: self._test_ktg93() @@ -222,6 +282,8 @@ class TestDistributions(unittest.TestCase): unittest for three_part_power_law """ + distribution_functions_pop = Population() + perl_results = [ 0, # perl value is actually 5.79767807698379 but that is not correct 2.35458895566605, @@ -233,9 +295,9 @@ class TestDistributions(unittest.TestCase): python_results = [] input_lists = [] - for mass in self.mass_list: + for mass in MASS_LIST: input_lists.append(mass) - python_results.append(ktg93(mass)) + python_results.append(distribution_functions_pop.ktg93(mass)) # GO over the results and check whether they are equal (within tolerance) for i in range(len(python_results)): @@ -243,15 +305,23 @@ class TestDistributions(unittest.TestCase): perl_results[i], python_results[i], str(input_lists[i]) ) self.assertLess( - np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg ) # extra test: self.assertEqual( - ktg93(10, newopts={"mmax": 300}), - three_part_powerlaw(10, 0.1, 0.5, 1, 300, -1.3, -2.2, -2.7), + distribution_functions_pop.ktg93(10, newopts={"mmax": 300}), + distribution_functions_pop.three_part_powerlaw( + 10, 0.1, 0.5, 1, 300, -1.3, -2.2, -2.7 + ), ) + +class test_imf_tinsley1980(unittest.TestCase): + """ + Class for unit test of imf_tinsley1980 + """ + def test_imf_tinsley1980(self): with Capturing() as output: self._test_imf_tinsley1980() @@ -261,12 +331,22 @@ class TestDistributions(unittest.TestCase): Unittest for function imf_tinsley1980 """ + distribution_functions_pop = Population() + m = 1.2 self.assertEqual( - imf_tinsley1980(m), - three_part_powerlaw(m, 0.1, 2.0, 10.0, 80.0, -2.0, -2.3, -3.3), + distribution_functions_pop.imf_tinsley1980(m), + distribution_functions_pop.three_part_powerlaw( + m, 0.1, 2.0, 10.0, 80.0, -2.0, -2.3, -3.3 + ), ) + +class test_imf_scalo1986(unittest.TestCase): + """ + Class for unit test of imf_scalo1986 + """ + def test_imf_scalo1986(self): with Capturing() as output: self._test_imf_scalo1986() @@ -276,12 +356,22 @@ class TestDistributions(unittest.TestCase): Unittest for function imf_scalo1986 """ + distribution_functions_pop = Population() + m = 1.2 self.assertEqual( - imf_scalo1986(m), - three_part_powerlaw(m, 0.1, 1.0, 2.0, 80.0, -2.35, -2.35, -2.70), + distribution_functions_pop.imf_scalo1986(m), + distribution_functions_pop.three_part_powerlaw( + m, 0.1, 1.0, 2.0, 80.0, -2.35, -2.35, -2.70 + ), ) + +class test_imf_scalo1998(unittest.TestCase): + """ + Class for unit test of imf_scalo1998 + """ + def test_imf_scalo1998(self): with Capturing() as output: self._test_imf_scalo1998() @@ -291,12 +381,22 @@ class TestDistributions(unittest.TestCase): Unittest for function imf_scalo1986 """ + distribution_functions_pop = Population() + m = 1.2 self.assertEqual( - imf_scalo1998(m), - three_part_powerlaw(m, 0.1, 1.0, 10.0, 80.0, -1.2, -2.7, -2.3), + distribution_functions_pop.imf_scalo1998(m), + distribution_functions_pop.three_part_powerlaw( + m, 0.1, 1.0, 10.0, 80.0, -1.2, -2.7, -2.3 + ), ) + +class test_imf_chabrier2003(unittest.TestCase): + """ + Class for unit test of imf_chabrier2003 + """ + def test_imf_chabrier2003(self): with Capturing() as output: self._test_imf_chabrier2003() @@ -306,8 +406,12 @@ class TestDistributions(unittest.TestCase): Unittest for function imf_chabrier2003 """ + distribution_functions_pop = Population() + input_1 = 0 - self.assertRaises(ValueError, imf_chabrier2003, input_1) + self.assertRaises( + ValueError, distribution_functions_pop.imf_chabrier2003, input_1 + ) masses = [0.1, 0.2, 0.5, 1, 2, 10, 15, 50] perl_results = [ @@ -320,7 +424,9 @@ class TestDistributions(unittest.TestCase): 0.000315578044662863, 1.97918170035704e-05, ] - python_results = [imf_chabrier2003(m) for m in masses] + python_results = [ + distribution_functions_pop.imf_chabrier2003(m) for m in masses + ] # GO over the results and check whether they are equal (within tolerance) for i in range(len(python_results)): @@ -328,9 +434,15 @@ class TestDistributions(unittest.TestCase): perl_results[i], python_results[i], str(masses[i]) ) self.assertLess( - np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg ) + +class test_duquennoy1991(unittest.TestCase): + """ + Class for unit test of duquennoy1991 + """ + def test_duquennoy1991(self): with Capturing() as output: self._test_duquennoy1991() @@ -340,7 +452,18 @@ class TestDistributions(unittest.TestCase): Unittest for function duquennoy1991 """ - self.assertEqual(duquennoy1991(4.2), gaussian(4.2, 4.8, 2.3, -2, 12)) + distribution_functions_pop = Population() + + self.assertEqual( + distribution_functions_pop.duquennoy1991(4.2), + distribution_functions_pop.gaussian(4.2, 4.8, 2.3, -2, 12), + ) + + +class test_gaussian(unittest.TestCase): + """ + Class for unit test of gaussian + """ def test_gaussian(self): with Capturing() as output: @@ -351,6 +474,8 @@ class TestDistributions(unittest.TestCase): unittest for three_part_power_law """ + distribution_functions_pop = Population() + perl_results = [ 0.00218800520299544, 0.0121641269671571, @@ -362,9 +487,11 @@ class TestDistributions(unittest.TestCase): python_results = [] input_lists = [] - for logper in self.logper_list: + for logper in LOGPER_LIST: input_lists.append(logper) - python_results.append(gaussian(logper, 4.8, 2.3, -2.0, 12.0)) + python_results.append( + distribution_functions_pop.gaussian(logper, 4.8, 2.3, -2.0, 12.0) + ) # GO over the results and check whether they are equal (within tolerance) for i in range(len(python_results)): @@ -372,15 +499,21 @@ class TestDistributions(unittest.TestCase): perl_results[i], python_results[i], str(input_lists[i]) ) self.assertLess( - np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg ) # Extra test: self.assertTrue( - gaussian(15, 4.8, 2.3, -2.0, 12.0) == 0, + distribution_functions_pop.gaussian(15, 4.8, 2.3, -2.0, 12.0) == 0, msg="Probability should be 0 because the input period is out of bounds", ) + +class test_Arenou2010_binary_fraction(unittest.TestCase): + """ + Class for unit test of Arenou2010_binary_fraction + """ + def test_Arenou2010_binary_fraction(self): with Capturing() as output: self._test_Arenou2010_binary_fraction() @@ -390,6 +523,8 @@ class TestDistributions(unittest.TestCase): unittest for three_part_power_law """ + distribution_functions_pop = Population() + perl_results = [ 0.123079723518677, 0.178895136157746, @@ -401,9 +536,11 @@ class TestDistributions(unittest.TestCase): python_results = [] input_lists = [] - for mass in self.mass_list: + for mass in MASS_LIST: input_lists.append(mass) - python_results.append(Arenou2010_binary_fraction(mass)) + python_results.append( + distribution_functions_pop.Arenou2010_binary_fraction(mass) + ) # GO over the results and check whether they are equal (within tolerance) for i in range(len(python_results)): @@ -411,9 +548,15 @@ class TestDistributions(unittest.TestCase): perl_results[i], python_results[i], str(input_lists[i]) ) self.assertLess( - np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg ) + +class test_raghavan2010_binary_fraction(unittest.TestCase): + """ + Class for unit test of raghavan2010_binary_fraction + """ + def test_raghavan2010_binary_fraction(self): with Capturing() as output: self._test_raghavan2010_binary_fraction() @@ -423,13 +566,17 @@ class TestDistributions(unittest.TestCase): unittest for three_part_power_law """ + distribution_functions_pop = Population() + perl_results = [0.304872297931597, 0.334079955706623, 0.41024, 1, 1, 1] python_results = [] input_lists = [] - for mass in self.mass_list: + for mass in MASS_LIST: input_lists.append(mass) - python_results.append(raghavan2010_binary_fraction(mass)) + python_results.append( + distribution_functions_pop.raghavan2010_binary_fraction(mass) + ) # GO over the results and check whether they are equal (within tolerance) for i in range(len(python_results)): @@ -437,9 +584,15 @@ class TestDistributions(unittest.TestCase): perl_results[i], python_results[i], str(input_lists[i]) ) self.assertLess( - np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg ) + +class test_Izzard2012_period_distribution(unittest.TestCase): + """ + Class for unit test of Izzard2012_period_distribution + """ + def test_Izzard2012_period_distribution(self): with Capturing() as output: self._test_Izzard2012_period_distribution() @@ -449,6 +602,8 @@ class TestDistributions(unittest.TestCase): unittest for three_part_power_law """ + distribution_functions_pop = Population() + perl_results = [ 0, 0.00941322840619318, @@ -490,11 +645,13 @@ class TestDistributions(unittest.TestCase): python_results = [] input_lists = [] - for mass in self.mass_list: - for per in self.per_list: + for mass in MASS_LIST: + for per in PER_LIST: input_lists.append([mass, per]) - python_results.append(Izzard2012_period_distribution(per, mass)) + python_results.append( + distribution_functions_pop.Izzard2012_period_distribution(per, mass) + ) # GO over the results and check whether they are equal (within tolerance) for i in range(len(python_results)): @@ -502,18 +659,26 @@ class TestDistributions(unittest.TestCase): perl_results[i], python_results[i], str(input_lists[i]) ) self.assertLess( - np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg ) + +class test_flatsections(unittest.TestCase): + """ + Class for unit test of flatsections + """ + def test_flatsections(self): with Capturing() as output: self._test_flatsections() def _test_flatsections(self): """ - unittest for three_part_power_law + unittest for flatsections """ + distribution_functions_pop = Population() + perl_results = [ 1.01010101010101, 1.01010101010101, @@ -525,10 +690,12 @@ class TestDistributions(unittest.TestCase): python_results = [] input_lists = [] - for q in self.q_list: + for q in Q_LIST: input_lists.append(q) python_results.append( - flatsections(q, [{"min": 0.01, "max": 1.0, "height": 1.0}]) + distribution_functions_pop.flatsections( + q, [{"min": 0.01, "max": 1.0, "height": 1.0}] + ) ) # GO over the results and check whether they are equal (within tolerance) @@ -537,9 +704,15 @@ class TestDistributions(unittest.TestCase): perl_results[i], python_results[i], str(input_lists[i]) ) self.assertLess( - np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg ) + +class test_sana12(unittest.TestCase): + """ + Class for unit test of sana12 + """ + def test_sana12(self): with Capturing() as output: self._test_sana12() @@ -549,6 +722,8 @@ class TestDistributions(unittest.TestCase): unittest for three_part_power_law """ + distribution_functions_pop = Population() + perl_results = [ 0.121764808010258, 0.121764808010258, @@ -770,9 +945,9 @@ class TestDistributions(unittest.TestCase): python_results = [] input_lists = [] - for mass in self.mass_list: - for q in self.q_list: - for per in self.per_list: + for mass in MASS_LIST: + for q in Q_LIST: + for per in PER_LIST: mass_2 = mass * q sep = calc_sep_from_period(mass, mass_2, per) @@ -782,7 +957,7 @@ class TestDistributions(unittest.TestCase): input_lists.append([mass, mass_2, per]) python_results.append( - sana12( + distribution_functions_pop.sana12( mass, mass_2, sep, per, sep_min, sep_max, 0.15, 5.5, -0.55 ) ) @@ -793,7 +968,7 @@ class TestDistributions(unittest.TestCase): perl_results[i], python_results[i], str(input_lists[i]) ) self.assertLess( - np.abs(python_results[i] - perl_results[i]), self.tolerance, msg=msg + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg ) diff --git a/binarycpython/tests/tests_population_extensions/test_grid_logging.py b/binarycpython/tests/tests_population_extensions/test_grid_logging.py new file mode 100644 index 0000000000000000000000000000000000000000..601487c49835998b3660fd06c78136070454cb40 --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_grid_logging.py @@ -0,0 +1,18 @@ +""" +Module containing the unittests for the grid_logging functions + +TODO: _set_custom_logging +TODO: _print_info +TODO: _set_loggers +TODO: vb1print +TODO: vb2print +TODO: verbose_print +TODO: _boxed +TODO: _get_stream_logger +TODO: _clean_up_custom_logging +""" + +import unittest + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/test_grid_options_defaults.py b/binarycpython/tests/tests_population_extensions/test_grid_options_defaults.py similarity index 61% rename from binarycpython/tests/test_grid_options_defaults.py rename to binarycpython/tests/tests_population_extensions/test_grid_options_defaults.py index 18291f2eed88a878fe165e889d8fc42b717e8f15..7739582943a2759c5a0c7ad8415ce35c971172c3 100644 --- a/binarycpython/tests/test_grid_options_defaults.py +++ b/binarycpython/tests/tests_population_extensions/test_grid_options_defaults.py @@ -1,5 +1,10 @@ """ Unittests for grid_options_defaults module + +TODO: get_grid_options_defaults_dict +TODO: get_grid_options_descriptions +TODO: print_option_descriptions +TODO: default_cache_dir """ import os import unittest @@ -8,18 +13,14 @@ from binarycpython.utils.functions import ( temp_dir, Capturing, ) -from binarycpython.utils.grid_options_defaults import ( - write_grid_options_to_rst_file, - grid_options_help, - grid_options_description_checker, -) +from binarycpython.utils.grid import Population TMP_DIR = temp_dir("tests", "test_grid_options_defaults") -class test_grid_options_defaults(unittest.TestCase): +class test_grid_options_help(unittest.TestCase): """ - Unit tests for the grid_options_defaults module + Unit tests for the grid_options_help function """ def test_grid_options_help(self): @@ -31,12 +32,14 @@ class test_grid_options_defaults(unittest.TestCase): Unit tests for the grid_options_help function """ + grid_options_defaults_pop = Population() + input_1 = "aa" - result_1 = grid_options_help(input_1) + result_1 = grid_options_defaults_pop.grid_options_help(input_1) self.assertEqual(result_1, {}, msg="Dict should be empty") input_2 = "num_cores" - result_2 = grid_options_help(input_2) + result_2 = grid_options_defaults_pop.grid_options_help(input_2) self.assertIn( input_2, result_2, @@ -47,7 +50,7 @@ class test_grid_options_defaults(unittest.TestCase): ) input_3 = "evolution_type" - result_3 = grid_options_help(input_3) + result_3 = grid_options_defaults_pop.grid_options_help(input_3) self.assertIn( input_3, result_3, @@ -55,6 +58,12 @@ class test_grid_options_defaults(unittest.TestCase): ) # self.assertEqual(result_3[input_3], "", msg="description should be empty") + +class test_grid_options_description_checker(unittest.TestCase): + """ + Unit tests for the grid_options_description_checker function + """ + def test_grid_options_description_checker(self): with Capturing() as output: self._test_grid_options_description_checker() @@ -64,11 +73,21 @@ class test_grid_options_defaults(unittest.TestCase): Unit tests for the grid_options_description_checker function """ - output_1 = grid_options_description_checker(print_info=True) + grid_options_defaults_pop = Population() + + output_1 = grid_options_defaults_pop.grid_options_description_checker( + print_info=True + ) self.assertTrue(isinstance(output_1, int)) self.assertTrue(output_1 > 0) + +class test_write_grid_options_to_rst_file(unittest.TestCase): + """ + Unit tests for the write_grid_options_to_rst_file function + """ + def test_write_grid_options_to_rst_file(self): with Capturing() as output: self._test_write_grid_options_to_rst_file() @@ -78,12 +97,17 @@ class test_grid_options_defaults(unittest.TestCase): Unit tests for the grid_options_description_checker function """ + grid_options_defaults_pop = Population() + input_1 = os.path.join(TMP_DIR, "test_write_grid_options_to_rst_file_1.txt") - output_1 = write_grid_options_to_rst_file(input_1) - self.assertIsNone(output_1) + self.assertRaises( + ValueError, + grid_options_defaults_pop.write_grid_options_to_rst_file, + input_1, + ) input_2 = os.path.join(TMP_DIR, "test_write_grid_options_to_rst_file_2.rst") - output_2 = write_grid_options_to_rst_file(input_2) + _ = grid_options_defaults_pop.write_grid_options_to_rst_file(input_2) self.assertTrue(os.path.isfile(input_2)) diff --git a/binarycpython/tests/tests_population_extensions/test_gridcode.py b/binarycpython/tests/tests_population_extensions/test_gridcode.py new file mode 100644 index 0000000000000000000000000000000000000000..7fdce8e6fd1e794d4858ddcc4562e727c17c4037 --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_gridcode.py @@ -0,0 +1,79 @@ +""" +Unittests for gridcode module + +TODO: _gridcode_filename +TODO: _add_code +TODO: _indent_block +TODO: _increment_indent_depth +TODO: _generate_grid_code +TODO: _write_gridcode_system_call +TODO: _load_grid_function +TODO: _last_grid_variable +TODO: update_grid_variable +TODO: delete_grid_variable +TODO: rename_grid_variable +""" + +import unittest + +from binarycpython.utils.functions import ( + temp_dir, + Capturing, +) + +from binarycpython.utils.grid import Population + + +class test_add_grid_variable(unittest.TestCase): + """ + Unittests for add_grid_variable function + """ + + def test_add_grid_variable(self): + with Capturing() as output: + self._test_add_grid_variable() + + def _test_add_grid_variable(self): + """ + Unittests for the function add_grid_variable + + TODO: Should I test more here? + """ + + test_pop = Population() + + resolution = {"M_1": 10, "q": 10} + + test_pop.add_grid_variable( + name="lnm1", + longname="Primary mass", + valuerange=[1, 100], + samplerfunc="const(math.log(1), math.log(100), {})".format( + resolution["M_1"] + ), + precode="M_1=math.exp(lnm1)", + probdist="three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 100, -1.3, -2.3, -2.3)*M_1", + dphasevol="dlnm1", + parameter_name="M_1", + condition="", # Impose a condition on this grid variable. Mostly for a check for yourself + ) + + test_pop.add_grid_variable( + name="q", + longname="Mass ratio", + valuerange=["0.1/M_1", 1], + samplerfunc="const(0.1/M_1, 1, {})".format(resolution["q"]), + probdist="flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])", + dphasevol="dq", + precode="M_2 = q * M_1", + parameter_name="M_2", + condition="", # Impose a condition on this grid variable. Mostly for a check for yourself + ) + + self.assertIn("q", test_pop.grid_options["_grid_variables"]) + self.assertIn("lnm1", test_pop.grid_options["_grid_variables"]) + self.assertEqual(len(test_pop.grid_options["_grid_variables"]), 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/tests_population_extensions/test_metadata.py b/binarycpython/tests/tests_population_extensions/test_metadata.py new file mode 100644 index 0000000000000000000000000000000000000000..3c98fe4c31886ecd7b6bf88baf36ee82b39b583f --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_metadata.py @@ -0,0 +1,12 @@ +""" +Unittests for metadata module + +TODO: add_system_metadata +TODO: add_ensemble_metadata +TODO: _metadata_keylist +""" + +import unittest + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/tests_population_extensions/test_slurm.py b/binarycpython/tests/tests_population_extensions/test_slurm.py new file mode 100644 index 0000000000000000000000000000000000000000..e3e2b1d9dba2762a90efb455626e5d8109a7e901 --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_slurm.py @@ -0,0 +1,244 @@ +""" +Unittests for slurm module + +TODO: slurmpath +TODO: slurm_status_file +TODO: slurm_grid +TODO: slurm_queue_stats +""" + +import os +import shutil +import unittest +from binarycpython.utils.functions import Capturing, temp_dir +from binarycpython.utils.grid import Population + +TMP_DIR = temp_dir("tests", "test_slurm") +shutil.rmtree(TMP_DIR) +os.makedirs(TMP_DIR, exist_ok=True) + + +class test_slurmID(unittest.TestCase): + """ + Unittests for function slurmID + """ + + def test_slurmID(self): + with Capturing() as output: + self._test_slurmID() + + def _test_slurmID(self): + """ + Unit test for slurmID for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + + self.assertEqual( + slurm_pop.HPC_jobID(), + "{jobid}.{jobarrayindex}".format(jobid=4, jobarrayindex=5), + ) + + +class test_slurm_dirs(unittest.TestCase): + """ + Unittests for function slurm_dirs + """ + + def test_slurm_dirs(self): + with Capturing() as output: + self._test_slurm_dirs() + + def _test_slurm_dirs(self): + """ + Unit test for slurm_dirs for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + self.assertEqual(slurm_pop.slurm_dirs(), ["slurm_dir"]) + + +class test_slurm_check_requirements(unittest.TestCase): + """ + Unittests for function slurm_check_requirements + """ + + def test_slurm_check_requirements(self): + with Capturing() as output: + self._test_slurm_check_requirements() + + def _test_slurm_check_requirements(self): + """ + Unit test for slurm_check_requirements for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + + # First the False test + result_1 = slurm_pop.slurm_check_requirements() + self.assertFalse(result_1[0]) + self.assertTrue(len(result_1[1]) > 0) + + # First the True test + slurm_pop.grid_options["slurm_dir"] = TMP_DIR + result_2 = slurm_pop.slurm_check_requirements() + self.assertTrue(result_2[0]) + self.assertTrue(len(result_2[1]) == 0) + + +class test_set_slurm_status(unittest.TestCase): + """ + Unittests for function set_slurm_status + """ + + def test_set_slurm_status(self): + with Capturing() as output: + self._test_set_slurm_status() + + def _test_set_slurm_status(self): + """ + Unit test for set_slurm_status for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + slurm_pop.grid_options["slurm_dir"] = TMP_DIR + + id_filename = os.path.isfile( + os.path.join(slurm_pop.grid_options["slurm_dir"], "jobid") + ) + if os.path.isfile(id_filename): + os.remove(id_filename) + + # + os.makedirs( + os.path.dirname( + slurm_pop.slurm_status_file( + slurm_dir=slurm_pop.grid_options["slurm_dir"] + ) + ), + exist_ok=True, + ) + slurm_pop.set_slurm_status("test_set_slurm_status") + + # Check if ID file exists + self.assertTrue(os.path.exists(id_filename)) + + # Check if status file exists + self.assertTrue( + os.path.isfile( + slurm_pop.slurm_status_file( + slurm_dir=slurm_pop.grid_options["slurm_dir"] + ) + ) + ) + + with open( + slurm_pop.slurm_status_file(slurm_dir=slurm_pop.grid_options["slurm_dir"]), + "r", + ) as f: + content_file = f.read() + self.assertTrue(content_file == "test_set_slurm_status") + + +class test_get_slurm_status(unittest.TestCase): + """ + Unittests for function get_slurm_status + """ + + def test_get_slurm_status(self): + with Capturing() as output: + self._test_get_slurm_status() + + def _test_get_slurm_status(self): + """ + Unit test for get_slurm_status for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + slurm_pop.grid_options["slurm_dir"] = TMP_DIR + + # + os.makedirs( + os.path.dirname( + slurm_pop.slurm_status_file( + slurm_dir=slurm_pop.grid_options["slurm_dir"] + ) + ), + exist_ok=True, + ) + slurm_pop.set_slurm_status("test_set_slurm_status") + + status = slurm_pop.get_slurm_status() + self.assertEqual(status, "test_set_slurm_status") + + +class test_slurm_outfile(unittest.TestCase): + """ + Unittests for function slurm_outfile + """ + + def test_slurm_outfile(self): + with Capturing() as output: + self._test_slurm_outfile() + + def _test_slurm_outfile(self): + """ + Unit test for slurm_outfile for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + slurm_pop.grid_options["slurm_dir"] = TMP_DIR + + outfile = slurm_pop.slurm_outfile() + slurm_id = slurm_pop.slurmID() + self.assertEqual(outfile, os.path.abspath(os.path.join(slurm_pop.grid_options["slurm_dir"], "results", "{}.gz".format(slurm_id)))) + + +class test_make_slurm_dirs(unittest.TestCase): + """ + Unittests for function slurm_outfile + """ + + def test_make_slurm_dirs(self): + with Capturing() as output: + self._test_make_slurm_dirs() + + def _test_make_slurm_dirs(self): + """ + Unit test for slurm_outfile for slurm + """ + + slurm_pop = Population(tmp_dir=TMP_DIR) + slurm_pop.grid_options["slurm"] = 1 + slurm_pop.grid_options["slurm_jobid"] = 4 + slurm_pop.grid_options["slurm_jobarrayindex"] = 5 + slurm_pop.grid_options["slurm_dir"] = TMP_DIR + + shutil.rmtree(TMP_DIR) + os.makedirs(TMP_DIR) + + # + slurm_pop.make_slurm_dirs() + + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "stdout"))) + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "stderr"))) + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "results"))) + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "status"))) + self.assertTrue(os.path.isdir(os.path.join(TMP_DIR, "snapshots"))) + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/test_spacing_functions.py b/binarycpython/tests/tests_population_extensions/test_spacing_functions.py similarity index 85% rename from binarycpython/tests/test_spacing_functions.py rename to binarycpython/tests/tests_population_extensions/test_spacing_functions.py index 51f6edc64b1309fe28e1c66b21bbf15683e0bbda..563081068a1fc0b63fae60bf34eb1410ff0e301c 100644 --- a/binarycpython/tests/test_spacing_functions.py +++ b/binarycpython/tests/tests_population_extensions/test_spacing_functions.py @@ -1,5 +1,13 @@ """ Unittests for spacing_functions module + + +TODO: const_linear +TODO: const_int +TODO: const_ranges +TODO: peak_normalized_gaussian_func +TODO: gaussian_zoom +TODO: const_dt """ import unittest diff --git a/binarycpython/tests/tests_population_extensions/test_version_info.py b/binarycpython/tests/tests_population_extensions/test_version_info.py new file mode 100644 index 0000000000000000000000000000000000000000..1f88f49febc68e2042d5b972e7b067987f9d3aec --- /dev/null +++ b/binarycpython/tests/tests_population_extensions/test_version_info.py @@ -0,0 +1,174 @@ +""" +Unit tests for the _version_info Population extension module + +TODO: minimum_stellar_mass +""" + +import os +import unittest + +from binarycpython.utils.functions import ( + temp_dir, + Capturing, +) +from binarycpython.utils.grid import Population + +TMP_DIR = temp_dir("tests", "test__version_info") + + +class test_return_binary_c_version_info(unittest.TestCase): + """ + Unittests for return_binary_c_version_info + """ + + def __init__(self, *args, **kwargs): + """ + init + """ + super(test_return_binary_c_version_info, self).__init__(*args, **kwargs) + self._version_info_pop = Population() + + def test_return_binary_c_version_info(self): + with Capturing() as output: + self._test_return_binary_c_version_info() + + def _test_return_binary_c_version_info(self): + """ + Unittests for the function return_binary_c_version_info + """ + + test_pop = Population() + binary_c_version_info = test_pop.return_binary_c_version_info(parsed=True) + + self.assertTrue(isinstance(binary_c_version_info, dict)) + self.assertIn("isotopes", binary_c_version_info) + self.assertIn("argpairs", binary_c_version_info) + self.assertIn("ensembles", binary_c_version_info) + self.assertIn("macros", binary_c_version_info) + self.assertIn("dt_limits", binary_c_version_info) + self.assertIn("nucleosynthesis_sources", binary_c_version_info) + self.assertIn("miscellaneous", binary_c_version_info) + + self.assertIsNotNone(binary_c_version_info["argpairs"]) + self.assertIsNotNone(binary_c_version_info["ensembles"]) + self.assertIsNotNone(binary_c_version_info["macros"]) + self.assertIsNotNone(binary_c_version_info["dt_limits"]) + self.assertIsNotNone(binary_c_version_info["miscellaneous"]) + + if binary_c_version_info["macros"]["NUCSYN"] == "on": + self.assertIsNotNone(binary_c_version_info["isotopes"]) + + if binary_c_version_info["macros"]["NUCSYN_ID_SOURCES"] == "on": + self.assertIsNotNone(binary_c_version_info["nucleosynthesis_sources"]) + + def test_not_parsed(self): + with Capturing() as output: + self._test_not_parsed() + + def _test_not_parsed(self): + """ + Test for the raw version_info output + """ + + version_info = self._version_info_pop.return_binary_c_version_info(parsed=False) + + self.assertTrue(isinstance(version_info, str)) + self.assertIn("Build", version_info) + self.assertIn("REIMERS_ETA_DEFAULT", version_info) + self.assertIn("SIGMA_THOMPSON", version_info) + + def test_parsed(self): + with Capturing() as output: + self._test_parsed() + + def _test_parsed(self): + """ + Test for the parssed version_info + """ + + # also tests the parse_version_info indirectly + version_info_parsed = self._version_info_pop.return_binary_c_version_info( + parsed=True + ) + + self.assertTrue(isinstance(version_info_parsed, dict)) + self.assertIn("isotopes", version_info_parsed.keys()) + self.assertIn("argpairs", version_info_parsed.keys()) + self.assertIn("ensembles", version_info_parsed.keys()) + self.assertIn("macros", version_info_parsed.keys()) + self.assertIn("elements", version_info_parsed.keys()) + self.assertIn("dt_limits", version_info_parsed.keys()) + self.assertIn("nucleosynthesis_sources", version_info_parsed.keys()) + self.assertIn("miscellaneous", version_info_parsed.keys()) + + def test_envvar(self): + with Capturing() as output: + self._test_envvar() + + def _test_envvar(self): + """ + Test for the parsed version info with a value already present + """ + + os.environ["BINARY_C_MACRO_HEADER"] = "macroxyz" + + # also tests the parse_version_info indirectly + version_info_parsed = self._version_info_pop.return_binary_c_version_info( + parsed=True + ) + + self.assertTrue(isinstance(version_info_parsed, dict)) + self.assertIn("isotopes", version_info_parsed.keys()) + self.assertIn("argpairs", version_info_parsed.keys()) + self.assertIn("ensembles", version_info_parsed.keys()) + self.assertIn("macros", version_info_parsed.keys()) + self.assertIn("elements", version_info_parsed.keys()) + self.assertIn("dt_limits", version_info_parsed.keys()) + self.assertIn("nucleosynthesis_sources", version_info_parsed.keys()) + self.assertIn("miscellaneous", version_info_parsed.keys()) + + +class test_parse_binary_c_version_info(unittest.TestCase): + """ + Unittests for function parse_binary_c_version_info + """ + + def test_1(self): + with Capturing() as output: + self._test_1() + + def _test_1(self): + """ + Test for the parsed versio info, more detailed + """ + + _version_info_pop = Population() + + # + info = _version_info_pop.return_binary_c_version_info(parsed=False) + parsed_info = _version_info_pop.parse_binary_c_version_info(info) + + self.assertIn("isotopes", parsed_info.keys()) + self.assertIn("argpairs", parsed_info.keys()) + self.assertIn("ensembles", parsed_info.keys()) + self.assertIn("macros", parsed_info.keys()) + self.assertIn("elements", parsed_info.keys()) + self.assertIn("dt_limits", parsed_info.keys()) + self.assertIn("nucleosynthesis_sources", parsed_info.keys()) + self.assertIn("miscellaneous", parsed_info.keys()) + + self.assertIsNotNone(parsed_info["argpairs"]) + self.assertIsNotNone(parsed_info["ensembles"]) + self.assertIsNotNone(parsed_info["macros"]) + self.assertIsNotNone(parsed_info["dt_limits"]) + self.assertIsNotNone(parsed_info["miscellaneous"]) + + if parsed_info["macros"]["NUCSYN"] == "on": + self.assertIsNotNone(parsed_info["isotopes"]) + + if parsed_info["macros"]["NUCSYN_ID_SOURCES"] == "on": + self.assertIsNotNone(parsed_info["nucleosynthesis_sources"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/binarycpython/tests/tmp_functions.py b/binarycpython/tests/tmp_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/binarycpython/utils/custom_logging_functions.py b/binarycpython/utils/custom_logging_functions.py index 12d7632135c03d2081f0f486b73e391dee459c84..73136f00c80e55b5d7aced5204984e3589af085d 100644 --- a/binarycpython/utils/custom_logging_functions.py +++ b/binarycpython/utils/custom_logging_functions.py @@ -4,12 +4,14 @@ The functions here make it possible for the user to define binaryc output logs o """ import os +import uuid +import ctypes +import socket import textwrap import subprocess -import socket -import ctypes -import uuid -from typing import Union, Tuple, Optional + +from typing import Tuple, Optional + from binarycpython.utils.functions import temp_dir, remove_file, verbose_print @@ -189,14 +191,14 @@ def binary_c_write_log_code(code: str, filename: str, verbosity: int = 0) -> Non def from_binary_c_config(config_file: str, flag: str) -> str: """ - Function to run the binaryc_config command with flags + Function to run the ``binaryc_config`` command with flags Args: - config_file: binary_c-config filepath TODO: change the name of this - flag: flag used in the binary_c-config call. + config_file: ``binary_c-config`` filepath. TODO: change the name of this + flag: flag used in the ``binary_c-config`` call. Returns: - returns the result of <binary_c-config> <flag> + returns the result of ``<binary_c-config> <flag>`` """ res = subprocess.check_output( @@ -207,7 +209,6 @@ def from_binary_c_config(config_file: str, flag: str) -> str: # convert and chop off newline res = res.decode("utf-8").rstrip() - # print(res) return res @@ -242,7 +243,7 @@ def return_compilation_dict(verbosity: int = 0) -> dict: else: raise NameError("Envvar BINARY_C doesnt exist") - # TODO: make more options for the compiling + # cc = from_binary_c_config(BINARY_C_CONFIG, "cc") # Check for binary_c @@ -251,7 +252,7 @@ def return_compilation_dict(verbosity: int = 0) -> dict: print("We require binary_c executable; have you built binary_c?") raise NameError("BINARY_C executable doesnt exist") - # TODO: debug + # libbinary_c = "-lbinary_c" binclibs = from_binary_c_config(BINARY_C_CONFIG, "libs") libdirs = "{} -L{}".format( @@ -321,7 +322,6 @@ def compile_shared_lib( """ Function to write the custom logging code to a file and then compile it. - TODO: nicely put in the -fPIC TODO: consider returning a status Args: diff --git a/binarycpython/utils/dicts.py b/binarycpython/utils/dicts.py index fd5a27ad8dada2a82f8e54070b920e884de0e819..a873117ea2b7a064967b7e7befaf3d636ba51591 100644 --- a/binarycpython/utils/dicts.py +++ b/binarycpython/utils/dicts.py @@ -1,152 +1,198 @@ """ -Module containing functions that binary_c-python uses to modify -dictionaries. +Module containing functions that binary_c-python uses to modify dictionaries. """ -import copy + import collections +from typing import Union + import astropy.units as u import numpy as np -from collections import ( - OrderedDict, -) - -# we need to convert keys to floats: -# this is ~ a factor 10 faster than David's -# recursive_change_key_to_float routine, -# probably because this version only does -# the float conversion, nothing else. -def keys_to_floats(json_data): - # assumes nested dicts ... - # new_data = {} - - # but this copies the variable type, but has some - # pointless copying - # new_data = copy.copy(json_data) - # new_data.clear() + +# Define all numerical types + +ALLOWED_NUMERICAL_TYPES = (int, float, complex, np.number) +UNION_ALLOWED_NUMERICAL_TYPES = Union[int, float, complex, np.number] + + +def keys_to_floats(input_dict: dict) -> dict: + """ + Function to convert all the keys of the dictionary to float to float + + we need to convert keys to floats: + this is ~ a factor 10 faster than David's ``recursive_change_key_to_float`` routine, probably because this version only does the float conversion, nothing else. + + Args: + input_dict: dict of which we want to turn all the keys to float types if possible + + Returns: + new_dict: dict of which the keys have been turned to float types where possible + """ # this adopts the type correctly *and* is fast - new_data = type(json_data)() + new_dict = type(input_dict)() + + for k, v in input_dict.items(): + # convert key to a float, if we can + # otherwise leave as is + try: + newkey = float(k) + except ValueError: + newkey = k - for k, v in json_data.items(): + # act on value(s) if isinstance(v, list): - v = [ + # list data + new_dict[newkey] = [ keys_to_floats(item) if isinstance(item, collections.abc.Mapping) else item for item in v ] elif isinstance(v, collections.abc.Mapping): - # dict, ordereddict, etc. - v = keys_to_floats(v) - try: - f = float(k) - new_data[f] = json_data[k] - except: - new_data[k] = v - return new_data + # dict, ordereddict, etc. data + new_dict[newkey] = keys_to_floats(v) + else: + # assume all other data are scalars + new_dict[newkey] = v + return new_dict -def recursive_change_key_to_float(input_dict): + +def recursive_change_key_to_float(input_dict: dict) -> dict: """ Function to recursively change the key to float This only works if the dict contains just sub-dicts or numbers/strings. + Does not work with lists as values + + Args: + input_dict: dict of which we want to turn all the keys to float types if possible + + Returns: + new_dict: dict of which the keys have been turned to float types where possible + + If input_dict is None or empty, returns an empty dict """ - new_dict = collections.OrderedDict() # TODO: check if this still works + new_dict = collections.OrderedDict() - for key in input_dict: - if isinstance(input_dict[key], (dict, collections.OrderedDict)): - try: - num_key = float(key) - new_dict[num_key] = recursive_change_key_to_float( - copy.deepcopy(input_dict[key]) - ) - except ValueError: - new_dict[key] = recursive_change_key_to_float( - copy.deepcopy(input_dict[key]) - ) - else: - try: - num_key = float(key) - new_dict[num_key] = input_dict[key] - except ValueError: - new_dict[key] = input_dict[key] + # if the input dict is None or empty, return an empty dict + if input_dict is None or not input_dict: + pass + + else: + # dict has keys, loop over them + for key in input_dict: + if isinstance(input_dict[key], (dict, collections.OrderedDict)): + try: + num_key = float(key) + new_dict[num_key] = recursive_change_key_to_float(input_dict[key]) + except ValueError: + new_dict[key] = recursive_change_key_to_float(input_dict[key]) + else: + try: + num_key = float(key) + new_dict[num_key] = input_dict[key] + except ValueError: + new_dict[key] = input_dict[key] return new_dict -def recursive_change_key_to_string(input_dict): +def recursive_change_key_to_string(input_dict: dict, custom_format: str = "{:g}"): """ - Function to recursively change the key back to a string but this time in a format that we decide + Function to recursively change the key back to a string but this time in a format that we decide. We'll try to turn a string key into a float key before formatting the key + + Args: + input_dict: dict of which we want to turn all the keys to string types (with a custom format) + custom_format: custom format used when turning the key to strings + + Returns: + new_dict: dict of which the keys have been turned to string types where possible """ - new_dict = collections.OrderedDict() # TODO: check if this still works + new_dict = collections.OrderedDict() for key in input_dict: + # Try to turn into a float + try: + string_key = float(key) + except ValueError: + string_key = key + + # Turn into string with new format + if not isinstance(string_key, str): + string_key = custom_format.format(string_key) + + # If dictionary type, call function again if isinstance(input_dict[key], (dict, collections.OrderedDict)): - if isinstance(key, (int, float)): - string_key = "{:g}".format(key) - new_dict[string_key] = recursive_change_key_to_string( - copy.deepcopy(input_dict[key]) - ) - else: - new_dict[key] = recursive_change_key_to_string( - copy.deepcopy(input_dict[key]) - ) + new_dict[string_key] = recursive_change_key_to_string( + input_dict[key], custom_format + ) else: - if isinstance(key, (int, float)): - string_key = "{:g}".format(key) - new_dict[string_key] = input_dict[key] - else: - new_dict[key] = input_dict[key] + new_dict[string_key] = input_dict[key] return new_dict -############################################################ -# code to walk a dictionary recursively based on -# https://stackoverflow.com/questions/13687924/setting-a-value-in-a-nested-python-dictionary-given-a-list-of-indices-and-value def _nested_set(dic, keys, value): + """ + Code to set a value of a nested dict based on a list of keys. We take into account the fact that the vallue in the dict might not be set at all by the setdefault call and the reverse looping of the keys + + https://stackoverflow.com/questions/13687924/setting-a-value-in-a-nested-python-dictionary-given-a-list-of-indices-and-value + + TODO: describe better + """ + for key in keys[:-1]: dic = dic.setdefault(key, {}) dic[keys[-1]] = value def _nested_get(dic, keys): + """ + Code to get a value of a nested dict based on a list of keys. We take into account the fact that the vallue in the dict might not be set at all by the setdefault call and the reverse looping of the keys + + TODO: unused. Remove? + """ + for key in keys[:-1]: dic = dic.setdefault(key, {}) return dic[keys[-1]] -# function to walk through the dictionary, multiplying -# only float values by a const -def _recursive_normalize_floats(path, d, const, parent=None, ignore=None): +def _recursive_normalize_floats(path, input_dict, factor, parent=None, ignore=None): + """ + Function to walk through the dictionary, multiplying only float values by a factor + """ + if not parent: - parent = d - for k, v in d.items(): + parent = input_dict + + for k, v in input_dict.items(): if ignore and k in ignore: continue if isinstance(v, float): path.append(k) - # must be a float, multiply by the constant - _nested_set(parent, path, v * const) + # must be a float, multiply by the factor + _nested_set(parent, path, v * factor) path.pop() - elif isinstance(v, str) or isinstance(v, int): + elif isinstance(v, (str, int)): path.append(k) # do nothing to strings or ints path.pop() elif v is None: path.append(k) path.pop() + # dicts # note: isinstance isn't enough, we need to check the Mapping elif isinstance(v, collections.abc.Mapping): path.append(k) # nested dict - _recursive_normalize_floats(path, v, const, parent=parent) + _recursive_normalize_floats(path, v, factor, parent=parent) path.pop() else: print( @@ -156,38 +202,39 @@ def _recursive_normalize_floats(path, d, const, parent=None, ignore=None): ) -def multiply_float_values(d, const, ignore=None): +def multiply_float_values(input_dict, factor, ignore=None): """ - multiply_float_values : A function to recursively multiply values of a (nested) dictionary that are floats by a constant. Nested dictionaries call this function recursively. + A function to recursively multiply values of a (nested) dictionary that are floats by a constant. Nested dictionaries call this function recursively. Args: - d = the dictionary - const = the constant that multiplies float values + input_dict: the dictionary + factor: the constant that multiplies float values """ + path = [] - _recursive_normalize_floats(path, d, const, parent=d, ignore=ignore) + _recursive_normalize_floats( + path, input_dict, factor, parent=input_dict, ignore=ignore + ) def subtract_dicts(dict_1: dict, dict_2: dict) -> dict: """ - Function to subtract two dictionaries. + Function to subtract two dictionaries, i.e. ``dict_1 - dict_2`` Only allows values to be either a dict or a numerical type For the overlapping keys (key name present in both dicts): - When the keys are of the same type: - - If the types are of numerical type: subtract the value at dict 2 from dict 1. - - If the types are both dictionaries: call this function with the subdicts + When the keys are of the same type: If the types are of numerical type we subtract the value at dict 2 from dict 1. If the types are both dictionaries: call this function with the subdicts - When the keys are not of the same type: - - if the keys are all of numerical types + When the keys are not of the same type: If the keys are all of numerical types we do the subtraction. If they are not numerical we raise an error. For the unique keys: - - if the key is from dict 1: adds the value to the new dict (be it numerical value or dict) - - If the key is from dict 2: Adds the negative of its value in case of numerical type. - if the type is a dict, the result of subtract_dicts({}, dict_2[key]) will be set + If the key is from dict 1: adds the value to the new dict (be it numerical value or dict) + + If the key is from dict 2: Adds the negative of its value in case of numerical type. If the type is a dict, the result of ``subtract_dicts({}, dict_2[key])`` will be set If the result is 0, the key will be removed from the resulting dict. + If that results in an empty dict, the dict will be removed too. Args: @@ -195,15 +242,12 @@ def subtract_dicts(dict_1: dict, dict_2: dict) -> dict: dict_2: second dictionary Returns: - Subtracted dictionary + Subtracted dictionary, i.e. ``dict_1 - dict_2`` """ # Set up new dict new_dict = {} - # Define allowed numerical types - ALLOWED_NUMERICAL_TYPES = (float, int, np.float64) - # keys_1 = dict_1.keys() keys_2 = dict_2.keys() @@ -223,10 +267,8 @@ def subtract_dicts(dict_1: dict, dict_2: dict) -> dict: if new_dict[key] == 0: del new_dict[key] - # Else, to be safe we should deepcopy them elif isinstance(dict_1[key], dict): - copy_dict = copy.deepcopy(dict_1[key]) - new_dict[key] = copy_dict + new_dict[key] = dict_1[key] else: msg = "Error: using unsupported type for key {}: {}".format( key, type(dict_1[key]) @@ -267,13 +309,12 @@ def subtract_dicts(dict_1: dict, dict_2: dict) -> dict: del new_dict[key] else: - msg = "Error key: {} value: {} type: {} and key: {} value: {} type: {} are not of the same type and cannot be merged".format( - key, - dict_1[key], - type(dict_1[key]), - key, - dict_2[key], - type(dict_2[key]), + msg = "Error key: {key} value: {value1} type: {type} and key: {key} value: {value2} type: {type2} are not of the same type and cannot be merged".format( + key=key, + value1=dict_1[key], + type=type(dict_1[key]), + value2=dict_2[key], + type2=type(dict_2[key]), ) print(msg) @@ -289,12 +330,10 @@ def subtract_dicts(dict_1: dict, dict_2: dict) -> dict: if new_dict[key] == 0: del new_dict[key] - # Else, to be safe we should deepcopy them elif isinstance(dict_1[key], dict): new_dict[key] = subtract_dicts(dict_1[key], dict_2[key]) # Remove entry if it results in an empty dict - # TODO: write test to prevent empty dicts from showing up if not new_dict[key]: del new_dict[key] else: @@ -323,6 +362,10 @@ class AutoVivificationDict(dict): """ def __getitem__(self, item): + """ + Getitem function for the autovivication dict + """ + try: return dict.__getitem__(self, item) except KeyError: @@ -330,6 +373,10 @@ class AutoVivificationDict(dict): return value def __iadd__(self, other): + """ + iadd function (handling the +=) for the autovivication dict. + """ + # if a value does not exist, assume it is 0.0 try: self += other @@ -358,7 +405,7 @@ def inspect_dict( type(input_dict[key]) (except if the value is a dict) """ - structure_dict = collections.OrderedDict() # TODO: check if this still works + structure_dict = collections.OrderedDict() # for key, value in input_dict.items(): @@ -375,9 +422,15 @@ def inspect_dict( return structure_dict -def count_keys_recursive(input_dict): +def count_keys_recursive(input_dict: dict) -> int: """ - Function to count the total number of keys in a dictionary + Function to recursively count the total number of keys in a dictionary. + + Args: + input_dict: dictionary that we want to know the total amount of keys from. + + Returns: + local_count: total amount of keys within the input_dict. """ local_count = 0 @@ -385,6 +438,7 @@ def count_keys_recursive(input_dict): local_count += 1 if isinstance(input_dict[key], (dict, collections.OrderedDict)): local_count += count_keys_recursive(input_dict[key]) + return local_count @@ -401,6 +455,10 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict: - dictionaries will be merged by calling recursively calling this function again - numbers will be added - (opt) lists will be appended + - booleans are merged with logical OR + - identical strings are just set to the string + - non-identical strings are concatenated + - NoneTypes are set to None - In the case that the instances do not match: for now I will raise an error Args: @@ -413,7 +471,7 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict: """ # Set up new dict - new_dict = collections.OrderedDict() # TODO: check if this still necessary + new_dict = collections.OrderedDict() # keys_1 = dict_1.keys() @@ -428,22 +486,10 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict: # Add the unique keys to the new dict for key in unique_to_dict_1: - # If these items are ints or floats, then just put them in - if isinstance(dict_1[key], (float, int)): - new_dict[key] = dict_1[key] - # Else, to be safe we should deepcopy them - else: - copy_dict = copy.deepcopy(dict_1[key]) - new_dict[key] = copy_dict + new_dict[key] = dict_1[key] for key in unique_to_dict_2: - # If these items are ints or floats, then just put them in - if isinstance(dict_2[key], (float, int)): - new_dict[key] = dict_2[key] - # Else, to be safe we should deepcopy them - else: - copy_dict = copy.deepcopy(dict_2[key]) - new_dict[key] = copy_dict + new_dict[key] = dict_2[key] # Go over the common keys: for key in overlapping_keys: @@ -451,8 +497,8 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict: # If they keys are not the same, it depends on their type whether we still deal with them at all, or just raise an error if not type(dict_1[key]) is type(dict_2[key]): # Exceptions: numbers can be added - if isinstance(dict_1[key], (int, float, np.float64)) and isinstance( - dict_2[key], (int, float, np.float64) + if isinstance(dict_1[key], ALLOWED_NUMERICAL_TYPES) and isinstance( + dict_2[key], ALLOWED_NUMERICAL_TYPES ): new_dict[key] = dict_1[key] + dict_2[key] @@ -464,20 +510,48 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict: ): new_dict[key] = merge_dicts(dict_1[key], dict_2[key]) + # string-int clash : convert both to ints and save + elif ( + isinstance(dict_1[key], str) + and isinstance(dict_2[key], int) + or isinstance(dict_1[key], int) + and isinstance(dict_2[key], str) + ): + try: + new_dict[key] = int(dict_1[key]) + int(dict_2[key]) + except ValueError as e: + msg = "{}: Failed to convert string (either '{}' or '{}') to an int".format( + key, dict_1[key], dict_2[key] + ) + raise ValueError(msg) from e + + # string-float clash : convert both to floats and save + elif ( + isinstance(dict_1[key], str) + and isinstance(dict_2[key], float) + or isinstance(dict_1[key], float) + and isinstance(dict_2[key], str) + ): + try: + new_dict[key] = float(dict_1[key]) + float(dict_2[key]) + except ValueError as e: + msg = "{}: Failed to convert string (either '{}' or '{}') to an float".format( + key, dict_1[key], dict_2[key] + ) + raise ValueError(msg) from e + # If the above cases have not dealt with it, then we should raise an error else: - print( - "Error key: {} value: {} type: {} and key: {} value: {} type: {} are not of the same type and cannot be merged".format( - key, - dict_1[key], - type(dict_1[key]), - key, - dict_2[key], - type(dict_2[key]), - ) + msg = "merge_dicts error: key: {key} value: {value1} type: {type1} and key: {key} value: {value2} type: {type2} are not of the same type and cannot be merged".format( + key=key, + value1=dict_1[key], + type1=type(dict_1[key]), + value2=dict_2[key], + type2=type(dict_2[key]), ) - raise ValueError + raise ValueError(msg) + # Here the keys are the same type # Here we check for the cases that we want to explicitly catch. Ints will be added, # floats will be added, lists will be appended (though that might change) and dicts will be # dealt with by calling this function again. @@ -508,17 +582,28 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict: elif isinstance(dict_1[key], dict) and isinstance(dict_2[key], dict): new_dict[key] = merge_dicts(dict_1[key], dict_2[key]) + # strings + elif isinstance(dict_1[key], str) and isinstance(dict_2[key], str): + if dict_1[key] == dict_2[key]: + # same strings + new_dict[key] = dict_1[key] + else: + # different strings: just concatenate them + new_dict[key] = dict_1[key] + dict_2[key] + + # None types + elif dict_1[key] is None and dict_2[key] is None: + new_dict[key] = None + else: - print( - "Object types {}: {} ({}), {} ({}) not supported.".format( - key, - dict_1[key], - type(dict_1[key]), - dict_2[key], - type(dict_2[key]), - ) + msg = "Object types {}: {} ({}), {} ({}) not supported.".format( + key, + dict_1[key], + type(dict_1[key]), + dict_2[key], + type(dict_2[key]), ) - raise ValueError + raise ValueError(msg) # return new_dict @@ -529,12 +614,9 @@ def update_dicts(dict_1: dict, dict_2: dict) -> dict: Function to update dict_1 with values of dict_2 in a recursive way. Behaviour: + When dict keys are only present in one of either: we just add the content to the new dict - When dict keys are only present in one of either: - - we just add the content to the new dict - - When dict keys are present in both, we decide based on the value types how to combine them: - - value of dict2 will be taken + When dict keys are present in both, we decide based on the value types how to combine them: value of dict2 will be taken Args: dict_1: first dictionary @@ -546,14 +628,9 @@ def update_dicts(dict_1: dict, dict_2: dict) -> dict: """ # Set up new dict of the same type as dict_1 - # - # Note: setting directly to OrderedDict fails in some cases - # so instead we take a (shallow) copy of dict_1 which will - # have the same type as dict_1, then clear it. (There must - # be a better way to do this...) - new_dict = dict_1.copy() # OrderedDict() # TODO: check if this still works - new_dict.clear() + new_dict = dict_1.__class__() + # Get keys keys_1 = dict_1.keys() keys_2 = dict_2.keys() @@ -566,22 +643,10 @@ def update_dicts(dict_1: dict, dict_2: dict) -> dict: # Add the unique keys to the new dict for key in unique_to_dict_1: - # If these items are ints or floats, then just put them in - if isinstance(dict_1[key], (float, int)): - new_dict[key] = dict_1[key] - # Else, to be safe we should deepcopy them - else: - copy_dict = copy.deepcopy(dict_1[key]) - new_dict[key] = copy_dict + new_dict[key] = dict_1[key] for key in unique_to_dict_2: - # If these items are ints or floats, then just put them in - if isinstance(dict_2[key], (float, int)): - new_dict[key] = dict_2[key] - # Else, to be safe we should deepcopy them - else: - copy_dict = copy.deepcopy(dict_2[key]) - new_dict[key] = copy_dict + new_dict[key] = dict_2[key] # Go over the common keys: for key in overlapping_keys: @@ -589,20 +654,19 @@ def update_dicts(dict_1: dict, dict_2: dict) -> dict: # See whether the types are actually the same if not type(dict_1[key]) is type(dict_2[key]): # Exceptions: - if (type(dict_1[key]) in [int, float]) and ( - type(dict_2[key]) in [int, float] + if isinstance(dict_1[key], ALLOWED_NUMERICAL_TYPES) and isinstance( + dict_2[key], ALLOWED_NUMERICAL_TYPES ): new_dict[key] = dict_2[key] else: print( - "Error key: {} value: {} type: {} and key: {} value: {} type: {} are not of the same type and cannot be merged".format( - key, - dict_1[key], - type(dict_1[key]), - key, - dict_2[key], - type(dict_2[key]), + "Error key: {key} value: {value1} type: {type1} and key: {key} value: {value2} type: {type2} are not of the same type and cannot be merged".format( + key=key, + value1=dict_1[key], + type1=type(dict_1[key]), + value2=dict_2[key], + type2=type(dict_2[key]), ) ) raise ValueError @@ -621,11 +685,20 @@ def update_dicts(dict_1: dict, dict_2: dict) -> dict: return new_dict -def multiply_values_dict(input_dict, factor): +def multiply_values_dict(input_dict: dict, factor: UNION_ALLOWED_NUMERICAL_TYPES): """ Function that goes over dictionary recursively and multiplies the value if possible by a factor - If the key equals "general_info", the multiplication gets skipped + If the key equals "general_info", the multiplication gets skipped. + + This function changes the values in-place, so the original dict is modified + + Args: + input_dict: dictionary of which we want to multiply the values by <factor> + factor: factor that we want to multiply the values with + + Returns: + multiplied_dict: dict containing the multiplied keys. This is the same object as we passed as input. """ for key in input_dict: @@ -639,7 +712,7 @@ def multiply_values_dict(input_dict, factor): return input_dict -def custom_sort_dict(input_dict): +def custom_sort_dict(input_dict: dict) -> dict: """ Returns a dictionary that is ordered, but can handle numbers better than normal OrderedDict @@ -649,6 +722,9 @@ def custom_sort_dict(input_dict): This is done until all the keys are sorted. All objects other than dictionary types are directly return as they are + + Args: + input_dict: object which will be sorted (and returned as a new object) if its a dictionary, otherwise it will be returned without change. """ # If the new input is a dictionary, then try to sort it @@ -666,6 +742,7 @@ def custom_sort_dict(input_dict): # If there are multiple types, then we loop over them and do a piece wise sort if len(all_types_keys) > 1: msg = "Different types in the same dictionary key set" + print(msg) # Create a string repr of the type name to sort them afterwards str_types = {repr(el): el for el in all_types_keys} @@ -684,9 +761,10 @@ def custom_sort_dict(input_dict): sorted_keys = sorted(keys) for key in sorted_keys: - new_dict[key] = custom_sort_dict(copy.deepcopy(input_dict[key])) + new_dict[key] = custom_sort_dict(input_dict[key]) return new_dict + return input_dict @@ -728,3 +806,69 @@ def filter_dict_through_values(arg_dict: dict, filter_list: list) -> dict: new_dict[key] = arg_dict[key] return new_dict + + +def prepare_dict(global_dict: dict, list_of_sub_keys: list) -> None: + """ + Function that makes sure that the global dict is prepared to have a value set there. + This dictionary will store values and factors for the distribution functions, + so that they don't have to be calculated each time. + + Args: + global_dict: globally accessible dictionary where factors are stored in + list_of_sub_keys: List of keys that must become be(come) present in the global_dict + """ + + internal_dict_value = global_dict + + # This loop almost mimics a recursive loop into the dictionary. + # It checks whether the first key of the list is present, if not; set it with an empty dict. + # Then it overrides itself to be that (new) item, and goes on to do that again, until the list + # exhausted + for k in list_of_sub_keys: + # If the sub key doesnt exist then make an empty dict + if not internal_dict_value.get(k, None): + internal_dict_value[k] = {} + internal_dict_value = internal_dict_value[k] + + +def set_opts(opts: dict, newopts: dict) -> dict: + """ + Function to take a default dict and override it with newer values. + + # TODO: consider changing this to just a dict.update + + Args: + opts: dictionary with default values + newopts: dictionary with new values + + Returns: + returns an updated dictionary + """ + + if newopts: + for opt in newopts.keys(): + if opt in opts.keys(): + opts[opt] = newopts[opt] + + return opts + + +def normalize_dict(result_dict: dict) -> dict: + """ + Function to normalise a dictionary by summing all the values and dividing each term by the total. Designed for dictionary containing only positive values. + + Args: + result_dict: dictionary where values should be positive number objects + + Returns: + normalized_dict: dictionary where the values are normalised to sum to 1 + """ + + normalized_dict = {} + + sum_result = sum(list(result_dict.values())) + for key in result_dict.keys(): + normalized_dict[key] = result_dict[key] / sum_result + + return normalized_dict diff --git a/binarycpython/utils/distribution_functions.py b/binarycpython/utils/distribution_functions.py deleted file mode 100644 index d6a99452af87c021707bd06012bae4695ca087f9..0000000000000000000000000000000000000000 --- a/binarycpython/utils/distribution_functions.py +++ /dev/null @@ -1,2425 +0,0 @@ -""" -Module containing the predefined distribution functions - -The user can use any of these distribution functions to -generate probability distributions for sampling populations - -There are distributions for the following parameters: - - mass - - period - - mass ratio - - binary fraction - -Tasks: - - TODO: make some things globally present? rob does this in his module..i guess it saves - calculations but not sure if I'm gonna do that now - - TODO: add eccentricity distribution: thermal - - TODO: Add SFH distributions depending on redshift - - TODO: Add metallicity distributions depending on redshift - - TODO: Add initial rotational velocity distributions - - TODO: make an n-part power law that's general enough to fix the three part and the 4 part -""" - -import functools -import math -import json - -import traceback -import sys - -from typing import Union - -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 ( - _MOE2017_VERBOSITY_LEVEL, - _MOE2017_VERBOSITY_INTERPOLATOR_LEVEL, -) - -### -# File containing probability distributions -# Mostly copied from the Perl modules -LOG_LN_CONVERTER = 1.0 / math.log(10.0) -distribution_constants = {} # To store the constants in - - -def prepare_dict(global_dict: dict, list_of_sub_keys: list) -> None: - """ - Function that makes sure that the global dict is prepared to have a value set there. - This dictionary will store values and factors for the distribution functions, - so that they don't have to be calculated each time. - - Args: - global_dict: globally accessible dictionary where factors are stored in - list_of_sub_keys: List of keys that must become be(come) present in the global_dict - """ - - internal_dict_value = global_dict - - # This loop almost mimics a recursive loop into the dictionary. - # It checks whether the first key of the list is present, if not; set it with an empty dict. - # Then it overrides itself to be that (new) item, and goes on to do that again, until the list - # exhausted - for k in list_of_sub_keys: - # If the sub key doesnt exist then make an empty dict - if not internal_dict_value.get(k, None): - internal_dict_value[k] = {} - internal_dict_value = internal_dict_value[k] - - -def set_opts(opts: dict, newopts: dict) -> dict: - """ - Function to take a default dict and override it with newer values. - - # TODO: consider changing this to just a dict.update - - Args: - opts: dictionary with default values - newopts: dictionary with new values - - Returns: - returns an updated dictionary - """ - - if newopts: - for opt in newopts.keys(): - if opt in opts.keys(): - opts[opt] = newopts[opt] - - return opts - - -def flat() -> float: - """ - Dummy distribution function that returns 1 - - Returns: - a flat uniform distribution: 1 - """ - - return 1.0 - - -def number(value: Union[int, float]) -> Union[int, float]: - """ - Dummy distribution function that returns the input - - Args: - value: the value that will be returned by this function. - - Returns: - the value that was provided - """ - - return value - - -def const( - min_bound: Union[int, float], max_bound: Union[int, float], val: float = None -) -> Union[int, float]: - """ - a constant distribution function between min=min_bound and max=max_bound. - - Args: - min_bound: lower bound of the range - max_bound: upper bound of the range - - Returns: - returns the value of 1/(max_bound-min_bound). If val is provided, it will check whether min_bound < val <= max_bound. if not: returns 0 - """ - - if val: - if not min_bound < val <= max_bound: - print("out of bounds") - prob = 0 - return prob - prob = 1.0 / (max_bound - min_bound) - return prob - - -@functools.lru_cache(maxsize=16) -def powerlaw_constant( - min_val: Union[int, float], max_val: Union[int, float], k: Union[int, float] -) -> Union[int, float]: - """ - Function that returns the constant to normalise a power law - - TODO: what if k is -1? - - Args: - min_val: lower bound of the range - max_val: upper bound of the range - k: power law slope - - Returns: - constant to normalise the given power law between the min_val and max_val range - """ - - k1 = k + 1.0 - # print( - # "Powerlaw consts from {} to {}, k={} where k1={}".format( - # min_val, max_val, k, k1 - # ) - # ) - - powerlaw_const = k1 / (max_val ** k1 - min_val ** k1) - return powerlaw_const - - -def powerlaw( - min_val: Union[int, float], - max_val: Union[int, float], - k: Union[int, float], - x: Union[int, float], -) -> Union[int, float]: - """ - Single power law with index k at x from min to max - - Args: - min_val: lower bound of the power law - max_val: upper bound of the power law - k: slope of the power law - x: position at which we want to evaluate - - Returns: - `probability` at the given position(x) - """ - - # Handle faulty value - if k == -1: - msg = "wrong value for k" - raise ValueError(msg) - - if (x < min_val) or (x > max_val): - print("input value is out of bounds!") - return 0 - - powerlaw_const = powerlaw_constant(min_val, max_val, k) - - # power law - prob = powerlaw_const * (x ** k) - # print( - # "Power law from {} to {}: const = {}, y = {}".format( - # min_val, max_val, const, y - # ) - # ) - return prob - - -@functools.lru_cache(maxsize=16) -def calculate_constants_three_part_powerlaw( - m0: Union[int, float], - m1: Union[int, float], - m2: Union[int, float], - m_max: Union[int, float], - p1: Union[int, float], - p2: Union[int, float], - p3: Union[int, float], -) -> Union[int, float]: - """ - Function to calculate the constants for a three-part power law - - TODO: use the power law_constant function to calculate all these values - - Args: - m0: lower bound mass - m1: second boundary, between the first slope and the second slope - m2: third boundary, between the second slope and the third slope - m_max: upper bound mass - p1: first slope - p2: second slope - p3: third slope - - Returns: - array of normalisation constants - """ - - # print("Initialising constants for the three-part powerlaw: m0={} m1={} m2={}\ - # m_max={} p1={} p2={} p3={}\n".format(m0, m1, m2, m_max, p1, p2, p3)) - - array_constants_three_part_powerlaw = [0, 0, 0] - - array_constants_three_part_powerlaw[1] = ( - ((m1 ** p2) * (m1 ** (-p1))) - * (1.0 / (1.0 + p1)) - * (m1 ** (1.0 + p1) - m0 ** (1.0 + p1)) - ) - array_constants_three_part_powerlaw[1] += ( - (m2 ** (1.0 + p2) - m1 ** (1.0 + p2)) - ) * (1.0 / (1.0 + p2)) - array_constants_three_part_powerlaw[1] += ( - ((m2 ** p2) * (m2 ** (-p3))) - * (1.0 / (1.0 + p3)) - * (m_max ** (1.0 + p3) - m2 ** (1.0 + p3)) - ) - array_constants_three_part_powerlaw[1] = 1.0 / ( - array_constants_three_part_powerlaw[1] + 1e-50 - ) - - array_constants_three_part_powerlaw[0] = array_constants_three_part_powerlaw[1] * ( - (m1 ** p2) * (m1 ** (-p1)) - ) - array_constants_three_part_powerlaw[2] = array_constants_three_part_powerlaw[1] * ( - (m2 ** p2) * (m2 ** (-p3)) - ) - - return array_constants_three_part_powerlaw - # $$array[1]=(($m1**$p2)*($m1**(-$p1)))* - # (1.0/(1.0+$p1))* - # ($m1**(1.0+$p1)-$m0**(1.0+$p1))+ - # (($m2**(1.0+$p2)-$m1**(1.0+$p2)))* - # (1.0/(1.0+$p2))+ - # (($m2**$p2)*($m2**(-$p3)))* - # (1.0/(1.0+$p3))* - # ($mmax**(1.0+$p3)-$m2**(1.0+$p3)); - # $$array[1]=1.0/($$array[1]+1e-50); - # $$array[0]=$$array[1]*$m1**$p2*$m1**(-$p1); - # $$array[2]=$$array[1]*$m2**$p2*$m2**(-$p3); - # #print "ARRAY SET @_ => @$array\n"; - # $threepart_powerlaw_consts{"@_"}=[@$array]; - - -def three_part_powerlaw( - m: Union[int, float], - m0: Union[int, float], - m1: Union[int, float], - m2: Union[int, float], - m_max: Union[int, float], - p1: Union[int, float], - p2: Union[int, float], - p3: Union[int, float], -) -> Union[int, float]: - """ - Generalised three-part power law, usually used for mass distributions - - Args: - m: mass at which we want to evaluate the distribution. - m0: lower bound mass - m1: second boundary, between the first slope and the second slope - m2: third boundary, between the second slope and the third slope - m_max: upper bound mass - p1: first slope - p2: second slope - p3: third slope - - Returns: - 'probability' at given mass m - """ - - # TODO: add check on whether the values exist - - three_part_powerlaw_constants = calculate_constants_three_part_powerlaw( - m0, m1, m2, m_max, p1, p2, p3 - ) - - # - if m < m0: - prob = 0 # Below lower bound TODO: make this clear. - elif m0 < m <= m1: - prob = three_part_powerlaw_constants[0] * (m ** p1) # Between M0 and M1 - elif m1 < m <= m2: - prob = three_part_powerlaw_constants[1] * (m ** p2) # Between M1 and M2 - elif m2 < m <= m_max: - prob = three_part_powerlaw_constants[2] * (m ** p3) # Between M2 and M_MAX - else: - prob = 0 # Above M_MAX - - return prob - - -@functools.lru_cache(maxsize=16) -def gaussian_normalizing_const( - mean: Union[int, float], - sigma: Union[int, float], - gmin: Union[int, float], - gmax: Union[int, float], -) -> Union[int, float]: - """ - Function to calculate the normalisation constant for the Gaussian - - Args: - mean: mean of the Gaussian - sigma: standard deviation of the Gaussian - gmin: lower bound of the range to calculate the probabilities in - gmax: upper bound of the range to calculate the probabilities in - - Returns: - normalisation constant for the Gaussian distribution(mean, sigma) between gmin and gmax - """ - - # First time; calculate multiplier for given mean and sigma - ptot = 0 - resolution = 1000 - d = (gmax - gmin) / resolution - - for i in range(resolution): - y = gmin + i * d - ptot += d * gaussian_func(y, mean, sigma) - - # TODO: Set value in global - return ptot - - -def gaussian_func( - x: Union[int, float], mean: Union[int, float], sigma: Union[int, float] -) -> Union[int, float]: - """ - Function to evaluate a Gaussian at a given point, but this time without any boundaries. - - Args: - x: location at which to evaluate the distribution - mean: mean of the Gaussian - sigma: standard deviation of the Gaussian - - Returns: - value of the Gaussian at x - """ - gaussian_prefactor = 1.0 / math.sqrt(2.0 * math.pi) - - r = 1.0 / (sigma) - y = (x - mean) * r - return gaussian_prefactor * r * math.exp(-0.5 * y ** 2) - - -def gaussian( - x: Union[int, float], - mean: Union[int, float], - sigma: Union[int, float], - gmin: Union[int, float], - gmax: Union[int, float], -) -> Union[int, float]: - """ - Gaussian distribution function. used for e.g. Duquennoy + Mayor 1991 - - Args: - x: location at which to evaluate the distribution - mean: mean of the Gaussian - sigma: standard deviation of the Gaussian - gmin: lower bound of the range to calculate the probabilities in - gmax: upper bound of the range to calculate the probabilities in - - Returns: - 'probability' of the Gaussian distribution between the boundaries, evaluated at x - """ - - # # location (X value), mean and sigma, min and max range - # my ($x,$mean,$sigma,$gmin,$gmax) = @_; - - if (x < gmin) or (x > gmax): - prob = 0 - else: - # normalise over given range - # TODO: add loading into global var - normalisation = gaussian_normalizing_const(mean, sigma, gmin, gmax) - prob = gaussian_func(x, mean, sigma) / normalisation - - return prob - - -##### -# Mass distributions -##### - - -def Kroupa2001(m: Union[int, float], newopts: dict = None) -> Union[int, float]: - """ - Probability distribution function for Kroupa 2001 IMF, where the default values to the - three_part_powerlaw are: default = {"m0": 0.1, "m1": 0.5, "m2": 1, "mmax": 100, "p1": -1.3, "p2": -2.3,"p3": -2.3} - - Args: - m: mass to evaluate the distribution at - newopts: optional dict to override the default values. - - Returns: - 'probability' of distribution function evaluated at m - """ - - # Default parameters and override them - default = { - "m0": 0.1, - "m1": 0.5, - "m2": 1, - "mmax": 100, - "p1": -1.3, - "p2": -2.3, - "p3": -2.3, - } - - value_dict = default.copy() - - if newopts: - value_dict.update(newopts) - - return three_part_powerlaw( - m, - value_dict["m0"], - value_dict["m1"], - value_dict["m2"], - value_dict["mmax"], - value_dict["p1"], - value_dict["p2"], - value_dict["p3"], - ) - - -def ktg93(m: Union[int, float], newopts: dict = None) -> Union[int, float]: - """ - Probability distribution function for KTG93 IMF, where the default values to the three_part_powerlaw are: default = {"m0": 0.1, "m1": 0.5, "m2": 1, "mmax": 80, "p1": -1.3, "p2": -2.2,"p3": -2.7} - - Args: - m: mass to evaluate the distribution at - newopts: optional dict to override the default values. - - Returns: - 'probability' of distribution function evaluated at m - """ - # TODO: ask rob what this means - - # if($m eq 'uncertainties') - # { - # # return (pointer to) the uncertainties hash - # return { - # m0=>{default=>0.1, - # fixed=>1}, - # m1=>{default=>0.5, - # fixed=>1}, - # m2=>{default=>1.0, - # fixed=>1}, - # mmax=>{default=>80.0, - # fixed=>1}, - # p1=>{default=>-1.3, - # low=>-1.3, - # high=>-1.3}, - # p2=>{default=>-2.2, - # low=>-2.2, - # high=>-2.2}, - # p3=>{default=>-2.7, - # low=>-2.7, - # high=>-2.7} - # }; - # } - - # set options - # opts = set_opts({'m0':0.1, 'm1':0.5, 'm2':1.0, 'mmax':80, 'p1':-1.3, 'p2':-2.2, 'p3':-2.7}, - # newopts) - - defaults = { - "m0": 0.1, - "m1": 0.5, - "m2": 1.0, - "mmax": 80, - "p1": -1.3, - "p2": -2.2, - "p3": -2.7, - } - value_dict = defaults.copy() - - if newopts: - value_dict.update(newopts) - - return three_part_powerlaw( - m, - value_dict["m0"], - value_dict["m1"], - value_dict["m2"], - value_dict["mmax"], - value_dict["p1"], - value_dict["p2"], - value_dict["p3"], - ) - - -# sub ktg93_lnspace -# { -# # wrapper for KTG93 on a ln(m) grid -# my $m=$_[0]; -# return ktg93(@_) * $m; -# } - - -def imf_tinsley1980(m: Union[int, float]) -> Union[int, float]: - """ - Probability distribution function for Tinsley 1980 IMF (defined up until 80Msol): three_part_powerlaw(m, 0.1, 2.0, 10.0, 80.0, -2.0, -2.3, -3.3) - - Args: - m: mass to evaluate the distribution at - - Returns: - 'probability' of distribution function evaluated at m - """ - - return three_part_powerlaw(m, 0.1, 2.0, 10.0, 80.0, -2.0, -2.3, -3.3) - - -def imf_scalo1986(m: Union[int, float]) -> Union[int, float]: - """ - Probability distribution function for Scalo 1986 IMF (defined up until 80Msol): three_part_powerlaw(m, 0.1, 1.0, 2.0, 80.0, -2.35, -2.35, -2.70) - - Args: - m: mass to evaluate the distribution at - - Returns: - 'probability' of distribution function evaluated at m - """ - return three_part_powerlaw(m, 0.1, 1.0, 2.0, 80.0, -2.35, -2.35, -2.70) - - -def imf_scalo1998(m: Union[int, float]) -> Union[int, float]: - """ - From Scalo 1998 - - Probability distribution function for Scalo 1998 IMF (defined up until 80Msol): three_part_powerlaw(m, 0.1, 1.0, 10.0, 80.0, -1.2, -2.7, -2.3) - - Args: - m: mass to evaluate the distribution at - - Returns: - 'probability' of distribution function evaluated at m - """ - - return three_part_powerlaw(m, 0.1, 1.0, 10.0, 80.0, -1.2, -2.7, -2.3) - - -def imf_chabrier2003(m: Union[int, float]) -> Union[int, float]: - """ - Probability distribution function for IMF of Chabrier 2003 PASP 115:763-795 - - Args: - m: mass to evaluate the distribution at - - Returns: - 'probability' of distribution function evaluated at m - """ - - chabrier_logmc = math.log10(0.079) - chabrier_sigma2 = 0.69 * 0.69 - chabrier_a1 = 0.158 - chabrier_a2 = 4.43e-2 - chabrier_x = -1.3 - if m <= 0: - msg = "below bounds" - raise ValueError(msg) - if 0 < m < 1.0: - A = 0.158 - dm = math.log10(m) - chabrier_logmc - prob = chabrier_a1 * math.exp(-(dm ** 2) / (2.0 * chabrier_sigma2)) - else: - prob = chabrier_a2 * (m ** chabrier_x) - prob = prob / (0.1202462 * m * math.log(10)) - return prob - - -######################################################################## -# Binary fractions -######################################################################## - - -def Arenou2010_binary_fraction(m: Union[int, float]) -> Union[int, float]: - """ - Arenou 2010 function for the binary fraction as f(M1) - - GAIA-C2-SP-OPM-FA-054 - www.rssd.esa.int/doc_fetch.php?id=2969346 - - Args: - m: mass to evaluate the distribution at - - Returns: - binary fraction at m - """ - - return 0.8388 * math.tanh(0.688 * m + 0.079) - - -# print(Arenou2010_binary_fraction(0.4)) - - -def raghavan2010_binary_fraction(m: Union[int, float]) -> Union[int, float]: - """ - Fit to the Raghavan 2010 binary fraction as a function of - spectral type (Fig 12). Valid for local stars (Z=Zsolar). - - The spectral type is converted mass by use of the ZAMS - effective temperatures from binary_c/BSE (at Z=0.02) - and the new "long_spectral_type" function of binary_c - (based on Jaschek+Jaschek's Teff-spectral type table). - - Rob then fitted the result - - Args: - m: mass to evaluate the distribution at - - Returns: - binary fraction at m - """ - - return min( - 1.0, - max( - (m ** 0.1) * (5.12310e-01) + (-1.02070e-01), - (1.10450e00) * (m ** (4.93670e-01)) + (-6.95630e-01), - ), - ) - - -# print(raghavan2010_binary_fraction(2)) - -######################################################################## -# Period distributions -######################################################################## - - -def duquennoy1991(logper: Union[int, float]) -> Union[int, float]: - """ - Period distribution from Duquennoy + Mayor 1991. Evaluated the function gaussian(logper, 4.8, 2.3, -2, 12) - - Args: - logper: logarithm of period to evaluate the distribution at - - Returns: - 'probability' at gaussian(logper, 4.8, 2.3, -2, 12) - """ - return gaussian(logper, 4.8, 2.3, -2, 12) - - -def sana12( - M1: Union[int, float], - M2: Union[int, float], - a: Union[int, float], - P: Union[int, float], - amin: Union[int, float], - amax: Union[int, float], - x0: Union[int, float], - x1: Union[int, float], - p: Union[int, float], -) -> Union[int, float]: - """ - distribution of initial orbital periods as found by Sana et al. (2012) - which is a flat distribution in ln(a) and ln(P) respectively for stars - * less massive than 15Msun (no O-stars) - * mass ratio q=M2/M1<0.1 - * log(P)<0.15=x0 and log(P)>3.5=x1 - and is be given by dp/dlogP ~ (logP)^p for all other binary configurations (default p=-0.55) - - arguments are M1, M2, a, Period P, amin, amax, x0=log P0, x1=log P1, p - - example args: 10, 5, sep(M1, M2, P), sep, ?, -2, 12, -0.55 - - # TODO: Fix this function! - - Args: - M1: Mass of primary - M2: Mass of secondary - a: separation of binary - P: period of binary - amin: minimum separation of the distribution (lower bound of the range) - amax: maximum separation of the distribution (upper bound of the range) - x0: log of minimum period of the distribution (lower bound of the range) - x1: log of maximum period of the distribution (upper bound of the range) - p: slope of the distribution - - Returns: - 'probability' of orbital period P given the other parameters - """ - - res = 0 - if (M1 < 15.0) or (M2 / M1 < 0.1): - res = 1.0 / (math.log(amax) - math.log(amin)) - else: - p1 = 1.0 + p - - # For more details see the LyX document of binary_c for this distribution - # where the variables and normalisations are given - # we use the notation x=log(P), xmin=log(Pmin), x0=log(P0), ... to determine the - x = LOG_LN_CONVERTER * math.log(P) - xmin = LOG_LN_CONVERTER * math.log(calc_period_from_sep(M1, M2, amin)) - xmax = LOG_LN_CONVERTER * math.log(calc_period_from_sep(M1, M2, amax)) - - # print("M1 M2 amin amax P x xmin xmax") - # print(M1, M2, amin, amax, P, x, xmin, xmax) - # my $x0 = 0.15; - # my $x1 = 3.5; - - A1 = 1.0 / ( - x0 ** p * (x0 - xmin) + (x1 ** p1 - x0 ** p1) / p1 + x1 ** p * (xmax - x1) - ) - A0 = A1 * x0 ** p - A2 = A1 * x1 ** p - - if x < x0: - res = 3.0 / 2.0 * LOG_LN_CONVERTER * A0 - elif x > x1: - res = 3.0 / 2.0 * LOG_LN_CONVERTER * A2 - else: - res = 3.0 / 2.0 * LOG_LN_CONVERTER * A1 * x ** p - - return res - - -# print(sana12(10, 2, 10, 100, 1, 1000, math.log(10), math.log(1000), 6)) - - -def interpolate_in_mass_izzard2012( - M: Union[int, float], high: Union[int, float], low: Union[int, float] -) -> Union[int, float]: - """ - Function to interpolate in mass - - TODO: fix this function. - TODO: describe the args - high: at M=16.3 - low: at 1.15 - - Args: - M: mass - high: - low: - - Returns: - - """ - - log_interpolation = False - - if log_interpolation: - return (high - low) / (math.log10(16.3) - math.log10(1.15)) * ( - math.log10(M) - math.log10(1.15) - ) + low - else: - return (high - low) / (16.3 - 1.15) * (M - 1.15) + low - - -def Izzard2012_period_distribution( - P: Union[int, float], M1: Union[int, float], log10Pmin: Union[int, float] = -1.0 -) -> Union[int, float]: - """ - period distribution which interpolates between - Duquennoy and Mayor 1991 at low mass (G/K spectral type <~1.15Msun) - and Sana et al 2012 at high mass (O spectral type >~16.3Msun) - - This gives dN/dlogP, i.e. DM/Raghavan's Gaussian in log10P at low mass - and Sana's power law (as a function of logP) at high mass - - TODO: fix this function - - Args: - P: period - M1: Primary star mass - log10Pmin: minimum period in base log10 (optional) - - Returns: - 'probability' of interpolated distribution function at P and M1 - - """ - - # Check if there is input and force it to be at least 1 - log10Pmin = max(-1.0, log10Pmin) - - # save mass input and limit mass used (M1 from now on) to fitted range - Mwas = M1 - M1 = max(1.15, min(16.3, M1)) - # print("Izzard2012 called for M={} (truncated to {}), P={}\n".format(Mwas, M1, P)) - - # Calculate the normalisations - # need to normalise the distribution for this mass - # (and perhaps secondary mass) - prepare_dict(distribution_constants, ["Izzard2012", M1]) - if not distribution_constants["Izzard2012"][M1].get(log10Pmin): - distribution_constants["Izzard2012"][M1][ - log10Pmin - ] = 1 # To prevent this loop from going recursive - N = 200.0 # Resolution for normalisation. I hope 1000 is enough - dlP = (10.0 - log10Pmin) / N - C = 0 # normalisation constant. - # print("LOOP",log10Pmin) - for lP in np.arange(log10Pmin, 10, dlP): - C += dlP * Izzard2012_period_distribution(10 ** lP, M1, log10Pmin) - - distribution_constants["Izzard2012"][M1][log10Pmin] = 1.0 / C - # print( - # "Normalisation constant for Izzard2012 M={} (log10Pmin={}) is\ - # {}\n".format( - # M1, log10Pmin, distribution_constants["Izzard2012"][M1][log10Pmin] - # ) - # ) - - lP = math.log10(P) - # log period - - # # fits - mu = interpolate_in_mass_izzard2012(M1, -17.8, 5.03) - sigma = interpolate_in_mass_izzard2012(M1, 9.18, 2.28) - K = interpolate_in_mass_izzard2012(M1, 6.93e-2, 0.0) - nu = interpolate_in_mass_izzard2012(M1, 0.3, -1) - g = 1.0 / (1.0 + 1e-30 ** (lP - nu)) - - lPmu = lP - mu - # print( - # "M={} ({}) P={} : mu={} sigma={} K={} nu={} norm=%g\n".format( - # Mwas, M1, P, mu, sigma, K, nu - # ) - # ) - - # print "FUNC $distdata{Izzard2012}{$M}{$log10Pmin} * (exp(- (x-$mu)**2/(2.0*$sigma*$sigma) ) + $K/MAX(0.1,$lP)) * $g;\n"; - - if (lP < log10Pmin) or (lP > 10.0): - return 0 - - else: - return ( - distribution_constants["Izzard2012"][M1][log10Pmin] - * (math.exp(-lPmu * lPmu / (2.0 * sigma * sigma)) + K / max(0.1, lP)) - * g - ) - - -######################################################################## -# Mass ratio distributions -######################################################################## - - -def flatsections(x: float, opts: dict) -> Union[float, int]: - """ - Function to generate flat distributions, possibly in multiple sections - - Args: - x: mass ratio value - opts: list containing the flat sections. Which are themselves dictionaries, with keys "max": upper bound, "min": lower bound and "height": value - - Returns: - probability of that mass ratio. - """ - - c = 0 - y = 0 - - for opt in opts: - dc = (opt["max"] - opt["min"]) * opt["height"] - # print("added flatsection ({}-{})*{} = {}\n".format( - # opt['max'], opt['min'], opt['height'], dc)) - c += dc - if opt["min"] <= x <= opt["max"]: - y = opt["height"] - # print("Use this\n") - - c = 1.0 / c - y = y * c - - # print("flatsections gives C={}: y={}\n",c,y) - return y - - -# print(flatsections(1, [{'min': 0, 'max': 2, 'height': 3}])) - -######################################################################## -# Eccentricity distributions -######################################################################## - -######################################################################## -# Star formation histories -######################################################################## - - -def cosmic_SFH_madau_dickinson2014(z): - """ - Cosmic star formation history distribution from Madau & Dickonson 2014 (https://arxiv.org/pdf/1403.0007.pdf) - - Args: - z: redshift - - Returns: - Cosmic star formation rate in Solar mass year^-1 mega parsec^-3 - """ - - CSFH = 0.015 * ((1 + z) ** 2.7) / (1 + (((1 + z) / 2.9) ** 5.6)) - - return CSFH - - -######################################################################## -# Metallicity distributions -######################################################################## - - -######################################################################## -# Moe & DiStefano 2017 functions -# -# The code below are functions that are used to set up and interpolate -# on the Moe & DiStefano 2017 data. The interpolators take the last -# known value if we try to interpolate outside of the tables. -# There are still some open tasks and improvements that can be made: -# -# TODO: Solve the memory issues that are present. -# Are the interpolators not cleaned? -# TODO: Parallelize the setting up of the interpolators -# TODO: Generalise the code such that we can input other/newer tables - -######################################################################## - -import py_rinterpolate - -# Global dictionary to store values in -Moecache = {} - - -def poisson(lambda_val, n, nmax=None, verbosity=0): - """ - Function that calculates the Poisson value and normalises - TODO: improve the description - """ - - cachekey = "{} {} {}".format(lambda_val, n, nmax) - - if distribution_constants.get("poisson_cache", None): - if distribution_constants["poisson_cache"].get(cachekey, None): - p_val = distribution_constants["poisson_cache"][cachekey] - - verbose_print( - "\tMoe and di Stefano 2017: found cached value for poisson({}, {}, {}): {}".format( - lambda_val, n, nmax, p_val - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - return p_val - - # Poisson distribution : note, n can be zero - # - # nmax is the truncation : if set, we normalise - # correctly. - p_val = _poisson(lambda_val, n) - - if nmax: - I_poisson = 0 - for i in range(nmax + 1): - I_poisson += _poisson(lambda_val, i) - p_val = p_val / I_poisson - - # Add to cache - if not distribution_constants.get("poisson_cache", None): - distribution_constants["poisson_cache"] = {} - distribution_constants["poisson_cache"][cachekey] = p_val - - verbose_print( - "\tMoe and di Stefano 2017: Poisson({}, {}, {}): {}".format( - lambda_val, n, nmax, p_val - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - return p_val - - -def _poisson(lambda_val, n): - """ - Function to return the Poisson value - """ - - return (lambda_val ** n) * np.exp(-lambda_val) / (1.0 * math.factorial(n)) - - -def get_max_multiplicity(multiplicity_array): - """ - Function to get the maximum multiplicity - """ - - max_multiplicity = 0 - for n in range(4): - if multiplicity_array[n] > 0: - max_multiplicity = n + 1 - return max_multiplicity - - -def merge_multiplicities(result_array, max_multiplicity, verbosity=0): - """ - Function to fold the multiplicities higher than the max_multiplicity onto the max_multiplicity - - if max_multiplicity == 1: - All the multiplicities are folded onto multiplicity == 1. This will always total to 1 - if max_multiplicity == 2: - The multiplicity fractions of the triple and quadruples are folded onto that of the binary multiplicity fraction - if max_multiplicity == 3: - The multiplicity fractions of the quadruples are folded onto that of the triples - """ - - if not max_multiplicity in range(1, 5): - 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( - msg, - verbosity, - 0, - ) - raise ValueError(msg) - - # Fold multiplicities: - verbose_print( - "\tMoe and di Stefano 2017: merge_multiplicities: Merging multiplicities with initial array {} and max multiplicity {}".format( - result_array, max_multiplicity - ), - verbosity, - _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( - "\tMoe and di Stefano 2017: merge_multiplicities: Merging multiplicities to new array {}".format( - result_array - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - return result_array - - -def normalize_dict(result_dict, verbosity=0): - """ - Function to normalise a dictionary - """ - - sum_result = sum([result_dict[key] for key in result_dict.keys()]) - for key in result_dict.keys(): - result_dict[key] = result_dict[key] / sum_result - return result_dict - - -def Moe_di_Stefano_2017_multiplicity_fractions(options, verbosity=0): - """ - Function that creates a list of probability fractions and - normalises and merges them according to the users choice. - - TODO: make an extrapolation functionality in this. log10(1.6e1) - is low, we can probably go a bit further - - The default result that is returned when sampling the mass outside - of the mass range is now the last known value - - Returns a list of multiplicity fractions for a given input of mass - """ - - # Use the global Moecache - global Moecache - - multiplicity_modulator_array = np.array( - options["multiplicity_modulator"] - ) # Modulator array - - # Check for length - if not len(multiplicity_modulator_array) == 4: - msg = "Multiplicity modulator has to have 4 elements. Now it is {}, len: {}".format( - multiplicity_modulator_array, len(multiplicity_modulator_array) - ) - verbose_print( - msg, - verbosity, - 0, - ) - raise ValueError(msg) - - # Set up some arrays - full_fractions_array = np.zeros(4) # Meant to contain the real fractions - weighted_fractions_array = np.zeros( - 4 - ) # Meant to contain the fractions multiplied by the multiplicity modulator - - # Get max multiplicity - max_multiplicity = get_max_multiplicity(multiplicity_modulator_array) - - # ... it's better to interpolate the multiplicity and then - # use a Poisson distribution to calculate the fractions - # (this is more accurate) - - # Set up the multiplicity interpolator - if not Moecache.get("rinterpolator_multiplicity", None): - Moecache["rinterpolator_multiplicity"] = py_rinterpolate.Rinterpolate( - 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 - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), - ) - - if options["multiplicity_model"] == "Poisson": - multiplicity = Moecache["rinterpolator_multiplicity"].interpolate( - [np.log10(options["M_1"])] - )[0] - - # Fill the multiplicity array - for n in range(4): - full_fractions_array[n] = poisson(multiplicity, n, 3, verbosity) - - # Normalize it so it fills to one when taking all the multiplicities: - full_fractions_array = full_fractions_array / np.sum(full_fractions_array) - - verbose_print( - "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: using model {}: full_fractions_array: {}".format( - "Poisson", full_fractions_array - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - elif options["multiplicity_model"] == "data": - # use the fractions calculated from Moe's data directly - # - # note that in this case, there are no quadruples: these - # are combined with triples - - # Fill with the raw values - for n in range(3): - full_fractions_array[n] = Moecache[ - "rinterpolator_multiplicity" - ].interpolate([np.log10(options["M_1"])])[n + 1] - - # Set last value - full_fractions_array[3] = 0.0 # no quadruples - verbose_print( - "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: using model {}: full_fractions_array: {}".format( - "data", full_fractions_array - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # Normalisation: - if options["normalize_multiplicities"] == "raw": - # Don't multiply by the multiplicity_array, but do give a fractions array - verbose_print( - "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Not normalising (using raw results): results: {}".format( - full_fractions_array - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - result = full_fractions_array - - elif options["normalize_multiplicities"] == "norm": - # Multiply the full_multiplicity_fraction array by the multiplicity_multiplier_array, creating a weighted fractions array - weighted_fractions_array = full_fractions_array * multiplicity_modulator_array - - # Normalise this so it is in total 1: - result = weighted_fractions_array / np.sum(weighted_fractions_array) - - verbose_print( - "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with {}. result: {}".format( - "norm", result - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - elif options["normalize_multiplicities"] == "merge": - # We first take the full multiplicity array - # (i.e. not multiplied by multiplier) and do the merging - result = merge_multiplicities( - full_fractions_array, max_multiplicity, verbosity=verbosity - ) - - # Then normalise to be sure - result = result / np.sum(result) - - verbose_print( - "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with {}, max_multiplicity={} result={}".format( - "merge", max_multiplicity, result - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - verbose_print( - "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: {}".format( - str(result) - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # return array reference - return result - - -def build_q_table(options, m, p, verbosity=0): - ############################################################ - # - # Build an interpolation table for q, given a mass and - # orbital period. - # - # $m and $p are labels which determine which system(s) - # to look up from Moe's data: - # - # $m can be M1, M2, M3, M4, or if set M1+M2 etc. - # $p can be P, P2, P3 - # - # The actual values are in $opts: - # - # mass is in $opts->{$m} - # period is $opts->{$p} - # - # 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. - # If we are below the lowest value of qmin in the table we need to extrapolate the data - # - # Anyway, the goal of this function is to provide some extrapolated values for q when we should sample outside of the boundaries - ############################################################ - - # We can check if we have a cached value for this already: - # TODO: fix this cache check. - incache = False - if Moecache.get("rinterpolator_q_metadata", None): - if (Moecache["rinterpolator_q_metadata"].get(m, None)) and ( - Moecache["rinterpolator_q_metadata"].get(p, None) - ): - if (Moecache["rinterpolator_q_metadata"][m] == options[m]) and ( - Moecache["rinterpolator_q_metadata"][p] == options[p] - ): - incache = True - - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: Found cached values for m={} p={}".format( - options[m], options[p] - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - else: - verbose_print( - "\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, - _MOE2017_VERBOSITY_LEVEL, - ) - - # - if not incache: - # trim and/or expand the table to the range $qmin to $qmax. - - # qmin is set by the minimum stellar mass : below this - # the companions are planets - # qmin = options["ranges"]["M"][ - # 0 - # ] # TODO: this lower range must not be lower than Mmin. - - qmin = options["Mmin"] / options["M_1"] - verbose_print( - "\tMoe and di Stefano 2017: build_q_table qmin: {}".format( - qmin, - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # qmax = maximum_mass_ratio_for_RLOF(options[m], options[p]) - # TODO: change this to the above - qmax = 1 - - # qdata contains the table that we modify: we get - # the original data by interpolating Moe's table - qdata = {} - can_renormalize = 1 - - qeps = 1e-8 # small number but such that qeps+1 != 1 - if qeps + 1 == 1.0: - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: qeps (= {}) +1 == 1. Make qeps larger".format( - qeps, - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - if qmin >= qmax: - # there may be NO binaries in this part of the parameter space: - # in which case, set up a table with lots of zero in it - - qdata = {0: 0, 1: 0} - can_renormalize = 0 - - else: - # qmin and qmax mean we'll get something non-zero - can_renormalize = 1 - - # require extrapolation sets whether we need to extrapolate - # at the low and high ends - require_extrapolation = {} - - if qmin >= 0.15: - # qmin is inside Moe's table : this is easy, - # we just keep points from qmin at the low - # end to qmax at the high end. - require_extrapolation["low"] = 0 - require_extrapolation[ - "high" - ] = 1 # TODO: shouldn't the extrapolation need to happen if qmax > 0.95 - qdata[qmin] = Moecache["rinterpolator_q"].interpolate( - [np.log10(options[m]), np.log10(options[p]), qmin] - )[0] - - for q in np.arange(0.15, 0.950001, 0.1): - if (q >= qmin) and (q <= qmax): - qdata[q] = Moecache["rinterpolator_q"].interpolate( - [np.log10(options[m]), np.log10(options[p]), q] - )[0] - else: - require_extrapolation["low"] = 1 - require_extrapolation["high"] = 1 - if qmax < 0.15: - # qmax < 0.15 which is off the edge - # of the table. In this case, choose - # two points at q=0.15 and 0.16 and interpolate - # at these in case we want to extrapolate. - for q in [0.15, 0.16]: - qdata[q] = Moecache["rinterpolator_q"].interpolate( - [np.log10(options[m]), np.log10(options[p]), q] - )[0] - else: - # qmin < 0.15 and qmax > 0.15, so we - # have to generate Moe's table for - # q = 0.15 (i.e. 0.1 to 0.2) to 0.95 (0.9 to 1) - # as a function of M1 and orbital period, - # to obtain the q distribution data. - - for q in np.arange(0.15, np.min([0.950001, qmax + 0.0001]), 0.1): - val = Moecache["rinterpolator_q"].interpolate( - [np.log10(options[m]), np.log10(options[p]), q] - )[0] - qdata[q] = val - - # just below qmin, if qmin>qeps, we want nothing - if qmin - 0.15 > qeps: - q = qmin - qeps - qdata[q] = 0 - require_extrapolation["low"] = 0 - - # just above qmax, if qmax<1, we want nothing - if qmax < 0.95: - q = qmax + qeps - qdata[q] = 0 - require_extrapolation["high"] = 0 - - # sorted list of qs - qs = sorted(qdata.keys()) - - if len(qs) == 0: - msg = "No qs found error" - raise ValueError(msg) - - elif len(qs) == 1: - # only one q value : pretend there are two - # with a flat distribution up to 1.0. - if qs[0] == 1.0: - qs[0] = 1.0 - 1e-6 - qs.append(1) - qdata[qs[0]] = 1 - qdata[qs[1]] = 1 - else: - qs.append(1) - qdata[qs[1]] = qs[0] - - # We actually should do the extrapolation now. - else: - # Loop over both the lower end and the upper end - for pre in ["low", "high"]: - if require_extrapolation[pre] == 0: - continue - else: - sign = -1 if pre == "low" else 1 - end_index = 0 if pre == "low" else len(qs) - 1 - indices = ( - [0, 1] if pre == "low" else [len(qs) - 1, len(qs) - 2] - ) # Based on whether we do the high or low end we need to use two different indices - method = options.get( - "q_{}_extrapolation_method".format(pre), None - ) - qlimit = qmin if pre == "low" else qmax - - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: Extrapolating: Q: {} method: {}, indices: {} End index: {}".format( - pre, method, indices, end_index - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # truncate the distribution - qdata[max(0.0, min(1.0, qlimit + sign * qeps))] = 0 - - if method == None: - # no extrapolation : just interpolate between 0.10 and 0.95 - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: using no extrapolations".format(), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - continue - elif method == "flat": - # use the end value and extrapolate it - # with zero slope - qdata[qlimit] = qdata[qs[end_index]] - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: using constant extrapolation".format(), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - elif method == "linear": - qdata[qlimit] = linear_extrapolation_q( - qs=qs, - indices=indices, - qlimit=qlimit, - qdata=qdata, - end_index=end_index, - verbosity=verbosity, - ) - - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: using linear extrapolation".format(), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - if pre == "low": - below_qlimit = qlimit - qeps - if below_qlimit > 0: - qdata[below_qlimit] = 0 - qdata[0] = 0 - verbose_print( - "\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, - _MOE2017_VERBOSITY_LEVEL, - ) - - elif method == "plaw2": - qdata[qlimit] = powerlaw_extrapolation_q( - qs=qs, indices=indices, qdata=qdata, verbosity=verbosity - ) - - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: using powerlaw extrapolation".format(), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - elif method == "nolowq": - newq = 0.05 - qdata[newq] = 0 - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: setting lowq to 0".format(), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - elif method == "poly": - # TODO: consider implementing the poly method (see Perl version) - raise ValueError( - "Moe and di Stefano 2017: build_q_table: Method 'poly' not implemented" - ) - - else: - 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, - _MOE2017_VERBOSITY_LEVEL, - ) - raise ValueError(msg) - - # regenerate qs in new table. This is now the updated list of qs where we have some extrapolated numbers - tmp_table = [] - for q in sorted(qdata.keys()): - tmp_table.append([q, qdata[q]]) - - # Make an interpolation table to contain our modified data - q_interpolator = py_rinterpolate.Rinterpolate( - table=tmp_table, - nparams=1, - ndata=1, # Contains the table of data # q # - verbosity=verbosity - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), - ) - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: Created a new Q table", - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - if can_renormalize: - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: Renormalising table", - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # now we integrate and renormalise (if the table is not all zero) - I = get_integration_constant_q( - q_interpolator, tmp_table, qdata, verbosity=verbosity - ) - - if I > 0: - # normalise to 1.0 by dividing the data by 1.0/$I - q_interpolator.multiply_table_column(1, 1.0 / I) - - # test this - new_I = get_integration_constant_q( - q_interpolator, tmp_table, qdata, verbosity=verbosity - ) - - # fail if error in integral > 1e-6 (should be ~ machine precision) - if abs(1.0 - new_I) > 1e-6: - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: Error: > 1e-6 in q probability integral: {}".format( - I - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - # set this new table in the cache - Moecache["rinterpolator_q_given_{}_log10{}".format(m, p)] = q_interpolator - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: stored q_interpolater as {}".format( - "rinterpolator_q_given_{}_log10{}".format(m, p) - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # Store the values for which this table was set up in the dict - if not Moecache.get("rinterpolator_q_metadata", None): - Moecache["rinterpolator_q_metadata"] = {} - Moecache["rinterpolator_q_metadata"][m] = options[m] - Moecache["rinterpolator_q_metadata"][p] = options[p] - - -def powerlaw_extrapolation_q(qdata, qs, indices, verbosity=0): - """ - Function to do the power law extrapolation at the lower end of the q range - """ - newq = 0.05 - - # use a power-law extrapolation down to q=0.05, if possible - if (qdata[qs[indices[0]]] == 0.0) and (qdata[qs[indices[1]]] == 0.0): - # not possible - return 0 - - else: - slope = (np.log10(qdata[qs[indices[1]]]) - np.log10(qdata[qs[indices[0]]])) / ( - np.log10(qs[indices[1]]) - np.log10(qs[indices[0]]) - ) - intercept = np.log10(qdata[qs[indices[0]]]) - slope * np.log10(qs[indices[0]]) - - return slope * newq + intercept - - -def linear_extrapolation_q(qs, indices, qlimit, qdata, end_index, verbosity=0): - """ - Function to do the linear extrapolation for q. - """ - - # linear extrapolation - dq = qs[indices[1]] - qs[indices[0]] - - if dq == 0: - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: linear dq=0".format(), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - # No change - return qs[end_index] - else: - slope = (qdata[qs[indices[1]]] - qdata[qs[indices[0]]]) / dq - - intercept = qdata[qs[indices[0]]] - slope * qs[indices[0]] - qdata[qlimit] = max(0.0, slope * qlimit + intercept) - verbose_print( - "\tMoe and di Stefano 2017: build_q_table: linear Slope: {} intercept: {} dn/dq({}) = {}".format( - slope, intercept, qlimit, qdata[qlimit] - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - return max(0.0, slope * qlimit + intercept) - - -def get_integration_constant_q(q_interpolator, tmp_table, qdata, verbosity=0): - """ - Function to integrate the q interpolator and return the integration constant - """ - - dq = 1e-3 # resolution of the integration/renormalisation - I = 0 - - # integrate: note that the value of the integral is - # meaningless to within a factor (which depends on $dq) - for q in np.arange(0, 1 + 2e-6, dq): - x = q_interpolator.interpolate([q]) - if len(x) == 0: - 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, - _MOE2017_VERBOSITY_LEVEL, - ) - raise ValueError(msg) - else: - I += x[0] * dq - # verbose_print( - # "\tMoe and di Stefano 2017: build_q_table: dn/dq ({}) = {} I -> = {}".format(q, x[0], I), - # verbosity, - # _MOE2017_VERBOSITY_LEVEL, - # ) - return I - - -def fill_data(sample_values, data_dict): - """ - Function that returns the normalised array of values for given logmass and logperiod - used for the e and q values - - TODO: make sure we do the correct thing with the dstep - """ - - data = {} - I = 0 - - dstep = float(sample_values[1]) - float(sample_values[0]) - - # Read out the data - for sample_value in sample_values: - val = data_dict[sample_value] - data[sample_value] = val - I += val - - # Normalise the data - for sample_value in sample_values: - data[sample_value] = data[sample_value] / I - - return data - - -def calc_e_integral( - options, - integrals_string, - interpolator_name, - mass_string, - period_string, - verbosity=0, -): - """ - Function to calculate the P integral - - We need to renormalise this because min_per > 0, and not all periods should be included - """ - - global Moecache - min_ecc = 0 - max_ecc = 0.9999 - - mass_period_string = "{}_{}".format(options[mass_string], options[period_string]) - - # Check if the dict exists - if not Moecache.get(integrals_string, None): - Moecache[integrals_string] = {} - - # Check for cached value. If it doesn't exist: calculate - if not Moecache[integrals_string].get(mass_period_string, None): - I = 0 - decc = 1e-3 - - for ecc in np.arange(min_ecc, max_ecc, decc): - # Loop over all the values in the table, between the min and max P - dp_decc = Moecache[interpolator_name].interpolate( - [np.log10(options[mass_string]), np.log10(options[period_string]), ecc] - )[0] - - I += dp_decc * decc - - # Set the integral value in the dict - Moecache[integrals_string][mass_period_string] = I - verbose_print( - "\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, - interpolator_name, - mass_string, - period_string, - options[mass_string], - options[period_string], - I, - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - else: - verbose_print( - "\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, - interpolator_name, - mass_string, - period_string, - options[mass_string], - options[period_string], - Moecache[integrals_string][mass_period_string], - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - -def calc_P_integral( - options, - min_logP, - max_logP, - integrals_string, - interpolator_name, - mass_string, - verbosity=0, -): - """ - Function to calculate the P integral - - We need to renormalise this because min_per > 0, and not all periods should be included - """ - - global Moecache - - # Check if the dict exists - if not Moecache.get(integrals_string, None): - Moecache[integrals_string] = {} - - # Check for cached value. If it doesn't exist: calculate - if not Moecache[integrals_string].get(options[mass_string], None): - I = 0 - dlogP = 1e-3 - - for logP in np.arange(min_logP, max_logP, dlogP): - # Loop over all the values in the table, between the min and max P - dp_dlogP = Moecache[interpolator_name].interpolate( - [np.log10(options[mass_string]), logP] - )[0] - - I += dp_dlogP * dlogP - - # Set the integral value in the dict - Moecache[integrals_string][options[mass_string]] = I - verbose_print( - "\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, - mass_string, - options[mass_string], - I, - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - else: - verbose_print( - "\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, - mass_string, - options[mass_string], - Moecache[integrals_string][options[mass_string]], - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - -def calc_total_probdens(prob_dict): - """ - Function to calculate the total probability density - """ - - total_probdens = 1 - for key in prob_dict: - total_probdens *= prob_dict[key] - prob_dict["total_probdens"] = total_probdens - - return prob_dict - - -def Moe_di_Stefano_2017_pdf(options, verbosity=0): - """ - Moe & diStefano function to calculate the probability density. - - takes a dictionary as input (in options) with options: - - M1, M2, M3, M4 => masses (Msun) [M1 required, rest optional] - P, P2, P3 => periods (days) [number: none=binary, 2=triple, 3=quadruple] - ecc, ecc2, ecc3 => eccentricities [numbering as for P above] - - mmin => minimum allowed stellar mass (default 0.07) - mmax => maximum allowed stellar mass (default 80.0) - """ - - verbose_print( - "\tMoe_di_Stefano_2017_pdf with options:\n\t\t{}".format(json.dumps(options)), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - prob_dict = ( - {} - ) # Dictionary containing all the pdf values for the different parameters - - # 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 = "\tMoe_di_Stefano_2017_pdf: Did not find a multiplicity value in the options dictionary" - verbose_print( - msg, - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - raise ValueError(msg) - # multiplicity = 1 - # for n in range(2, 5): - # multiplicity += 1 if options.get("M{}".format(n), None) else 0 - else: - multiplicity = options["multiplicity"] - - # Immediately return 0 if the multiplicity modulator is 0 - if options["multiplicity_modulator"][multiplicity - 1] == 0: - verbose_print( - "\tMoe_di_Stefano_2017_pdf: returning 0 because of the multiplicity modulator being 0", - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - return 0 - - ############################################################ - # multiplicity fraction - # Calculate the probability, or rather, fraction, of stars that belong to this mass - - multiplicity_probability = Moe_di_Stefano_2017_multiplicity_fractions( - options, verbosity - )[multiplicity - 1] - prob_dict["multiplicity"] = multiplicity_probability - verbose_print( - "\tMoe_di_Stefano_2017_pdf: Appended multiplicity (mass1 = {}) probability ({}) to the prob dict ({})".format( - options["M_1"], prob_dict["multiplicity"], prob_dict - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - ############################################################ - # always require an IMF for the primary star - # - # NB multiply by M1 to convert dN/dM to dN/dlnM - # (dlnM = dM/M, so 1/dlnM = M/dM) - - # TODO: Create an n-part-powerlaw method that can have breakpoints and slopes. I'm using a three-part power law now. - # TODO: is this actually the correct way? putting the M1 in there? Do we sample in log space? - M1_probability = Kroupa2001(options["M_1"]) * options["M_1"] - prob_dict["M_1"] = M1_probability - verbose_print( - "\tMoe_di_Stefano_2017_pdf: Appended Mass (m={}) probability ({}) to the prob dict ({})".format( - options["M_1"], prob_dict["M_1"], prob_dict - ), - verbosity, - _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) - # return prob_dict - - """ - From here we go through the multiplicities. - """ - if multiplicity >= 2: - # If the multiplicity is higher than 1, we will need to construct the following tables: - # - period distribution table - # - q distribution table - # - eccentricity distribution table - - # Set up the interpolator for the periods - if not Moecache.get("rinterpolator_log10P", None): - Moecache["rinterpolator_log10P"] = py_rinterpolate.Rinterpolate( - table=Moecache["period_distributions"], # Contains the table of data - nparams=2, # log10M, log10P - ndata=2, # binary, triple - verbosity=verbosity - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), - ) - verbose_print( - "\tMoe_di_Stefano_2017_pdf: Created new period interpolator: {}".format( - Moecache["rinterpolator_log10P"] - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # Make a table storing Moe's data for q distributions - if ( - options.get("M_2", None) - or options.get("M_3", None) - or options.get("M_4", None) - ): - if not Moecache.get("rinterpolator_q", None): - Moecache["rinterpolator_q"] = py_rinterpolate.Rinterpolate( - table=Moecache["q_distributions"], # Contains the table of data - nparams=3, # log10M, log10P, q - ndata=1, # - verbosity=verbosity - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), - ) - verbose_print( - "\tMoe_di_Stefano_2017_pdf: Created new q interpolator: {}".format( - Moecache["rinterpolator_q"] - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # Make a table storing Moe's data for q distributions, but only if the ecc is actually sampled - if "ecc" in options: - if not options["ecc"] == None: - if not Moecache.get("rinterpolator_e", None): - Moecache["rinterpolator_e"] = py_rinterpolate.Rinterpolate( - table=Moecache[ - "ecc_distributions" - ], # Contains the table of data - nparams=3, # log10M, log10P, e - ndata=1, # - verbosity=verbosity - - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), - ) - verbose_print( - "\tMoe_di_Stefano_2017_pdf: Created new e interpolator: {}".format( - Moecache["rinterpolator_e"] - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - ############### - # Calculation for period of the binary - - if options.get("M_2", None): - # Separation of the inner binary - options["sep"] = calc_sep_from_period( - options["M_1"], options["M_2"], options["P"] - ) - # TODO: add check for min_logP with instant RLOF? - # TODO: Actually use the value above. - # Total mass inner binary: - options["M_1+M_2"] = options["M_1"] + options["M_2"] - - # Calculate P integral or use cached value - - # get the periods from the Moecahe - min_logP = float(Moecache["logperiods"][0]) - max_logP = float(Moecache["logperiods"][-1]) - - calc_P_integral( - options, - min_logP, - max_logP, - "P_integrals", - "rinterpolator_log10P", - "M_1", - verbosity, - ) - - # Set probabilty for P1 - p_val = Moecache["rinterpolator_log10P"].interpolate( - [np.log10(options["M_1"]), np.log10(options["P"])] - )[0] - p_val = p_val / Moecache["P_integrals"][options["M_1"]] - prob_dict["P"] = p_val - verbose_print( - "\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, - _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) - # return prob_dict - - ############################################################ - # mass ratio (0 < q = M2/M1 < qmax) - # - # we need to construct the q table for the given M1 - # subject to qmin = Mmin/M1 - - if options.get("M_2", None): - # Build the table for q - primary_mass = options["M_1"] - secondary_mass = options["M_2"] - m_label = "M_1" - p_label = "P" - - # Construct the q table - build_q_table(options, m_label, p_label, verbosity=verbosity) - verbose_print( - "\tMoe_di_Stefano_2017_pdf: Created q_table ({}) for m={} p={}".format( - Moecache[ - "rinterpolator_q_given_{}_log10{}".format(m_label, p_label) - ], - options[m_label], - options[p_label], - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # Add probability for the mass ratio - q_prob = Moecache[ - "rinterpolator_q_given_{}_log10{}".format(m_label, p_label) - ].interpolate([secondary_mass / primary_mass])[0] - prob_dict["q"] = q_prob - verbose_print( - "\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"], - prob_dict["q"], - prob_dict, - ), - verbosity, - _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) - # return prob_dict - - ############################################################ - # Eccentricity - # TODO: ask rob if the eccentricity requires an extrapolation as well. - - # Only do this if the eccentricity is sampled - if "ecc" in options: - if not options["ecc"] == None: - # Calculate ecc integral or use cached value - calc_e_integral( - options, "ecc_integrals", "rinterpolator_e", "M_1", "P", verbosity - ) - mass_period_string = "{}_{}".format(options["M_1"], options["P"]) - - # Set probability for ecc - ecc_val = Moecache["rinterpolator_e"].interpolate( - [np.log10(options["M_1"]), np.log10(options["P"]), options["ecc"]] - )[0] - ecc_val = ecc_val / Moecache["ecc_integrals"][mass_period_string] - prob_dict["ecc"] = ecc_val - verbose_print( - "\tMoe_di_Stefano_2017_pdf: Appended eccentricity (m={}, P={}, ecc={}) probability ({}) to the prob list ({})".format( - options["M_1"], - options["P"], - options["ecc"], - prob_dict["ecc"], - prob_dict, - ), - verbosity, - _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) - # return prob_dict - - # Calculations for when multiplicity is bigger than 3 - # BEWARE: binary_c does not evolve these systems actually and the code below should be revised for when binary_c actually evolves triples. - # For that reason, I would not advise to use things with multiplicity > 3 - if multiplicity >= 3: - - ############################################################ - # orbital period 2 = - # orbital period of star 3 (multiplicity==3) or - # the star3+star4 binary (multiplicity==4) - # - # we assume the same period distribution for star 3 - # (or stars 3 and 4) but with a separation that is >10*a*(1+e) - # where 10*a*(1+e) is the maximum apastron separation of - # stars 1 and 2 - - # TODO: Is this a correct assumption? - max_sep = 10.0 * options["sep"] * (1.0 + options["ecc"]) - min_P2 = calc_period_from_sep(options["M_1+M_2"], options["mmin"], max_sep) - min_logP2 = math.log10(min_P2) - # max_logP2 = 10.0 - # min_logP = Moecache['logperiods'][0] - max_logP2 = float(Moecache["logperiods"][-1]) - - if options["P2"] < min_P2: - # period is too short : system is not hierarchical - prob_dict["P2"] = 0 - verbose_print( - "\tMoe_di_Stefano_2017_pdf: period2 is too short: {} < {}, system is not hierarchical. Added 0 to probability list".format( - options["P1"], min_P2 - ), - verbosity, - _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) - # return prob_dict - - else: - # period is long enough that the system is hierarchical - # hence the separation between the outer star - # and inner binary - options["sep2"] = calc_sep_from_period( - options["M_3"], options["M_1+M_2"], options["P2"] - ) - - # Check for cached value of P integral or calculate - calc_P_integral( - options, - min_logP2, - max_logP2, - "P2_integrals", - "rinterpolator_log10P", - "M_1+M_2", - verbosity, - ) - - # Add the probability - p_val = Moecache["rinterpolator_log10P"].interpolate( - [np.log10(options["M_1+M_2"]), np.log10(options["P2"])] - )[0] - p_val = p_val / Moecache["P2_integrals"][options["M_1+M_2"]] - prob_dict["P2"] = p_val - verbose_print( - "\tMoe_di_Stefano_2017_pdf: Appended period2 (m1={} m2={}, P2={}) probability ({}) to the prob list ({})".format( - options["M_1"], - options["M_2"], - options["P2"], - prob_dict["P2"], - prob_dict, - ), - verbosity, - _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) - # return prob_dict - - ############################################################ - # mass ratio 2 = q2 = M3 / (M1+M2) - # - # we need to construct the q table for the given M1 - # subject to qmin = Mmin/(M1+M2) - - # Set the variables for the masses and their names - primary_mass = options["M_1+M_2"] - secondary_mass = options["M_3"] - m_label = "M_1+M_2" - p_label = "P2" - - # Build q table - build_q_table(options, m_label, p_label, verbosity=verbosity) - verbose_print( - "\tMoe_di_Stefano_2017_pdf: Called build_q_table", - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # Add the probability - q2_val = Moecache[ - "rinterpolator_q_given_{}_log10{}".format(m_label, p_label) - ].interpolate([secondary_mass / primary_mass])[0] - prob_dict["q2"] = q2_val - verbose_print( - "\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"], - secondary_mass / primary_mass, - prob_dict["q2"], - prob_dict, - ), - verbosity, - _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) - # return prob_dict - - # TODO: Implement ecc2 calculation - if multiplicity == 4: - # quadruple system. - # TODO: Ask Rob about the structure of the quadruple. Is this only double binary quadruples? - - ############################################################ - # orbital period 3 - # - # we assume the same period distribution for star 4 - # as for any other stars but Pmax must be such that - # sep3 < sep2 * 0.2 - - # TODO: fix this here - max_sep3 = 0.2 * options["sep2"] * (1.0 + options["ecc2"]) - max_per3 = calc_period_from_sep( - options["M_1+M_2"], options["mmin"], max_sep3 - ) - - # Calculate P integral or use the cached value - # TODO: Make sure we use the correct period idea here. - calc_P_integral( - options, - min_logP2, - max_logP2, - "P2_integrals", - "rinterpolator_log10P", - "M_1+M_2", - verbosity, - ) - - # Set probability - p_val = Moecache["rinterpolator_log10P"].interpolate( - [np.log10(options["M_1+M_2"]), np.log10(options["P2"])] - )[0] - p_val = p_val / Moecache["P2_integrals"][options["M_1+M_2"]] - prob_dict["P3"] = p_val - verbose_print( - "\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"], - prob_dict["P3"], - prob_dict, - ), - verbosity, - _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) - # return prob_dict - - ############################################################ - # mass ratio 2 - # - # we need to construct the q table for the given M1 - # subject to qmin = Mmin/(M1+M2) - # Make a table storing Moe's data for q distributions - - # Build the table for q2 - primary_mass = options["M_1+M_2"] - secondary_mass = options["M_3"] - m_label = "M_1+M_2" - p_label = "P2" - - # Calculate new q table - build_q_table(options, m_label, p_label, verbosity=verbosity) - verbose_print( - "\tMoe_di_Stefano_2017_pdf: Created q_table ".format(), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - - # Add the probability - q3_prob = Moecache[ - "rinterpolator_q_given_{}_log10{}".format(m_label, p_label) - ].interpolate([secondary_mass / primary_mass])[0] - prob_dict["q3"] = q3_prob - verbose_print( - "\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"], - secondary_mass / primary_mass, - prob_dict["q3"], - prob_dict, - ), - verbosity, - _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) - # return prob_dict - - # TODO ecc 3 - - # check for input of multiplicity - elif multiplicity not in range(1, 5): - msg = "\tMoe_di_Stefano_2017_pdf: Unknown multiplicity {}".format(multiplicity) - verbose_print( - msg, - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - raise ValueError(msg) - - # Calculate total probdens: - prob_dict = calc_total_probdens(prob_dict) - - # Some info - if multiplicity == 1: - verbose_print( - "\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, - _MOE2017_VERBOSITY_LEVEL, - ) - elif multiplicity == 2: - verbose_print( - "\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"]), - options["ecc"] if options.get("ecc", None) else "N/A", - len(prob_dict), - str(prob_dict), - prob_dict["total_probdens"], - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - elif multiplicity == 3: - verbose_print( - "\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"]), - options["ecc"] if options.get("ecc", None) else "N/A", - options["M_3"], - np.log10(options["P2"]), - options["ecc2"] if options.get("ecc2", None) else "N/A", - len(prob_dict), - str(prob_dict), - prob_dict["total_probdens"], - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - elif multiplicity == 4: - verbose_print( - "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"]), - options["ecc"] if options.get("ecc", None) else "N/A", - options["M_3"], - np.log10(options["P2"]), - options["ecc2"] if options.get("ecc2", None) else "N/A", - options["M_4"], - np.log10(options["P3"]), - options["ecc3"] if options.get("ecc3", None) else "N/A", - len(prob_dict), - str(prob_dict), - prob_dict["total_probdens"], - ), - verbosity, - _MOE2017_VERBOSITY_LEVEL, - ) - return prob_dict diff --git a/binarycpython/utils/ensemble.py b/binarycpython/utils/ensemble.py index 72a0ced7d9879a9398135c70adb028e729b447d5..4c27268e0d52612a593c33515948525a9ae5549f 100644 --- a/binarycpython/utils/ensemble.py +++ b/binarycpython/utils/ensemble.py @@ -13,15 +13,12 @@ import gc import gzip import inspect - from halo import Halo import msgpack import py_rinterpolate import simplejson -# import orjson - from binarycpython.utils.dicts import ( keys_to_floats, recursive_change_key_to_float, @@ -72,21 +69,22 @@ def ensemble_setting(ensemble, parameter_name): return value -def open_ensemble(filename): +def open_ensemble(filename, encoding="utf-8"): """ Function to open an ensemble at filename for reading and decompression if required. """ + compression = ensemble_compression(filename) - if ensemble_file_type(filename) is "msgpack": + if ensemble_file_type(filename) == "msgpack": flags = "rb" else: flags = "rt" - if compression is "bzip2": - file_object = bz2.open(filename, flags) - elif compression is "gzip": - file_object = gzip.open(filename, flags) + if compression == "bzip2": + file_object = bz2.open(filename, flags, encoding=encoding) + elif compression == "gzip": + file_object = gzip.open(filename, flags, encoding=encoding) else: - file_object = open(filename, flags) + file_object = open(filename, flags, encoding=encoding) return file_object @@ -94,18 +92,19 @@ def ensemble_compression(filename): """ Return the compression type of the ensemble file, based on its filename extension. """ + if filename.endswith(".bz2"): return "bzip2" - elif filename.endswith(".gz"): + if filename.endswith(".gz"): return "gzip" - else: - return None + return None def ensemble_file_type(filename): """ Returns the file type of an ensemble file. """ + if ".json" in filename: filetype = "JSON" elif ".msgpack" in filename: @@ -115,7 +114,9 @@ def ensemble_file_type(filename): return filetype -def load_ensemble(filename, convert_float_keys=True, select_keys=None, timing=False): +def load_ensemble( + filename, convert_float_keys=True, select_keys=None, timing=False, flush=False +): """ Function to load an ensemeble file, even if it is compressed, and return its contents to as a Python dictionary. @@ -128,7 +129,7 @@ def load_ensemble(filename, convert_float_keys=True, select_keys=None, timing=Fa # open the file # load with some info to the terminal - print("Loading JSON...") + print("Loading JSON...", flush=flush) # open the ensemble and get the file type file_object = open_ensemble(filename) @@ -136,7 +137,8 @@ def load_ensemble(filename, convert_float_keys=True, select_keys=None, timing=Fa if not filetype or not file_object: print( - "Unknown filetype : your ensemble should be saved either as JSON or msgpack data." + "Unknown filetype : your ensemble should be saved either as JSON or msgpack data.", + flush=flush, ) sys.exit() @@ -145,8 +147,12 @@ def load_ensemble(filename, convert_float_keys=True, select_keys=None, timing=Fa _loaded = False def _hook(obj): + """ + Hook to load ensemble + """ + nonlocal _loaded - if _loaded == False: + if _loaded is False: _loaded = True print( "\nLoaded {} data, now putting in a dictionary".format(filetype), @@ -154,7 +160,7 @@ def load_ensemble(filename, convert_float_keys=True, select_keys=None, timing=Fa ) return obj - if filetype is "JSON": + if filetype == "JSON": # orjson promises to be fast, but it doesn't seem to be # and fails on "Infinity"... oops # data = orjson.loads(file_object.read()) @@ -162,13 +168,15 @@ def load_ensemble(filename, convert_float_keys=True, select_keys=None, timing=Fa # simplejson is faster than standard json and "just works" # on the big Moe set in 37s data = simplejson.load(file_object, object_hook=_hook) + file_object.close() # standard json module # on the big Moe set takes 42s # data = json.load(file_object, # object_hook=_hook) - elif filetype is "msgpack": + elif filetype == "msgpack": data = msgpack.load(file_object, object_hook=_hook) + file_object.close() if timing: print( @@ -191,11 +199,11 @@ def load_ensemble(filename, convert_float_keys=True, select_keys=None, timing=Fa # data = recursive_change_key_to_float(data) # 61s data = keys_to_floats(data) # 6.94s - if timing: - print( - "\n\nTook {} s to convert floats\n\n".format(time.time() - tstart), - flush=True, - ) + if timing: + print( + "\n\nTook {} s to convert floats\n\n".format(time.time() - tstart), + flush=True, + ) # return data return data @@ -258,12 +266,10 @@ def handle_ensemble_string_to_json(raw_output): raw_output: raw output of the ensemble dump by binary_c Returns: - json.loads(raw_output, cls=binarycDecoder) + json.loads(raw_output, cls=BinarycDecoder) """ - - # return json.loads(json.dumps(ast.literal_eval(raw_output)), cls=binarycDecoder) - return json.loads(raw_output, cls=binarycDecoder) + return json.loads(raw_output, cls=BinarycDecoder) def binaryc_json_serializer(obj: Any) -> Any: @@ -282,10 +288,16 @@ def binaryc_json_serializer(obj: Any) -> Any: if inspect.isfunction(obj) or isinstance(obj, py_rinterpolate.Rinterpolate): return str(obj) - return obj - + else: + try: + string_version = str(obj) + return string_version + except: + raise TypeError( + "Unserializable object {} of type {}. Attempted to convert to string but that failed.".format(obj, type(obj)) + ) -class binarycDecoder(json.JSONDecoder): +class BinarycDecoder(json.JSONDecoder): """ Custom decoder to transform the numbers that are strings to actual floats """ @@ -323,7 +335,7 @@ class binarycDecoder(json.JSONDecoder): return o -class BinaryCEncoder(json.JSONEncoder): +class BinarycEncoder(json.JSONEncoder): """ Encoding class function to attempt to convert things to strings. """ @@ -332,6 +344,7 @@ class BinaryCEncoder(json.JSONEncoder): """ Converting function. Well, could be more precise. look at the JSON module """ + try: str_repr = str(o) except TypeError: diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py index 1480a418e8e1aaf142b59a535621ba040bb015f2..2b3013ad9795af8e446fa33b642cf7cdb43e7c8d 100644 --- a/binarycpython/utils/functions.py +++ b/binarycpython/utils/functions.py @@ -8,52 +8,64 @@ Tasks: - TODO: change all prints to verbose_prints """ - -import bz2 -import collections -from colorama import Fore, Back, Style -import copy -import datetime as dt -import gc -import gzip -from halo import Halo -import h5py -import humanize -import inspect -from io import StringIO -import json -import msgpack -import numpy as np import os -import psutil -import py_rinterpolate -import re -import resource import sys -import subprocess -import tempfile import time +import json +import datetime +import collections +import resource +import tempfile +import subprocess import types -from typing import Union, Any - -import simplejson -# import orjson +from typing import Union +from io import StringIO -import astropy.units as u -import binarycpython.utils.moe_di_stefano_2017_data as moe_di_stefano_2017_data +import h5py +import humanize +import numpy as np +import psutil +from colorama import Fore, Back, Style from binarycpython import _binary_c_bindings -from binarycpython.utils.dicts import filter_dict, filter_dict_through_values - +from binarycpython.utils.dicts import filter_dict_through_values ######################################################## # Unsorted ######################################################## +def now(now_object=None, style=None, custom_format=None): + """ + convenience function to return a string of the current time, using the format ``%m/%d/%Y %H:%M:%S`` + + Args: + style : if "nospace" then return the date/time with the format ``%Y%m%d_%H%M%S``, else use format ``%m/%d/%Y %H:%M:%S`` + + custom_format: if set, uses this as a format rather than whatever is set by default or in the style variable + """ + + if not now_object: + now_object = datetime.datetime.now() + + if not custom_format: + if style == "nospace": + # special case + date_format = "%Y%m%d_%H%M%S" + else: + # our default + date_format = "%m/%d/%Y %H:%M:%S" + else: + date_format = custom_format + + return datetime.datetime.strftime(now_object, date_format) + + def format_number(number): - # compact number formatter + """ + Function to take a number, express format it in scientific notation, and remove the trailing 0 if the exponent is 0 + """ string = "{number:.2g}".format(number=number) string = string.replace("e+0", "e+") @@ -67,12 +79,7 @@ def check_if_in_shell(): Function to check whether the script is running from a shell """ - if sys.stdin and sys.stdin.isatty(): - in_shell = True - else: - in_shell = False - - return in_shell + return bool(sys.stdin and sys.stdin.isatty()) def timedelta(delta): @@ -82,7 +89,7 @@ def timedelta(delta): """ # currently use the humanize module to do this t = humanize.time.precisedelta( - dt.timedelta(seconds=delta), + datetime.timedelta(seconds=delta), format="%0.2f", minimum_unit="milliseconds", suppress=["milliseconds"], @@ -100,6 +107,10 @@ def timedelta(delta): def get_ANSI_colours(): + """ + Function that returns a dictionary with text-colors in ANSI formatting + """ + # ANSI colours dictionary foreground_colours = { "red": Fore.RED, @@ -110,6 +121,7 @@ def get_ANSI_colours(): "magenta": Fore.MAGENTA, "white": Fore.WHITE, "black": Fore.BLACK, + "bold": Style.BRIGHT, } background_colours = { @@ -126,18 +138,19 @@ def get_ANSI_colours(): default_style = Style.BRIGHT colours = {} - for c in foreground_colours: - colours[c] = default_style + foreground_colours[c] - for d in background_colours: - colours[c + " on " + d] = foreground_colours[c] + background_colours[d] + for c, foreground_colour in foreground_colours.items(): + colours[c] = default_style + foreground_colour + for d, background_colour in background_colours.items(): + colours[c + " on " + d] = foreground_colour + background_colour colours["reset"] = Style.RESET_ALL - return colours def mem_use(): """ - Return current process memory use in MB. (Takes no arguments) Note: this is per-thread only. + Return current process memory use in MB. (Takes no arguments) + + Note: this is per-thread only. """ return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024.0 @@ -145,11 +158,19 @@ def mem_use(): def trem(dt, count, dn, n): """ - Estimate time remaining (seconds) given a differential time and count (i.e. progress = $count/$n). $dt is the time since the last call, $count is the current progress count, $dn is the number run since the last call, and $n is the total number required. + Estimate time remaining (seconds) given a differential time and count (i.e. ``progress = count/n``). + + Args: + dt: is the time since the last call. + count: is the current progress count. + dn: is the number run since the last call. + n: is the total number required. """ + tpr = dt / max(1, dn) etasecs = tpr * (n - count) (eta, units) = conv_time_units(etasecs) + return (eta, units, tpr, etasecs) @@ -170,9 +191,16 @@ def conv_time_units(t): def bin_data(value, binwidth): """ - Function that bins the data + Function that bins the data using the absolute value of binwidth using the following formula:: + + ((0.5 if value > 0.0 else -0.5) + int(value / abs(binwidth))) * abs(binwidth) + + Args: + value: value that we want to bin + binwidth: width of the binning - Uses the absolute value of binwidth + Returns: + binned value """ return ((0.5 if value > 0.0 else -0.5) + int(value / abs(binwidth))) * abs(binwidth) @@ -204,6 +232,7 @@ def get_size(obj, seen=None): obj_id = id(obj) if obj_id in seen: return 0 + # Important mark as seen *before* entering recursion to gracefully handle # self-referential objects seen.add(obj_id) @@ -217,69 +246,51 @@ def get_size(obj, seen=None): return size -def get_moe_di_stefano_dataset(options, verbosity=0): +def imports(): """ - Function to get the default Moe and di Stefano dataset or accept a user input. - - Returns a dict containing the (JSON) data. + Generator that generates the names of all the modules that are loaded in the globals """ - json_data = None + for _, val in globals().items(): + if isinstance(val, types.ModuleType): + yield val.__name__ - if "JSON" in options: - # use the JSON data passed in - json_data = options["JSON"] - elif "file" in options: - # use the file passed in, if provided - if not os.path.isfile(options["file"]): - verbose_print( - "The provided 'file' Moe and de Stefano JSON file does not seem to exist at {}".format( - options["file"] - ), - verbosity, - 1, - ) +def isfloat(x: Union[str, float, int]): + """ + Function to return `True` if the "number" x, which could be a string, is an float, otherwise return `False`. - raise ValueError - if not options["file"].endswith(".json"): - verbose_print( - "Provided filename is not a json file", - verbosity, - 1, - ) + Args: + x: string float or int that we will attempt to convert to an `float` value. + """ - else: - # Read input data and Clean up the data if there are white spaces around the keys - with open(options["file"], "r") as data_filehandle: - datafile_data = data_filehandle.read() - datafile_data = datafile_data.replace('" ', '"') - datafile_data = datafile_data.replace(' "', '"') - datafile_data = datafile_data.replace(' "', '"') - json_data = json.loads(datafile_data) - - if not json_data: - # no JSON data or filename given, use the default 2017 dataset - verbose_print( - "Using the default Moe and de Stefano 2017 datafile", - verbosity, - 1, - ) - json_data = copy.deepcopy(moe_di_stefano_2017_data.moe_di_stefano_2017_data) + try: + _ = float(x) + return True + except ValueError: + return False - return json_data +def isint(x: Union[str, float, int]): + """ + Function to return `True` if the "number" x, which could be a string, is an int, otherwise return `False`. -def imports(): - for name, val in globals().items(): - if isinstance(val, types.ModuleType): - yield val.__name__ + Args: + x: string float or int that we will attempt to convert to an `int` value. + """ + + try: + _ = int(x) + return True + except ValueError: + return False def convfloat(x): """ Convert scalar x to a float if we can, in which case return the float, otherwise just return x without changing it. Usually, x is a string, but could be anything that float() can handle without failure. """ + try: y = float(x) return y @@ -290,11 +301,13 @@ def convfloat(x): def datalinedict(line: str, parameters: list): """ Convert a line of data to a more convenient dictionary. + Arguments: line = a line of data as a string parameters = a list of the parameter names - Note: if the parameter is a floating point number, it will be converted to Python's float type. + Note: + If the parameter is a floating point number, it will be converted to Python's float type. """ return {param: convfloat(value) for param, value in zip(parameters, line.split())} @@ -303,6 +316,10 @@ def datalinedict(line: str, parameters: list): def pad_output_distribution(dist: dict, binwidth: float): """ Given a distribution, dist (a dictionary), which should be binned every binwidth (float), fill the distribution with zeros when there is no data. Note: this changes the data in place. + + Args: + dist: dictionary containing the distribution data. + binwidth: binwidth that is used to fill the distribution with 0 in places where there is no value/key. """ # sorted list of the keys @@ -321,19 +338,19 @@ def pad_output_distribution(dist: dict, binwidth: float): return dist -class catchtime(object): +class catchtime: """ Context manager to calculate time spent """ def __enter__(self): """On entry we start the clock""" - self.t = time.clock() + self.t = time.process_time() return self - def __exit__(self, type, value, traceback): + def __exit__(self, exc_type, exc_val, exc_tb): """On exit we stop the clock and measure the time spent""" - self.t = time.clock() - self.t + self.t = time.process_time() - self.t print("Took {}s".format(self.t)) @@ -370,11 +387,11 @@ def call_binary_c_config(argument): """ Function to interface with the binary_c config file - input: - - argument: argument for the binary_c config + Args: + argument: argument for the binary_c config Returns: - - raw output of binary_c-config + raw output of binary_c-config """ BINARY_C_DIR = os.getenv("BINARY_C", None) @@ -399,21 +416,25 @@ def call_binary_c_config(argument): ######################################################## -def verbose_print(message: str, verbosity: int, minimal_verbosity: int) -> None: +def verbose_print( + message: str, verbosity: int, minimal_verbosity: int, newline: str = "\n" +) -> None: """ Function that decides whether to print a message based on the current verbosity - and its minimum verbosity - - if verbosity is equal or higher than the minimum, then we print + and its minimum verbosity. If verbosity is equal or higher than the minimum, then we print. Args: - message: message to print - verbosity: current verbosity level - minimal_verbosity: threshold verbosity above which to print + message: message to print. + verbosity: current verbosity level. + minimal_verbosity: threshold verbosity above which to print. + newline: newline character (or set of characters), defaults to ``\\n`` but ``\\x0d`` (carriage return) might be useful. """ if verbosity >= minimal_verbosity: - print(message) + if newline == "\n": + print(message) + else: + print(message, newline, sep="", end="") sys.stdout.flush() @@ -451,17 +472,21 @@ def remove_file(file: str, verbosity: int = 0) -> None: def get_username(): + """ + Function to get the username of the user that spawned the current process + """ + return psutil.Process().username() -def temp_dir(*args: str) -> str: +def temp_dir(*child_dirs: str) -> str: """ - Function to create directory within the TMP directory of the file system + Function to create directory within the TMP directory of the file system, starting with `/<TMP>/binary_c_python-<username>` Makes use of os.makedirs exist_ok which requires python 3.2+ Args: - function arguments: str input where each next input will be a child of the previous full_path. e.g. temp_dir('tests', 'grid') will become '/tmp/binary_c_python/tests/grid' + *child_dirs: str input where each next input will be a child of the previous full_path. e.g. ``temp_dir('tests', 'grid')`` will become ``'/tmp/binary_c_python-<username>/tests/grid'`` Returns: the path of a sub directory called binary_c_python in the TMP of the file system @@ -472,8 +497,8 @@ def temp_dir(*args: str) -> str: path = os.path.join(tmp_dir, "binary_c_python-{}".format(username)) # loop over the other paths if there are any: - if args: - for extra_dir in args: + if child_dirs: + for extra_dir in child_dirs: path = os.path.join(path, extra_dir) # @@ -506,21 +531,23 @@ def create_hdf5(data_dir: str, name: str) -> None: content_data_dir = os.listdir(data_dir) # Settings - if any([file.endswith("_settings.json") for file in content_data_dir]): + if any(file.endswith("_settings.json") for file in content_data_dir): print("Adding settings to HDF5 file") settings_file = os.path.join( data_dir, [file for file in content_data_dir if file.endswith("_settings.json")][0], ) - with open(settings_file, "r") as settings_file: + with open(settings_file, "r", encoding="utf-8") as settings_file: settings_json = json.load(settings_file) # Create settings group settings_grp = hdf5_file.create_group("settings") # Write version_string to settings_group - settings_grp.create_dataset("used_settings", data=json.dumps(settings_json)) + settings_grp.create_dataset( + "used_settings", data=json.dumps(settings_json, ensure_ascii=False) + ) # Get data files data_files = [el for el in content_data_dir if el.endswith(".dat")] @@ -551,325 +578,6 @@ def create_hdf5(data_dir: str, name: str) -> None: hdf5_file.close() -######################################################## -# version_info functions -######################################################## - - -def return_binary_c_version_info(parsed: bool = True) -> Union[str, dict]: - """ - Function that returns the version information of binary_c. This function calls the function - _binary_c_bindings.return_version_info() - - Args: - parsed: Boolean flag whether to parse the version_info output of binary_c. default = False - - Returns: - Either the raw string of binary_c or a parsed version of this in the form of a nested - dictionary - """ - - found_prev = False - if "BINARY_C_MACRO_HEADER" in os.environ: - # the env var is already present. lets save that and put that back later - found_prev = True - prev_value = os.environ["BINARY_C_MACRO_HEADER"] - - # - os.environ["BINARY_C_MACRO_HEADER"] = "macroxyz" - - # Get version_info - version_info = _binary_c_bindings.return_version_info().strip() - - # parse if wanted - if parsed: - version_info = parse_binary_c_version_info(version_info) - - # delete value - del os.environ["BINARY_C_MACRO_HEADER"] - - # put stuff back if we found a previous one - if found_prev: - os.environ["BINARY_C_MACRO_HEADER"] = prev_value - - return version_info - - -def parse_binary_c_version_info(version_info_string: str) -> dict: - """ - Function that parses the binary_c version info. Long function with a lot of branches - - TODO: fix this function. stuff is missing: isotopes, macros, nucleosynthesis_sources - - Args: - version_info_string: raw output of version_info call to binary_c - - Returns: - Parsed version of the version info, which is a dictionary containing the keys: 'isotopes' for isotope info, 'argpairs' for argument pair info (TODO: explain), 'ensembles' for ensemble settings/info, 'macros' for macros, 'elements' for atomic element info, 'DTlimit' for (TODO: explain), 'nucleosynthesis_sources' for nucleosynthesis sources, and 'miscellaneous' for all those that were not caught by the previous groups. 'git_branch', 'git_build', 'revision' and 'email' are also keys, but its clear what those contain. - """ - - version_info_dict = {} - - # Clean data and put in correct shape - splitted = version_info_string.strip().splitlines() - cleaned = {el.strip() for el in splitted if not el == ""} - - ########################## - # Network: - # Split off all the networks and parse the info. - - networks = {el for el in cleaned if el.startswith("Network ")} - cleaned = cleaned - networks - - networks_dict = {} - for el in networks: - network_dict = {} - split_info = el.split("Network ")[-1].strip().split("==") - - network_number = int(split_info[0]) - network_dict["network_number"] = network_number - - network_info_split = split_info[1].split(" is ") - - shortname = network_info_split[0].strip() - network_dict["shortname"] = shortname - - if not network_info_split[1].strip().startswith(":"): - network_split_info_extra = network_info_split[1].strip().split(":") - - longname = network_split_info_extra[0].strip() - network_dict["longname"] = longname - - implementation = ( - network_split_info_extra[1].strip().replace("implemented in", "") - ) - if implementation: - network_dict["implemented_in"] = implementation.strip().split() - - networks_dict[network_number] = copy.deepcopy(network_dict) - version_info_dict["networks"] = networks_dict if networks_dict else None - - ########################## - # Isotopes: - # Split off - isotopes = {el for el in cleaned if el.startswith("Isotope ")} - cleaned = cleaned - isotopes - - isotope_dict = {} - for el in isotopes: - split_info = el.split("Isotope ")[-1].strip().split(" is ") - - isotope_info = split_info[-1] - name = isotope_info.split(" ")[0].strip() - - # Get details - mass_g = float( - isotope_info.split(",")[0].split("(")[1].split("=")[-1][:-2].strip() - ) - mass_amu = float( - isotope_info.split(",")[0].split("(")[-1].split("=")[-1].strip() - ) - mass_mev = float( - isotope_info.split(",")[-3].split("=")[-1].replace(")", "").strip() - ) - A = int(isotope_info.split(",")[-1].strip().split("=")[-1].replace(")", "")) - Z = int(isotope_info.split(",")[-2].strip().split("=")[-1]) - - # - isotope_dict[int(split_info[0])] = { - "name": name, - "Z": Z, - "A": A, - "mass_mev": mass_mev, - "mass_g": mass_g, - "mass_amu": mass_amu, - } - version_info_dict["isotopes"] = isotope_dict if isotope_dict else None - - ########################## - # Arg pairs: - # Split off - argpairs = set([el for el in cleaned if el.startswith("ArgPair")]) - cleaned = cleaned - argpairs - - argpair_dict = {} - for el in sorted(argpairs): - split_info = el.split("ArgPair ")[-1].split(" ") - - if not argpair_dict.get(split_info[0], None): - argpair_dict[split_info[0]] = {split_info[1]: split_info[2]} - else: - argpair_dict[split_info[0]][split_info[1]] = split_info[2] - - version_info_dict["argpairs"] = argpair_dict if argpair_dict else None - - ########################## - # ensembles: - # Split off - ensembles = {el for el in cleaned if el.startswith("Ensemble")} - cleaned = cleaned - ensembles - - ensemble_dict = {} - ensemble_filter_dict = {} - for el in ensembles: - split_info = el.split("Ensemble ")[-1].split(" is ") - - if len(split_info) > 1: - if not split_info[0].startswith("filter"): - ensemble_dict[int(split_info[0])] = split_info[-1] - else: - filter_no = int(split_info[0].replace("filter ", "")) - ensemble_filter_dict[filter_no] = split_info[-1] - - version_info_dict["ensembles"] = ensemble_dict if ensemble_dict else None - version_info_dict["ensemble_filters"] = ( - ensemble_filter_dict if ensemble_filter_dict else None - ) - - ########################## - # macros: - # Split off - macros = {el for el in cleaned if el.startswith("macroxyz")} - cleaned = cleaned - macros - - param_type_dict = { - "STRING": str, - "FLOAT": float, - "MACRO": str, - "INT": int, - "LONG_INT": int, - "UINT": int, - } - - macros_dict = {} - for el in macros: - split_info = el.split("macroxyz ")[-1].split(" : ") - param_type = split_info[0] - - new_split = "".join(split_info[1:]).split(" is ") - param_name = new_split[0] - param_value = " is ".join(new_split[1:]) - - # Sometimes the macros have extra information behind it. Needs an update in outputting by binary_c - try: - macros_dict[param_name] = param_type_dict[param_type](param_value) - except ValueError: - macros_dict[param_name] = str(param_value) - version_info_dict["macros"] = macros_dict if macros_dict else None - - ########################## - # Elements: - # Split off: - elements = {el for el in cleaned if el.startswith("Element")} - cleaned = cleaned - elements - - # Fill dict: - elements_dict = {} - for el in elements: - split_info = el.split("Element ")[-1].split(" : ") - name_info = split_info[0].split(" is ") - - # get isotope info - isotopes = {} - if not split_info[-1][0] == "0": - isotope_string = split_info[-1].split(" = ")[-1] - isotopes = { - int(split_isotope.split("=")[0]): split_isotope.split("=")[1] - for split_isotope in isotope_string.split(" ") - } - - elements_dict[int(name_info[0])] = { - "name": name_info[-1], - "atomic_number": int(name_info[0]), - "amt_isotopes": len(isotopes), - "isotopes": isotopes, - } - version_info_dict["elements"] = elements_dict if elements_dict else None - - ########################## - # dt_limits: - # split off - dt_limits = {el for el in cleaned if el.startswith("DTlimit")} - cleaned = cleaned - dt_limits - - # Fill dict - dt_limits_dict = {} - for el in dt_limits: - split_info = el.split("DTlimit ")[-1].split(" : ") - dt_limits_dict[split_info[1].strip()] = { - "index": int(split_info[0]), - "value": float(split_info[-1]), - } - - version_info_dict["dt_limits"] = dt_limits_dict if dt_limits_dict else None - - ########################## - # Nucleosynthesis sources: - # Split off - nucsyn_sources = {el for el in cleaned if el.startswith("Nucleosynthesis")} - cleaned = cleaned - nucsyn_sources - - # Fill dict - nucsyn_sources_dict = {} - for el in nucsyn_sources: - split_info = el.split("Nucleosynthesis source")[-1].strip().split(" is ") - nucsyn_sources_dict[int(split_info[0])] = split_info[-1] - - version_info_dict["nucleosynthesis_sources"] = ( - nucsyn_sources_dict if nucsyn_sources_dict else None - ) - - ########################## - # miscellaneous: - # All those that I didn't catch with the above filters. Could try to get some more out though. - # TODO: filter a bit more. - - misc_dict = {} - - # Filter out git revision - git_revision = [el for el in cleaned if el.startswith("git revision")] - misc_dict["git_revision"] = ( - git_revision[0].split("git revision ")[-1].replace('"', "") - ) - cleaned = cleaned - set(git_revision) - - # filter out git url - git_url = [el for el in cleaned if el.startswith("git URL")] - misc_dict["git_url"] = git_url[0].split("git URL ")[-1].replace('"', "") - cleaned = cleaned - set(git_url) - - # filter out version - version = [el for el in cleaned if el.startswith("Version")] - misc_dict["version"] = str(version[0].split("Version ")[-1]) - cleaned = cleaned - set(version) - - git_branch = [el for el in cleaned if el.startswith("git branch")] - misc_dict["git_branch"] = git_branch[0].split("git branch ")[-1].replace('"', "") - cleaned = cleaned - set(git_branch) - - build = [el for el in cleaned if el.startswith("Build")] - misc_dict["build"] = build[0].split("Build: ")[-1].replace('"', "") - cleaned = cleaned - set(build) - - email = [el for el in cleaned if el.startswith("Email")] - misc_dict["email"] = email[0].split("Email ")[-1].split(",") - cleaned = cleaned - set(email) - - other_items = set([el for el in cleaned if " is " in el]) - cleaned = cleaned - other_items - - for el in other_items: - split = el.split(" is ") - key = split[0].strip() - val = " is ".join(split[1:]).strip() - misc_dict[key] = val - - misc_dict["uncaught"] = list(cleaned) - - version_info_dict["miscellaneous"] = misc_dict if misc_dict else None - return version_info_dict - - ######################################################## # binary_c output functions ######################################################## @@ -1078,7 +786,7 @@ def get_help( Will check whether it is a valid parameter. - Binary_c will output things in the following order; + Binary_c will output things in the following order: - Did you mean? - binary_c help for variable - default @@ -1086,9 +794,6 @@ def get_help( This function reads out that structure and catches the different components of this output - Tasks: - - TODO: consider not returning None, but return empty dict - Args: param_name: name of the parameter that you want info from. Will get checked whether its a valid parameter name @@ -1097,8 +802,8 @@ def get_help( parameter isn't valid Returns: - Dictionary containing the help info. This dictionary contains 'parameter_name', - 'parameter_value_input_type', 'description', optionally 'macros' + Dictionary containing the help info. This dictionary contains `parameter_name`, + `parameter_value_input_type`, `description`, optionally `macros` """ available_arg_keys = get_arg_keys() @@ -1166,20 +871,20 @@ def get_help( help_info_dict["macros"] = macros if print_help: - for key in help_info_dict: - print("{}:\n\t{}".format(key, help_info_dict[key])) + for key, value in help_info_dict.items(): + print("{}:\n\t{}".format(key, value)) return help_info_dict - else: - if not fail_silently: - print( - "{} is not a valid parameter name. Please choose from the \ - following parameters:\n\t{}".format( - param_name, list(available_arg_keys) - ) + if not fail_silently: + print( + "{} is not a valid parameter name. Please choose from the \ + following parameters:\n\t{}".format( + param_name, list(available_arg_keys) ) - return None + ) + + return {} def get_help_all(print_help: bool = True) -> dict: @@ -1208,11 +913,11 @@ def get_help_all(print_help: bool = True) -> dict: help_all_dict = {} # Select the section name and the contents of that section. Note, not all sections have content! - for i in range(len(section_nums)): + for i, section_num in enumerate(section_nums): if not i == len(section_nums) - 1: - params = cleaned[section_nums[i] + 1 : section_nums[i + 1]] + params = cleaned[section_num + 1 : section_nums[i + 1]] else: - params = cleaned[section_nums[i] + 1 : len(cleaned)] + params = cleaned[section_num + 1 : len(cleaned)] section_name = ( cleaned[section_nums[i]] .lstrip("#####") @@ -1310,21 +1015,14 @@ def get_help_super(print_help: bool = False, fail_silently: bool = True) -> dict # Get help_all information help_all_dict = get_help_all(print_help=False) - for section_name in help_all_dict: - section = help_all_dict[section_name] - - # print(section_name) - # for parameter_name in section["parameters"].keys(): - # print("\t", parameter_name) + # help_all_super_dict = help_all_dict.copy() # Loop over all sections and stuff - for section_name in help_all_dict: + for section_name, section in help_all_dict.items(): # Skipping the section i/o because that one shouldn't be available to python anyway if not section_name == "i/o": - section = help_all_dict[section_name] - for parameter_name in section["parameters"].keys(): parameter = section["parameters"][parameter_name] @@ -1339,7 +1037,7 @@ def get_help_super(print_help: bool = False, fail_silently: bool = True) -> dict # check whether the descriptions of help_all and detailed help are the same if not fail_silently: if not parameter["description"] == detailed_help["description"]: - print(json.dumps(parameter, indent=4)) + print(json.dumps(parameter, indent=4, ensure_ascii=False)) ## put values into help all super dict # input type @@ -1351,13 +1049,13 @@ def get_help_super(print_help: bool = False, fail_silently: bool = True) -> dict parameter["default"] = detailed_help["default"] # macros - if "macros" in detailed_help.keys(): + if "macros" in detailed_help: parameter["macros"] = detailed_help["macros"] section["parameters"][parameter_name] = parameter if print_help: - print(json.dumps(help_all_super_dict, indent=4)) + print(json.dumps(help_all_super_dict, indent=4, ensure_ascii=False)) return help_all_super_dict @@ -1369,8 +1067,11 @@ def make_build_text() -> str: Returns: string containing information about the build and the git branch """ + from binarycpython.utils.grid import Population - version_info = return_binary_c_version_info(parsed=True) + version_pop = Population() + version_info = version_pop.return_binary_c_version_info(parsed=True) + # version_info = return_binary_c_version_info(parsed=True) git_revision = version_info["miscellaneous"]["git_revision"] git_branch = version_info["miscellaneous"]["git_branch"] @@ -1390,11 +1091,8 @@ def write_binary_c_parameter_descriptions_to_rst_file(output_file: str) -> None: """ Function that calls the get_help_super() to get the help text/descriptions for all the parameters available in that build. - Writes the results to a .rst file that can be included in the docs. - Tasks: - - TODO: add the specific version git branch, git build, git commit, and binary_c version to - this document + Writes the results to a .rst file that can be included in the docs. Args: output_file: name of the output .rst file containing the ReStructuredText formatted output @@ -1407,10 +1105,13 @@ def write_binary_c_parameter_descriptions_to_rst_file(output_file: str) -> None: build_info = make_build_text() if not output_file.endswith(".rst"): - print("Filename doesn't end with .rst, please provide a proper filename") - return None + raise ValueError( + "Filename ({}) doesn't end with .rst, please provide a proper filename.".format( + output_file + ) + ) - with open(output_file, "w") as f: + with open(output_file, "w", encoding="utf-8") as f: print("Binary\\_c parameters", file=f) print("{}".format("=" * len("Binary\\_c parameters")), file=f) @@ -1425,13 +1126,19 @@ def write_binary_c_parameter_descriptions_to_rst_file(output_file: str) -> None: for el in arguments_dict.keys(): print("Section: {}".format(el), file=f) print("{}\n".format("-" * len("Section: {}".format(el))), file=f) - # print(arguments_dict[el]['parameters'].keys()) for arg in arguments_dict[el]["parameters"].keys(): argdict = arguments_dict[el]["parameters"][arg] print("| **Parameter**: {}".format(argdict["param_name"]), file=f) - print("| **Description**: {}".format(argdict["description"]), file=f) + print( + "| **Description**: {}".format( + argdict["description"].replace( + "|Rout/Rin-1|", "abs(Rout/Rin-1)" + ) + ), + file=f, + ) if "parameter_value_input_type" in argdict: print( "| **Parameter input type**: {}".format( @@ -1453,14 +1160,14 @@ def write_binary_c_parameter_descriptions_to_rst_file(output_file: str) -> None: ######################################################## -def load_logfile(logfile: str) -> None: +def load_logfile(logfile: str) -> None: # pragma: no cover """ Experimental function that parses the generated log file of binary_c. This function is not finished and shouldn't be used yet. Tasks: - - TODO: + - TODO: fix this function Args: - logfile: filename of the log file you want to parse @@ -1469,7 +1176,7 @@ def load_logfile(logfile: str) -> None: """ - with open(logfile, "r") as file: + with open(logfile, "r", encoding="utf-8") as file: logfile_data = file.readlines() time_list = [] @@ -1502,3 +1209,15 @@ def load_logfile(logfile: str) -> None: event_list.append(" ".join(split_line[9:])) print(event_list) + +def quotewrap(list): + """ + Given a list, wrap each item in double quotes and return the new list + """ + return ['"' + _x + '"' for _x in list] + +def command_string_from_list(list): + """ + Given a list, turn it into a quoted command string + """ + return ' '.join(quotewrap(list)) diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index 785ddf13a07d720f20880d58a7e34e334769983b..a55f231ca31c2b8aed15e13b40ca444d538de176 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -3,6 +3,8 @@ Module containing the Population grid class object. Here all the functionality of a Population object is defined. +TODO: the save_snapshots and save_snapshot, are they actually distinct? + Tasks: - TODO: add functionality to 'on-init' set arguments - TODO: add functionality to return the initial_abundance_hash @@ -15,117 +17,99 @@ Tasks: - TODO: consider spreading the functions over more files. - TODO: type the private functions - TODO: fix the correct object types for the default values of the bse_options - - TODO: uncomment and implement the HPC functionality - TODO: think of a clean and nice way to unload and remove the custom_logging_info library from memory (and from disk) - TODO: think of a nice way to remove the loaded grid_code/ generator from memory. + +TODO: Some of the methods that we have defined in the (mixin) class are designed to be used as a portal to information (return_binary_c_version_info for example.) THe current design is that they are all instance methods, but that is not always necessary. We can decorate them with @staticmethod, or @classmethod to make it easier to use them (https://realpython.com/instance-class-and-static-methods-demystified/) """ -import argparse -import bz2 -import copy -import datetime -import json -import gc -import gzip -import importlib.util -import logging -import msgpack -import multiprocessing import os -import py_rinterpolate -import re -import resource -import setproctitle -import strip_ansi +import gc import sys import time +import copy +import json import uuid +import queue +import signal +import datetime +import functools +import traceback +import multiprocessing -_count = 0 -from typing import Union, Any from collections import ( OrderedDict, ) from collections.abc import Iterable # drop `.abc` with Python 2.7 or lower +from typing import Union, Any +import psutil import setproctitle -import py_rinterpolate - +import str2bool from colorama import init as colorama_init -colorama_init() - -from binarycpython.utils.grid_options_defaults import ( - grid_options_defaults_dict, - moe_di_stefano_default_options, - _MOE2017_VERBOSITY_LEVEL, - _CUSTOM_LOGGING_VERBOSITY_LEVEL, - _LOGGER_VERBOSITY_LEVEL, -) - -from binarycpython.utils.custom_logging_functions import ( - autogen_C_logging_code, - binary_c_log_code, - create_and_load_logging_function, -) - from binarycpython.utils.functions import ( - get_defaults, - remove_file, + check_if_in_shell, filter_arg_dict, + get_ANSI_colours, + get_defaults, get_help_all, - return_binary_c_version_info, - verbose_print, - get_moe_di_stefano_dataset, - trem, - conv_time_units, mem_use, - get_ANSI_colours, - check_if_in_shell, - format_number, timedelta, + now, ) from binarycpython.utils.ensemble import ( binaryc_json_serializer, - ensemble_compression, - ensemble_file_type, extract_ensemble_json_from_string, format_ensemble_results, ) from binarycpython.utils.dicts import ( AutoVivificationDict, - custom_sort_dict, merge_dicts, - multiply_values_dict, - recursive_change_key_to_float, - recursive_change_key_to_string, - update_dicts, + keys_to_floats, ) -# from binarycpython.utils.hpc_functions import ( -# get_condor_version, -# get_slurm_version, -# create_directories_hpc, -# path_of_calling_script, -# get_python_details, -# ) - -from binarycpython.utils.distribution_functions import ( - Moecache, - LOG_LN_CONVERTER, - fill_data, - get_max_multiplicity, - Arenou2010_binary_fraction, - raghavan2010_binary_fraction, - Moe_di_Stefano_2017_multiplicity_fractions, - normalize_dict, +from binarycpython.utils.population_extensions.analytics import analytics +from binarycpython.utils.population_extensions.cache import cache +from binarycpython.utils.population_extensions.dataIO import dataIO +from binarycpython.utils.population_extensions.distribution_functions import ( + distribution_functions, ) +from binarycpython.utils.population_extensions.grid_logging import grid_logging +from binarycpython.utils.population_extensions.grid_options_defaults import ( + grid_options_defaults, +) +from binarycpython.utils.population_extensions.gridcode import gridcode +from binarycpython.utils.population_extensions.HPC import HPC +from binarycpython.utils.population_extensions.metadata import metadata +from binarycpython.utils.population_extensions.Moe_di_Stefano_2017 import ( + Moe_di_Stefano_2017, +) +from binarycpython.utils.population_extensions.spacing_functions import ( + spacing_functions, +) +from binarycpython.utils.population_extensions.version_info import version_info + from binarycpython import _binary_c_bindings -secs_per_day = 86400 # probably needs to go somewhere more sensible +# Initialise the colorama stuff +colorama_init() -class Population: +class Population( + analytics, + cache, + dataIO, + distribution_functions, + grid_logging, + grid_options_defaults, + gridcode, + HPC, + metadata, + Moe_di_Stefano_2017, + spacing_functions, + version_info, +): """ Population Object. Contains all the necessary functions to set up, run and process a population of systems @@ -136,8 +120,26 @@ class Population: Initialisation function of the population class """ - # Different sections of options + # Initialise the parent classes + analytics.__init__(self) + cache.__init__(self) + dataIO.__init__(self) + distribution_functions.__init__(self) + grid_logging.__init__(self) + grid_options_defaults.__init__(self) + gridcode.__init__(self) + HPC.__init__(self) + metadata.__init__(self) + Moe_di_Stefano_2017.__init__(self) + spacing_functions.__init__(self) + version_info.__init__(self) + + # caches + self.caches = {} + self.cached_function_cache = {} + self.original_function_cache = {} + # Different sections of options # get binary_c defaults and create a cleaned up dict # Setting stuff will check against the defaults to see if the input is correct. self.defaults = get_defaults() @@ -146,42 +148,55 @@ class Population: self.special_params = [ el for el in list(self.defaults.keys()) if el.endswith("%d") ] + self.preloaded_population = None + self.signal_count = {} # make the input dictionary self.bse_options = {} # bse_options is just empty. # Grid options - self.grid_options = copy.deepcopy(grid_options_defaults_dict) + self.grid_options = copy.deepcopy(self.get_grid_options_defaults_dict()) # Custom options - self.custom_options = {} + # TODO: is this really necessary here? The custom options should be empty on start i think + self.custom_options = { + "save_snapshot": False, + } # grid code generation self.indent_depth = 0 self.indent_string = " " self.code_string = "" + # cached value of minimum stellar mass + self._minimum_stellar_mass = None + + # logging levels + self._LOGGER_VERBOSITY_LEVEL = 1 + self._CUSTOM_LOGGING_VERBOSITY_LEVEL = 2 + # Set the options that are passed at creation of the object self.set(**kwargs) # Load Moe and di Stefano options self.grid_options["Moe2017_options"] = copy.deepcopy( - moe_di_stefano_default_options + self.get_Moe_di_Stefano_2017_default_options() ) - # Write MOE2017 options to a file. NOTE: not sure why i put this here anymore + # Write MOE2017 options to a file. NOTE: (david) not sure why i put this here anymore os.makedirs( os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), exist_ok=True ) - with open( + with self.open( os.path.join( os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), "moeopts.dat", ), "w", ) as f: - f.write(json.dumps(self.grid_options["Moe2017_options"], indent=4)) - f.close() + json.dump( + self.grid_options["Moe2017_options"], f, indent=4, ensure_ascii=False + ) # Argline dict self.argline_dict = {} @@ -197,7 +212,7 @@ class Population: # ANSI colours: use them if in a shell self.ANSI_colours = get_ANSI_colours() - if self.in_shell == False: + if self.in_shell is False: for c in self.ANSI_colours: self.ANSI_colours[c] = "" @@ -208,11 +223,61 @@ class Population: self.process_ID = 0 # Create location to store results. Users should write to this dictionary. - # The AutoVivificationDict allows for perls method of accessing possibly non-existant subdicts + # The AutoVivificationDict allows for Perl-like addition of possibly + # non-existant subdicts. self.grid_results = AutoVivificationDict() - # Create location where ensemble results are written to - self.grid_ensemble_results = {} + # Create grid ensemble data location + self.grid_ensemble_results = self._new_grid_ensemble_results() + + # add metadata + self.add_system_metadata() + + # set up function cache. + # NOTE: (david) I added this here to be able to test the distributions functions without actually running anything. + self.setup_function_cache() + + def jobID(self): + """ + Function to return the job ID number of this process as a string. + + Normal processes return their process ID (PID) + HPC processes return whatever HPC_jobID() gives. + """ + if self.HPC_job(): + jobID = self.HPC_jobID() + if not jobID: + # fallback: use process ID but with "HPC" prepended + # (this should never happen!) + jobID = "HPC{}".format(self.process_ID) + else: + jobID = "{}".format(self.process_ID) + return jobID + + def exit(self, code=None, message=True, flush=True, stacktrace=False): + """ + Exit function: use this to exit from a Population object. + Really it's just a wrapper for sys.exit() to return the correct exit code, + but also to post a message (if message is True, default is True) + and perhaps a stacktrace (if stacktrace is True, default is False). + """ + # if we've been killed, set exit code to 1 + if self.grid_options["exit_code"] == 0 and self.grid_options["_killed"]: + self.grid_options["exit_code"] = 1 + # but override with code passed in + if code: + self.grid_options["exit_code"] = code + if message: + print( + "exit from binary_c-python Population with code {}".format( + self.grid_options["exit_code"] + ) + ) + if flush: + sys.stdout.flush() + if stacktrace or self.grid_options["print_stack_on_exit"]: + traceback.print_stack() + sys.exit(self.grid_options["exit_code"]) ################################################### # Argument functions @@ -253,24 +318,21 @@ class Population: # Go over all the input for key in kwargs: # Filter out keys for the bse_options - if key in self.defaults.keys(): - verbose_print( + if key in self.defaults: + self.verbose_print( "adding: {}={} to BSE_options".format(key, kwargs[key]), self.grid_options["verbosity"], - 1, + 2, ) self.bse_options[key] = kwargs[key] # Extra check to check if the key fits one of parameter names that end with %d + # TODO: abstract this function elif any( - [ - True - if (key.startswith(param[:-2]) and len(param[:-2]) < len(key)) - else False - for param in self.special_params - ] + bool(key.startswith(param[:-2]) and len(param[:-2]) < len(key)) + for param in self.special_params ): - verbose_print( + self.verbose_print( "adding: {}={} to BSE_options by catching the %d".format( key, kwargs[key] ), @@ -281,7 +343,7 @@ class Population: # Filter out keys for the grid_options elif key in self.grid_options.keys(): - verbose_print( + self.verbose_print( "adding: {}={} to grid_options".format(key, kwargs[key]), self.grid_options["verbosity"], 1, @@ -290,7 +352,7 @@ class Population: # The of the keys go into a custom_options dict else: - verbose_print( + self.verbose_print( "<<<< Warning: Key does not match previously known parameter: \ adding: {}={} to custom_options >>>>".format( key, kwargs[key] @@ -320,7 +382,7 @@ class Population: cmdline_args = sys.argv[1:] if cmdline_args: - verbose_print( + self.verbose_print( "Found cmdline args. Parsing them now", self.grid_options["verbosity"], 1, @@ -334,47 +396,98 @@ class Population: cmdline_dict = {} for cmdline_arg in cmdline_args: split = cmdline_arg.split("=") - parameter = split[0] - value = split[1] - old_value_found = False - - # Find an old value - if parameter in self.grid_options: - old_value = self.grid_options[parameter] - old_value_found = True - - elif parameter in self.defaults: - old_value = self.defaults[parameter] - old_value_found = True - - elif parameter in self.custom_options: - old_value = self.custom_options[parameter] - old_value_found = True - - # (attempt to) convert - if old_value_found: - try: - verbose_print( - "Converting type of {} from {} to {}".format( - parameter, type(value), type(old_value) - ), - self.grid_options["verbosity"], - 2, - ) - value = type(old_value)(value) - verbose_print("Success!", self.grid_options["verbosity"], 2) - except ValueError: - verbose_print( - "Tried to convert the given parameter {}/value {} to its correct type {} (from old value {}). But that wasn't possible.".format( - parameter, value, type(old_value), old_value - ), - self.grid_options["verbosity"], - 0, - ) + if len(split) == 2: + parameter = split[0] + value = split[1] + old_value_found = False + + # Find an old value + if parameter in self.grid_options: + old_value = self.grid_options[parameter] + old_value_found = True + + elif parameter in self.custom_options: + old_value = self.custom_options[parameter] + old_value_found = True + + elif parameter in self.bse_options: + old_value = self.bse_options[parameter] + old_value_found = True + + elif parameter in self.defaults: + # this will revert to a string type, always + old_value = self.defaults[parameter] + old_value_found = True + + # (attempt to) convert type + if old_value_found: + if old_value is not None: + try: + self.verbose_print( + "Converting type of {} from {} to {}".format( + parameter, type(value), type(old_value) + ), + self.grid_options["verbosity"], + 3, + ) + try: + if isinstance(old_value, bool): + value = str2bool.str2bool(value) + else: + value = type(old_value)(value) + self.verbose_print( + "Success!", self.grid_options["verbosity"], 2 + ) + except Exception as e: + print( + "Failed to convert {param} value with type {type}: old_value is '{old}', new value is '{new}', {e}".format( + param=parameter, + old=old_value, + type=type(old_value), + new=split[1], + e=e, + ) + ) + self.exit(code=1) + + except ValueError: + + # might be able to eval the parameter, e.g. + # an expression like "2-1" can eval to "1" + # which would be valid + try: + evaled = eval(value) + value = type(old_value)(evaled) + self.verbose_print( + "Success! (evaled)", + self.grid_options["verbosity"], + 2, + ) + + except ValueError: + self.verbose_print( + "Tried to convert the given parameter {}/value {} to its correct type {} (from old value {}). But that wasn't possible.".format( + parameter, value, type(old_value), old_value + ), + self.grid_options["verbosity"], + 0, + ) + # Add to dict + self.verbose_print( + "setting {} = {} ".format(parameter, value), + self.grid_options["verbosity"], + 3, + ) + cmdline_dict[parameter] = value - # Add to dict - cmdline_dict[parameter] = value + else: + print( + "Error: I do not know how to process", + cmdline_arg, + " : cmdline args should be in the format x=y, yours appears not to be.", + ) + self.exit(1) # unpack the dictionary into the setting function that handles where the values are set self.set(**cmdline_dict) @@ -392,246 +505,8 @@ class Population: for param_name in sorted(parameter_dict): argline += "{} {} ".format(param_name, parameter_dict[param_name]) argline = argline.strip() - return argline - def _last_grid_variable(self): - """ - Function that returns the last grid variable - (i.e. the one with the highest grid_variable_number) - """ - - number = len(self.grid_options["_grid_variables"]) - for grid_variable in self.grid_options["_grid_variables"]: - if ( - self.grid_options["_grid_variables"][grid_variable][ - "grid_variable_number" - ] - == number - 1 - ): - return grid_variable - - def update_grid_variable(self, name: str, **kwargs) -> None: - """ - Function to update the values of a grid variable. - - Args: - name: - name of the grid variable to be changed. - **kwargs: - key-value pairs to override the existing grid variable data. See add_grid_variable for these names. - """ - - grid_variable = None - try: - grid_variable = self.grid_options["_grid_variables"][name] - except KeyError: - msg = "Unknown grid variable {} - please create it with the add_grid_variable() method.".format( - name - ) - raise KeyError(msg) - - for key, value in kwargs.items(): - grid_variable[key] = value - verbose_print( - "Updated grid variable: {}".format(json.dumps(grid_variable, indent=4)), - self.grid_options["verbosity"], - 1, - ) - - def delete_grid_variable( - self, - name: str, - ) -> None: - try: - del self.grid_options["_grid_variables"][name] - verbose_print( - "Deleted grid variable: {}".format(name), - self.grid_options["verbosity"], - 1, - ) - except: - msg = "Failed to remove grid variable {} : please check it exists.".format( - name - ) - raise ValueError(msg) - - def rename_grid_variable(self, oldname: str, newname: str) -> None: - """ - Function to rename a grid variable. - - note: this does NOT alter the order - of the self.grid_options["_grid_variables"] dictionary. - - The order in which the grid variables are loaded into the grid is based on their - `grid_variable_number` property - - Args: - oldname: - old name of the grid variable - newname: - new name of the grid variable - """ - - try: - self.grid_options["_grid_variables"][newname] = self.grid_options[ - "_grid_variables" - ].pop(oldname) - self.grid_options["_grid_variables"][newname]["name"] = newname - verbose_print( - "Rename grid variable: {} to {}".format(oldname, newname), - self.grid_options["verbosity"], - 1, - ) - except: - msg = "Failed to rename grid variable {} to {}.".format(oldname, newname) - raise ValueError(msg) - - def add_grid_variable( - self, - name: str, - parameter_name: str, - longname: str, - valuerange: Union[list, str], - samplerfunc: str, - probdist: str, - dphasevol: Union[str, int], - gridtype: str = "centred", - branchpoint: int = 0, - branchcode: Union[str, None] = None, - precode: Union[str, None] = None, - postcode: Union[str, None] = None, - topcode: Union[str, None] = None, - bottomcode: Union[str, None] = None, - condition: Union[str, None] = None, - ) -> None: - """ - Function to add grid variables to the grid_options. - - The execution of the grid generation will be through a nested for loop. - Each of the grid variables will get create a deeper for loop. - - The real function that generates the numbers will get written to a new file in the TMP_DIR, - and then loaded imported and evaluated. - beware that if you insert some destructive piece of code, it will be executed anyway. - Use at own risk. - - Tasks: - - TODO: Fix this complex function. - - Args: - name: - name of parameter used in the grid Python code. - This is evaluated as a parameter and you can use it throughout - the rest of the function - - Examples: - name = 'lnm1' - - parameter_name: - name of the parameter in binary_c - - This name must correspond to a Python variable of the same name, - which is automatic if parameter_name == name. - - Note: if parameter_name != name, you must set a - variable in "precode" or "postcode" to define a Python variable - called parameter_name - - longname: - Long name of parameter - - Examples: - longname = 'Primary mass' - range: - Range of values to take. Does not get used really, the samplerfunc is used to - get the values from - - Examples: - range = [math.log(m_min), math.log(m_max)] - samplerfunc: - Function returning a list or numpy array of samples spaced appropriately. - You can either use a real function, or a string representation of a function call. - - Examples: - samplerfunc = "const(math.log(m_min), math.log(m_max), {})".format(resolution['M_1']) - - precode: - Extra room for some code. This code will be evaluated within the loop of the - sampling function (i.e. a value for lnm1 is chosen already) - - Examples: - precode = 'M_1=math.exp(lnm1);' - postcode: - Code executed after the probability is calculated. - probdist: - Function determining the probability that gets assigned to the sampled parameter - - Examples: - probdist = 'Kroupa2001(M_1)*M_1' - dphasevol: - part of the parameter space that the total probability is calculated with. Put to -1 - if you want to ignore any dphasevol calculations and set the value to 1 - Examples: - dphasevol = 'dlnm1' - condition: - condition that has to be met in order for the grid generation to continue - Examples: - condition = 'self.grid_options['binary']==1' - gridtype: - Method on how the value range is sampled. Can be either 'edge' (steps starting at - the lower edge of the value range) or 'centred' - (steps starting at lower edge + 0.5 * stepsize). - - topcode: - Code added at the very top of the block. - - bottomcode: - Code added at the very bottom of the block. - """ - - # Add grid_variable - grid_variable = { - "name": name, - "parameter_name": parameter_name, - "longname": longname, - "valuerange": valuerange, - # "resolution": 0, - "samplerfunc": samplerfunc, - "precode": precode, - "postcode": postcode, - "probdist": probdist, - "dphasevol": dphasevol, - "condition": condition, - "gridtype": gridtype, - "branchpoint": branchpoint, - "branchcode": branchcode, - "topcode": topcode, - "bottomcode": bottomcode, - "grid_variable_number": len(self.grid_options["_grid_variables"]), - } - - # Check for gridtype input - if not gridtype in [ - "edge", - "right", - "right edge", - "left", - "left edge", - "centred", - "centre", - "center", - ]: - msg = "Unknown gridtype value. Please start another one" - raise ValueError(msg) - - # Load it into the grid_options - self.grid_options["_grid_variables"][grid_variable["name"]] = grid_variable - - verbose_print( - "Added grid variable: {}".format(json.dumps(grid_variable, indent=4)), - self.grid_options["verbosity"], - 1, - ) + return argline ################################################### # Return functions @@ -654,15 +529,6 @@ class Population: return options - def return_binary_c_version_info(self, parsed=False): - """ - Function that returns the version information of binary_c - """ - - version_info = return_binary_c_version_info(parsed=parsed) - - return version_info - def return_binary_c_defaults(self): """ Function that returns the defaults of the binary_c version that is used. @@ -710,7 +576,7 @@ class Population: all_info["binary_c_defaults"] = binary_c_defaults if include_binary_c_version_info: - binary_c_version_info = return_binary_c_version_info(parsed=True) + binary_c_version_info = self.return_binary_c_version_info(parsed=True) all_info["binary_c_version_info"] = binary_c_version_info if include_binary_c_help_all: @@ -727,14 +593,13 @@ class Population: include_binary_c_defaults: bool = True, include_binary_c_version_info: bool = True, include_binary_c_help_all: bool = True, + ensure_ascii: str = False, + indent: int = 4, ) -> Union[str, None]: """ Function that exports the all_info to a JSON file Tasks: - - TODO: if any of the values in the dicts here is of a not-serialisable form, then we - need to change that to a string or something so, use a recursive function that - goes over the all_info dict and finds those that fit - TODO: Fix to write things to the directory. which options do which etc - TODO: there's flawed logic here. rewrite this part pls - TODO: consider actually just removing the whole 'output to file' part and let the @@ -754,6 +619,9 @@ class Population: <custom_options["base_filename"]>_settings.json. Otherwise a file called simulation_<date+time>_settings.json will be created outfile: if use_datadir is false, a custom filename will be used + ensure_ascii: the ensure_ascii flag passed to json.dump and/or json.dumps + (Default: False) + indent: indentation passed to json.dump and/or json.dumps (default 4) """ all_info = self.return_all_info( @@ -769,17 +637,14 @@ class Population: if use_datadir: if self.custom_options.get("data_dir", None): if not self.custom_options.get("base_filename", None): - base_name = "simulation_{}".format( - datetime.datetime.strftime( - datetime.datetime.now(), "%Y%m%d_%H%M%S" - ) - ) + base_name = "simulation_{}".format(now(style="nospace")) else: base_name = os.path.splitext(self.custom_options["base_filename"])[ 0 ] - settings_name = base_name + "_settings.json" + # save settings as gzipped JSON + settings_name = base_name + "_settings.json.gz" # Check directory, make if necessary os.makedirs(self.custom_options["data_dir"], exist_ok=True) @@ -788,184 +653,96 @@ class Population: self.custom_options["data_dir"], settings_name ) - verbose_print( - "Writing settings to {}".format(settings_fullname), - self.grid_options["verbosity"], - 1, - ) - # if not outfile.endswith('json'): - with open(settings_fullname, "w") as file: - file.write( - json.dumps( - all_info_cleaned, - indent=4, - default=binaryc_json_serializer, - ) + print("ok") + + # open locked settings file, then output if we get the lock + (f, lock) = self.locked_open_for_write(settings_fullname, vb=True) + print("ok") + + if lock and f: + self.verbose_print( + "Writing settings to {}".format(settings_fullname), + self.grid_options["verbosity"], + 1, ) + json.dump( + all_info_cleaned, + f, + indent=indent, + default=binaryc_json_serializer, + ensure_ascii=ensure_ascii, + ) + print("ok pre") + self.locked_close(f, lock) + print("ok ret") return settings_fullname - else: - msg = "Exporting all info without passing a value for `outfile` requires custom_options['data_dir'] to be present. That is not the cause. Either set the `data_dir` or pass a value for `outfile` " - raise ValueError + + # TODO: turn it around and have the exception be within the if statement + msg = "Exporting all info without passing a value for `outfile` requires custom_options['data_dir'] to be present. That is not the cause. Either set the `data_dir` or pass a value for `outfile` " + raise ValueError(msg) else: - verbose_print( + self.verbose_print( "Writing settings to {}".format(outfile), self.grid_options["verbosity"], 1, ) if not outfile.endswith("json"): - verbose_print( + self.verbose_print( "Error: outfile ({}) must end with .json".format(outfile), self.grid_options["verbosity"], 0, ) raise ValueError - with open(outfile, "w") as file: - file.write( - json.dumps( - all_info_cleaned, indent=4, default=binaryc_json_serializer - ) + with self.open(outfile, "w") as file: + json.dump( + all_info_cleaned, + file, + indent=indent, + default=binaryc_json_serializer, + ensure_ascii=ensure_ascii, ) return outfile - def _boxed(self, *list, colour="yellow on black", boxchar="*", separator="\n"): - """ - Function to output a list of strings in a single box. - - Args: - list = a list of strings to be output. If these contain the separator - (see below) these strings are split by it. - separator = strings are split on this, default "\n" - colour = the colour to be used, usually this is 'yellow on black' - as set in the ANSI_colours dict - boxchar = the character used to make the box, '*' by default - - Note: handles tabs (\t) badly, do not use them! - """ - strlen = 0 - strings = [] - lengths = [] - - # make a list of strings - if separator: - for l in list: - strings += l.split(sep=separator) - else: - strings = list - - # get lengths without ANSI codes - for string in strings: - lengths.append(len(strip_ansi.strip_ansi(string))) - - # hence the max length - strlen = max(lengths) - strlen += strlen % 2 - header = boxchar * (4 + strlen) - - # start output - out = self.ANSI_colours[colour] + header + "\n" - - # loop over strings to output, padding as required - for n, string in enumerate(strings): - if lengths[n] % 2 == 1: - string = " " + string - pad = " " * int((strlen - lengths[n]) / 2) - out = out + boxchar + " " + pad + string + pad + " " + boxchar + "\n" - # close output and return - out = out + header + "\n" + self.ANSI_colours["reset"] - return out - - def _set_custom_logging(self): - """ - Function/routine to set all the custom logging so that the function memory pointer - is known to the grid. + ################################################### + # Evolution functions + ################################################### - When the memory adress is loaded and the library file is set we'll skip rebuilding the library + def _set_nprocesses(self): """ + Function to set the number of processes used in multiprocessing. - # Only if the values are the 'default' unset values - if ( - self.grid_options["custom_logging_func_memaddr"] == -1 - and self.grid_options["_custom_logging_shared_library_file"] is None - ): - verbose_print( - "Creating and loading custom logging functionality", - self.grid_options["verbosity"], - 1, - ) - # C_logging_code gets priority of C_autogen_code - if self.grid_options["C_logging_code"]: - # Generate entire shared lib code around logging lines - custom_logging_code = binary_c_log_code( - self.grid_options["C_logging_code"], - verbosity=self.grid_options["verbosity"] - - (_CUSTOM_LOGGING_VERBOSITY_LEVEL - 1), - ) - - # Load memory address - ( - self.grid_options["custom_logging_func_memaddr"], - self.grid_options["_custom_logging_shared_library_file"], - ) = create_and_load_logging_function( - custom_logging_code, - verbosity=self.grid_options["verbosity"] - - (_CUSTOM_LOGGING_VERBOSITY_LEVEL - 1), - custom_tmp_dir=self.grid_options["tmp_dir"], - ) - - elif self.grid_options["C_auto_logging"]: - # Generate real logging code - logging_line = autogen_C_logging_code( - self.grid_options["C_auto_logging"], - verbosity=self.grid_options["verbosity"] - - (_CUSTOM_LOGGING_VERBOSITY_LEVEL - 1), - ) + If grid_options['num_cores'] <= 0, set automatically - # Generate entire shared lib code around logging lines - custom_logging_code = binary_c_log_code( - logging_line, - verbosity=self.grid_options["verbosity"] - - (_CUSTOM_LOGGING_VERBOSITY_LEVEL - 1), - ) + If grid_options['num_cores'] is 0, we use as many as we have available + """ + # backwards compatibility + if "amt_cores" in self.grid_options: + self.grid_options["num_processes"] = self.grid_options["amt_cores"] + self.grid_options["num_cores"] = self.grid_options["amt_cores"] - # Load memory address - ( - self.grid_options["custom_logging_func_memaddr"], - self.grid_options["_custom_logging_shared_library_file"], - ) = create_and_load_logging_function( - custom_logging_code, - verbosity=self.grid_options["verbosity"] - - (_CUSTOM_LOGGING_VERBOSITY_LEVEL - 1), - custom_tmp_dir=self.grid_options["tmp_dir"], - ) + if self.grid_options["num_cores"] == 0: + # use all logical cores available to us + self.grid_options["num_processes"] = max(1, psutil.cpu_count(logical=True)) + elif self.grid_options["num_cores"] == -1: + # use all physical cores available to us + self.grid_options["num_processes"] = max(1, psutil.cpu_count(logical=False)) else: - verbose_print( - "Custom logging library already loaded. Not setting them again.", - self.grid_options["verbosity"], - 1, - ) - - ################################################### - # Ensemble functions - ################################################### - - # Now they are stored in the _process_run_population thing. - # Needed less code since they all - - ################################################### - # Evolution functions - ################################################### + # manually specify number of cores made available + self.grid_options["num_processes"] = self.grid_options["num_cores"] - def _pre_run_cleanup(self) -> None: + def _pre_run_setup(self) -> None: """ Function to clean up some stuff in the grid before a run (like results, ensemble results etc) """ # empty results - self.grid_options["results"] = {} self.grid_results = AutoVivificationDict() - self.grid_ensemble_results = {} + self.grid_ensemble_results = self._new_grid_ensemble_results() + + # set number of processes/cores we want to use + self._set_nprocesses() # Reset the process ID (should not have a value initially, but can't hurt if it does) self.process_ID = 0 @@ -978,7 +755,6 @@ class Population: # set previous logging time _t = time.time() - self.shared_memory["prev_log_time"] = multiprocessing.Array( "d", [_t] * self.grid_options["n_logging_stats"] ) @@ -990,85 +766,167 @@ class Population: # arrays to store memory and max memory use per-thread mem = 1.0 * mem_use() - self.shared_memory["memory_use_per_thread"] = multiprocessing.Array( - "d", [mem] * self.grid_options["num_cores"] - ) - self.shared_memory["max_memory_use_per_thread"] = multiprocessing.Array( - "d", [mem] * self.grid_options["num_cores"] - ) + for x in ["", "max_"]: + self.shared_memory[x + "memory_use_per_thread"] = multiprocessing.Array( + "d", [mem] * self.grid_options["num_processes"] + ) + + ############################################################ + # set and check default directory locations + ############################################################ + + # check tmp_dir exists + if self.grid_options["tmp_dir"] is None or not os.path.isdir( + self.grid_options["tmp_dir"] + ): + print( + "grid_options['tmp_dir'] is not set or it is not a directory : this should point to a temporary directory location, preferably local to your CPUs" + ) + self.exit(code=1) + + # check any HPC requirements are met + if self.HPC_job() and not self.HPC_check_requirements()[0]: + print(self.HPC_check_requirements()[1]) + self.exit(code=1) + + # default status_dir and cache_dir to be in tmp_dir + # + # NOTE: binary_c-python uses its own status_dir, which is not + # the same dir as HPC jobs use (so tmp_dir can be local + # to an HPC job, while the HPC status dir is common to + # all jobs) + for x in ["status", "cache"]: + if self.grid_options[x + "_dir"] is None: + self.grid_options[x + "_dir"] = os.path.join( + self.grid_options["tmp_dir"], x + ) + + # make list of directories we want to use + dirs = ["tmp_dir", "status_dir", "cache_dir"] + self.HPC_dirs() + + for dir in dirs: + # try to make directories if they don't exist + path = self.grid_options[dir] + if path is not None: + os.makedirs(path, exist_ok=True) + + # check directories exist and can be written to + if path is not None and self.dir_ok(path) is False: + print( + "Directory {dir} currently set to {path} cannot be written to. Please check that this directory is correct and you have write access.".format( + dir=dir, path=path + ) + ) + self.exit(code=1) + + # Make sure the subdirs of the tmp dir exist + subdirs = [ + "failed_systems", + "process_summary", + "runtime_systems", + "snapshots", + ] + for subdir in subdirs: + path = os.path.join(self.grid_options["tmp_dir"], subdir) + os.makedirs(path, exist_ok=True) + if self.dir_ok(path) is False: + print( + "Sub-Directory {subdir} (in tmp_dir) currently set to {path} cannot be written to. Please check that this directory is correct and you have write access.".format( + subdir=subdir, path=path + ) + ) + self.exit(code=1) + + # make sure the arg logging directory exists if we need it + if self.grid_options["log_args"]: + path = os.path.join( + self.grid_options["log_args_dir"] + ) + os.makedirs(path, exist_ok=True) + if self.dir_ok(path) is False: + print( + "Failed to make directory at {log_args_dir} for output of system arguments. Please check that this directory is correct and you have write access.".format( + subdir=subdir, path=path + ) + ) + self.exit(code=1) + + # restore from existing HPC files + self.HPC_restore() + + # set up function cache + self.setup_function_cache() + + return def clean(self) -> None: """ Clean the contents of the population object so it can be reused. - Calling _pre_run_cleanup() + Calling _pre_run_setup() TODO: decide to deprecate this function """ - self._pre_run_cleanup() + self._pre_run_setup() def evolve(self) -> None: """ Entry point function of the whole object. From here, based on the settings, - we set up a SLURM or CONDOR grid, or if no setting is given we go straight - to evolving the population. - - There are no direct arguments to this function, rather it is based on the grid_options settings: - grid_options['slurm']: integer Boolean whether to use a slurm_grid evolution - grid_options['condor']: integer Boolean whether to use a condor_grid evolution - - If neither of the above is set, we continue without using HPC routines - (that doesn't mean this cannot be run on a server with many cores) + we set up a grid and (probably) evolve the population. - Returns an dictionary containing the analytics of the run + There are no direct arguments to this function, the grid_options + contain all the relevant settings. - TODO: change the way this is done. Slurm & CONDOR should probably do this differently - NOTE: SLURM and CONDOR options are not working properly yet + Returns: + a dictionary containing the analytics of the run. """ # Just to make sure we don't have stuff from a previous run hanging around - self._pre_run_cleanup() - - # Check which type: - if self.grid_options["slurm"] == 1: - # Execute Slurm subroutines - # self._slurm_grid() - raise ValueError("Slurm evolution not available at this moment") - - elif self.grid_options["condor"] == 1: - # Execute condor subroutines - # self._condor_grid() - raise ValueError("Condor evolution not available at this moment") - - else: - # Execute population evolution subroutines - self._evolve_population() - - # Put all interesting stuff in a variable and output that afterwards, as analytics of the run. - analytics_dict = { - "population_name": self.grid_options["_population_id"], - "evolution_type": self.grid_options["evolution_type"], - "failed_count": self.grid_options["_failed_count"], - "failed_prob": self.grid_options["_failed_prob"], - "failed_systems_error_codes": self.grid_options[ - "_failed_systems_error_codes" - ].copy(), - "errors_exceeded": self.grid_options["_errors_exceeded"], - "errors_found": self.grid_options["_errors_found"], - "total_probability": self.grid_options["_probtot"], - "total_count": self.grid_options["_count"], - "start_timestamp": self.grid_options["_start_time_evolution"], - "end_timestamp": self.grid_options["_end_time_evolution"], - "total_mass_run": self.grid_options["_total_mass_run"], - "total_probability_weighted_mass_run": self.grid_options[ - "_total_probability_weighted_mass_run" - ], - "zero_prob_stars_skipped": self.grid_options["_zero_prob_stars_skipped"], - } - - # Add analytics dict to the metadata too: - self.grid_ensemble_results["metadata"].update(analytics_dict) + self._pre_run_setup() + + if self.HPC_job(): + # run HPC grid: if this returns True, then exit immediately + self.grid_options["symlink_latest_gridcode"] = False + if self.HPC_grid(): + self.exit(code=0) + + if self.grid_options["evolution_type"] == "join": + # join previously calculated data and return immediately + self.HPC_join_previous() + return + + # Execute population evolution subroutines + self._evolve_population() + + # make analytics information + analytics_dict = self.make_analytics_dict() + + if self.HPC_job(): + self.HPC_dump_status("HPC grid after analytics") + + if self.custom_options["save_snapshot"]: + # we must save a snapshot, not the population object + # ... also save the new starting point: this has to take into + # account where we originally started, and that the modulo may + # not be == 1. + self.grid_options["start_at"] = ( + self.grid_options["start_at"] + + self.grid_options["_count"] * self.grid_options["modulo"] + ) + # then save the snapshot + self.save_snapshot() + exitcode = 1 if self.was_killed() else 0 + self.exit(code=exitcode) + + # Save object to a pickle file + elif self.grid_options["save_population_object"]: + self.save_population_object() + + # if we're running an HPC grid, exit here + # unless we're joining + if self.HPC_job() and self.grid_options["evolution_type"] != "join": + self.exit() ## # Clean up code: remove files, unset values, unload interpolators etc. This is placed in the general evolve function, @@ -1090,22 +948,20 @@ class Population: - TODO: include options for different ways of generating a population here. (i.e. MC or source file) """ - ## + ############################################################ # Prepare code/initialise grid. # set custom logging, set up store_memaddr, build grid code. dry run grid code. - self._setup() + if self._setup() is False: + return - ## - # Evolve systems: via grid_options one can choose to do this linearly, or - # multiprocessing method. + ############################################################ + # Evolve systems + self.set_time("start") if ( self.grid_options["evolution_type"] in self.grid_options["_evolution_type_options"] ): - if self.grid_options["evolution_type"] == "grid": - self._evolve_population_grid() - elif self.grid_options["evolution_type"] == "custom_generator": - # Use the same as the normal grid evolution but just a different generator + if self.grid_options["evolution_type"] in ["grid", "custom_generator"]: self._evolve_population_grid() # elif self.grid_options["evolution_type"] == "mc": @@ -1117,30 +973,40 @@ class Population: self.grid_options["_evolution_type_options"] ) ) + self.set_time("end") - # finished! - self.grid_options["_end_time_evolution"] = time.time() - + ############################################################ # Log and print some information - dtsecs = ( - self.grid_options["_end_time_evolution"] - - self.grid_options["_start_time_evolution"] - ) string1 = "Population-{} finished!\nThe total probability is {:g}.".format( self.grid_options["_population_id"], self.grid_options["_probtot"] ) - string2 = "It took a total of {dtsecs} to run {starcount} systems on {ncores} cores\n = {totaldtsecs} of CPU time.\nMaximum memory use {memuse:.3f} MB".format( - dtsecs=timedelta(dtsecs), - starcount=self.grid_options["_total_starcount"], - ncores=self.grid_options["num_cores"], - totaldtsecs=timedelta(dtsecs * self.grid_options["num_cores"]), + string2 = "It took a total of {dtsecs} to run {starcount} systems on {ncores} cores\n = {CPUtime} of CPU time.\nMaximum memory use {memuse:.3f} MB".format( + dtsecs=timedelta(self.grid_options["_time_elapsed"]), + starcount=self.grid_options[ + "_count" + ], # not _total_count! we may have ended the run early... + ncores=self.grid_options["num_processes"], + CPUtime=timedelta(self.CPU_time()), memuse=sum(self.shared_memory["max_memory_use_per_thread"]), ) - verbose_print(self._boxed(string1, string2), self.grid_options["verbosity"], 0) + ############################################################ + # add warning about a grid that was killed + ############################################################ + if self.was_killed(): + string2 += "\n>>> Grid was killed <<<" + self.set_status("killed") + + self.verbose_print( + self._boxed(string1, string2), self.grid_options["verbosity"], 0 + ) + + ############################################################ + # handle errors + ############################################################ if self.grid_options["_errors_found"]: # Some information afterwards - verbose_print( + self.verbose_print( self._boxed( "During the run {} failed systems were found\nwith a total probability of {:g}\nwith the following unique error codes: {} ".format( self.grid_options["_failed_count"], @@ -1152,7 +1018,7 @@ class Population: 0, ) # Some information afterwards - verbose_print( + self.verbose_print( "The full argline commands for {} these systems have been written to {}".format( "ALL" if not self.grid_options["_errors_exceeded"] @@ -1168,36 +1034,26 @@ class Population: 0, ) else: - verbose_print( - "There were no errors found in this run.", + self.verbose_print( + "No failed systems were found in this run.", self.grid_options["verbosity"], 0, ) - def _get_stream_logger(self, level=logging.DEBUG): - """Return logger with configured StreamHandler.""" - stream_logger = logging.getLogger("stream_logger") - stream_logger.handlers = [] - stream_logger.setLevel(level) - sh = logging.StreamHandler() - sh.setLevel(level) - fmt = "[%(asctime)s %(levelname)-8s %(processName)s] --- %(message)s" - formatter = logging.Formatter(fmt) - sh.setFormatter(formatter) - stream_logger.addHandler(sh) - - return stream_logger - - def _system_queue_filler(self, job_queue, num_cores): + return + + def _system_queue_filler(self, job_queue, num_processes): """ Function that is responsible for keeping the queue filled. This will generate the systems until it is full, and then keeps trying to fill it. Will have to play with the size of this. + + This function is called as part of the parent process. """ stream_logger = self._get_stream_logger() - if self.grid_options["verbosity"] >= _LOGGER_VERBOSITY_LEVEL: + if self.grid_options["verbosity"] >= self._LOGGER_VERBOSITY_LEVEL: stream_logger.debug(f"setting up the system_queue_filler now") # Setup of the generator @@ -1213,35 +1069,73 @@ class Population: self, print_results=False ) - # TODO: build in method to handle with the HPC. - # Continuously fill the queue + # start_at can be an expression : we should eval it + # prior to running the loop + self.grid_options["start_at"] = eval(str(self.grid_options["start_at"])) + if self.grid_options["start_at"] > 0: + print("Starting at model {} ".format(self.grid_options["start_at"])) + + # Continuously fill the queue while we are allowed to for system_number, system_dict in enumerate(generator): + if self.grid_options["stop_queue"]: + break + + # skip systems before start_at + elif system_number < self.grid_options["start_at"]: + self.verbose_print( + "skip system {n} because < start_at = {start}".format( + n=system_number, start=self.grid_options["start_at"] + ), + self.grid_options["verbosity"], + 3, + ) + continue - # skip systems before start_at, and apply modulo + # apply modulo if not ( - system_number >= self.grid_options["start_at"] - and (system_number - self.grid_options["start_at"]) + (system_number - self.grid_options["start_at"]) % self.grid_options["modulo"] == 0 ): + self.verbose_print( + "skip system {n} because modulo {mod} == {donemod}".format( + n=system_number, + mod=self.grid_options["modulo"], + donemod=(system_number - self.grid_options["start_at"]) + % self.grid_options["modulo"], + ), + self.grid_options["verbosity"], + 3, + ) + continue # Put job in queue - job_queue.put((system_number, system_dict)) - - # Print some info - verbose_print( - "Queue produced system {}".format(system_number), - self.grid_options["verbosity"], - 3, - ) + if self.grid_options["stop_queue"]: + break + else: + try: + job_queue.put((system_number, system_dict), block=True) + except Exception as e: + # error on queueing : stop the queue + self.grid_options["stop_queue"] = True + + # Print some info + self.verbose_print( + "Queue produced system {}".format(system_number), + self.grid_options["verbosity"], + 3, + ) + + self.grid_options["_queue_done"] = True # Send closing signal to workers. When they receive this they will terminate - if self.grid_options["verbosity"] >= _LOGGER_VERBOSITY_LEVEL: - stream_logger.debug(f"Signaling stop to processes") # DEBUG + if self.grid_options["verbosity"] >= self._LOGGER_VERBOSITY_LEVEL: + stream_logger.debug(f"Signalling processes to stop") # DEBUG - for _ in range(num_cores): - job_queue.put("STOP") + if True: # not self.grid_options['stop_queue']: + for _ in range(num_processes): + job_queue.put("STOP") def _evolve_population_grid(self): """ @@ -1249,7 +1143,7 @@ class Population: First we set up the multiprocessing manager and the job and result queue. - Then we spawn <self.grid_options["num_cores"]> number of process instances, + Then we spawn <self.grid_options["num_processes"]> number of process instances, and signal them to start. While the processes are waiting for their instructions, we start the queue filler, @@ -1260,25 +1154,35 @@ class Population: When all the systems have been put in the queue we pass a STOP signal that will make the processes wrap up. + We then add any previous population + We read out the information in the result queue and store them in the grid object """ # Set process name setproctitle.setproctitle("binarycpython parent process") + # if max_queue_size is zero, calculate automatically + # to be double the number of processes - you don't want to + # make the queue too large because when it's killed you + # want to end quickly + if self.grid_options["max_queue_size"] == 0: + self.grid_options["max_queue_size"] = 2 * self.grid_options["num_processes"] + # Set up the manager object that can share info between processes manager = multiprocessing.Manager() job_queue = manager.Queue(maxsize=self.grid_options["max_queue_size"]) + result_queue = manager.Queue(maxsize=self.grid_options["num_processes"]) - # backwards compatibility - if "amt_cores" in self.grid_options: - self.grid_options["num_cores"] = self.grid_options["amt_cores"] - - result_queue = manager.Queue(maxsize=self.grid_options["num_cores"]) + # data to be sent to signal handlers + signal_data = { + "where": "_evolve_population_grid", + "queue": job_queue, + } - # Create process instances + # Create process instances to run the stars processes = [] - for ID in range(self.grid_options["num_cores"]): + for ID in range(self.grid_options["num_processes"]): processes.append( multiprocessing.Process( target=self._process_run_population_grid, @@ -1290,34 +1194,102 @@ class Population: for p in processes: p.start() - # Set up the system_queue - self._system_queue_filler(job_queue, num_cores=self.grid_options["num_cores"]) + # activate signal handlers + # * the child processes ignore these signals + # * the parent will be in _system_queue_filler when these are caught + signal.signal( + signal.SIGTERM, functools.partial(self._parent_signal_handler, signal_data) + ) + signal.signal( + signal.SIGINT, functools.partial(self._parent_signal_handler, signal_data) + ) + + # Set up the system_queue in the parent process + self._system_queue_filler( + job_queue, num_processes=self.grid_options["num_processes"] + ) # Join the processes + print("Do join of subprocesses ...") for p in processes: p.join() + print("Joined subprocesses.") + + # todo: error codes # Handle the results by merging all the dictionaries. How that merging happens exactly is # described in the merge_dicts description. - combined_output_dict = OrderedDict() + # + # If there is a preloaded_population, we add this first, + # then we add the populations run just now + + # 1) + # use preloaded population's data as a basis + # for our combined_output_dict + if self.preloaded_population: + combined_output_dict = { + "ensemble_results": keys_to_floats( + self.preloaded_population.grid_ensemble_results + ), + "results": keys_to_floats(self.preloaded_population.grid_results), + } + + for x in self._metadata_keylist(): + try: + combined_output_dict[x] = self.preloaded_population.grid_options[x] + except Exception as e: + print( + "Tried to set combined_output_dict key", + x, + "from preloaded_popuation, but this failed:", + e, + ) + print( + "Pre-loaded data from {} stars".format(combined_output_dict["_count"]) + ) + # do not propagate _killed + # combined_output_dict['results']['_killed'] = False + # combined_output_dict['_killed'] = False + + self.preloaded_population = None + gc.collect() + else: + # new empty combined output + combined_output_dict = OrderedDict() + combined_output_dict["ensemble_results"] = OrderedDict() + combined_output_dict["results"] = OrderedDict() + + # 2) + # combine the dicts that were output from our + # subprocesses sentinel = object() for output_dict in iter(result_queue.get, sentinel): - combined_output_dict = merge_dicts(combined_output_dict, output_dict) + if output_dict: + # don't let Xinit be added + if ( + "ensemble_results" in combined_output_dict + and "ensemble" in combined_output_dict["ensemble_results"] + and "Xinit" in combined_output_dict["ensemble_results"]["ensemble"] + ): + del combined_output_dict["ensemble_results"]["ensemble"]["Xinit"] + + # merge dicts + combined_output_dict = merge_dicts( + combined_output_dict, keys_to_floats(output_dict) + ) if result_queue.empty(): break # Extra ensemble result manipulation: - combined_output_dict["ensemble_results"]["ensemble"] = format_ensemble_results( - combined_output_dict["ensemble_results"].get("ensemble", {}) - ) + if "ensemble_results" in combined_output_dict: + combined_output_dict["ensemble_results"][ + "ensemble" + ] = format_ensemble_results( + combined_output_dict["ensemble_results"].get("ensemble", {}) + ) gc.collect() - # Take into account that we run this on multiple cores - combined_output_dict[ - "_total_probability_weighted_mass_run" - ] = combined_output_dict["_total_probability_weighted_mass_run"] - # Put the values back as object properties self.grid_results = combined_output_dict["results"] @@ -1328,57 +1300,11 @@ class Population: ] # Ensemble results are also passed as output from that dictionary # Add metadata - self.grid_ensemble_results["metadata"] = {} - self.grid_ensemble_results["metadata"]["population_id"] = self.grid_options[ - "_population_id" - ] - self.grid_ensemble_results["metadata"][ - "total_probability_weighted_mass" - ] = combined_output_dict["_total_probability_weighted_mass_run"] - self.grid_ensemble_results["metadata"][ - "factored_in_probability_weighted_mass" - ] = False - if self.grid_options["ensemble_factor_in_probability_weighted_mass"]: - multiply_values_dict( - self.grid_ensemble_results["ensemble"], - 1 - / self.grid_ensemble_results["metadata"][ - "total_probability_weighted_mass" - ], - ) - self.grid_ensemble_results["metadata"][ - "factored_in_probability_weighted_mass" - ] = True + self.add_ensemble_metadata(combined_output_dict) - # Add settings of the populations - all_info = self.return_all_info( - include_population_settings=True, - include_binary_c_defaults=True, - include_binary_c_version_info=True, - include_binary_c_help_all=True, - ) - self.grid_ensemble_results["metadata"]["settings"] = json.loads( - json.dumps(all_info, default=binaryc_json_serializer) - ) - - ############################## - # Update grid options - self.grid_options["_failed_count"] = combined_output_dict["_failed_count"] - self.grid_options["_failed_prob"] = combined_output_dict["_failed_prob"] - self.grid_options["_failed_systems_error_codes"] = list( - set(combined_output_dict["_failed_systems_error_codes"]) - ) - self.grid_options["_errors_exceeded"] = combined_output_dict["_errors_exceeded"] - self.grid_options["_errors_found"] = combined_output_dict["_errors_found"] - self.grid_options["_probtot"] = combined_output_dict["_probtot"] - self.grid_options["_count"] = combined_output_dict["_count"] - self.grid_options["_total_mass_run"] = combined_output_dict["_total_mass_run"] - self.grid_options[ - "_total_probability_weighted_mass_run" - ] = combined_output_dict["_total_probability_weighted_mass_run"] - self.grid_options["_zero_prob_stars_skipped"] = combined_output_dict[ - "_zero_prob_stars_skipped" - ] + # if we were killed, save snapshot + if self.grid_options["save_snapshots"] and self.grid_options["_killed"]: + self.custom_options["save_snapshot"] = True def _evolve_system_mp(self, full_system_dict): """ @@ -1418,6 +1344,84 @@ class Population: self.custom_options["parameter_dict"] = full_system_dict self.grid_options["parse_function"](self, out) + return + + def _parent_signal_handler(self, signal_data, signum, frame): + """ + Signal handling function for the parent process. + """ + + # this function is called by both queues when they + # catch a signal + sigstring = signal.Signals(signum).name + + if sigstring in self.signal_count: + self.signal_count[sigstring] += 1 + else: + self.signal_count[sigstring] = 1 + + if self.signal_count[sigstring] > 3: + print("caught > 3 times : exit") + self.exit(code=2) + + # tell the user what has happened + print( + "Parent signal {} caught (count {}) handler set in {} [ keys {} ]".format( + sigstring, + self.signal_count[sigstring], + signal_data["where"], + ",".join(signal_data.keys()), + ) + ) + + # set status files + self.set_status("signal {sig}".format(sig=sigstring)) + + if signum == signal.SIGINT: + # caught SIGINT: e.g. CTRL-C or HPC job manager + # shutting us down + print("Parent set stop_queue to True") + self.grid_options["stop_queue"] = True + self.custom_options["save_snapshot"] = True + self.grid_options["_killed"] = True + return + else: + # what to do? + return + + def _child_signal_handler(self, signal_data, signum, frame): + """ + Signal handler for child processes. + """ + sigstring = signal.Signals(signum).name + + if sigstring in self.signal_count: + self.signal_count[sigstring] += 1 + else: + self.signal_count[sigstring] = 1 + + # if we receive the signal three times, exit + if self.signal_count[sigstring] > 3: + print("caught > 3 times : exit") + self.exit(code=2) + + print( + "Child signal {} caught (count {}) handler set in {} [ keys {} ]".format( + sigstring, + self.signal_count[sigstring], + signal_data["where"], + ",".join(signal_data.keys()), + ) + ) + + # SIGINT should stop the queue nicely + if signum == signal.SIGINT: + self.grid_options["stop_queue"] = True + self.grid_options["_killed"] = True + + # propagate signal to parent + os.kill(self.grid_options["_main_pid"], signum) + def _process_run_population_grid(self, job_queue, result_queue, ID): """ Worker process that gets items from the job_queue and runs those systems. @@ -1430,43 +1434,46 @@ class Population: """ + # ignore SIGINT and SIGTERM : these are + # handled by our parent process (hence in + # _evolve_population_grid) + signal.signal( + signal.SIGTERM, + functools.partial( + self._child_signal_handler, {"where": "_process_run_population_grid"} + ), + ) + signal.signal( + signal.SIGINT, + functools.partial( + self._child_signal_handler, {"where": "_process_run_population_grid"} + ), + ) + # set start timer start_process_time = datetime.datetime.now() - # - self.process_ID = ( - ID # Store the ID as a object property again, lets see if that works. - ) + # set the process ID + self.process_ID = ID stream_logger = self._get_stream_logger() - if self.grid_options["verbosity"] >= _LOGGER_VERBOSITY_LEVEL: + if self.grid_options["verbosity"] >= self._LOGGER_VERBOSITY_LEVEL: stream_logger.debug(f"Setting up processor: process-{self.process_ID}") # Set the process names - name = "binarycpython population thread {}".format(ID) name_proc = "binarycpython population process {}".format(ID) setproctitle.setproctitle(name_proc) - # setproctitle.setthreadtitle(name) # Set to starting up - with open( - os.path.join( - self.grid_options["tmp_dir"], - "process_status", - "process_{}.txt".format(self.process_ID), - ), - "w", - ) as f: - f.write("STARTING") - f.close() + self.set_status("starting") # lets try out making stores for all the grids: self.grid_options["_store_memaddr"] = _binary_c_bindings.return_store_memaddr() - verbose_print( + self.verbose_print( "Process {} started at {}.\tUsing store memaddr {}".format( ID, - datetime.datetime.now().isoformat(), + now(), self.grid_options["_store_memaddr"], ), self.grid_options["verbosity"], @@ -1484,7 +1491,7 @@ class Population: self.process_ID: persistent_data_memaddr } - verbose_print( + self.verbose_print( "\tUsing persistent_data memaddr: {}".format(persistent_data_memaddr), self.grid_options["verbosity"], 3, @@ -1498,12 +1505,10 @@ class Population: 0 # counter for the probability of the actual systems this tread ran ) number_of_systems_run = ( - 0 # counter for the actual amt of systems this thread ran + 0 # counter for the actual number of systems this thread ran ) zero_prob_stars_skipped = 0 - total_time_calling_binary_c = 0 - total_mass_run = 0 total_probability_weighted_mass_run = 0 @@ -1514,23 +1519,24 @@ class Population: ) next_mem_update_time = start_grid_time + self.grid_options["log_dt"] + # Set status to running + self.set_status("running") + + ############################################################ + # Run stellar systems in the queue ############################################################ - # Go over the queue for system_number, system_dict in iter(job_queue.get, "STOP"): - # At the first system set the status of the thread to running - if localcounter == 0: - # Set status to running - with open( - os.path.join( - self.grid_options["tmp_dir"], - "process_status", - "process_{}.txt".format(self.process_ID), - ), - "w", - ) as f: - f.write("RUNNING") - f.close() + if False: + print( + "Child: Job Queue system_number = {}, dict={}, n={} check {}".format( + system_number, + system_dict, + number_of_systems_run, + self.grid_options["stop_queue"], + ) + ) + sys.stdout.flush() # Combine that with the other settings full_system_dict = self.bse_options.copy() @@ -1561,26 +1567,16 @@ class Population: ) raise ValueError(msg) - # self._print_info( - # i + 1, self.grid_options["_total_starcount"], full_system_dict - # ) - - # verbose_print( - # "Process {} is handling system {}".format(ID, system_number), - # self.grid_options["verbosity"], - # 1, - # ) - ###################### # Print status of runs # save the current time (used often) - now = time.time() + time_now = time.time() # update memory use stats every log_dt seconds (not every time, this is likely a bit expensive) - if now > next_mem_update_time: + if time_now > next_mem_update_time: m = mem_use() self.shared_memory["memory_use_per_thread"][ID] = m - next_mem_update_time = now + self.grid_options["log_dt"] + next_mem_update_time = time_now + self.grid_options["log_dt"] if m > self.shared_memory["max_memory_use_per_thread"][ID]: self.shared_memory["max_memory_use_per_thread"][ID] = m @@ -1591,16 +1587,16 @@ class Population: # Check if we need to log info again # TODO: Check if we can put this functionality elsewhere - if now > next_log_time: + if time_now > next_log_time: # we have exceeded the next log time : output and update timers # Lock the threads. TODO: Do we need to release this? lock = multiprocessing.Lock() # Do the printing itself - self.vb1print(ID, now, system_number, system_dict) + self.vb1print(ID, time_now, system_number, system_dict) # Set some values for next time - next_log_time = now + self.grid_options["log_dt"] + next_log_time = time_now + self.grid_options["log_dt"] # print("PREV ",self.shared_memory["prev_log_time"]) # print("N LOG STATS",self.shared_memory["n_saved_log_stats"].value) @@ -1618,7 +1614,7 @@ class Population: ] # set the current time and system number - self.shared_memory["prev_log_time"][0] = now + self.shared_memory["prev_log_time"][0] = time_now self.shared_memory["prev_log_system_number"][0] = system_number # increase the number of stats @@ -1637,16 +1633,17 @@ class Population: # that was on, we log each current system to a file (each thread has one). # Each new system overrides the previous if self.grid_options["log_args"]: - with open( - os.path.join( - self.grid_options["log_args_dir"], - "current_system", - "process_{}.txt".format(self.process_ID), - ), - "w", + argfile = os.path.join( + self.grid_options["log_args_dir"], + "process_{}.txt".format(self.jobID()), + ) + with self.open( + argfile, + "w", + encoding="utf-8", ) as f: - binary_cmdline_string = self._return_argline(full_system_dict) - f.write(binary_cmdline_string) + binary_c_cmdline_string = self._return_argline(full_system_dict) + f.write(binary_c_cmdline_string) f.close() ############## @@ -1678,13 +1675,14 @@ class Population: # Debug line: logging all the lines if self.grid_options["log_runtime_systems"] == 1: - with open( + with self.open( os.path.join( self.grid_options["tmp_dir"], "runtime_systems", "process_{}.txt".format(self.process_ID), ), "a+", + encoding="utf-8", ) as f: binary_cmdline_string = self._return_argline(full_system_dict) f.write( @@ -1716,19 +1714,22 @@ class Population: total_mass_system * full_system_dict.get("probability", 1) ) + if self.grid_options["stop_queue"]: + print("Child: Stop queue at system {n}".format(n=number_of_systems_run)) + break + + if self.grid_options["stop_queue"]: + # any remaining jobs should be ignored + try: + while True: + job_queue.get_nowait() + except queue.Empty: + pass + # Set status to finishing - with open( - os.path.join( - self.grid_options["tmp_dir"], - "process_status", - "process_{}.txt".format(self.process_ID), - ), - "w", - ) as f: - f.write("FINISHING") - f.close() + self.set_status("finishing") - if self.grid_options["verbosity"] >= _LOGGER_VERBOSITY_LEVEL: + if self.grid_options["verbosity"] >= self._LOGGER_VERBOSITY_LEVEL: stream_logger.debug(f"Process-{self.process_ID} is finishing.") ########################### @@ -1737,7 +1738,7 @@ class Population: # if ensemble==1, then either directly write that data to a file, or combine everything into 1 file. ensemble_json = {} # Make sure it exists already if self.bse_options.get("ensemble", 0) == 1: - verbose_print( + self.verbose_print( "Process {}: is freeing ensemble output (using persistent_data memaddr {})".format( ID, self.persistent_data_memory_dict[self.process_ID] ), @@ -1752,11 +1753,15 @@ class Population: ) if ensemble_raw_output is None: - verbose_print( + self.verbose_print( "Process {}: Warning! Ensemble output is empty. ".format(ID), self.grid_options["verbosity"], 1, ) + ensemble_output = None + else: + # convert ensemble_raw_output to a dictionary + ensemble_output = extract_ensemble_json_from_string(ensemble_raw_output) # save the ensemble chunk to a file if ( @@ -1770,7 +1775,7 @@ class Population: self.grid_options["_population_id"], self.process_ID ), ) - verbose_print( + self.verbose_print( "Writing process {} JSON ensemble chunk output to {} ".format( ID, output_file ), @@ -1779,26 +1784,20 @@ class Population: ) ensemble_output = extract_ensemble_json_from_string(ensemble_raw_output) - - ensemble_output = extract_ensemble_json_from_string(ensemble_raw_output) - self.write_ensemble(output_file, ensemble_output) # combine ensemble chunks if self.grid_options["combine_ensemble_with_thread_joining"] is True: - verbose_print( + self.verbose_print( "Process {}: Extracting ensemble info from raw string".format(ID), self.grid_options["verbosity"], 1, ) - - ensemble_json["ensemble"] = extract_ensemble_json_from_string( - ensemble_raw_output - ) # Load this into a dict so that we can combine it later + ensemble_json["ensemble"] = ensemble_output ########################## # Clean up and return - verbose_print( + self.verbose_print( "process {} free memory and return ".format(ID), self.grid_options["verbosity"], 1, @@ -1822,15 +1821,18 @@ class Population: "_total_mass_run": total_mass_run, "_total_probability_weighted_mass_run": total_probability_weighted_mass_run, "_zero_prob_stars_skipped": zero_prob_stars_skipped, + "_killed": self.grid_options["_killed"], } end_process_time = datetime.datetime.now() + killed = self.was_killed() + # thread end message colour = "cyan on black" - verbose_print( + self.verbose_print( self._boxed( - "{colour}Process {ID} finished:\ngenerator started at {start}\ngenerator finished at {end}\ntotal: {timesecs}\nof which {binary_c_secs} with binary_c\nRan {nsystems} systems\nwith a total probability of {psystems:g}\n{failcolour}This thread had {nfail} failing systems{colour}\n{failcolour}with a total failed probability of {pfail}{colour}\n{zerocolour}Skipped a total of {nzero} zero-probability systems{zeroreset}\n".format( + "{colour}Process {ID} finished:\ngenerator started at {start}\ngenerator finished at {end}\ntotal: {timesecs}\nof which {binary_c_secs} with binary_c\nRan {nsystems} systems\nwith a total probability of {psystems:g}\n{failcolour}This thread had {nfail} failing systems{colour}\n{failcolour}with a total failed probability of {pfail}{colour}\n{zerocolour}Skipped a total of {nzero} zero-probability systems{zeroreset}\n{failednotice}".format( colour=self.ANSI_colours[colour], ID=ID, start=start_process_time.isoformat(), @@ -1856,6 +1858,7 @@ class Population: zeroreset=self.ANSI_colours[colour] if zero_prob_stars_skipped > 0 else "", + failednotice=">>> Process was killed <<<\n" if killed else "", ), colour=colour, ), @@ -1879,44 +1882,35 @@ class Population: ], "zero_prob_stars_skipped": zero_prob_stars_skipped, } - with open( + with self.open( os.path.join( self.grid_options["tmp_dir"], "process_summary", "process_{}.json".format(self.process_ID), ), "w", + encoding="utf-8", ) as f: - f.write(json.dumps(summary_dict, indent=4)) - f.close() + json.dump(summary_dict, f, indent=4, ensure_ascii=False) # Set status to finished - with open( - os.path.join( - self.grid_options["tmp_dir"], - "process_status", - "process_{}.txt".format(self.process_ID), - ), - "w", - ) as f: - f.write("FINISHED") - f.close() + if self.was_killed(): + self.set_status("killed") + else: + self.set_status("finished") - verbose_print( + self.verbose_print( "process {} queue put output_dict ".format(ID), self.grid_options["verbosity"], 1, ) + result_queue.put(output_dict) - if self.grid_options["verbosity"] >= _LOGGER_VERBOSITY_LEVEL: + if self.grid_options["verbosity"] >= self._LOGGER_VERBOSITY_LEVEL: stream_logger.debug(f"Process-{self.process_ID} is finished.") - # Don't do this : Clean up the interpolators if they exist - - # TODO: make a cleanup function for the individual threads - # TODO: make sure this is necessary. Actually its probably not, because we have a centralised queue - verbose_print( + self.verbose_print( "process {} return ".format(ID), self.grid_options["verbosity"], 1, @@ -1946,7 +1940,7 @@ class Population: # Get argument line and argline = self._return_argline(self.bse_options) - verbose_print( + self.verbose_print( "Running {}".format(argline), self.grid_options["verbosity"], 1 ) @@ -1984,6 +1978,10 @@ class Population: Since we have different methods of running a population, this setup function will do different things depending on different settings + Returns: + True if we want to continue. + False if we should return to the original calling script. + Tasks: TODO: Make other kinds of populations possible. i.e, read out type of grid, and set up accordingly @@ -1991,22 +1989,9 @@ class Population: function """ - # Make sure the subdirs of the tmp dir exist: - os.makedirs( - os.path.join(self.grid_options["tmp_dir"], "failed_systems"), exist_ok=True - ) - os.makedirs( - os.path.join(self.grid_options["tmp_dir"], "current_system"), exist_ok=True - ) - os.makedirs( - os.path.join(self.grid_options["tmp_dir"], "process_status"), exist_ok=True - ) - os.makedirs( - os.path.join(self.grid_options["tmp_dir"], "process_summary"), exist_ok=True - ) - os.makedirs( - os.path.join(self.grid_options["tmp_dir"], "runtime_systems"), exist_ok=True - ) + # Check for restore + if self.grid_options["restore_from_snapshot_file"]: + self.load_snapshot(self.grid_options["restore_from_snapshot_file"]) # Check for parse function if not self.grid_options["parse_function"]: @@ -2020,24 +2005,25 @@ class Population: ## check the settings and set all the warnings. if self.bse_options.get("ensemble", None): if not self.bse_options.get("ensemble_defer", 0) == 1: - verbose_print( + self.verbose_print( "Error, if you want to run an ensemble in a population, the output needs to be deferred. Please set 'ensemble_defer' to 1", self.grid_options["verbosity"], 0, ) + print("BSE",self.bse_options) raise ValueError if not any( [key.startswith("ensemble_filter_") for key in self.bse_options] ): - verbose_print( + self.verbose_print( "Warning: Running the ensemble without any filter requires a lot of available RAM", self.grid_options["verbosity"], 0, ) if self.bse_options.get("ensemble_filters_off", 0) != 1: - verbose_print( + self.verbose_print( "Warning: Running the ensemble without any filter requires a lot of available RAM", self.grid_options["verbosity"], 0, @@ -2045,7 +2031,7 @@ class Population: if self.grid_options["combine_ensemble_with_thread_joining"] == False: if not self.custom_options.get("data_dir", None): - verbose_print( + self.verbose_print( "Error: chosen to write the ensemble output directly to files but data_dir isn't set", self.grid_options["verbosity"], 0, @@ -2058,15 +2044,22 @@ class Population: ## Check which type of population generation # grid type if self.grid_options["evolution_type"] == "grid": - ####################### - # Dry run and getting starcount + ################################################## + # Grid run + ############################################################ + # Set up LRU cache + self.setup_function_cache() + ############################################################ + # Dry run and getting starcount + ############################################################ # Put in check if len(self.grid_options["_grid_variables"]) == 0: print("Error: you haven't defined any grid variables! Aborting") raise ValueError # Set up the grid code with a dry run option to see total probability + print("Do dry run? {}".format(self.grid_options["do_dry_run"])) if self.grid_options["do_dry_run"]: print("Doing dry run to calculate total starcount and probability") self._generate_grid_code(dry_run=True) @@ -2077,9 +2070,10 @@ class Population: # Do a dry run self._dry_run() - verbose_print( + self.verbose_print( self._boxed( - "Total starcount for this run is {starcount}".format( + "Dry run", + "Total starcount is {starcount}".format( starcount=self.grid_options["_total_starcount"] ), "Total probability is {probtot:g}".format( @@ -2090,16 +2084,25 @@ class Population: 0, ) if self.grid_options["exit_after_dry_run"]: - sys.exit() + print( + "Exiting after dry run {}".format( + self.grid_options["exit_after_dry_run"] + ) + ) + self.exit(code=0) + elif self.grid_options["return_after_dry_run"]: + print( + "Returning after dry run {}".format( + self.grid_options["exit_after_dry_run"] + ) + ) + return False ####################### # Reset values and prepare the grid function self.grid_options[ "_probtot" ] = 0 # To make sure that the values are reset. TODO: fix this in a cleaner way - self.grid_options[ - "_start_time_evolution" - ] = time.time() # Setting start time of grid # # Making sure the loaded grid code isn't lingering in the main PID # self._generate_grid_code(dry_run=False) @@ -2128,14 +2131,14 @@ class Population: # TODO: fix this function raise ValueError("This functionality is not available yet") - # Source file + # Monte-carlo elif self.grid_options["evolution_type"] == "montecarlo": if self.grid_options["do_dry_run"]: # Do a dry run self._dry_run_source_file() print( - "Total starcount for this run will be: {}".format( + "Total starcount will be: {}".format( self.grid_options["_total_starcount"] ) ) @@ -2145,9 +2148,6 @@ class Population: self.grid_options[ "_probtot" ] = 0 # To make sure that the values are reset. TODO: fix this in a cleaner way - self.grid_options[ - "_start_time_evolution" - ] = time.time() # Setting start time of grid # # TODO: fix this function @@ -2158,9 +2158,8 @@ class Population: self.grid_options[ "_probtot" ] = 0 # To make sure that the values are reset. TODO: fix this in a cleaner way - self.grid_options[ - "_start_time_evolution" - ] = time.time() # Setting start time of grid + + return True def _cleanup(self): """ @@ -2174,1531 +2173,120 @@ class Population: """ # Reset values - self.grid_options["_count"] = 0 - self.grid_options["_probtot"] = 0 + for x in [ + "_count", + "_probtot", + "_failed_count", + "_failed_prob", + "_total_mass_run", + "_total_probability_weighted_mass_run", + ]: + self.grid_options[x] = 0 + for x in ["_errors_found", "_errors_exceeded"]: + self.grid_options[x] = False self.grid_options["_system_generator"] = None - self.grid_options["_failed_count"] = 0 - self.grid_options["_failed_prob"] = 0 - self.grid_options["_errors_found"] = False - self.grid_options["_errors_exceeded"] = False self.grid_options["_failed_systems_error_codes"] = [] - self.grid_options["_total_mass_run"] = 0 - self.grid_options["_total_probability_weighted_mass_run"] = 0 - - # Remove files - # TODO: remove files - # Unload functions - # TODO: unload functions + def _dry_run(self): + """ + Function to dry run the grid and know how many stars it will run - # Unload/free custom_logging_code - # TODO: cleanup custom logging code. + Requires the grid to be built as a dry run grid + """ + self.verbose_print( + "Doing a dry run of the grid.", self.grid_options["verbosity"], 1 + ) + system_generator = self.grid_options["_system_generator"] + total_starcount = system_generator(self) + self.grid_options["_total_starcount"] = total_starcount ################################################### - # Grid code functions + # Population from file functions # - # Function below are used to run populations with - # a variable grid + # Functions below are used to run populations from + # a file containing binary_c calls ################################################### - - def _add_code(self, *args, indent=0): - """ - Function to add code to the grid code string - - add code to the code_string - - indent (=0) is added once at the beginning - mindent (=0) is added for every line - - don't use both! - """ - - indent_block = self._indent_block(indent) - for thing in args: - self.code_string += indent_block + thing - - def _indent_block(self, n=0): + def _dry_run_source_file(self): """ - return an indent block, with n extra blocks in it + Function to go through the source_file and count the number of lines and the total probability """ - return (self.indent_depth + n) * self.indent_string + system_generator = self.grid_options["_system_generator"] + total_starcount = 0 - def _increment_indent_depth(self, delta): - """ - increment the indent indent_depth by delta - """ + for _ in system_generator: + total_starcount += 1 - self.indent_depth += delta + total_starcount = system_generator(self) + self.grid_options["_total_starcount"] = total_starcount - def _generate_grid_code(self, dry_run=False): + def _load_source_file(self, check=False): """ - Function that generates the code from which the population will be made. - - dry_run: when True, it will return the starcount at the end so that we know - what the total number of systems is. - - The phasevol values are handled by generating a second array - - # TODO: Add correct logging everywhere - # TODO: add part to handle separation if orbital_period is added. Idea. use default values - # for orbital parameters and possibly overwrite those or something. - # TODO: add sensible description to this function. - # TODO: Check whether all the probability and phasevol values are correct. - # TODO: import only the necessary packages/functions - # TODO: Put all the masses, eccentricities and periods in there already - # TODO: Put the certain blocks that are repeated in some sub functions - # TODO: make sure running systems with multiplicity 3+ is also possible. - - Results in a generated file that contains a system_generator function. + Function that loads the source_file that contains a binary_c calls """ - verbose_print("Generating grid code", self.grid_options["verbosity"], 1) - - total_grid_variables = len(self.grid_options["_grid_variables"]) - - self._add_code( - # Import packages - "import math\n", - "import numpy as np\n", - "from collections import OrderedDict\n", - "from binarycpython.utils.distribution_functions import *\n", - "from binarycpython.utils.spacing_functions import *\n", - "from binarycpython.utils.useful_funcs import *\n", - "\n\n", - # Make the function - "def grid_code(self, print_results=True):\n", - ) + if not os.path.isfile(self.grid_options["source_file_filename"]): + self.verbose_print( + "Source file doesnt exist", self.grid_options["verbosity"], 0 + ) - # Increase indent_depth - self._increment_indent_depth(+1) - - self._add_code( - # Write some info in the function - "# Grid code generated on {}\n".format(datetime.datetime.now().isoformat()), - "# This function generates the systems that will be evolved with binary_c\n\n" - # Set some values in the generated code: - "# Setting initial values\n", - "_total_starcount = 0\n", - "starcounts = [0 for i in range({})]\n".format(total_grid_variables + 1), - "probabilities = {}\n", - "probabilities_list = [0 for i in range({})]\n".format( - total_grid_variables + 1 - ), - "probabilities_sum = [0 for i in range({})]\n".format( - total_grid_variables + 1 + self.verbose_print( + message="Loading source file from {}".format( + self.grid_options["gridcode_filename"] ), - "parameter_dict = {}\n", - "phasevol = 1\n", - ) - - # Set up the system parameters - self._add_code( - "M_1 = None\n", - "M_2 = None\n", - "M_3 = None\n", - "M_4 = None\n", - "orbital_period = None\n", - "orbital_period_triple = None\n", - "orbital_period_quadruple = None\n", - "eccentricity = None\n", - "eccentricity2 = None\n", - "eccentricity3 = None\n", - "\n", - # Prepare the probability - "# setting probability lists\n", + verbosity=self.grid_options["verbosity"], + minimal_verbosity=1, ) - for grid_variable_el in sorted( - self.grid_options["_grid_variables"].items(), - key=lambda x: x[1]["grid_variable_number"], - ): - # Make probabilities dict - grid_variable = grid_variable_el[1] - self._add_code('probabilities["{}"] = 0\n'.format(grid_variable["name"])) - - ################################################################################# - # Start of code generation - ################################################################################# - self._add_code("\n") - - # turn vb to True to have debugging output - vb = False - - # Generate code - print("Generating grid code") - for loopnr, grid_variable_el in enumerate( - sorted( - self.grid_options["_grid_variables"].items(), - key=lambda x: x[1]["grid_variable_number"], - ) - ): - verbose_print( - "Constructing/adding: {}".format(grid_variable_el[0]), - self.grid_options["verbosity"], - 2, + # We can choose to perform a check on the source file, which checks if the lines start with 'binary_c' + if check: + source_file_check_filehandle = self.open( + self.grid_options["source_file_filename"], "r", encoding="utf-8" ) - grid_variable = grid_variable_el[1] - - #################### - # top code - if grid_variable["topcode"]: - self._add_code(grid_variable["topcode"]) - - ######################### - # Setting up the for loop - # Add comment for for loop - self._add_code( - "# for loop for {}".format(grid_variable["name"]) + "\n", - "sampled_values_{} = {}".format( - grid_variable["name"], grid_variable["samplerfunc"] + for line in source_file_check_filehandle: + if not line.startswith("binary_c"): + failed = True + break + if failed: + self.verbose_print( + "Error, sourcefile contains lines that do not start with binary_c", + self.grid_options["verbosity"], + 0, ) - + "\n", - ) + raise ValueError - if vb: - self._add_code( - "print('samples','{}',':',sampled_values_{})\n".format( - grid_variable["name"], grid_variable["name"] - ) - ) + source_file_filehandle = self.open( + self.grid_options["source_file_filename"], "r", encoding="utf-8" + ) - # # Some print statement - # self._add_code(( - # "print('phasevol_{}:', phasevol_{})".format(grid_variable["name"], - # grid_variable["name"]) - # + "\n" - # ) - - # TODO: make sure this works - # Adding for loop structure - # self._add_code(( - # "for {} in sampled_values_{}:".format( - # grid_variable["name"], grid_variable["name"] - # ) - # + "\n" - # ) - - if vb: - self._add_code( - "print('sample {} from',sampled_values_{})".format( - grid_variable["name"], grid_variable["name"] - ) - + "\n" - ) + self.grid_options["_system_generator"] = source_file_filehandle - # if grid_variable["resolution"] == 0: - # sample from the sampled_values - self._add_code( - "for {}_sample_number in range(max(0,len(sampled_values_{})-1)):".format( - grid_variable["name"], grid_variable["name"] - ) - + "\n" - ) + self.verbose_print("Source file loaded", self.grid_options["verbosity"], 1) - # old code: use resolution passed in - # else: - # # use resolution passed in - # self._add_code( - # "for {}_sample_number in range({} if {} != 0 else max(0,len(sampled_values_{})-1)):".format( - # grid_variable["name"], - # grid_variable["resolution"], - # grid_variable["resolution"], - # grid_variable["name"], - # ) - # + "\n" - # ) - - self._increment_indent_depth(+1) - - # {}_this and {}_next are this grid point's index and the next - # grid point's index, used in many calculations below - self._add_code("if {}_sample_number == 0:\n".format(grid_variable["name"])) - self._add_code("{}_this = 0;\n".format(grid_variable["name"]), indent=1) - self._add_code("else:\n") - self._add_code( - "{}_this = {}_sample_number; ".format( - grid_variable["name"], grid_variable["name"] - ), - indent=1, - ) - self._add_code( - "\n", - "{}_next = {}_this + 1".format( - grid_variable["name"], grid_variable["name"] - ), - "\n", - ) + def _dict_from_line_source_file(self, line): + """ + Function that creates a dict from a binary_c arg line + """ + if line.startswith("binary_c "): + line = line.replace("binary_c ", "") - # TODO: Make clear that the phasevol only works good - # TODO: add option to ignore this phasevol calculation and set it to 1 - # if you sample linearly in that thing. - # if phasevol is <= 0 then we SKIP that whole loop. Its not working then. - if ( - not grid_variable["dphasevol"] == -1 - ): # A method to turn off this calculation and allow a phasevol = 1 - self._add_code( - "phasevol_{} = sampled_values_{}[{}_next]-sampled_values_{}[{}_this]".format( - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - ) - + "\n" - ) - else: - self._add_code("phasevol_{} = 1\n".format(grid_variable["name"])) + split_line = line.split() + arg_dict = {} - ############## - # Add phasevol check: - self._add_code("if phasevol_{} <= 0:\n".format(grid_variable["name"])) - - # TODO: We might actually want to add the starcount and probability to the totals regardless. - # n that case we need another local variable which will prevent it from being run but will track those parameters - # Add phasevol check action: - self._add_code( - 'print("Grid generator: phasevol_{} <= 0! (this=",{}_this,"=",sampled_values_{}[{}_this],", next=",{}_next,"=",sampled_values_{}[{}_next],") Skipping current sample.")'.format( - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - ) - + "\n", - "continue\n", - indent=1, - ) + for i in range(0, len(split_line), 2): + if "." in split_line[i + 1]: + arg_dict[split_line[i]] = float(split_line[i + 1]) + else: + arg_dict[split_line[i]] = int(split_line[i + 1]) - if vb: - self._add_code( - "print('sample {} from ',sampled_values_{},' at this=',{}_this,', next=',{}_next)".format( - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - ) - + "\n" - ) - - # select point location based on gridtype (left, centre or right) - if ( - grid_variable["gridtype"] == "edge" - or grid_variable["gridtype"] == "left" - or grid_variable["gridtype"] == "left edge" - ): - self._add_code( - "{} = sampled_values_{}[{}_this]".format( - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - ) - + "\n" - ) - elif ( - grid_variable["gridtype"] == "right" - or grid_variable["gridtype"] == "right edge" - ): - self._add_code( - +"{} = sampled_values_{}[{}_next]".format( - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - ) - + "\n" - ) - elif ( - grid_variable["gridtype"] == "centred" - or grid_variable["gridtype"] == "centre" - or grid_variable["gridtype"] == "center" - ): - self._add_code( - "{} = 0.5 * (sampled_values_{}[{}_next] + sampled_values_{}[{}_this])".format( - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - grid_variable["name"], - ) - + "\n" - ) - else: - msg = "Unknown gridtype value. PLease choose a different one" - raise ValueError(msg) - - if vb: - self._add_code( - "print('hence {} = ',{})\n".format( - grid_variable["name"], grid_variable["name"] - ) - ) - - ################################################################################# - # Check condition and generate for loop - - # If the grid variable has a condition, write the check and the action - if grid_variable["condition"]: - - self._add_code( - # Add comment - "# Condition for {}\n".format(grid_variable["name"]), - # Add condition check - "if not {}:\n".format(grid_variable["condition"]), - indent=0, - ) - - # Add condition failed action: - if self.grid_options["verbosity"] >= 3: - self._add_code( - 'print("Grid generator: Condition for {} not met!")'.format( - grid_variable["name"] - ) - + "\n", - "continue" + "\n", - indent=1, - ) - else: - self._add_code( - "continue" + "\n", - indent=1, - ) - # Add some whitespace - self._add_code("\n") - - # # Add debugging: - # if grid_variable['name']=='q': - # self._add_code(( - # indent=1, - # 'print("sampling:", sampled_values_{}, M_1)'.format( - # grid_variable["name"], grid_variable["name"] - # ) - # + "\n" - # ) - - # Add some whitespace - self._add_code("\n") - - ######################### - # Setting up pre-code and value in some cases - # Add pre-code - if grid_variable["precode"]: - self._add_code( - "{}".format( - grid_variable["precode"].replace( - "\n", "\n" + self._indent_block(0) - ) - ) - + "\n" - ) - - # Set phasevol - self._add_code( - "phasevol *= phasevol_{}\n".format( - grid_variable["name"], - ) - ) - - ####################### - # Probabilities - # Calculate probability - self._add_code( - "\n", - "# Setting probabilities\n", - "d{} = phasevol_{} * ({})".format( - grid_variable["name"], - grid_variable["name"], - grid_variable["probdist"], - ) - + "\n", - # Save probability sum - "probabilities_sum[{}] += d{}".format( - grid_variable["grid_variable_number"], grid_variable["name"] - ) - + "\n", - ) - - if grid_variable["grid_variable_number"] == 0: - self._add_code( - "probabilities_list[0] = d{}".format(grid_variable["name"]) + "\n" - ) - else: - self._add_code( - "probabilities_list[{}] = probabilities_list[{}] * d{}".format( - grid_variable["grid_variable_number"], - grid_variable["grid_variable_number"] - 1, - grid_variable["name"], - ) - + "\n" - ) - - ############## - # postcode - if grid_variable["postcode"]: - self._add_code( - "{}".format( - grid_variable["postcode"].replace( - "\n", "\n" + self._indent_block(0) - ) - ) - + "\n" - ) - - ####################### - # Increment starcount for this parameter - self._add_code( - "\n", - "# Increment starcount for {}\n".format(grid_variable["name"]), - "starcounts[{}] += 1".format( - grid_variable["grid_variable_number"], - ) - + "\n", - # Add value to dict - 'parameter_dict["{}"] = {}'.format( - grid_variable["parameter_name"], grid_variable["parameter_name"] - ) - + "\n", - "\n", - ) - - self._increment_indent_depth(-1) - - # The final parts of the code, where things are returned, are within the deepest loop, - # but in some cases code from a higher loop needs to go under it again - # SO I think its better to put an if statement here that checks - # whether this is the last loop. - if loopnr == len(self.grid_options["_grid_variables"]) - 1: - self._write_gridcode_system_call( - grid_variable, - dry_run, - grid_variable["branchpoint"], - grid_variable["branchcode"], - ) - - # increment indent_depth - self._increment_indent_depth(+1) - - #################### - # bottom code - if grid_variable["bottomcode"]: - self._add_code(grid_variable["bottomcode"]) - - self._increment_indent_depth(-1) - self._add_code("\n") - - # Write parts to write below the part that yield the results. - # this has to go in a reverse order: - # Here comes the stuff that is put after the deepest nested part that calls returns stuff. - # Here we will have a - reverse_sorted_grid_variables = sorted( - self.grid_options["_grid_variables"].items(), - key=lambda x: x[1]["grid_variable_number"], - reverse=True, - ) - for loopnr, grid_variable_el in enumerate(reverse_sorted_grid_variables): - grid_variable = grid_variable_el[1] - - self._increment_indent_depth(+1) - self._add_code( - "#" * 40 + "\n", - "# Code below is for finalising the handling of this iteration of the parameter {}\n".format( - grid_variable["name"] - ), - ) - - # Set phasevol - # TODO: fix. this isn't supposed to be the value that we give it here. discuss - self._add_code("phasevol /= phasevol_{}\n\n".format(grid_variable["name"])) - - self._increment_indent_depth(-2) - - # Check the branchpoint part here. The branchpoint makes sure that we can construct - # a grid with several multiplicities and still can make the system calls for each - # multiplicity without reconstructing the grid each time - if grid_variable["branchpoint"] > 0: - - self._increment_indent_depth(+1) - - self._add_code( - # Add comment - "# Condition for branchpoint at {}".format( - reverse_sorted_grid_variables[loopnr + 1][1]["name"] - ) - + "\n", - # # Add condition check - # "if not {}:".format(grid_variable["condition"]) - # + "\n" - # Add branchpoint - "if multiplicity=={}:".format(grid_variable["branchpoint"]) + "\n", - ) - - self._write_gridcode_system_call( - reverse_sorted_grid_variables[loopnr + 1][1], - dry_run, - grid_variable["branchpoint"], - grid_variable["branchcode"], - ) - self._increment_indent_depth(-1) - self._add_code("\n") - - ############################### - # Finalising print statements - # - self._increment_indent_depth(+1) - self._add_code("\n", "#" * 40 + "\n", "if print_results:\n") - self._add_code( - "print('Grid has handled {} stars with a total probability of {:g}'.format(_total_starcount,self.grid_options['_probtot']))\n", - indent=1, - ) - - ################ - # Finalising return statement for dry run. - # - if dry_run: - self._add_code("return _total_starcount\n") - - self._increment_indent_depth(-1) - ################################################################################# - # Stop of code generation. Here the code is saved and written - - # Save the grid code to the grid_options - verbose_print( - "Saving grid code to grid_options", self.grid_options["verbosity"], 1 - ) - - self.grid_options["code_string"] = self.code_string - - # Write to file - gridcode_filename = os.path.join( - self.grid_options["tmp_dir"], - "binary_c_grid_{}.py".format(self.grid_options["_population_id"]), - ) - self.grid_options["gridcode_filename"] = gridcode_filename - - verbose_print( - "{}Writing grid code to {} [dry_run = {}]{}".format( - self.ANSI_colours["blue"], - gridcode_filename, - dry_run, - self.ANSI_colours["reset"], - ), - self.grid_options["verbosity"], - 1, - ) - - with open(gridcode_filename, "w") as file: - file.write(self.code_string) - - # perhaps create symlink - if self.grid_options["symlink latest gridcode"]: - global _count - symlink = os.path.join( - self.grid_options["tmp_dir"], "binary_c_grid-latest" + str(_count) - ) - _count += 1 - if os.path.exists(symlink): - os.unlink(symlink) - - try: - os.symlink(gridcode_filename, symlink) - verbose_print( - "{}Symlinked grid code to {} {}".format( - self.ANSI_colours["blue"], symlink, self.ANSI_colours["reset"] - ), - self.grid_options["verbosity"], - 1, - ) - except OSError: - print("symlink failed") - - def _write_gridcode_system_call( - self, grid_variable, dry_run, branchpoint, branchcode - ): - ################################################################################# - # Here are the calls to the queuing or other solution. this part is for every system - # Add comment - self._increment_indent_depth(+1) - self._add_code("#" * 40 + "\n") - - if branchcode: - self._add_code("# Branch code\nif {}:\n", branchcode) - - if branchpoint: - self._add_code( - "# Code below will get evaluated for every system at this level of multiplicity (last one of that being {})\n".format( - grid_variable["name"] - ) - ) - else: - self._add_code( - "# Code below will get evaluated for every generated system\n" - ) - - # Factor in the custom weight input - self._add_code( - "\n", - "# Weigh the probability by a custom weighting factor\n", - 'probability = self.grid_options["weight"] * probabilities_list[{}]'.format( - grid_variable["grid_variable_number"] - ) - + "\n", - # Take into account the multiplicity fraction: - "\n", - "# Factor the multiplicity fraction into the probability\n", - "probability = probability * self._calculate_multiplicity_fraction(parameter_dict)" - + "\n", - # Add division by number of repeats - "\n", - "# Divide the probability by the number of repeats\n", - 'probability = probability / self.grid_options["repeat"]' + "\n", - # Now we yield the system self.grid_options["repeat"] times. - "\n", - "# Loop over the repeats\n", - 'for _ in range(self.grid_options["repeat"]):' + "\n", - ) - self._add_code( - "_total_starcount += 1\n", - # set probability and phasevol values into the system dict - 'parameter_dict["{}"] = {}'.format("probability", "probability") + "\n", - 'parameter_dict["{}"] = {}'.format("phasevol", "phasevol") + "\n", - # Increment total probability - "self._increment_probtot(probability)\n", - indent=1, - ) - - if not dry_run: - # Handling of what is returned, or what is not. - self._add_code("yield(parameter_dict)\n", indent=1) - - # If its a dry run, dont do anything with it - else: - self._add_code("pass\n", indent=1) - - self._add_code("#" * 40 + "\n") - - self._increment_indent_depth(-1) - - return self.code_string - - def _load_grid_function(self): - """ - Function that loads the script containing the grid code. - - TODO: Update this description - Test function to run grid stuff. mostly to test the import - """ - - # Code to load the - verbose_print( - message="Loading grid code function from {}".format( - self.grid_options["gridcode_filename"] - ), - verbosity=self.grid_options["verbosity"], - minimal_verbosity=1, - ) - - spec = importlib.util.spec_from_file_location( - "binary_c_python_grid", - os.path.join(self.grid_options["gridcode_filename"]), - ) - grid_file = importlib.util.module_from_spec(spec) - spec.loader.exec_module(grid_file) - generator = grid_file.grid_code - - self.grid_options["_system_generator"] = generator - - verbose_print("Grid code loaded", self.grid_options["verbosity"], 1) - - def _dry_run(self): - """ - Function to dry run the grid and know how many stars it will run - - Requires the grid to be built as a dry run grid - """ - verbose_print("Dry run of the grid", self.grid_options["verbosity"], 1) - system_generator = self.grid_options["_system_generator"] - total_starcount = system_generator(self) - self.grid_options["_total_starcount"] = total_starcount - - def _print_info(self, run_number, total_systems, full_system_dict): - """ - Function to print info about the current system and the progress of the grid. - - # color info tricks from https://ozzmaker.com/add-colour-to-text-in-python/ - https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python - """ - - # Define frequency - if self.grid_options["verbosity"] == 1: - print_freq = 1 - else: - print_freq = 10 - - # Calculate amount of time left - # calculate amount of time passed - # time_passed = time.time() - self.grid_options["_start_time_evolution"] - - if run_number % print_freq == 0: - binary_cmdline_string = self._return_argline(full_system_dict) - info_string = "{color_part_1} \ - {text_part_1}{end_part_1}{color_part_2} \ - {text_part_2}{end_part_2}".format( - color_part_1="\033[1;32;41m", - text_part_1="{}/{}".format(run_number, total_systems), - end_part_1="\033[0m", - color_part_2="\033[1;32;42m", - text_part_2="{}".format(binary_cmdline_string), - end_part_2="\033[0m", - ) - print(info_string) + return arg_dict - ################################################### - # Monte Carlo functions - # - # Functions below are used to run populations with - # Monte Carlo - ################################################### - - ################################################### - # Population from file functions - # - # Functions below are used to run populations from - # a file containing binary_c calls - ################################################### - def _dry_run_source_file(self): - """ - Function to go through the source_file and count the number of lines and the total probability - """ - - system_generator = self.grid_options["_system_generator"] - - total_starcount = 0 - total_probability = 0 - - contains_probability = False - - for line in system_generator: - total_starcount += 1 - - total_starcount = system_generator(self) - self.grid_options["_total_starcount"] = total_starcount - - def _load_source_file(self, check=False): - """ - Function that loads the source_file that contains a binary_c calls - """ - - if not os.path.isfile(self.grid_options["source_file_filename"]): - verbose_print("Source file doesnt exist", self.grid_options["verbosity"], 0) - - verbose_print( - message="Loading source file from {}".format( - self.grid_options["gridcode_filename"] - ), - verbosity=self.grid_options["verbosity"], - minimal_verbosity=1, - ) - - # We can choose to perform a check on the source file, which checks if the lines start with 'binary_c' - if check: - source_file_check_filehandle = open( - self.grid_options["source_file_filename"], "r" - ) - for line in source_file_check_filehandle: - if not line.startswith("binary_c"): - failed = True - break - if failed: - verbose_print( - "Error, sourcefile contains lines that do not start with binary_c", - self.grid_options["verbosity"], - 0, - ) - raise ValueError - - source_file_filehandle = open(self.grid_options["source_file_filename"], "r") - - self.grid_options["_system_generator"] = source_file_filehandle - - verbose_print("Source file loaded", self.grid_options["verbosity"], 1) - - def _dict_from_line_source_file(self, line): - """ - Function that creates a dict from a binary_c arg line - """ - - if line.startswith("binary_c "): - line = line.replace("binary_c ", "") - - split_line = line.split() - arg_dict = {} - - for i in range(0, len(split_line), 2): - if "." in split_line[i + 1]: - arg_dict[split_line[i]] = float(split_line[i + 1]) - else: - arg_dict[split_line[i]] = int(split_line[i + 1]) - - return arg_dict - - ################################################### - # SLURM functions - # - # subroutines to run SLURM grids - ################################################### - - # def _slurm_grid(self): - # """ - # Main function that manages the SLURM setup. - - # Has three stages: - - # - setup - # - evolve - # - join - - # Which stage is used is determined by the value of grid_options['slurm_command']: - - # <empty>: the function will know its the user that executed the script and - # it will set up the necessary condor stuff - - # 'evolve': evolve_population is called to evolve the population of stars - - # 'join': We will attempt to join the output - # """ - - # # Check version - # # TODO: Put in function - # slurm_version = get_slurm_version() - # if not slurm_version: - # verbose_print( - # "SLURM: Error: No installation of slurm found", - # self.grid_options["verbosity"], - # 0, - # ) - # else: - # major_version = int(slurm_version.split(".")[0]) - # minor_version = int(slurm_version.split(".")[1]) - - # if major_version > 17: - # verbose_print( - # "SLURM: Found version {} which is new enough".format(slurm_version), - # self.grid_options["verbosity"], - # 1, - # ) - # else: - # verbose_print( - # "SLURM: Found version {} which is too old (we require 17+)".format( - # slurm_version - # ), - # self.grid_options["verbosity"], - # 0, - # ) - - # verbose_print( - # "SLURM: Running slurm grid. command={}".format( - # self.grid_options["slurm_command"] - # ), - # self.grid_options["verbosity"], - # 1, - # ) - - # if not self.grid_options["slurm_command"]: - # # Setting up - # verbose_print( - # "SLURM: Main controller script. Setting up", - # self.grid_options["verbosity"], - # 1, - # ) - - # # Set up working directories: - # verbose_print( - # "SLURM: creating working directories", self.grid_options["verbosity"], 1 - # ) - # create_directories_hpc(self.grid_options["slurm_dir"]) - - # # Create command - # python_details = get_python_details() - # scriptname = path_of_calling_script() - # command = "{} {}".format(python_details["executable"], scriptname) - # command += '{}'.format( - # " ".join( - # [ - # "{}".format(self.grid_options["_commandline_input"]), - # "offset=$jobarrayindex", - # "modulo={}".format(self.grid_options["slurm_njobs"]), - # "vb={}".format(self.grid_options["verbosity"]), - # "slurm_jobid=$jobid", - # "slurm_jobarrayindex=$jobarrayindex", - # "slurm_jobname='binary_grid_'$jobid'.'$jobarrayindex", - # "slurm_njobs={}".format(self.grid_options["slurm_njobs"]), - # "slurm_dir={}".format(self.grid_options["slurm_dir"]), - # "rungrid=1", - # "slurm_command=evolve", - # ] - # ).strip() - # ) - - # # Construct dict with settings for the script while checking the settings at the same time - # # Check settings: - # # TODO: check settings - # # Create SLURM_DIR script: - # slurm_script_options = {} - # slurm_script_options["n"] = self.grid_options["slurm_njobs"] - # slurm_script_options["njobs"] = self.grid_options["slurm_njobs"] - # slurm_script_options["dir"] = self.grid_options["slurm_dir"] - # slurm_script_options["memory"] = self.grid_options["slurm_memory"] - # slurm_script_options["working_dir"] = self.grid_options[ - # "slurm_dir" - # ] # TODO: check this - # slurm_script_options["command"] = command - # # slurm_script_options['streams'] = self.grid_options['streams'] - - # # Construct the script - # slurm_script_contents = "" - # slurm_script_contents += "#!/bin/bash\n" - # slurm_script_contents += "# Slurm file for binary_grid and slurm\n" - # slurm_script_contents += "#SBATCH --error={}/stderr/%A.%a\n".format( - # self.grid_options["slurm_dir"] - # ) - # slurm_script_contents += "#SBATCH --output={}/stdout/%A.%a\n".format( - # self.grid_options["slurm_dir"] - # ) - # slurm_script_contents += "#SBATCH --job-name={}\n".format( - # self.grid_options["slurm_jobname"] - # ) - # slurm_script_contents += "#SBATCH --partition={}\n".format( - # self.grid_options["slurm_partition"] - # ) - # slurm_script_contents += "#SBATCH --time={}\n".format( - # self.grid_options["slurm_time"] - # ) - # slurm_script_contents += "#SBATCH --mem={}\n".format( - # self.grid_options["slurm_memory"] - # ) - # slurm_script_contents += "#SBATCH --ntasks={}\n".format( - # self.grid_options["slurm_ntasks"] - # ) - # slurm_script_contents += "#SBATCH --array={}\n".format( - # self.grid_options["slurm_array"] - # ) - # slurm_script_contents += "\n" - - # if self.grid_options["slurm_extra_settings"]: - # slurm_script_contents += "# Extra settings by user:" - # slurm_script_contents += "\n".join( - # [ - # "--{}={}".format( - # key, self.grid_options["slurm_extra_settings"][key] - # ) - # for key in self.grid_options["slurm_extra_settings"] - # ] - # ) - - # slurm_script_contents += '# set status to "running"\n' - # slurm_script_contents += ( - # 'echo "running" > {}/status/$jobid.$jobarrayindex\n\n'.format( - # self.grid_options["slurm_dir"] - # ) - # ) - # slurm_script_contents += "# run grid of stars\n" - # slurm_script_contents += "{}\n\n".format(command) - # slurm_script_contents += '# set status to "finished"\n' - # slurm_script_contents += ( - # 'echo "finished" > {}/status/$jobid.$jobarrayindex\n'.format( - # self.grid_options["slurm_dir"] - # ) - # ) - # slurm_script_contents += "\n" - - # if self.grid_options["slurm_postpone_join"]: - # slurm_script_contents += "{} rungrid=0 results_hash_dumpfile={}/results/$jobid.all slurm_command=join\n".format( - # command, self.grid_options["slurm_dir"] - # ) - - # # Write script to file - # slurm_script_filename = os.path.join( - # self.grid_options["slurm_dir"], "slurm_script" - # ) - # with open(slurm_script_filename, "w") as slurm_script_file: - # slurm_script_file.write(slurm_script_contents) - - # # Execute or postpone - # if self.grid_options["slurm_postpone_sbatch"]: - # # Execute or postpone the real call to sbatch - # sbatch_command = "sbatch {}".format(slurm_script_filename) - # verbose_print( - # "running slurm script {}".format(slurm_script_filename), - # self.grid_options["verbosity"], - # 0, - # ) - # # subprocess.Popen(sbatch_command, close_fds=True) - # # subprocess.Popen(sbatch_command, creationflags=subprocess.DETACHED_PROCESS) - # verbose_print("Submitted scripts.", self.grid_options["verbosity"], 0) - # else: - # verbose_print( - # "Slurm script is in {} but hasnt been executed".format( - # slurm_script_filename - # ), - # self.grid_options["verbosity"], - # 0, - # ) - - # verbose_print("all done!", self.grid_options["verbosity"], 0) - # sys.exit() - - # elif self.grid_options["slurm_command"] == "evolve": - # # Part to evolve the population. - # # TODO: decide how many CPUs - # verbose_print( - # "SLURM: Evolving population", self.grid_options["verbosity"], 1 - # ) - - # # - # self.evolve_population() - - # elif self.grid_options["slurm_command"] == "join": - # # Joining the output. - # verbose_print("SLURM: Joining results", self.grid_options["verbosity"], 1) - - ################################################### - # CONDOR functions - # - # subroutines to run CONDOR grids - ################################################### - - # def _condor_grid(self): - # """ - # Main function that manages the CONDOR setup. - - # Has three stages: - - # - setup - # - evolve - # - join - - # Which stage is used is determined by the value of grid_options['condor_command']: - - # <empty>: the function will know its the user that executed the script and - # it will set up the necessary condor stuff - - # 'evolve': evolve_population is called to evolve the population of stars - - # 'join': We will attempt to join the output - # """ - - # # TODO: Put in function - # condor_version = get_condor_version() - # if not condor_version: - # verbose_print( - # "CONDOR: Error: No installation of condor found", - # self.grid_options["verbosity"], - # 0, - # ) - # else: - # major_version = int(condor_version.split(".")[0]) - # minor_version = int(condor_version.split(".")[1]) - - # if (major_version == 8) and (minor_version > 4): - # verbose_print( - # "CONDOR: Found version {} which is new enough".format( - # condor_version - # ), - # self.grid_options["verbosity"], - # 0, - # ) - # elif major_version > 9: - # verbose_print( - # "CONDOR: Found version {} which is new enough".format( - # condor_version - # ), - # self.grid_options["verbosity"], - # 0, - # ) - # else: - # verbose_print( - # "CONDOR: Found version {} which is too old (we require 8.3/8.4+)".format( - # condor_version - # ), - # self.grid_options["verbosity"], - # 0, - # ) - - # verbose_print( - # "Running Condor grid. command={}".format( - # self.grid_options["condor_command"] - # ), - # self.grid_options["verbosity"], - # 1, - # ) - # if not self.grid_options["condor_command"]: - # # Setting up - # verbose_print( - # "CONDOR: Main controller script. Setting up", - # self.grid_options["verbosity"], - # 1, - # ) - - # # Set up working directories: - # verbose_print( - # "CONDOR: creating working directories", - # self.grid_options["verbosity"], - # 1, - # ) - # create_directories_hpc(self.grid_options["condor_dir"]) - - # # Create command - # current_workingdir = os.getcwd() - # python_details = get_python_details() - # scriptname = path_of_calling_script() - # # command = "".join([ - # # "{}".python_details['executable'], - # # "{}".scriptname, - # # "offset=$jobarrayindex", - # # "modulo={}".format(self.grid_options['condor_njobs']), - # # "vb={}".format(self.grid_options['verbosity']) - - # # "results_hash_dumpfile=$self->{_grid_options}{slurm_dir}/results/$jobid.$jobarrayindex", - # # 'slurm_jobid='.$jobid, - # # 'slurm_jobarrayindex='.$jobarrayindex, - # # 'slurm_jobname=binary_grid_'.$jobid.'.'.$jobarrayindex, - # # "slurm_njobs=$njobs", - # # "slurm_dir=$self->{_grid_options}{slurm_dir}", - # # ); - - # # Create directory with info for the condor script. By creating this directory we also check whether all the values are set correctly - # # TODO: create the condor script. - # condor_script_options = {} - # # condor_script_options['n'] = - # condor_script_options["njobs"] = self.grid_options["condor_njobs"] - # condor_script_options["dir"] = self.grid_options["condor_dir"] - # condor_script_options["memory"] = self.grid_options["condor_memory"] - # condor_script_options["working_dir"] = self.grid_options[ - # "condor_working_dir" - # ] - # condor_script_options["command"] = self.grid_options["command"] - # condor_script_options["streams"] = self.grid_options["streams"] - - # # TODO: condor works with running an executable. - - # # Create script contents - # condor_script_contents = "" - # condor_script_contents += """ - # ################################################# - # # - # # Condor script to run a binary_grid via python - # # - # ################################################# - # """ - # condor_script_contents += "Executable\t= {}".format(executable) - # condor_script_contents += "arguments\t= {}".format(arguments) - # condor_script_contents += "environment\t= {}".format(environment) - # condor_script_contents += "universe\t= {}".format( - # self.grid_options["condor_universe"] - # ) - # condor_script_contents += "\n" - # condor_script_contents += "output\t= {}/stdout/$id\n".format( - # self.grid_options["condor_dir"] - # ) - # condor_script_contents += "error\t={}/sterr/$id".format( - # self.grid_options["condor_dir"] - # ) - # condor_script_contents += "log\t={}\n".format( - # self.grid_options["condor_dir"] - # ) - # condor_script_contents += "initialdir\t={}\n".format(current_workingdir) - # condor_script_contents += "remote_initialdir\t={}\n".format( - # current_workingdir - # ) - # condor_script_contents += "\n" - # condor_script_contents += "steam_output\t={}".format(stream) - # condor_script_contents += "steam_error\t={}".format(stream) - # condor_script_contents += "+WantCheckpoint = False" - # condor_script_contents += "\n" - # condor_script_contents += "request_memory\t={}".format( - # self.grid_options["condor_memory"] - # ) - # condor_script_contents += "ImageSize\t={}".format( - # self.grid_options["condor_memory"] - # ) - # condor_script_contents += "\n" - - # if self.grid_options["condor_extra_settings"]: - # slurm_script_contents += "# Extra settings by user:" - # slurm_script_contents += "\n".join( - # [ - # "{}\t={}".format( - # key, self.grid_options["condor_extra_settings"][key] - # ) - # for key in self.grid_options["condor_extra_settings"] - # ] - # ) - - # condor_script_contents += "\n" - - # # request_memory = $_[0]{memory} - # # ImageSize = $_[0]{memory} - - # # Requirements = (1) \&\& (". - # # $self->{_grid_options}{condor_requirements}.")\n"; - - # # - # # file name: my_program.condor - # # Condor submit description file for my_program - # # Executable = my_program - # # Universe = vanilla - # # Error = logs/err.$(cluster) - # # Output = logs/out.$(cluster) - # # Log = logs/log.$(cluster) - - # # should_transfer_files = YES - # # when_to_transfer_output = ON_EXIT - # # transfer_input_files = files/in1,files/in2 - - # # Arguments = files/in1 files/in2 files/out1 - # # Queue - - # # Write script contents to file - # if self.grid_options["condor_postpone_join"]: - # condor_script_contents += "{} rungrid=0 results_hash_dumpfile={}/results/$jobid.all condor_command=join\n".format( - # command, self.grid_options["condor_dir"] - # ) - - # condor_script_filename = os.path.join( - # self.grid_options["condor_dir"], "condor_script" - # ) - # with open(condor_script_filename, "w") as condor_script_file: - # condor_script_file.write(condor_script_contents) - - # if self.grid_options["condor_postpone_sbatch"]: - # # Execute or postpone the real call to sbatch - # submit_command = "condor_submit {}".format(condor_script_filename) - # verbose_print( - # "running condor script {}".format(condor_script_filename), - # self.grid_options["verbosity"], - # 0, - # ) - # # subprocess.Popen(sbatch_command, close_fds=True) - # # subprocess.Popen(sbatch_command, creationflags=subprocess.DETACHED_PROCESS) - # verbose_print("Submitted scripts.", self.grid_options["verbosity"], 0) - # else: - # verbose_print( - # "Condor script is in {} but hasnt been executed".format( - # condor_script_filename - # ), - # self.grid_options["verbosity"], - # 0, - # ) - - # verbose_print("all done!", self.grid_options["verbosity"], 0) - # sys.exit() - - # elif self.grid_options["condor_command"] == "evolve": - # # TODO: write this function - # # Part to evolve the population. - # # TODO: decide how many CPUs - # verbose_print( - # "CONDOR: Evolving population", self.grid_options["verbosity"], 1 - # ) - - # # - # self.evolve_population() - - # elif self.grid_options["condor_command"] == "join": - # # TODO: write this function - # # Joining the output. - # verbose_print("CONDOR: Joining results", self.grid_options["verbosity"], 1) - - # pass ################################################### # Unordered functions # # Functions that aren't ordered yet ################################################### - def write_ensemble(self, output_file, data=None, sort_keys=True, indent=4): - """ - write_ensemble : Write ensemble results to a file. - - Args: - output_file : the output filename. - - If the filename has an extension that we recognise, - e.g. .gz or .bz2, we compress the output appropriately. - - The filename should contain .json or .msgpack, the two - currently-supported formats. - - Usually you'll want to output to JSON, but we can - also output to msgpack. - - data : the data dictionary to be converted and written to the file. - If not set, this defaults to self.grid_ensemble_results. - - sort_keys : if True, and output is to JSON, the keys will be sorted. - (default: True, passed to json.dumps) - - indent : number of space characters used in the JSON indent. (Default: 4, - passed to json.dumps) - """ - # TODO: consider writing this in a formatted structure - - # get the file type - file_type = ensemble_file_type(output_file) - - # choose compression algorithm based on file extension - compression = ensemble_compression(output_file) - - # default to using grid_ensemble_results if no data is given - if data is None: - data = self.grid_ensemble_results - - if not file_type: - print( - "Unable to determine file type from ensemble filename {} : it should be .json or .msgpack." - ).format(output_file) - sys.exit() - elif file_type is "JSON": - # JSON output - if compression == "gzip": - # gzip - f = gzip.open(output_file, "wt") - elif compression == "bzip2": - # bzip2 - f = bz2.open(output_file, "wt") - else: - # raw output (not compressed) - f = open(output_file, "wt") - f.write(json.dumps(data, sort_keys=sort_keys, indent=indent)) - - elif file_type is "msgpack": - # msgpack output - if compression == "gzip": - f = gzip.open(output_file, "wb") - elif compression == "bzip2": - f = bz2.open(output_file, "wb") - else: - f = open(output_file, "wb") - msgpack.dump(data, f) - f.close() - - print( - "Thread {thread}: Wrote ensemble results to file: {colour}{file}{reset} (file type {file_type}, compression {compression})".format( - thread=self.process_ID, - file=output_file, - colour=self.ANSI_colours["green"], - reset=self.ANSI_colours["reset"], - file_type=file_type, - compression=compression, - ) - ) - - ############################################################ - def write_binary_c_calls_to_file( - self, - output_dir: Union[str, None] = None, - output_filename: Union[str, None] = None, - include_defaults: bool = False, - ) -> None: - """ - Function that loops over the grid code and writes the generated parameters to a file. - In the form of a command line call - - Only useful when you have a variable grid as system_generator. MC wouldn't be that useful - - Also, make sure that in this export there are the basic parameters - like m1,m2,sep, orb-per, ecc, probability etc. - - On default this will write to the datadir, if it exists - - Tasks: - - TODO: test this function - - TODO: make sure the binary_c_python .. output file has a unique name - - Args: - output_dir: (optional, default = None) directory where to write the file to. If custom_options['data_dir'] is present, then that one will be used first, and then the output_dir - output_filename: (optional, default = None) filename of the output. If not set it will be called "binary_c_calls.txt" - include_defaults: (optional, default = None) whether to include the defaults of binary_c in the lines that are written. Beware that this will result in very long lines, and it might be better to just export the binary_c defaults and keep them in a separate file. - - Returns: - filename: filename that was used to write the calls to - """ - - # Check if there is no compiled grid yet. If not, lets try to build it first. - if not self.grid_options["_system_generator"]: - - ## check the settings: - if self.bse_options.get("ensemble", None): - if self.bse_options["ensemble"] == 1: - if not self.bse_options.get("ensemble_defer", 0) == 1: - verbose_print( - "Error, if you want to run an ensemble in a population, the output needs to be deferred", - self.grid_options["verbosity"], - 0, - ) - raise ValueError - - # Put in check - if len(self.grid_options["_grid_variables"]) == 0: - print("Error: you haven't defined any grid variables! Aborting") - raise ValueError - - # - self._generate_grid_code(dry_run=False) - - # - self._load_grid_function() - - # then if the _system_generator is present, we go through it - if self.grid_options["_system_generator"]: - # Check if there is an output dir configured - if self.custom_options.get("data_dir", None): - binary_c_calls_output_dir = self.custom_options["data_dir"] - # otherwise check if there's one passed to the function - else: - if not output_dir: - print( - "Error. No data_dir configured and you gave no output_dir. Aborting" - ) - raise ValueError - binary_c_calls_output_dir = output_dir - - # check if there's a filename passed to the function - if output_filename: - binary_c_calls_filename = output_filename - # otherwise use default value - else: - binary_c_calls_filename = "binary_c_calls.txt" - - binary_c_calls_full_filename = os.path.join( - binary_c_calls_output_dir, binary_c_calls_filename - ) - print("Writing binary_c calls to {}".format(binary_c_calls_full_filename)) - - # Write to file - with open(binary_c_calls_full_filename, "w") as file: - # Get defaults and clean them, then overwrite them with the set values. - if include_defaults: - # TODO: make sure that the defaults here are cleaned up properly - cleaned_up_defaults = self.cleaned_up_defaults - full_system_dict = cleaned_up_defaults.copy() - full_system_dict.update(self.bse_options.copy()) - else: - full_system_dict = self.bse_options.copy() - - for system in self.grid_options["_system_generator"](self): - # update values with current system values - full_system_dict.update(system) - - binary_cmdline_string = self._return_argline(full_system_dict) - file.write(binary_cmdline_string + "\n") - else: - print("Error. No grid function found!") - raise ValueError - - return binary_c_calls_full_filename - def _cleanup_defaults(self): """ Function to clean up the default values: @@ -3718,53 +2306,6 @@ class Population: return cleaned_dict - def _clean_up_custom_logging(self, evol_type): - """ - Function to clean up the custom logging. - Has two types: - 'single': - - removes the compiled shared library - (which name is stored in grid_options['_custom_logging_shared_library_file']) - - TODO: unloads/frees the memory allocated to that shared library - (which is stored in grid_options['custom_logging_func_memaddr']) - - sets both to None - 'multiple': - - TODO: make this and design this - """ - - if evol_type == "single": - verbose_print( - "Cleaning up the custom logging stuff. type: single", - self.grid_options["verbosity"], - 1, - ) - - # TODO: Explicitly unload the library - - # Reset the memory adress location - self.grid_options["custom_logging_func_memaddr"] = -1 - - # remove shared library files - if self.grid_options["_custom_logging_shared_library_file"]: - remove_file( - self.grid_options["_custom_logging_shared_library_file"], - self.grid_options["verbosity"], - ) - self.grid_options["_custom_logging_shared_library_file"] = None - - if evol_type == "population": - verbose_print( - "Cleaning up the custom logging stuffs. type: population", - self.grid_options["verbosity"], - 1, - ) - - # TODO: make sure that these also work. not fully sure if necessary tho. - # whether its a single file, or a dict of files/mem addresses - - if evol_type == "MC": - pass - def _increment_probtot(self, prob): """ Function to add to the total probability. For now not used @@ -3778,43 +2319,16 @@ class Population: """ self.grid_options["_count"] += 1 - def _set_loggers(self): - """ - Function to set the loggers for the execution of the grid - """ - - # Set log file - binary_c_logfile = self.grid_options["log_file"] - - # Create directory - os.makedirs(os.path.dirname(binary_c_logfile), exist_ok=True) - - # Set up logger - self.logger = logging.getLogger("binary_c_python_logger") - self.logger.setLevel(self.grid_options["verbosity"]) - - # Reset handlers - self.logger.handlers = [] - - # Set formatting of output - log_formatter = logging.Formatter( - "%(asctime)s - %(name)s - %(levelname)s - %(message)s" - ) - - # Make and add file handlers - # make handler for output to file - handler_file = logging.FileHandler(filename=os.path.join(binary_c_logfile)) - handler_file.setFormatter(log_formatter) - handler_file.setLevel(logging.INFO) + def was_killed(self): + """ + Function to determine if the process was killed. Returns True if so, false otherwise. + """ + killed = self.grid_options["_killed"] - # Make handler for output to stdout - handler_stdout = logging.StreamHandler(sys.stdout) - handler_stdout.setFormatter(log_formatter) - handler_stdout.setLevel(logging.INFO) + if "_killed" in self.grid_ensemble_results.get("metadata", {}): + killed = killed or self.grid_ensemble_results["metadata"]["_killed"] - # Add the loggers - self.logger.addHandler(handler_file) - self.logger.addHandler(handler_stdout) + return killed def _check_binary_c_error(self, binary_c_output, system_dict): """ @@ -3825,7 +2339,7 @@ class Population: if (binary_c_output.splitlines()[0].startswith("SYSTEM_ERROR")) or ( binary_c_output.splitlines()[-1].startswith("SYSTEM_ERROR") ): - verbose_print( + self.verbose_print( "FAILING SYSTEM FOUND", self.grid_options["verbosity"], 0, @@ -3853,7 +2367,7 @@ class Population: error_code ) except ValueError: - verbose_print( + self.verbose_print( "Failed to extract the error-code", self.grid_options["verbosity"], 1, @@ -3865,7 +2379,7 @@ class Population: > self.grid_options["failed_systems_threshold"] ): if not self.grid_options["_errors_exceeded"]: - verbose_print( + self.verbose_print( self._boxed( "Process {} exceeded the maximum ({}) number of failing systems. Stopped logging them to files now".format( self.process_ID, @@ -3881,1093 +2395,30 @@ class Population: else: # Write arg lines to file argstring = self._return_argline(system_dict) - with open( + with self.open( os.path.join( self.grid_options["tmp_dir"], "failed_systems", "process_{}.txt".format(self.process_ID), ), "a+", + encoding="utf-8", ) as f: f.write(argstring + "\n") f.close() else: - verbose_print( + self.verbose_print( "binary_c output nothing - this is strange. If there is ensemble output being generated then this is fine.", self.grid_options["verbosity"], 3, ) - def set_moe_di_stefano_settings(self, options=None): - """ - Function to set user input configurations for the Moe & di Stefano methods - - If nothing is passed then we just use the default options - """ - - if not options: - options = {} - - # Take the option dictionary that was given and override. - options = update_dicts(self.grid_options["Moe2017_options"], options) - self.grid_options["Moe2017_options"] = copy.deepcopy(options) - - # Write options to a file - os.makedirs( - os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), - exist_ok=True, - ) - with open( - os.path.join( - os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), - "moeopts.dat", - ), - "w", - ) as f: - f.write(json.dumps(self.grid_options["Moe2017_options"], indent=4)) - f.close() - - def _load_moe_di_stefano_data(self): - """ - Function to load the moe & di stefano data - """ - - # Only if the grid is loaded and Moecache contains information - if not self.grid_options["_loaded_Moe2017_data"]: # and not Moecache: - - if self.grid_options["_Moe2017_JSON_data"]: - # Use the existing (perhaps modified) JSON data - json_data = self.grid_options["_Moe2017_JSON_data"] - - else: - # Load the JSON data from a file - json_data = get_moe_di_stefano_dataset( - self.grid_options["Moe2017_options"], - verbosity=self.grid_options["verbosity"], - ) - - # entry of log10M1 is a list containing 1 dict. - # We can take the dict out of the list - if isinstance(json_data["log10M1"], list): - json_data["log10M1"] = json_data["log10M1"][0] - - # save this data in case we want to modify it later - self.grid_options["_Moe2017_JSON_data"] = json_data - - # Get all the masses - logmasses = sorted(json_data["log10M1"].keys()) - if not logmasses: - msg = "The table does not contain masses." - verbose_print( - "\tMoe_di_Stefano_2017: {}".format(msg), - self.grid_options["verbosity"], - 0, - ) - raise ValueError(msg) - - # Write to file - os.makedirs( - os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), - exist_ok=True, - ) - with open( - os.path.join( - os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), - "moe.log", - ), - "w", - ) as logfile: - logfile.write("logâ‚â‚€Masses(M☉) {}\n".format(logmasses)) - - # Get all the periods and see if they are all consistently present - logperiods = [] - for logmass in logmasses: - if not logperiods: - logperiods = sorted(json_data["log10M1"][logmass]["logP"].keys()) - dlog10P = float(logperiods[1]) - float(logperiods[0]) - - current_logperiods = sorted(json_data["log10M1"][logmass]["logP"]) - if not (logperiods == current_logperiods): - msg = ( - "Period values are not consistent throughout the dataset\logperiods = " - + " ".join(str(x) for x in logperiods) - + "\nCurrent periods = " - + " ".join(str(x) for x in current_logperiods) - ) - verbose_print( - "\tMoe_di_Stefano_2017: {}".format(msg), - self.grid_options["verbosity"], - 0, - ) - raise ValueError(msg) - - ############################################################ - # log10period binwidth : of course this assumes a fixed - # binwidth, so we check for this too. - for i in range(len(current_logperiods) - 1): - if not dlog10P == ( - float(current_logperiods[i + 1]) - float(current_logperiods[i]) - ): - msg = "Period spacing is not consistent throughout the dataset" - verbose_print( - "\tMoe_di_Stefano_2017: {}".format(msg), - self.grid_options["verbosity"], - 0, - ) - raise ValueError(msg) - - # save the logperiods list in the cache: - # this is used in the renormalization integration - Moecache["logperiods"] = logperiods - - # Write to file - os.makedirs( - os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), - exist_ok=True, - ) - with open( - os.path.join(self.grid_options["tmp_dir"], "moe_distefano", "moe.log"), - "a", - ) as logfile: - logfile.write("logâ‚â‚€Periods(days) {}\n".format(logperiods)) - - # Fill the global dict - for logmass in logmasses: - # Create the multiplicity table - if not Moecache.get("multiplicity_table", None): - Moecache["multiplicity_table"] = [] - - # multiplicity as a function of primary mass - Moecache["multiplicity_table"].append( - [ - float(logmass), - json_data["log10M1"][logmass]["f_multi"], - json_data["log10M1"][logmass]["single star fraction"], - json_data["log10M1"][logmass]["binary star fraction"], - json_data["log10M1"][logmass]["triple/quad star fraction"], - ] - ) - - ############################################################ - # a small log10period which we can shift just outside the - # table to force integration out there to zero - epslog10P = 1e-8 * dlog10P - - ############################################################ - # loop over either binary or triple-outer periods - first = 1 - - # Go over the periods - for logperiod in logperiods: - ############################################################ - # distributions of binary and triple star fractions - # as a function of mass, period. - # - # Note: these should be per unit log10P, hence we - # divide by dlog10P - - if first: - first = 0 - - # Create the multiplicity table - if not Moecache.get("period_distributions", None): - Moecache["period_distributions"] = [] - - ############################################################ - # lower bound the period distributions to zero probability - Moecache["period_distributions"].append( - [ - float(logmass), - float(logperiod) - 0.5 * dlog10P - epslog10P, - 0.0, - 0.0, - ] - ) - Moecache["period_distributions"].append( - [ - float(logmass), - float(logperiod) - 0.5 * dlog10P, - json_data["log10M1"][logmass]["logP"][logperiod][ - "normed_bin_frac_p_dist" - ] - / dlog10P, - json_data["log10M1"][logmass]["logP"][logperiod][ - "normed_tripquad_frac_p_dist" - ] - / dlog10P, - ] - ) - - Moecache["period_distributions"].append( - [ - float(logmass), - float(logperiod), - json_data["log10M1"][logmass]["logP"][logperiod][ - "normed_bin_frac_p_dist" - ] - / dlog10P, - json_data["log10M1"][logmass]["logP"][logperiod][ - "normed_tripquad_frac_p_dist" - ] - / dlog10P, - ] - ) - - ############################################################ - # distributions as a function of mass, period, q - # - # First, get a list of the qs given by Moe - # - qs = sorted(json_data["log10M1"][logmass]["logP"][logperiod]["q"]) - - # Fill the data and 'normalise' - qdata = fill_data( - qs, json_data["log10M1"][logmass]["logP"][logperiod]["q"] - ) - - # Create the multiplicity table - if not Moecache.get("q_distributions", None): - Moecache["q_distributions"] = [] - - for q in qs: - Moecache["q_distributions"].append( - [float(logmass), float(logperiod), float(q), qdata[q]] - ) - - ############################################################ - # eccentricity distributions as a function of mass, period, ecc - eccs = sorted(json_data["log10M1"][logmass]["logP"][logperiod]["e"]) - - # Fill the data and 'normalise' - ecc_data = fill_data( - eccs, json_data["log10M1"][logmass]["logP"][logperiod]["e"] - ) - - # Create the multiplicity table - if not Moecache.get("ecc_distributions", None): - Moecache["ecc_distributions"] = [] - - for ecc in eccs: - Moecache["ecc_distributions"].append( - [ - float(logmass), - float(logperiod), - float(ecc), - ecc_data[ecc], - ] - ) - - ############################################################ - # upper bound the period distributions to zero probability - Moecache["period_distributions"].append( - [ - float(logmass), - float(logperiods[-1]) + 0.5 * dlog10P, # TODO: why this shift? - json_data["log10M1"][logmass]["logP"][logperiods[-1]][ - "normed_bin_frac_p_dist" - ] - / dlog10P, - json_data["log10M1"][logmass]["logP"][logperiods[-1]][ - "normed_tripquad_frac_p_dist" - ] - / dlog10P, - ] - ) - Moecache["period_distributions"].append( - [ - float(logmass), - float(logperiods[-1]) + 0.5 * dlog10P + epslog10P, - 0.0, - 0.0, - ] - ) - - verbose_print( - "\tMoe_di_Stefano_2017: Length period_distributions table: {}".format( - len(Moecache["period_distributions"]) - ), - self.grid_options["verbosity"], - _MOE2017_VERBOSITY_LEVEL, - ) - verbose_print( - "\tMoe_di_Stefano_2017: Length multiplicity table: {}".format( - len(Moecache["multiplicity_table"]) - ), - self.grid_options["verbosity"], - _MOE2017_VERBOSITY_LEVEL, - ) - verbose_print( - "\tMoe_di_Stefano_2017: Length q table: {}".format( - len(Moecache["q_distributions"]) - ), - self.grid_options["verbosity"], - _MOE2017_VERBOSITY_LEVEL, - ) - verbose_print( - "\tMoe_di_Stefano_2017: Length ecc table: {}".format( - len(Moecache["ecc_distributions"]) - ), - self.grid_options["verbosity"], - _MOE2017_VERBOSITY_LEVEL, - ) - - # Write to log file - os.makedirs( - os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), - exist_ok=True, - ) - with open( - os.path.join( - os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), - "moecache.json", - ), - "w", - ) as cache_filehandle: - cache_filehandle.write(json.dumps(Moecache, indent=4)) - - # Signal that the data has been loaded - self.grid_options["_loaded_Moe2017_data"] = True - - def _set_moe_di_stefano_distributions(self): - """ - Function to set the Moe & di Stefano distribution - """ - - ############################################################ - # first, the multiplicity, this is 1,2,3,4, ... - # for singles, binaries, triples, quadruples, ... - - max_multiplicity = get_max_multiplicity( - self.grid_options["Moe2017_options"]["multiplicity_modulator"] - ) - verbose_print( - "\tMoe_di_Stefano_2017: Max multiplicity = {}".format(max_multiplicity), - self.grid_options["verbosity"], - _MOE2017_VERBOSITY_LEVEL, - ) - ###### - # Setting up the grid variables - - # Multiplicity - self.add_grid_variable( - name="multiplicity", - parameter_name="multiplicity", - longname="multiplicity", - valuerange=[1, max_multiplicity], - samplerfunc="const(1, {n}, {n})".format(n=max_multiplicity), - precode='self.grid_options["multiplicity"] = multiplicity; self.bse_options["multiplicity"] = multiplicity; options={}'.format( - self.grid_options["Moe2017_options"] - ), - condition="({}[int(multiplicity)-1] > 0)".format( - str(self.grid_options["Moe2017_options"]["multiplicity_modulator"]) - ), - gridtype="edge", - dphasevol=-1, - probdist=1, - ) - - ############################################################ - # always require M1, for all systems - # - # log-spaced m1 with given resolution - self.add_grid_variable( - name="lnm1", - parameter_name="M_1", - longname="Primary mass", - samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"]["M"][0] - or "const(np.log({}), np.log({}), {})".format( - 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["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["Moe2017_options"]))[1:-1], - "'multiplicity': multiplicity", - "'M_1': M_1", - ), - ) - - # Go to higher multiplicities - if max_multiplicity >= 2: - # binaries: period - self.add_grid_variable( - name="log10per", - parameter_name="orbital_period", - longname="log10(Orbital_Period)", - probdist=1.0, - condition='(self.grid_options["multiplicity"] >= 2)', - branchpoint=1 - if max_multiplicity > 1 - else 0, # Signal here to put a branchpoint if we have a max multiplicity higher than 1. - gridtype="centred", - dphasevol="({} * dlog10per)".format(LOG_LN_CONVERTER), - valuerange=[ - self.grid_options["Moe2017_options"]["ranges"]["logP"][0], - self.grid_options["Moe2017_options"]["ranges"]["logP"][1], - ], - samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"][ - "logP" - ][0] - or "const({}, {}, {})".format( - 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["Moe2017_options"]["Mmin"] - ), - ) # TODO: change the maximum_mass_ratio_for_RLOF - - # binaries: mass ratio - self.add_grid_variable( - name="q", - parameter_name="M_2", - longname="Mass ratio", - valuerange=[ - 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["Moe2017_options"]["ranges"]["q"][1] - if self.grid_options["Moe2017_options"] - .get("ranges", {}) - .get("q", None) - else "qmax", - ], - probdist=1, - gridtype="centred", - dphasevol="dq", - precode=""" -M_2 = q * M_1 -sep = calc_sep_from_period(M_1, M_2, orbital_period) - """, - samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"]["M"][1] - or "const({}, {}, {})".format( - 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["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["Moe2017_options"]["resolutions"]["M"][1], - ), - ) - - # (optional) binaries: eccentricity - if self.grid_options["Moe2017_options"]["resolutions"]["ecc"][0] > 0: - self.add_grid_variable( - name="ecc", - parameter_name="eccentricity", - longname="Eccentricity", - probdist=1, - gridtype="centred", - dphasevol="decc", - precode="eccentricity=ecc", - valuerange=[ - self.grid_options["Moe2017_options"]["ranges"]["ecc"][ - 0 - ], # Just fail if not defined. - self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], - ], - samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"][ - "ecc" - ][0] - or "const({}, {}, {})".format( - self.grid_options["Moe2017_options"]["ranges"]["ecc"][ - 0 - ], # Just fail if not defined. - self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], - self.grid_options["Moe2017_options"]["resolutions"]["ecc"][0], - ), - ) - - # Now for triples and quadruples - if max_multiplicity >= 3: - # Triple: period - self.add_grid_variable( - name="log10per2", - parameter_name="orbital_period_triple", - longname="log10(Orbital_Period2)", - probdist=1.0, - condition='(self.grid_options["multiplicity"] >= 3)', - branchpoint=2 - if max_multiplicity > 2 - else 0, # Signal here to put a branchpoint if we have a max multiplicity higher than 1. - gridtype="centred", - dphasevol="({} * dlog10per2)".format(LOG_LN_CONVERTER), - valuerange=[ - self.grid_options["Moe2017_options"]["ranges"]["logP"][0], - self.grid_options["Moe2017_options"]["ranges"]["logP"][1], - ], - samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"][ - "logP" - ][1] - or "const({}, {}, {})".format( - 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["Moe2017_options"]["Mmin"] - ), - ) - - # Triples: mass ratio - # Note, the mass ratio is M_outer/M_inner - self.add_grid_variable( - name="q2", - parameter_name="M_3", - longname="Mass ratio outer/inner", - valuerange=[ - 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["Moe2017_options"]["ranges"]["q"][1] - if self.grid_options["Moe2017_options"] - .get("ranges", {}) - .get("q", None) - else "q2max", - ], - probdist=1, - gridtype="centred", - dphasevol="dq2", - precode=""" -M_3 = q2 * (M_1 + M_2) -sep2 = calc_sep_from_period((M_1+M_2), M_3, orbital_period_triple) -eccentricity2=0 -""", - samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"][ - "M" - ][2] - or "const({}, {}, {})".format( - 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["Moe2017_options"]["ranges"]["q"][1] - if self.grid_options["Moe2017_options"] - .get("ranges", {}) - .get("q", None) - else "q2max", - self.grid_options["Moe2017_options"]["resolutions"]["M"][2], - ), - ) - - # (optional) triples: eccentricity - if self.grid_options["Moe2017_options"]["resolutions"]["ecc"][1] > 0: - self.add_grid_variable( - name="ecc2", - parameter_name="eccentricity2", - longname="Eccentricity of the triple", - probdist=1, - gridtype="centred", - dphasevol="decc2", - precode="eccentricity2=ecc2", - valuerange=[ - self.grid_options["Moe2017_options"]["ranges"]["ecc"][ - 0 - ], # Just fail if not defined. - self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], - ], - samplerfunc=self.grid_options["Moe2017_options"][ - "samplerfuncs" - ]["ecc"][1] - or "const({}, {}, {})".format( - self.grid_options["Moe2017_options"]["ranges"]["ecc"][ - 0 - ], # Just fail if not defined. - self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], - self.grid_options["Moe2017_options"]["resolutions"]["ecc"][ - 1 - ], - ), - ) - - if max_multiplicity == 4: - # Quadruple: period - self.add_grid_variable( - name="log10per3", - parameter_name="orbital_period_quadruple", - longname="log10(Orbital_Period3)", - probdist=1.0, - condition='(self.grid_options["multiplicity"] >= 4)', - branchpoint=3 - if max_multiplicity > 3 - else 0, # Signal here to put a branchpoint if we have a max multiplicity higher than 1. - gridtype="centred", - dphasevol="({} * dlog10per3)".format(LOG_LN_CONVERTER), - valuerange=[ - self.grid_options["Moe2017_options"]["ranges"]["logP"][0], - self.grid_options["Moe2017_options"]["ranges"]["logP"][1], - ], - samplerfunc=self.grid_options["Moe2017_options"][ - "samplerfuncs" - ]["logP"][2] - or "const({}, {}, {})".format( - 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["Moe2017_options"]["Mmin"] - ), - ) - - # Quadruple: mass ratio : M_outer / M_inner - self.add_grid_variable( - name="q3", - parameter_name="M_4", - longname="Mass ratio outer low/outer high", - valuerange=[ - 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["Moe2017_options"]["ranges"]["q"][1] - if self.grid_options["Moe2017_options"] - .get("ranges", {}) - .get("q", None) - else "q3max", - ], - probdist=1, - gridtype="centred", - dphasevol="dq3", - precode=""" -M_4 = q3 * M_3 -sep3 = calc_sep_from_period((M_3), M_4, orbital_period_quadruple) -eccentricity3=0 -""", - samplerfunc=self.grid_options["Moe2017_options"][ - "samplerfuncs" - ]["M"][3] - or "const({}, {}, {})".format( - 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["Moe2017_options"]["ranges"]["q"][1] - if self.grid_options["Moe2017_options"] - .get("ranges", {}) - .get("q", None) - else "q3max", - self.grid_options["Moe2017_options"]["resolutions"]["M"][2], - ), - ) - - # (optional) triples: eccentricity - 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", - probdist=1, - gridtype="centred", - dphasevol="decc3", - precode="eccentricity3=ecc3", - valuerange=[ - self.grid_options["Moe2017_options"]["ranges"]["ecc"][ - 0 - ], # Just fail if not defined. - self.grid_options["Moe2017_options"]["ranges"]["ecc"][ - 1 - ], - ], - samplerfunc=self.grid_options["Moe2017_options"][ - "samplerfuncs" - ]["ecc"][2] - or "const({}, {}, {})".format( - self.grid_options["Moe2017_options"]["ranges"]["ecc"][ - 0 - ], # Just fail if not defined. - self.grid_options["Moe2017_options"]["ranges"]["ecc"][ - 1 - ], - self.grid_options["Moe2017_options"]["resolutions"][ - "ecc" - ][2], - ), - ) - - # Now we are at the last part. - # Here we should combine all the information that we calculate and update the options - # dictionary. This will then be passed to the Moe_di_Stefano_2017_pdf to calculate - # the real probability. The trick we use is to strip the options_dict as a string - # and add some keys to it: - - updated_options = "{{{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}}".format( - str(dict(self.grid_options["Moe2017_options"]))[1:-1], - '"multiplicity": multiplicity', - '"M_1": M_1', - '"M_2": M_2', - '"M_3": M_3', - '"M_4": M_4', - '"P": orbital_period', - '"P2": orbital_period_triple', - '"P3": orbital_period_quadruple', - '"ecc": eccentricity', - '"ecc2": eccentricity2', - '"ecc3": eccentricity3', - ) - - probdist_addition = "Moe_di_Stefano_2017_pdf({}, verbosity=self.grid_options['verbosity'])['total_probdens']".format( - updated_options - ) - - # and finally the probability calculator - self.grid_options["_grid_variables"][self._last_grid_variable()][ - "probdist" - ] = probdist_addition - - verbose_print( - "\tMoe_di_Stefano_2017: Added final call to the pdf function", - self.grid_options["verbosity"], - _MOE2017_VERBOSITY_LEVEL, - ) - - # Signal that the MOE2017 grid has been set - self.grid_options["_set_Moe2017_grid"] = True - - ################################################################################################ - def Moe_di_Stefano_2017(self, options=None): + def _new_grid_ensemble_results(self): """ - Function to handle setting the user input settings, - set up the data and load that into interpolators and - then set the distribution functions - - Takes a dictionary as its only argument + Function to return a new grid_ensemble_results dict: this should + be pre-filled by sub-dicts to prevent later errors. """ - - default_options = { - "apply settings": True, - "setup grid": True, - "load data": True, - "clean cache": False, - "clean load flag": False, - "clean all": False, + return { + 'metadata' : {}, + 'ensemble' : {} } - if not options: - options = {} - options = update_dicts(default_options, options) - - # clean cache? - if options["clean all"] or options["clean cache"]: - Moecache.clear() - - if options["clean all"] or options["clean load flag"]: - self.grid_options["_loaded_Moe2017_data"] = False - - # Set the user input - if options["apply settings"]: - self.set_moe_di_stefano_settings(options=options) - - # Load the data - if options["load data"]: - self._load_moe_di_stefano_data() - - # construct the grid here - if options["setup grid"]: - self._set_moe_di_stefano_distributions() - - def _clean_interpolators(self): - """ - Function to clean up the interpolators after a run - - We look in the Moecache global variable for items that are interpolators. - Should be called by the general cleanup function AND the thread cleanup function - """ - - interpolator_keys = [] - for key in Moecache.keys(): - if isinstance(Moecache[key], py_rinterpolate.Rinterpolate): - interpolator_keys.append(key) - - for key in interpolator_keys: - Moecache[key].destroy() - del Moecache[key] - gc.collect() - - ##### Unsorted functions - def _calculate_multiplicity_fraction(self, system_dict): - """ - Function to calculate multiplicity fraction - - Makes use of the self.bse_options['multiplicity'] value. If its not set, it will raise an error - - grid_options['multiplicity_fraction_function'] will be checked for the choice - - TODO: add option to put a manual binary fraction in here (solve via negative numbers being the functions) - """ - - # Just return 1 if no option has been chosen - if self.grid_options["multiplicity_fraction_function"] in [0, "None"]: - verbose_print( - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.", - self.grid_options["verbosity"], - 3, - ) - - return 1 - - # Raise an error if the multiplicity is not set - if not system_dict.get("multiplicity", None): - msg = "Multiplicity value has not been set. When using a specific multiplicity fraction function please set the multiplicity" - raise ValueError(msg) - - # Go over the chosen options - if self.grid_options["multiplicity_fraction_function"] in [1, "Arenou2010"]: - # Arenou 2010 will be used - verbose_print( - "_calculate_multiplicity_fraction: Using Arenou 2010 to calculate multiplicity fractions", - self.grid_options["verbosity"], - 3, - ) - - binary_fraction = Arenou2010_binary_fraction(system_dict["M_1"]) - multiplicity_fraction_dict = { - 1: 1 - binary_fraction, - 2: binary_fraction, - 3: 0, - 4: 0, - } - - elif self.grid_options["multiplicity_fraction_function"] in [2, "Raghavan2010"]: - # Raghavan 2010 will be used - verbose_print( - "_calculate_multiplicity_fraction: Using Raghavan (2010) to calculate multiplicity fractions", - self.grid_options["verbosity"], - 3, - ) - - binary_fraction = raghavan2010_binary_fraction(system_dict["M_1"]) - multiplicity_fraction_dict = { - 1: 1 - binary_fraction, - 2: binary_fraction, - 3: 0, - 4: 0, - } - - elif self.grid_options["multiplicity_fraction_function"] in [3, "Moe2017"]: - # We need to check several things now here: - - # 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) - - # Second: is the Moecache filled. - if not Moecache: - verbose_print( - "_calculate_multiplicity_fraction: Moecache is empty. It needs to be filled with the data for the interpolators. Loading the data now", - self.grid_options["verbosity"], - 3, - ) - - # Load the data - self._load_moe_di_stefano_data() - - # record the prev value - prev_M1_value_ms = self.grid_options["Moe2017_options"].get("M_1", None) - - # Set value of M1 of the current system - 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["Moe2017_options"], self.grid_options["verbosity"] - ) - - # Turn into dict - multiplicity_fraction_dict = { - el + 1: multiplicity_fraction_list[el] - for el in range(len(multiplicity_fraction_list)) - } - - # Set the prev value back - self.grid_options["Moe2017_options"]["M_1"] = prev_M1_value_ms - - # we don't know what to do next - else: - msg = "Chosen value for the multiplicity fraction function is not known." - raise ValueError(msg) - - # To make sure we normalize the dictionary - multiplicity_fraction_dict = normalize_dict( - multiplicity_fraction_dict, verbosity=self.grid_options["verbosity"] - ) - - verbose_print( - "Multiplicity: {} multiplicity_fraction: {}".format( - system_dict["multiplicity"], - multiplicity_fraction_dict[system_dict["multiplicity"]], - ), - self.grid_options["verbosity"], - 3, - ) - - return multiplicity_fraction_dict[system_dict["multiplicity"]] - - ###################### - # Status logging - - def vb1print(self, ID, now, system_number, system_dict): - """ - Verbosity-level 1 printing, to keep an eye on a grid. - Arguments: - ID: thread ID for debugging (int) - now: the time now as a UNIX-style epoch in seconds (float) - system_number: the system number - - TODO: add information about the number of cores. the TPR shows the dt/dn but i want to see the number per core too - """ - - # calculate estimated time of arrive (eta and eta_secs), time per run (tpr) - localtime = time.localtime(now) - - # calculate stats - n = self.shared_memory["n_saved_log_stats"].value - if n < 2: - # simple 1-system calculation: inaccurate - # but best for small n - dt = now - self.shared_memory["prev_log_time"][0] - dn = system_number - self.shared_memory["prev_log_system_number"][0] - else: - # average over n_saved_log_stats - dt = ( - self.shared_memory["prev_log_time"][0] - - self.shared_memory["prev_log_time"][n - 1] - ) - dn = ( - self.shared_memory["prev_log_system_number"][0] - - self.shared_memory["prev_log_system_number"][n - 1] - ) - - eta, units, tpr, eta_secs = trem( - dt, system_number, dn, self.grid_options["_total_starcount"] - ) - - # compensate for multithreading and modulo - tpr *= self.grid_options["num_cores"] * self.grid_options["modulo"] - - if eta_secs < secs_per_day: - fintime = time.localtime(now + eta_secs) - etf = "{hours:02d}:{minutes:02d}:{seconds:02d}".format( - hours=fintime.tm_hour, minutes=fintime.tm_min, seconds=fintime.tm_sec - ) - else: - d = int(eta_secs / secs_per_day) - if d == 1: - etf = "Tomorrow" - else: - etf = "In {} days".format(d) - - # modulo information - if self.grid_options["modulo"] == 1: - modulo = "" # usual case - else: - modulo = "%" + str(self.grid_options["modulo"]) - - # add up memory use from each thread - total_mem_use = sum(self.shared_memory["memory_use_per_thread"]) - - # make a string to describe the system e.g. M1, M2, etc. - system_string = "" - - # use the multiplicity if given - if "multiplicity" in system_dict: - nmult = system_dict["multiplicity"] - else: - nmult = 4 - - # masses - for i in range(nmult): - i1 = str(i + 1) - if "M_" + i1 in system_dict: - system_string += ( - "M{}=".format(i1) + format_number(system_dict["M_" + i1]) + " " - ) - - # separation and orbital period - if "separation" in system_dict: - system_string += "a=" + format_number(system_dict["separation"]) - if "orbital_period" in system_dict: - system_string += "P=" + format_number(system_dict["orbital_period"]) - - # do the print - verbose_print( - "{opening_colour}{system_number}/{total_starcount}{modulo} {pc_colour}{pc_complete:5.1f}% complete {time_colour}{hours:02d}:{minutes:02d}:{seconds:02d} {ETA_colour}ETA={ETA:7.1f}{units} tpr={tpr:2.2e} {ETF_colour}ETF={ETF} {mem_use_colour}mem:{mem_use:.1f}MB {system_string_colour}{system_string}{closing_colour}".format( - opening_colour=self.ANSI_colours["reset"] - + self.ANSI_colours["yellow on black"], - system_number=system_number, - total_starcount=self.grid_options["_total_starcount"], - modulo=modulo, - pc_colour=self.ANSI_colours["blue on black"], - pc_complete=(100.0 * system_number) - / (1.0 * self.grid_options["_total_starcount"]) - if self.grid_options["_total_starcount"] - else -1, - time_colour=self.ANSI_colours["green on black"], - hours=localtime.tm_hour, - minutes=localtime.tm_min, - seconds=localtime.tm_sec, - ETA_colour=self.ANSI_colours["red on black"], - ETA=eta, - units=units, - tpr=tpr, - ETF_colour=self.ANSI_colours["blue"], - ETF=etf, - mem_use_colour=self.ANSI_colours["magenta"], - mem_use=total_mem_use, - system_string_colour=self.ANSI_colours["yellow"], - system_string=system_string, - closing_colour=self.ANSI_colours["reset"], - ), - self.grid_options["verbosity"], - 1, - ) - - def vb2print(self, system_dict, cmdline_string): - print( - "Running this system now on thread {ID}\n{blue}{cmdline}{reset}\n".format( - ID=self.process_ID, - blue=self.ANSI_colours["blue"], - cmdline=cmdline_string, - reset=self.ANSI_colours["reset"], - ) - ) diff --git a/binarycpython/utils/grid_options_defaults.py b/binarycpython/utils/grid_options_defaults.py index bfe7a48b0ee789ed505ffaea73f6682dc86d199b..02ecbf34f0a054c4f2f681121d93dc19047b7bf9 100644 --- a/binarycpython/utils/grid_options_defaults.py +++ b/binarycpython/utils/grid_options_defaults.py @@ -102,6 +102,7 @@ grid_options_defaults_dict = { "_evolution_type_options": [ "grid", "custom_generator", + "source_file", ], # available choices for type of population evolution. # TODO: fill later with Monte Carlo, source file "_system_generator": None, # value that holds the function that generates the system # (result of building the grid script) @@ -475,8 +476,8 @@ grid_options_descriptions = { "_commandline_input": "String containing the arguments passed to the population object via the command line. Set and used by the population object.", "_system_generator": "Function object that contains the system generator function. This can be from a grid, or a source file, or a Monte Carlo grid.", "gridcode_filename": "Filename for the grid code. Set and used by the population object. TODO: allow the user to provide their own function, rather than only a generated function.", - "log_args": "Boolean to log the arguments. Unused ", # TODO: fix the functionality for this and describe it properly - "log_args_dir": "Directory to log the arguments to. Unused", # TODO: fix the functionality for this and describe it properly + "log_args": "Boolean to log the arguments of the current running system. ", + "log_args_dir": "Directory to log the arguments of the current running system to.", "log_file": "Log file for the population object. Unused", # TODO: fix the functionality for this and describe it properly "custom_logging_func_memaddr": "Memory address where the custom_logging_function is stored. Input: int", "_count": "Counter tracking which system the generator is on.", diff --git a/binarycpython/utils/hpc_functions.py b/binarycpython/utils/hpc_functions.py deleted file mode 100644 index 87d3fe8b909b4c3496f430a9add8454016f8ac2a..0000000000000000000000000000000000000000 --- a/binarycpython/utils/hpc_functions.py +++ /dev/null @@ -1,151 +0,0 @@ -""" -File containing functions for HPC computing, distributed tasks on clusters etc. - -Functions that the Slurm and Condor subroutines of the population object use. - -Mainly divided in 2 sections: Slurm and Condor -""" - -# import os -# import sys -# import time -# import subprocess -# from typing import Union -# import __main__ as main - - -# def get_slurm_version() -> Union[str, None]: -# """ -# Function that checks whether slurm is installed and returns the version if its installed. - -# Only tested this with slurm v17+ - -# Returns: -# slurm version, or None -# """ - -# slurm_version = None - -# try: -# slurm_version = ( -# subprocess.run(["sinfo", "-V"], stdout=subprocess.PIPE, check=True) -# .stdout.decode("utf-8") -# .split() -# )[1] -# except FileNotFoundError as err: -# print(err) -# print(err.args) -# print("Slurm is not installed or not loaded") -# except Exception as err: -# print(err) -# print(err.args) -# print("Unknown error, contact me about this") - -# return slurm_version - - -# def get_condor_version() -> Union[str, None]: -# """ -# Function that checks whether slurm is installed and returns the version if its installed. - -# otherwise returns None - -# Result has to be condor v8 or higher - -# Returns: -# condor version, or None -# """ - -# condor_version = None - -# try: -# condor_version = ( -# subprocess.run( -# ["condor_q", "--version"], stdout=subprocess.PIPE, check=True -# ) -# .stdout.decode("utf-8") -# .split() -# )[1] -# except FileNotFoundError as err: -# print("Slurm is not installed or not loaded: ") -# print(err) -# print(err.args) -# except Exception as err: -# print("Unknown error, contact me about this: ") -# print(err) -# print(err.args) - -# return condor_version - - -# def create_directories_hpc(working_dir: str) -> None: -# """ -# Function to create a set of directories, given a root directory - -# These directories will contain stuff for the HPC runs - -# Args: -# working_dir: main working directory of the run. Under this directory all the dirs will be created -# """ - -# # Check if working_dir exists -# if not os.path.isdir(working_dir): -# print("Error. Working directory {} does not exist! Aborting") -# raise ValueError - -# directories_list = [ -# "scripts", -# "stdout", -# "stderr", -# "results", -# "logs", -# "status", -# "joining", -# ] - -# # Make directories. -# for subdir in directories_list: -# full_path = os.path.join(working_dir, subdir) -# os.makedirs(full_path, exist_ok=True) - -# # Since the directories are probably made on some mount which has to go over NFS -# # we should explicitly check if they are created -# print("Checking if creating the directories has finished...") -# directories_exist = False -# while directories_exist: -# directories_exist = True - -# for subdir in directories_list: -# full_path = os.path.join(working_dir, subdir) - -# if not os.path.isdir(full_path): -# time.sleep(1) -# directories_exist = False -# print("..Finished! Directories exist.") - - -# def path_of_calling_script() -> str: -# """ -# Function to get the name of the script the user executes. -# TODO: fix this function. seems not to work properly. -# """ - -# return main.__file__ - - -# def get_python_details() -> dict: -# """ -# Function to get some info about the used python version and virtualenv etc - -# Returns: -# dictionary with python executable, virtual environment and version information. -# """ - -# python_info_dict = {} - -# # -# python_info_dict["virtualenv"] = os.getenv("VIRTUAL_ENV") -# python_info_dict["executable"] = sys.executable -# python_info_dict["version"] = sys.version - -# return python_info_dict diff --git a/binarycpython/utils/plot_functions.py b/binarycpython/utils/plot_functions.py index 19bfbd45d3f090d69fb06c0ba4d5ab35e3cf5c1d..4ee603a88a91afcb2b6dc316495a381921c7af78 100644 --- a/binarycpython/utils/plot_functions.py +++ b/binarycpython/utils/plot_functions.py @@ -1,7 +1,7 @@ """ -Module that contains functionality to plot some properties of (binary) systems. +Module that contains functionality to plot some properties of (binary) systems. -Different routines are defined here to plot orbits, masses, angular momenta etc. +Different routines are defined here to plot orbits, masses, angular momenta etc. Structure of file: custom logging strings @@ -13,8 +13,8 @@ All the loose components here can of course be used in other routines if you wan There is no pre loaded matplotlib rc, you should do that yourself -These plotting routines are designed for binary systems, and admittedly they are here mostly for -inspirational purposes, since one would probably want to customise the plots. +These plotting routines are designed for binary systems, and admittedly they are here mostly for +inspirational purposes, since one would probably want to customise the plots. Regardless, having some plotting routines in here seemed like a nice idea Tasks @@ -164,10 +164,10 @@ def plot_HR_diagram( prefactor = (1 / (4 * math.pi * omega_sb)) ** (1.0 / 4) if show_stellar_types: - fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(20, 20)) - fig, colors = add_stellar_types_bar(df, fig, ax_index=-1, only_colorbar=True) + fig, _ = plt.subplots(ncols=1, nrows=1, figsize=(20, 20)) + # fig, colors = add_stellar_types_bar(df, fig, ax_index=-1, only_colorbar=True) else: - fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(20, 20)) + fig, _ = plt.subplots(ncols=1, nrows=1, figsize=(20, 20)) df = df.assign( teff_1=prefactor @@ -229,8 +229,7 @@ def plot_HR_diagram( # Show or return if show_plot: plt.show() - else: - return fig + return fig def plot_orbit(df, show_stellar_types: bool = False, show_plot: bool = True): @@ -254,10 +253,10 @@ def plot_orbit(df, show_stellar_types: bool = False, show_plot: bool = True): """ if show_stellar_types: - fig, ax = plt.subplots(ncols=1, nrows=4, figsize=(20, 10)) + fig, _ = plt.subplots(ncols=1, nrows=4, figsize=(20, 10)) fig.subplots_adjust(hspace=0) else: - fig, ax = plt.subplots(ncols=1, nrows=3, figsize=(20, 10), sharex=True) + fig, _ = plt.subplots(ncols=1, nrows=3, figsize=(20, 10), sharex=True) fig.subplots_adjust(hspace=0) # @@ -286,8 +285,7 @@ def plot_orbit(df, show_stellar_types: bool = False, show_plot: bool = True): # Show or return if show_plot: plt.show() - else: - return fig + return fig def plot_masses(df, show_stellar_types: bool = False, show_plot: bool = True): @@ -322,10 +320,10 @@ def plot_masses(df, show_stellar_types: bool = False, show_plot: bool = True): """ if show_stellar_types: - fig, ax = plt.subplots(ncols=1, nrows=2, figsize=(20, 10)) + fig, _ = plt.subplots(ncols=1, nrows=2, figsize=(20, 10)) fig.subplots_adjust(hspace=0) else: - fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(20, 10)) + fig, _ = plt.subplots(ncols=1, nrows=1, figsize=(20, 10)) max_total_mass = ( df["pms_mass_1"].values.tolist()[0] + df["pms_mass_2"].values.tolist()[0] @@ -393,14 +391,16 @@ def plot_masses(df, show_stellar_types: bool = False, show_plot: bool = True): # Show or return if show_plot: plt.show() - else: - return fig + return fig # Define the parse functions for the plotting routines def dummy(): - """Placeholder""" - pass + """ + Placeholder function + """ + + return None def parse_function_hr_diagram(output: str): @@ -543,11 +543,6 @@ def plot_system(plot_type, **kwargs): - orbit_evolution - hr_diagram - Tasks: - - TODO: Complex Function! - - TODO: make sure this way of passing args works correctly. - - TODO: make the plotting specific keywords available via the inspect stuff - All keywords are considered kwargs, except for plot_type Args: @@ -602,15 +597,15 @@ def plot_system(plot_type, **kwargs): # run_system will handle the rest run_system_arg_dict = {} - for key in kwargs.keys(): + for key, value in kwargs.items(): if key == "show_plot": - show_plot = kwargs[key] + show_plot = value elif key == "show_stellar_types": - show_stellar_types = kwargs[key] + show_stellar_types = value # The rest will be passed to run_system else: - run_system_arg_dict[key] = kwargs[key] + run_system_arg_dict[key] = value # TODO: When a list of plot_types is passed, make it so that the strings are chained, # and that the output of the binary_c call is handled by multiple parsers @@ -628,22 +623,4 @@ def plot_system(plot_type, **kwargs): binary_c_output_df, show_plot=show_plot, show_stellar_types=show_stellar_types ) - if not show_plot: - return fig - - -# from david_phd_functions.plotting.custom_mpl_settings import load_mpl_rc -# load_mpl_rc() - -# fig = plot_system( -# plot_type="mass_evolution", -# M_1=10, -# M_2=5, -# separation=1000000, -# orbital_period=100000000, -# max_evolution_time=15000, -# show_plot=True, -# ) - -# fig.axes[0].set_xlim(0, 150) -# plt.show() + return fig diff --git a/binarycpython/utils/population_extensions/HPC.py b/binarycpython/utils/population_extensions/HPC.py new file mode 100644 index 0000000000000000000000000000000000000000..5a5555a75a3c3ab0522b3c594385b803871fa500 --- /dev/null +++ b/binarycpython/utils/population_extensions/HPC.py @@ -0,0 +1,736 @@ +""" +Module containing the functions to HPC functionality + +These functions form a single API through which you can access HPC resources. + +Generally, you should call an HPC function rather than the Slurm or Condor interface +directly. The HPC function then decides which interface to use, so that all the +other modules can use a single API rather than have to choose to use the Slurm or +Condor API. + +This class object is an extension to the population grid object +""" + +# pylint: disable=E1101 + +import glob +import json +import os + +from binarycpython.utils.functions import ( + now, +) + +from binarycpython.utils.population_extensions.slurm import slurm +from binarycpython.utils.population_extensions.condor import condor + + +class HPC(condor, slurm): + """ + Extension to the population grid object that contains functionality to handle handle the Moe & distefano distributions + """ + + def __init__(self, **kwargs): + """ + Init function for the gridcode class + """ + + condor.__init__(self) + slurm.__init__(self) + + def HPC_njobs(self): + """ + Function to return the number of jobs this HPC jobs will use, as an int. + """ + + if self.grid_options["slurm"] > 0: + n = self.grid_options["slurm_njobs"] + elif self.grid_options["condor"] > 0: + n = self.grid_options["condor_njobs"] + else: + n = None + return int(n) + + def HPC_make_joiningfile( + self, + hpc_jobid=None, + hpc_dir=None, + n=None, + overwrite=False, + error_on_overwrite=False, + ): + """ + Function to make the joiningfile file that contains the filenames of results from each job. When all these exist, we can join. + + Note: you normally don't need to set any of the option arguments. + + Args: + hpc_jobid : the job ID number, or self.HPC_jobID_tuple()[0] if None (default=None). + hpc_dir : the HPC directory, or self.HPC_dir() if None (default=None). + n : the number of jobs, or self.HPC_njobs() if None (default=None). + overwrite : if True, overwrite an existing joiningfile (default=False) + error_on_overwite : if True, and we try to overwrite, issue and error and exit (default=False) + + Returns: + True if the file is made, False otherwise. + + """ + + # defaults + if hpc_dir is None: + hpc_dir = self.HPC_dir() + if n is None: + n = self.HPC_njobs() + if hpc_jobid is None: + hpc_jobid = self.HPC_jobID_tuple()[0] + + # make path and filename + prefix = os.path.join(hpc_dir, "results") + file = os.path.join(prefix, hpc_jobid + ".all") + + # make the output before checking anything, we do + # this to remove any asynchronicity + lines = [] + for i in self.HPC_job_id_range(): + lines += [ + os.path.join( + prefix, "{hpc_jobid}.{i}.gz\n".format(hpc_jobid=hpc_jobid, i=i) + ) + ] + string = "".join(lines) + + # check the joiningfile doesn't exist + if not overwrite and os.path.isfile(file): + # file already exists + print( + "Cannot make joiningfile at {file} because it already exists, instead I am waiting for it to be unlocked.".format( + file=file + ) + ) + self.wait_for_unlock(file) + joinfiles = self.HPC_load_joinfiles_list(joinlist=file) + print( + "Unlocked and got {} should be {}".format( + len(joinfiles), self.HPC_njobs() + ) + ) + # perhaps exit here? (e.g. for debugging) + if error_on_overwrite: + self.exit(code=1) + x = False + else: + # open the file, but locked so we have first unique access + (f, lock) = self.locked_open_for_write(file) + + # write to it if we are first to obtain unique access + if lock and f: + print("Making joiningfile list range (0,{}) at {}".format(n, file)) + f.write(string) + f.flush() + os.fsync(f.fileno()) + x = True + self.locked_close(f, lock) + os.sync() + self.NFS_flush_hack(file) + + print( + "Checking joiningfile {} length (size = {})".format( + file, os.path.getsize(file) + ) + ) + joinfiles = self.HPC_load_joinfiles_list(joinlist=file) + print("Got {} should be {}".format(len(joinfiles), self.HPC_njobs())) + + else: + x = False + print("Joiningfile failed to get lock: waiting for it to be unlocked") + self.wait_for_unlock(file) + return x + + def HPC_joinlist(self, joinlist=None): + """ + Function to return the default HPC joinlist file. + """ + + if joinlist is None: + joinlist = self.grid_options["joinlist"] + return joinlist + + def HPC_load_joinfiles_list(self, joinlist=None): + """ + Function to load in the list of files we should join, and return it. + + If grid_options['HPC_rebuild_joinlist'] is True, we rebuild it. + """ + + prefix = os.path.join(self.HPC_dir(), "results") + + if self.grid_options["HPC_rebuild_joinlist"] == 1: + # we should rebuild the joinlist from the + # files we find at the prefix directory + print("Rebuild joinlist from existing files") + joinlist = glob.glob(str(prefix) + "/*.gz") + return joinlist + + joinlist = self.HPC_joinlist(joinlist=joinlist) + try: + self.wait_for_unlock(joinlist) + f = self.open(joinlist, "r", encoding="utf-8") + joinlist = f.read().splitlines() + f.close() + + if False: + print( + "HPC_load_joinfiles_list read joinlist {joinlist} -> gave file joinlist of length {len_joinlist} with contents {joinlist}".format( + joinlist=joinlist, len_joinlist=len(joinlist) + ) + ) + except Exception as e: + print( + "Failed to open joinlist at {joinlist} : {e}".format( + joinlist=joinlist, e=e + ) + ) + self.exit(code=1) + + return joinlist + + def HPC_join_from_files(self, newobj, joinfiles): + """ + Merge the results from the list joinfiles into newobj. + """ + for file in joinfiles: + print("Join data in", file) + self.merge_populations_from_file(newobj, file) + return newobj + + def HPC_can_join(self, joinfiles, joiningfile, vb=False): + """ + Check the joinfiles to make sure they all exist + and their .saved equivalents also exist + """ + + print("HPC check if we can join at {}".format(now())) + + if self.grid_options["HPC_force_join"] == 0 and os.path.exists(joiningfile): + if vb: + print( + "cannot join : joiningfile exists at {} (check 1)".format( + joiningfile + ) + ) + return False + else: + if vb: + print("joiningfile (at {}) does not exist".format(joiningfile)) + + for file in joinfiles: + if vb: + print("check for {}".format(file)) + + if os.path.exists(file) is False: + if vb: + print('cannot join : file "{}" does not exist'.format(file)) + return False + + savedfile = file + ".saved" + if vb: + print("check for {}".format(savedfile)) + + if os.path.exists(savedfile) is False: + if vb: + print( + 'cannot join : savedfile "{}" does not exist'.format(savedfile) + ) + return False + + # found both files + if vb: + print("found {} and {}".format(file, savedfile)) + + # check for joiningfile again + if self.grid_options["HPC_force_join"] == 1: + print("Forcing join because HPC_force_join is set") + x = True + elif os.path.exists(joiningfile): + if vb: + print( + "cannot join: joiningfile exists at {} (check 2)".format( + joiningfile + ) + ) + x = False + elif vb: + print("joiningfile at {} does not exist : can join".format(joiningfile)) + x = True + + if vb: + print("returning {} from HPC_can_join()".format(x)) + + return x + + def HPC_job(self): + """ + Function to return True if we're running an HPC (Slurm or Condor) job, False otherwise. + """ + + return bool(self.grid_options["slurm"] > 0 or self.grid_options["condor"] > 0) + + def HPC_job_task(self): + """ + Function to return the HPC task number, which is 1 when setting + up and running the scripts, 2 when joining data. + """ + if self.grid_options["slurm"] > 0: + x = self.grid_options["slurm"] + elif self.grid_options["condor"] > 0: + x = self.grid_options["condor"] + else: + x = 0 + return x + + def HPC_job_type(self): + """ + Function to return a string telling us the type of an HPC job, i.e. + "slurm", "condor" or "None". + """ + if self.grid_options["slurm"] > 0: + hpc_type = "slurm" + elif self.grid_options["condor"] > 0: + hpc_type = "condor" + else: + hpc_type = "None" + return hpc_type + + def HPC_jobID(self): + """ + Function to return an HPC (Slurm or Condor) job id in the form of a string, x.y. Returns None if not an HPC job. + """ + + if self.grid_options["slurm"] > 0: + hpc_jobid = self.slurmID() + elif self.grid_options["condor"] > 0: + hpc_jobid = self.condorID() + else: + # not an HPC job + hpc_jobid = None + + return hpc_jobid + + def HPC_jobID_tuple(self): + """ + Return the job ID as a tuple of ints, (x,y), or (None,None) on failure + """ + + hpc_jobid = self.HPC_jobID() + + if hpc_jobid is None or hpc_jobid.startswith("None"): + split_hpc_jobid = [None, None] + else: + split_hpc_jobid = hpc_jobid.split(".") + if not split_hpc_jobid[0]: + split_hpc_jobid[0] = None + if not split_hpc_jobid[1]: + split_hpc_jobid[1] = None + return tuple(split_hpc_jobid) + + def HPC_set_status(self, string): + """ + Set the appropriate HPC job (Condor or Slurm) status file to whatever is given in string. + + Arguments: + string : the new contents of the status file + """ + + if self.grid_options["slurm"] > 0: + self.set_slurm_status(string) + elif self.grid_options["condor"] > 0: + self.set_condor_status(string) + else: + pass + + def HPC_get_status(self, job_id=None, job_index=None, hpc_dir=None): + """ + Get and return the appropriate HPC job (Condor or Slurm) status string for this job (or, if given, the job at id.index) + + Args: + hpc_dir : optional HPC run directory. If not set, the default (e.g. slurm_dir or condor_dir) + is used. + job_id,job_index : the id and index of the job to be queried + """ + + if self.grid_options["slurm"] > 0: + status = self.get_slurm_status( + jobid=job_id, jobarrayindex=job_index, slurm_dir=hpc_dir + ) + elif self.grid_options["condor"] > 0: + status = self.get_condor_status( + ClusterID=job_id, Process=job_index, condor_dir=hpc_dir + ) + else: + status = None + + return status + + def HPC_dirs(self): + """ + Function to return a list of directories required for this HPC job. + """ + if self.grid_options["slurm"] > 0: + dirs = self.slurm_dirs() + elif self.grid_options["condor"] > 0: + dirs = self.condor_dirs() + else: + dirs = [] + return dirs + + def HPC_grid(self, makejoiningfile=True): # pragma: no cover + """ + Function to call the appropriate HPC grid function + (e.g. Slurm or Condor) and return what it returns. + + Args: + makejoiningfile : if True, and we're the first job with self.HPC_task() == 2, we build the joiningfile. (default=True) This option exists in case you don't want to overwrite an existing joiningfile, or want to build it in another way (e.g. in the HPC scripts). + + TODO: Exclude this function from testing for now + TODO: Comment this function better + """ + + jobid = self.HPC_jobID_tuple()[0] + + # give some current status about the HPC run + self.HPC_dump_status("HPC grid before") + + if makejoiningfile and self.HPC_job_task() == 2 and jobid is not None: + self.HPC_make_joiningfile() + + if self.grid_options["slurm"] > 0: + x = self.slurm_grid() + elif self.grid_options["condor"] > 0: + x = self.condor_grid() + else: + x = None # should not happen + + # give some current status about the HPC run + self.HPC_dump_status("HPC grid after") + + return x + + def HPC_check_requirements(self): + """ + Function to check HPC option requirements have been met. Returns a tuple: (True,"") if all is ok, (False,<warning string>) otherwise. + """ + if self.grid_options["slurm"] > 0: + t = self.slurm_check_requirements() + elif self.grid_options["condor"] > 0: + t = self.condor_check_requirements() + else: + t = (True, "") + return t + + def HPC_id_filename(self): + """ + HPC jobs have a filename in their directory which specifies the job id. This function returns the contents of that file as a string, or None on failure. + """ + + if self.grid_options["slurm"] > 0: + filename = "jobid" + elif self.grid_options["condor"] > 0: + filename = "ClusterID" + else: + filename = None + return filename + + def HPC_id_from_dir(self, hpc_dir): + """ + Function to return the ID of an HPC run given its (already existing) directory. + """ + + filename = self.HPC_id_filename() + if not filename: + return None + + file = os.path.join(hpc_dir, filename) + f = self.open(file, "r", encoding="utf-8") + if not f: + print( + "Error: could not open {file} to read the HPC jobid of the directory {hpc_dir}".format( + file=file, hpc_dir=hpc_dir + ) + ) + self.exit(code=1) + + oldjobid = f.read().strip() + if not oldjobid: + print("Error: could not find jobid in {hpc_dir}".format(hpc_dir=hpc_dir)) + self.exit(code=1) + else: + f.close() + return oldjobid + + def HPC_restore(self): + """ + Set grid_options['restore_from_snapshot_file'] so that we restore data from existing + an HPC run if self.grid_options[hpc_job_type+'_restart_dir'], where hpc_job_type is "slurm" or "condor", + is provided, otherwise do nothing. This only works if grid_options[hpc_job_type] == self.HPC_job_task() == 2, which is + the run-grid stage of the process. + """ + + hpc_job_type = self.HPC_job_type() + if hpc_job_type is None: + return + + key = hpc_job_type + "_restart_dir" + if key not in self.grid_options: + return + + # get restart directory + hpc_dir = self.grid_options[hpc_job_type + "_restart_dir"] + if hpc_dir is None: + return + + # get HPC job index + index = self.HPC_jobID_tuple()[1] + if index is None: + return + + if self.HPC_job_task() == 2: # (same as) self.grid_options[hpc_job_type] == 2: + old_id = self.HPC_id_from_dir(hpc_dir) + print( + "Restart from hpc_dir {hpc_dir} which was has (old) ID {old_id}, we are job index {index}".format( + hpc_dir=hpc_dir, old_id=old_id, index=index + ) + ) + + # check status: if "finished", we don't have to do anything + status = self.HPC_get_status(hpc_dir=hpc_dir) + + if status == "finished": + print("Status is finished, cannot and do not need to restart.") + self.exit(code=0) + + file = os.path.join( + dir, "snapshots", "{id}.{index}.gz".format(id=old_id, index=index) + ) + + if os.path.exists(file): + # have data from which we can restore, set it in + # the appropriate grid option + print("Restore this run from snapshot {file}".format(file=file)) + self.grid_options["restore_from_snapshot_file"] = file + else: + # no snapshot: so no need to restore, just exit + print( + "Expected snapshot at {file} but none was found".format(file=file) + ) + self.exit(code=0) + return + + def HPC_join_previous(self): + """ + Function to join previously generated datasets. + """ + # check that our job has finished + status = self.HPC_get_status() + print("Job status", status) + + if self.grid_options["HPC_force_join"] == 0 and status != "finished": + # job did not finish : save a snapshot + print( + "This job did not finish (status is {status}) : cannot join".format( + status=status + ) + ) + else: + # our job has finished + HPC_status = self.HPC_status() + + # HPC_queue_stats = self.HPC_queue_stats() + + if HPC_status["status"]["finished"] != HPC_status["njobs"]: + print( + "HPC_status reports {} finished jobs out of {}. We cannot join because not all the jobs are finished. Exiting.".format( + HPC_status["status"]["finished"], HPC_status["njobs"] + ) + ) + self.exit(1) + + joinfiles = self.HPC_load_joinfiles_list() + joiningfile = self.HPC_path("joining") + print( + "Joinfile list n={n} (should be {m})".format( + n=len(joinfiles), m=self.HPC_njobs() + ) + ) + print("Joingingfile path : ", joiningfile) + + if len(joinfiles) != self.HPC_njobs(): + print("Number of joinfiles != njobs : this is wrong, exiting.") + self.exit(1) + + if self.HPC_can_join(joinfiles, joiningfile, vb=True): + # join object files + print("We can join") + try: + # touch joiningfile + if self.grid_options["HPC_force_join"] == 0: + print("Making joiningfile at {}".format(joiningfile)) + self.HPC_touch(joiningfile) + try: + print("Calling HPC_join_from_files()") + self.HPC_join_from_files(self, joinfiles) + except Exception as e: + print("Join gave exception", e) + # disable analytics calculations : use the + # values we just loaded + self.grid_options["do_analytics"] = False + return + except Exception as e: + print("pass {}", e) + pass + else: + print("cannot join : other tasks are not yet finished\n") + print("Finished this job : exiting") + self.exit(code=1) + + def HPC_path(self, path): + """ + Function to file the filename of this HPC job's file at path. + """ + if self.grid_options["slurm"] > 0: + p = self.slurmpath(path) + elif self.grid_options["condor"] > 0: + p = self.condorpath(path) + else: + p = None + return p + + def HPC_snapshot_filename(self): + """ + Function to return an HPC job's snapshot filename. + """ + if self.HPC_job(): + file = os.path.join(self.HPC_dir, "snapshots", self.HPC_jobID() + ".gz") + else: + file = None + return file + + def HPC_dir(self): + """ + Function to return an HPC job's directory. + """ + if self.grid_options["slurm"] > 0: + d = self.grid_options["slurm_dir"] + elif self.grid_options["condor"] > 0: + d = self.grid_options["condor_dir"] + else: + d = None + return d + + def HPC_touch(self, filename, string=None): + """ + Function to touch the file at filename, put into it the job number + and (if given) the string passed in. + """ + + try: + f = self.open(filename, "w", encoding="utf-8") + + if f: + job = self.HPC_jobID() + jobtype = self.HPC_job_type() + if job: + s = str(job) + if jobtype: + s += " " + str(jobtype) + f.write(s + "\n") + if string: + f.write(string) + f.flush() + f.close() + + self.NFS_flush_hack(filename) + except: + pass + + def HPC_status(self): + """ + Return a dict of useful information about the current status + of this HPC run. + """ + d = {} # returned + _id, _index = self.HPC_jobID_tuple() + d["job_id"] = _id + d["job_index"] = _index + if _id and _index: + n = self.HPC_njobs() + d["njobs"] = n + d["job_task"] = self.HPC_job_task() + d["job_type"] = self.HPC_job_type() + d["job_status"] = self.HPC_get_status() + d["dir"] = self.HPC_dir() + d["dirs"] = self.HPC_dirs() + + # get fellow jobs' status + d["status"] = {} + d["joblist"] = {} + + # default types + for x in ["running", "starting", "finishing", "finished", "killed"]: + d["status"][x] = 0 + d["joblist"][x] = [] + + for i in self.HPC_job_id_range(): + s = self.HPC_get_status(job_id=_id, job_index=i) + #print("HPC get job",_id,':',i," status=",s) + if s is None: + s = "unknown" + if not s in d["status"]: + d["status"][s] = 1 + else: + d["status"][s] += 1 + if not s in d["joblist"]: + d["joblist"][s] = [str(_id) + "." + str(i)] + else: + d["joblist"][s] += [str(_id) + "." + str(i)] + + return d + + def HPC_dump_status(self, string=None): + """ + Function to print the status of the HPC grid + """ + + if not string: + string = "" + + d = self.HPC_status() + + print("############################################################") + print("HPC job status " + string) + print(json.dumps(d, indent=4)) + print("############################################################") + + def HPC_queue_stats(self): # pragma: no cover + """ + Function that returns the queue stats for the HPC grid + """ + + if self.grid_options["slurm"] > 0: + x = self.slurm_queue_stats() + elif self.grid_options["condor"] > 0: + x = self.condor_queue_stats() + else: + x = None + + return x + + def HPC_job_id_range(self): + n = self.HPC_njobs() + if self.grid_options["slurm"] > 0: + return range(1, n+1) + elif self.grid_options["condor"] > 0: + return range(0, n) + else: + print("Called HPC_job_id_range when not running an HPC grid : you cannot do this.") + raise diff --git a/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.py b/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.py new file mode 100644 index 0000000000000000000000000000000000000000..2988cbf3e1d74c052ac328b7d913036efcde7b24 --- /dev/null +++ b/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.py @@ -0,0 +1,1229 @@ +""" +Module containing the functions to handle the Moe&Distrefano data + +This class object is an extension to the population grid object +""" + +# pylint: disable=E1101 + +import os +import gc +import copy +import json + +import py_rinterpolate + +from binarycpython.utils.functions import ( + verbose_print, +) +from binarycpython.utils.dicts import update_dicts, normalize_dict +from binarycpython.utils.population_extensions.distribution_functions import ( + Moecache, + LOG_LN_CONVERTER, +) +from binarycpython.utils.population_extensions.grid_options_defaults import ( + _MOE2017_VERBOSITY_LEVEL, +) +from binarycpython.utils import moe_di_stefano_2017_data + + +class Moe_di_Stefano_2017: + """ + Extension to the population grid object that contains functionality to handle handle the Moe & distefano distributions + """ + + def __init__(self, **kwargs): + """ + Init function for the Moe_di_Stefano_2017 class + """ + + return + + def set_moe_di_stefano_settings(self, options=None): + """ + Function to set user input configurations for the Moe & di Stefano methods + + If nothing is passed then we just use the default options + """ + + if not options: + options = {} + + # Take the option dictionary that was given and override. + options = update_dicts(self.grid_options["Moe2017_options"], options) + self.grid_options["Moe2017_options"] = copy.deepcopy(options) + + # Write options to a file + os.makedirs( + os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), + exist_ok=True, + ) + with open( + os.path.join( + os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), + "moeopts.dat", + ), + "w", + encoding="utf-8", + ) as f: + f.write( + json.dumps( + self.grid_options["Moe2017_options"], indent=4, ensure_ascii=False + ) + ) + f.close() + + def _load_moe_di_stefano_data(self): + """ + Function to load the moe & di stefano data + """ + + # Only if the grid is loaded and Moecache contains information + if not self.grid_options["_loaded_Moe2017_data"]: # and not Moecache: + + if self.grid_options["_Moe2017_JSON_data"]: + # Use the existing (perhaps modified) JSON data + json_data = self.grid_options["_Moe2017_JSON_data"] + + else: + # Load the JSON data from a file + json_data = self.get_moe_di_stefano_dataset( + self.grid_options["Moe2017_options"], + verbosity=self.grid_options["verbosity"], + ) + + # entry of log10M1 is a list containing 1 dict. + # We can take the dict out of the list + if isinstance(json_data["log10M1"], list): + json_data["log10M1"] = json_data["log10M1"][0] + + # save this data in case we want to modify it later + self.grid_options["_Moe2017_JSON_data"] = json_data + + # Get all the masses + logmasses = sorted(json_data["log10M1"].keys()) + if not logmasses: + msg = "The table does not contain masses." + verbose_print( + "\tMoe_di_Stefano_2017: {}".format(msg), + self.grid_options["verbosity"], + 0, + ) + raise ValueError(msg) + + # Write to file + os.makedirs( + os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), + exist_ok=True, + ) + with open( + os.path.join( + os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), + "moe.log", + ), + "w", + encoding="utf-8", + ) as logfile: + logfile.write("logâ‚â‚€Masses(M☉) {}\n".format(logmasses)) + + # Get all the periods and see if they are all consistently present + logperiods = [] + for logmass in logmasses: + if not logperiods: + logperiods = sorted(json_data["log10M1"][logmass]["logP"].keys()) + dlog10P = float(logperiods[1]) - float(logperiods[0]) + + current_logperiods = sorted(json_data["log10M1"][logmass]["logP"]) + if logperiods != current_logperiods: + msg = ( + "Period values are not consistent throughout the dataset logperiods = " + + " ".join(str(x) for x in logperiods) + + "\nCurrent periods = " + + " ".join(str(x) for x in current_logperiods) + ) + verbose_print( + "\tMoe_di_Stefano_2017: {}".format(msg), + self.grid_options["verbosity"], + 0, + ) + raise ValueError(msg) + + ############################################################ + # log10period binwidth : of course this assumes a fixed + # binwidth, so we check for this too. + for i in range(len(current_logperiods) - 1): + if not dlog10P == ( + float(current_logperiods[i + 1]) - float(current_logperiods[i]) + ): + msg = "Period spacing is not consistent throughout the dataset" + verbose_print( + "\tMoe_di_Stefano_2017: {}".format(msg), + self.grid_options["verbosity"], + 0, + ) + raise ValueError(msg) + + # save the logperiods list in the cache: + # this is used in the renormalization integration + Moecache["logperiods"] = logperiods + + # Write to file + os.makedirs( + os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), + exist_ok=True, + ) + with open( + os.path.join(self.grid_options["tmp_dir"], "moe_distefano", "moe.log"), + "a", + encoding="utf-8", + ) as logfile: + logfile.write("logâ‚â‚€Periods(days) {}\n".format(logperiods)) + + # Fill the global dict + for logmass in logmasses: + # Create the multiplicity table + if not Moecache.get("multiplicity_table", None): + Moecache["multiplicity_table"] = [] + + # multiplicity as a function of primary mass + Moecache["multiplicity_table"].append( + [ + float(logmass), + json_data["log10M1"][logmass]["f_multi"], + json_data["log10M1"][logmass]["single star fraction"], + json_data["log10M1"][logmass]["binary star fraction"], + json_data["log10M1"][logmass]["triple/quad star fraction"], + ] + ) + + ############################################################ + # a small log10period which we can shift just outside the + # table to force integration out there to zero + epslog10P = 1e-8 * dlog10P + + ############################################################ + # loop over either binary or triple-outer periods + first = 1 + + # Go over the periods + for logperiod in logperiods: + ############################################################ + # distributions of binary and triple star fractions + # as a function of mass, period. + # + # Note: these should be per unit log10P, hence we + # divide by dlog10P + + if first: + first = 0 + + # Create the multiplicity table + if not Moecache.get("period_distributions", None): + Moecache["period_distributions"] = [] + + ############################################################ + # lower bound the period distributions to zero probability + Moecache["period_distributions"].append( + [ + float(logmass), + float(logperiod) - 0.5 * dlog10P - epslog10P, + 0.0, + 0.0, + ] + ) + Moecache["period_distributions"].append( + [ + float(logmass), + float(logperiod) - 0.5 * dlog10P, + json_data["log10M1"][logmass]["logP"][logperiod][ + "normed_bin_frac_p_dist" + ] + / dlog10P, + json_data["log10M1"][logmass]["logP"][logperiod][ + "normed_tripquad_frac_p_dist" + ] + / dlog10P, + ] + ) + + Moecache["period_distributions"].append( + [ + float(logmass), + float(logperiod), + json_data["log10M1"][logmass]["logP"][logperiod][ + "normed_bin_frac_p_dist" + ] + / dlog10P, + json_data["log10M1"][logmass]["logP"][logperiod][ + "normed_tripquad_frac_p_dist" + ] + / dlog10P, + ] + ) + + ############################################################ + # distributions as a function of mass, period, q + # + # First, get a list of the qs given by Moe + # + qs = sorted(json_data["log10M1"][logmass]["logP"][logperiod]["q"]) + + # Fill the data and 'normalise' + qdata = self.fill_data( + qs, json_data["log10M1"][logmass]["logP"][logperiod]["q"] + ) + + # Create the multiplicity table + if not Moecache.get("q_distributions", None): + Moecache["q_distributions"] = [] + + for q in qs: + Moecache["q_distributions"].append( + [float(logmass), float(logperiod), float(q), qdata[q]] + ) + + ############################################################ + # eccentricity distributions as a function of mass, period, ecc + eccs = sorted(json_data["log10M1"][logmass]["logP"][logperiod]["e"]) + + # Fill the data and 'normalise' + ecc_data = self.fill_data( + eccs, json_data["log10M1"][logmass]["logP"][logperiod]["e"] + ) + + # Create the multiplicity table + if not Moecache.get("ecc_distributions", None): + Moecache["ecc_distributions"] = [] + + for ecc in eccs: + Moecache["ecc_distributions"].append( + [ + float(logmass), + float(logperiod), + float(ecc), + ecc_data[ecc], + ] + ) + + ############################################################ + # upper bound the period distributions to zero probability + Moecache["period_distributions"].append( + [ + float(logmass), + float(logperiods[-1]) + + 0.5 * dlog10P, # TODO: why this shift? to center it? + json_data["log10M1"][logmass]["logP"][logperiods[-1]][ + "normed_bin_frac_p_dist" + ] + / dlog10P, + json_data["log10M1"][logmass]["logP"][logperiods[-1]][ + "normed_tripquad_frac_p_dist" + ] + / dlog10P, + ] + ) + Moecache["period_distributions"].append( + [ + float(logmass), + float(logperiods[-1]) + 0.5 * dlog10P + epslog10P, + 0.0, + 0.0, + ] + ) + + verbose_print( + "\tMoe_di_Stefano_2017: Length period_distributions table: {}".format( + len(Moecache["period_distributions"]) + ), + self.grid_options["verbosity"], + _MOE2017_VERBOSITY_LEVEL, + ) + verbose_print( + "\tMoe_di_Stefano_2017: Length multiplicity table: {}".format( + len(Moecache["multiplicity_table"]) + ), + self.grid_options["verbosity"], + _MOE2017_VERBOSITY_LEVEL, + ) + verbose_print( + "\tMoe_di_Stefano_2017: Length q table: {}".format( + len(Moecache["q_distributions"]) + ), + self.grid_options["verbosity"], + _MOE2017_VERBOSITY_LEVEL, + ) + verbose_print( + "\tMoe_di_Stefano_2017: Length ecc table: {}".format( + len(Moecache["ecc_distributions"]) + ), + self.grid_options["verbosity"], + _MOE2017_VERBOSITY_LEVEL, + ) + + # Write to log file + os.makedirs( + os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), + exist_ok=True, + ) + with open( + os.path.join( + os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), + "moecache.json", + ), + "w", + encoding="utf-8", + ) as cache_filehandle: + cache_filehandle.write( + json.dumps(Moecache, indent=4, ensure_ascii=False) + ) + + # Signal that the data has been loaded + self.grid_options["_loaded_Moe2017_data"] = True + + def _set_moe_di_stefano_distributions(self): + """ + Function to set the Moe & di Stefano distribution + """ + + ############################################################ + # first, the multiplicity, this is 1,2,3,4, ... + # for singles, binaries, triples, quadruples, ... + + max_multiplicity = self.get_max_multiplicity( + self.grid_options["Moe2017_options"]["multiplicity_modulator"] + ) + verbose_print( + "\tMoe_di_Stefano_2017: Max multiplicity = {}".format(max_multiplicity), + self.grid_options["verbosity"], + _MOE2017_VERBOSITY_LEVEL, + ) + ###### + # Setting up the grid variables + + # Multiplicity + self.add_grid_variable( + name="multiplicity", + parameter_name="multiplicity", + longname="multiplicity", + valuerange=[1, max_multiplicity], + samplerfunc="self.const_int(1, {n}, {n})".format(n=max_multiplicity), + precode='self.grid_options["multiplicity"] = multiplicity; self.bse_options["multiplicity"] = multiplicity; options={}'.format( + self.grid_options["Moe2017_options"] + ), + condition="({}[int(multiplicity)-1] > 0)".format( + str(self.grid_options["Moe2017_options"]["multiplicity_modulator"]) + ), + gridtype="discrete", + probdist=1, + ) + + ############################################################ + # always require M1, for all systems + # + # log-spaced m1 with given resolution + self.add_grid_variable( + name="lnM_1", + parameter_name="M_1", + longname="Primary mass", + samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"]["M"][0] + or "self.const_linear(np.log({}), np.log({}), {})".format( + 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["Moe2017_options"]["ranges"]["M"][0] + ), + "np.log({})".format( + self.grid_options["Moe2017_options"]["ranges"]["M"][1] + ), + ], + gridtype="centred", + dphasevol="dlnM_1", + precode='M_1 = np.exp(lnM_1); options["M_1"]=M_1', + probdist="self.Moe_di_Stefano_2017_pdf({{{}, {}, {}}}, verbosity=self.grid_options['verbosity'])['total_probdens'] if multiplicity == 1 else 1".format( + str(dict(self.grid_options["Moe2017_options"]))[1:-1], + "'multiplicity': multiplicity", + "'M_1': M_1", + ), + ) + + # Go to higher multiplicities + if max_multiplicity >= 2: + # binaries: period + self.add_grid_variable( + name="log10per", + parameter_name="orbital_period", + longname="log10(Orbital_Period)", + probdist=1.0, + condition='(self.grid_options["multiplicity"] >= 2)', + branchpoint=1 + if max_multiplicity > 1 + else 0, # Signal here to put a branchpoint if we have a max multiplicity higher than 1. + gridtype="centred", + dphasevol="({} * dlog10per)".format(LOG_LN_CONVERTER), + valuerange=[ + self.grid_options["Moe2017_options"]["ranges"]["logP"][0], + self.grid_options["Moe2017_options"]["ranges"]["logP"][1], + ], + samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"][ + "logP" + ][0] + or "self.const_linear({}, {}, {})".format( + 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["Moe2017_options"]["Mmin"] + ), + ) # TODO: change the maximum_mass_ratio_for_RLOF + + # binaries: mass ratio + self.add_grid_variable( + name="q", + parameter_name="M_2", + longname="Mass ratio", + valuerange=[ + 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["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"] + .get("ranges", {}) + .get("q", None) + else "qmax", + ], + probdist=1, + gridtype="centred", + dphasevol="dq", + precode=""" +M_2 = q * M_1 +sep = calc_sep_from_period(M_1, M_2, orbital_period) + """, + samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"]["M"][1] + or "self.const_linear({}, {}, {})".format( + 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["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["Moe2017_options"]["resolutions"]["M"][1], + ), + ) + + # (optional) binaries: eccentricity + if self.grid_options["Moe2017_options"]["resolutions"]["ecc"][0] > 0: + self.add_grid_variable( + name="ecc", + parameter_name="eccentricity", + longname="Eccentricity", + probdist=1, + gridtype="centred", + dphasevol="decc", + precode="eccentricity=ecc", + valuerange=[ + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ + 0 + ], # Just fail if not defined. + self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], + ], + samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"][ + "ecc" + ][0] + or "self.const_linear({}, {}, {})".format( + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ + 0 + ], # Just fail if not defined. + self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], + self.grid_options["Moe2017_options"]["resolutions"]["ecc"][0], + ), + ) + + # Now for triples and quadruples + if max_multiplicity >= 3: + # Triple: period + self.add_grid_variable( + name="log10per2", + parameter_name="orbital_period_triple", + longname="log10(Orbital_Period2)", + probdist=1.0, + condition='(self.grid_options["multiplicity"] >= 3)', + branchpoint=2 + if max_multiplicity > 2 + else 0, # Signal here to put a branchpoint if we have a max multiplicity higher than 1. + gridtype="centred", + dphasevol="({} * dlog10per2)".format(LOG_LN_CONVERTER), + valuerange=[ + self.grid_options["Moe2017_options"]["ranges"]["logP"][0], + self.grid_options["Moe2017_options"]["ranges"]["logP"][1], + ], + samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"][ + "logP" + ][1] + or "self.const_linear({}, {}, {})".format( + 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["Moe2017_options"]["Mmin"] + ), + ) + + # Triples: mass ratio + # Note, the mass ratio is M_outer/M_inner + self.add_grid_variable( + name="q2", + parameter_name="M_3", + longname="Mass ratio outer/inner", + valuerange=[ + 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["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"] + .get("ranges", {}) + .get("q", None) + else "q2max", + ], + probdist=1, + gridtype="centred", + dphasevol="dq2", + precode=""" +M_3 = q2 * (M_1 + M_2) +sep2 = calc_sep_from_period((M_1+M_2), M_3, orbital_period_triple) +eccentricity2=0 +""", + samplerfunc=self.grid_options["Moe2017_options"]["samplerfuncs"][ + "M" + ][2] + or "self.const_linear({}, {}, {})".format( + 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["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"] + .get("ranges", {}) + .get("q", None) + else "q2max", + self.grid_options["Moe2017_options"]["resolutions"]["M"][2], + ), + ) + + # (optional) triples: eccentricity + if self.grid_options["Moe2017_options"]["resolutions"]["ecc"][1] > 0: + self.add_grid_variable( + name="ecc2", + parameter_name="eccentricity2", + longname="Eccentricity of the triple", + probdist=1, + gridtype="centred", + dphasevol="decc2", + precode="eccentricity2=ecc2", + valuerange=[ + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ + 0 + ], # Just fail if not defined. + self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], + ], + samplerfunc=self.grid_options["Moe2017_options"][ + "samplerfuncs" + ]["ecc"][1] + or "self.const_linear({}, {}, {})".format( + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ + 0 + ], # Just fail if not defined. + self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], + self.grid_options["Moe2017_options"]["resolutions"]["ecc"][ + 1 + ], + ), + ) + + if max_multiplicity == 4: + # Quadruple: period + self.add_grid_variable( + name="log10per3", + parameter_name="orbital_period_quadruple", + longname="log10(Orbital_Period3)", + probdist=1.0, + condition='(self.grid_options["multiplicity"] >= 4)', + branchpoint=3 + if max_multiplicity > 3 + else 0, # Signal here to put a branchpoint if we have a max multiplicity higher than 1. + gridtype="centred", + dphasevol="({} * dlog10per3)".format(LOG_LN_CONVERTER), + valuerange=[ + self.grid_options["Moe2017_options"]["ranges"]["logP"][0], + self.grid_options["Moe2017_options"]["ranges"]["logP"][1], + ], + samplerfunc=self.grid_options["Moe2017_options"][ + "samplerfuncs" + ]["logP"][2] + or "self.const_linear({}, {}, {})".format( + 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["Moe2017_options"]["Mmin"] + ), + ) + + # Quadruple: mass ratio : M_outer / M_inner + self.add_grid_variable( + name="q3", + parameter_name="M_4", + longname="Mass ratio outer low/outer high", + valuerange=[ + 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["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"] + .get("ranges", {}) + .get("q", None) + else "q3max", + ], + probdist=1, + gridtype="centred", + dphasevol="dq3", + precode=""" +M_4 = q3 * M_3 +sep3 = calc_sep_from_period((M_3), M_4, orbital_period_quadruple) +eccentricity3=0 +""", + samplerfunc=self.grid_options["Moe2017_options"][ + "samplerfuncs" + ]["M"][3] + or "self.const_linear({}, {}, {})".format( + 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["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"] + .get("ranges", {}) + .get("q", None) + else "q3max", + self.grid_options["Moe2017_options"]["resolutions"]["M"][2], + ), + ) + + # (optional) triples: eccentricity + 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", + probdist=1, + gridtype="centred", + dphasevol="decc3", + precode="eccentricity3=ecc3", + valuerange=[ + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ + 0 + ], # Just fail if not defined. + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ + 1 + ], + ], + samplerfunc=self.grid_options["Moe2017_options"][ + "samplerfuncs" + ]["ecc"][2] + or "self.const_linear({}, {}, {})".format( + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ + 0 + ], # Just fail if not defined. + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ + 1 + ], + self.grid_options["Moe2017_options"]["resolutions"][ + "ecc" + ][2], + ), + ) + + # Now we are at the last part. + # Here we should combine all the information that we calculate and update the options + # dictionary. This will then be passed to the Moe_di_Stefano_2017_pdf to calculate + # the real probability. The trick we use is to strip the options_dict as a string + # and add some keys to it: + + updated_options = "{{{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}}".format( + str(dict(self.grid_options["Moe2017_options"]))[1:-1], + '"multiplicity": multiplicity', + '"M_1": M_1', + '"M_2": M_2', + '"M_3": M_3', + '"M_4": M_4', + '"P": orbital_period', + '"P2": orbital_period_triple', + '"P3": orbital_period_quadruple', + '"ecc": eccentricity', + '"ecc2": eccentricity2', + '"ecc3": eccentricity3', + ) + + probdist_addition = "self.Moe_di_Stefano_2017_pdf({}, verbosity=self.grid_options['verbosity'])['total_probdens']".format( + updated_options + ) + + # and finally the probability calculator + self.grid_options["_grid_variables"][self._last_grid_variable()][ + "probdist" + ] = probdist_addition + + verbose_print( + "\tMoe_di_Stefano_2017: Added final call to the pdf function", + self.grid_options["verbosity"], + _MOE2017_VERBOSITY_LEVEL, + ) + + # Signal that the MOE2017 grid has been set + self.grid_options["_set_Moe2017_grid"] = True + + ################################################################################################ + def Moe_di_Stefano_2017(self, options=None): + """ + Function to handle setting the user input settings, + set up the data and load that into interpolators and + then set the distribution functions + + Takes a dictionary as its only argument + """ + + default_options = { + "apply settings": True, + "setup grid": True, + "load data": True, + "clean cache": False, + "clean load flag": False, + "clean all": False, + } + + if not options: + options = {} + options = update_dicts(default_options, options) + + # clean cache? + if options["clean all"] or options["clean cache"]: + Moecache.clear() + + if options["clean all"] or options["clean load flag"]: + self.grid_options["_loaded_Moe2017_data"] = False + + # Set the user input + if options["apply settings"]: + self.set_moe_di_stefano_settings(options=options) + + # Load the data + if options["load data"]: + self._load_moe_di_stefano_data() + + # construct the grid here + if options["setup grid"]: + self._set_moe_di_stefano_distributions() + + def _clean_interpolators(self): + """ + Function to clean up the interpolators after a run + + We look in the Moecache global variable for items that are interpolators. + Should be called by the general cleanup function AND the thread cleanup function + """ + + interpolator_keys = [] + for key, value in Moecache.items(): + if isinstance(value, py_rinterpolate.Rinterpolate): + interpolator_keys.append(key) + + for key in interpolator_keys: + Moecache[key].destroy() + del Moecache[key] + gc.collect() + + def _calculate_multiplicity_fraction(self, system_dict): + """ + Function to calculate multiplicity fraction + + Makes use of the self.bse_options['multiplicity'] value. If its not set, it will raise an error + + grid_options['multiplicity_fraction_function'] will be checked for the choice + + TODO: add option to put a manual binary fraction in here (solve via negative numbers being the functions) + """ + + # Just return 1 if no option has been chosen + if self.grid_options["multiplicity_fraction_function"] in [0, "None"]: + verbose_print( + "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.", + self.grid_options["verbosity"], + 3, + ) + + return 1 + + # Raise an error if the multiplicity is not set + if not system_dict.get("multiplicity", None): + msg = "Multiplicity value has not been set. When using a specific multiplicity fraction function please set the multiplicity" + raise ValueError(msg) + + # Go over the chosen options + if self.grid_options["multiplicity_fraction_function"] in [1, "Arenou2010"]: + # Arenou 2010 will be used + verbose_print( + "_calculate_multiplicity_fraction: Using Arenou 2010 to calculate multiplicity fractions", + self.grid_options["verbosity"], + 3, + ) + + binary_fraction = self.Arenou2010_binary_fraction(system_dict["M_1"]) + multiplicity_fraction_dict = { + 1: 1 - binary_fraction, + 2: binary_fraction, + 3: 0, + 4: 0, + } + + elif self.grid_options["multiplicity_fraction_function"] in [2, "Raghavan2010"]: + # Raghavan 2010 will be used + verbose_print( + "_calculate_multiplicity_fraction: Using Raghavan (2010) to calculate multiplicity fractions", + self.grid_options["verbosity"], + 3, + ) + + binary_fraction = self.raghavan2010_binary_fraction(system_dict["M_1"]) + multiplicity_fraction_dict = { + 1: 1 - binary_fraction, + 2: binary_fraction, + 3: 0, + 4: 0, + } + + elif self.grid_options["multiplicity_fraction_function"] in [3, "Moe2017"]: + # We need to check several things now here: + + # 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) + + # Second: is the Moecache filled. + if not Moecache: + verbose_print( + "_calculate_multiplicity_fraction: Moecache is empty. It needs to be filled with the data for the interpolators. Loading the data now", + self.grid_options["verbosity"], + 3, + ) + + # Load the data + self._load_moe_di_stefano_data() + + # record the prev value + prev_M1_value_ms = self.grid_options["Moe2017_options"].get("M_1", None) + + # Set value of M1 of the current system + self.grid_options["Moe2017_options"]["M_1"] = system_dict["M_1"] + + # Calculate the multiplicity fraction + multiplicity_fraction_list = ( + self.Moe_di_Stefano_2017_multiplicity_fractions( + self.grid_options["Moe2017_options"], self.grid_options["verbosity"] + ) + ) + + # Turn into dict + multiplicity_fraction_dict = { + el + 1: multiplicity_fraction_list[el] + for el in range(len(multiplicity_fraction_list)) + } + + # Set the prev value back + self.grid_options["Moe2017_options"]["M_1"] = prev_M1_value_ms + + # we don't know what to do next + else: + msg = "Chosen value for the multiplicity fraction function is not known." + raise ValueError(msg) + + # To make sure we normalize the dictionary + multiplicity_fraction_dict = normalize_dict( + multiplicity_fraction_dict, verbosity=self.grid_options["verbosity"] + ) + + verbose_print( + "Multiplicity: {} multiplicity_fraction: {}".format( + system_dict["multiplicity"], + multiplicity_fraction_dict[system_dict["multiplicity"]], + ), + self.grid_options["verbosity"], + 3, + ) + + return multiplicity_fraction_dict[system_dict["multiplicity"]] + + def get_moe_di_stefano_dataset(self, options, verbosity=0): + """ + Function to get the default Moe and di Stefano dataset or accept a user input. + + Returns a dict containing the (JSON) data. + """ + + json_data = None + + if "JSON" in options: + # use the JSON data passed in + json_data = options["JSON"] + + elif "file" in options: + # use the file passed in, if provided + if not os.path.isfile(options["file"]): + verbose_print( + "The provided 'file' Moe and de Stefano JSON file does not seem to exist at {}".format( + options["file"] + ), + verbosity, + 1, + ) + + raise ValueError + if not options["file"].endswith(".json"): + verbose_print( + "Provided filename is not a json file", + verbosity, + 1, + ) + + else: + # Read input data and Clean up the data if there are white spaces around the keys + with open(options["file"], "r", encoding="utf-8") as data_filehandle: + datafile_data = data_filehandle.read() + datafile_data = datafile_data.replace('" ', '"') + datafile_data = datafile_data.replace(' "', '"') + datafile_data = datafile_data.replace(' "', '"') + json_data = json.loads(datafile_data) + + if not json_data: + # no JSON data or filename given, use the default 2017 dataset + verbose_print( + "Using the default Moe and de Stefano 2017 datafile", + verbosity, + 1, + ) + json_data = copy.deepcopy(moe_di_stefano_2017_data.moe_di_stefano_2017_data) + + return json_data + + def get_Moe_di_Stefano_2017_default_options(self): + """ + Function that returns the default options for the Moe & diStefano grid options + """ + + return { + # place holder for the JSON data to be used if a file + # isn't specified + "JSON": None, + # resolution data + "resolutions": { + "M": [ + 20, # M1 + 20, # M2 (i.e. q) + 0, # M3 currently unused + 0, # M4 currently unused + ], + "logP": [ + 20, # P2 (binary period) + 0, # P3 (triple period) currently unused + 0, # P4 (quadruple period) currently unused + ], + "ecc": [ + 10, # e (binary eccentricity) + 0, # e2 (triple eccentricity) currently unused + 0, # e3 (quadruple eccentricity) currently unused + ], + }, + "samplerfuncs": { + "M": [None, None, None, None], + "logP": [None, None, None], + "ecc": [None, None, None], + }, + "ranges": { + # stellar masses (Msun) + "M": [ + self.minimum_stellar_mass() + * 1.05, # 0.08 is a tad bit above the minimum mass. Don't sample at 0.07, otherwise the first row of q values will have a phasevol of 0. Anything higher is fine. + 80.0, # (rather arbitrary) upper mass cutoff + ], + "q": [ + None, # artificial qmin : set to None to use default + None, # artificial qmax : set to None to use default + ], + "logP": [0.0, 8.0], # 0 = log10(1 day) # 8 = log10(10^8 days) + "ecc": [0.0, 0.99], + }, + # minimum stellar mass + "Mmin": self.minimum_stellar_mass(), # We take the value that binary_c has set as the default + # multiplicity model (as a function of log10M1) + # + # You can use 'Poisson' which uses the system multiplicity + # given by Moe and maps this to single/binary/triple/quad + # fractions. + # + # Alternatively, 'data' takes the fractions directly + # from the data, but then triples and quadruples are + # combined (and there are NO quadruples). + "multiplicity_model": "Poisson", + # multiplicity modulator: + # [single, binary, triple, quadruple] + # + # e.g. [1,0,0,0] for single stars only + # [0,1,0,0] for binary stars only + # + # defaults to [1,1,0,0] i.e. all types + # + "multiplicity_modulator": [ + 1, # single + 1, # binary + 0, # triple + 0, # quadruple + ], + # given a mix of multiplicities, you can either (noting that + # here (S,B,T,Q) = appropriate modulator * model(S,B,T,Q) ) + # + # 'norm' : normalise so the whole population is 1.0 + # after implementing the appropriate fractions + # S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) + # + # 'raw' : stick to what is predicted, i.e. + # S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) + # without normalisation + # (in which case the total probability < 1.0 unless + # all you use single, binary, triple and quadruple) + # + # 'merge' : e.g. if you only have single and binary, + # add the triples and quadruples to the binaries, so + # binaries represent all multiple systems + # ... + # *** this is canonical binary population synthesis *** + # + # Note: if multiplicity_modulator == [1,1,1,1] this + # option does nothing (equivalent to 'raw'). + # + # + # note: if you only set one multiplicity_modulator + # to 1, and all the others to 0, then normalising + # will mean that you effectively have the same number + # of stars as single, binary, triple or quad (whichever + # is non-zero) i.e. the multiplicity fraction is ignored. + # This is probably not useful except for + # testing purposes or comparing to old grids. + "normalize_multiplicities": "merge", + # q extrapolation (below 0.15 and above 0.9) method. We can choose from ['flat', 'linear', 'plaw2', 'nolowq'] + "q_low_extrapolation_method": "linear", + "q_high_extrapolation_method": "linear", + } + + def get_Moe_di_Stefano_2017_default_options_description(self): + """ + Function to return the descriptions for all the Moe & diStefano grid options + """ + + return { + "resolutions": "", + "ranges": "", + "Mmin": "Minimum stellar mass", + "multiplicity_model": """ + multiplicity model (as a function of log10M1) + + You can use 'Poisson' which uses the system multiplicity + given by Moe and maps this to single/binary/triple/quad + fractions. + + Alternatively, 'data' takes the fractions directly + from the data, but then triples and quadruples are + combined (and there are NO quadruples). + """, + "multiplicity_modulator": """ + [single, binary, triple, quadruple] + + e.g. [1,0,0,0] for single stars only + [0,1,0,0] for binary stars only + + defaults to [1,1,0,0] i.e. singles and binaries + """, + "normalize_multiplicities": """ + 'norm': normalise so the whole population is 1.0 + after implementing the appropriate fractions + S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) + given a mix of multiplicities, you can either (noting that + here (S,B,T,Q) = appropriate modulator * model(S,B,T,Q) ) + note: if you only set one multiplicity_modulator + to 1, and all the others to 0, then normalising + will mean that you effectively have the same number + of stars as single, binary, triple or quad (whichever + is non-zero) i.e. the multiplicity fraction is ignored. + This is probably not useful except for + testing purposes or comparing to old grids. + + 'raw' : stick to what is predicted, i.e. + S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) + without normalisation + (in which case the total probability < 1.0 unless + all you use single, binary, triple and quadruple) + + 'merge' : e.g. if you only have single and binary, + add the triples and quadruples to the binaries, so + binaries represent all multiple systems + ... + *** this is canonical binary population synthesis *** + + It only takes the maximum multiplicity into account, + i.e. it doesn't multiply the resulting array by the multiplicity modulator again. + This prevents the resulting array to always be 1 if only 1 multiplicity modulator element is nonzero + + Note: if multiplicity_modulator == [1,1,1,1]. this option does nothing (equivalent to 'raw'). + """, + "q_low_extrapolation_method": """ + q extrapolation (below 0.15) method + none + flat + linear2 + plaw2 + nolowq + """, + "q_high_extrapolation_method": "Same as q_low_extrapolation_method", + } diff --git a/binarycpython/utils/population_extensions/__init__.py b/binarycpython/utils/population_extensions/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/binarycpython/utils/population_extensions/analytics.py b/binarycpython/utils/population_extensions/analytics.py new file mode 100644 index 0000000000000000000000000000000000000000..57bbb25d6b469d471c39a0c582a6a9684753944f --- /dev/null +++ b/binarycpython/utils/population_extensions/analytics.py @@ -0,0 +1,119 @@ +""" +The class extension for the population object that contains analytics functionality +""" + +# pylint: disable=E1101 + +import time + + +class analytics: + """ + Extension for the Population class containing the functions for analytics + """ + + def __init__(self, **kwargs): + """ + Init function for the analytics class + """ + + return + + ####################### + # time used functions + ####################### + + def make_analytics_dict(self): + """ + Function to create the analytics dictionary + """ + + print("Do analytics") + + analytics_dict = {} + + if self.grid_options["do_analytics"]: + # Put all interesting stuff in a variable and output that afterwards, as analytics of the run. + analytics_dict = { + "population_id": self.grid_options["_population_id"], + "evolution_type": self.grid_options["evolution_type"], + "failed_count": self.grid_options["_failed_count"], + "failed_prob": self.grid_options["_failed_prob"], + "failed_systems_error_codes": self.grid_options[ + "_failed_systems_error_codes" + ].copy(), + "errors_exceeded": self.grid_options["_errors_exceeded"], + "errors_found": self.grid_options["_errors_found"], + "total_probability": self.grid_options["_probtot"], + "total_count": self.grid_options["_count"], + "start_timestamp": self.grid_options["_start_time_evolution"], + "end_timestamp": self.grid_options["_end_time_evolution"], + "time_elapsed": self.time_elapsed(), + "total_mass_run": self.grid_options["_total_mass_run"], + "total_probability_weighted_mass_run": self.grid_options[ + "_total_probability_weighted_mass_run" + ], + "zero_prob_stars_skipped": self.grid_options[ + "_zero_prob_stars_skipped" + ], + } + + if "metadata" in self.grid_ensemble_results: + # Add analytics dict to the metadata too: + self.grid_ensemble_results["metadata"].update(analytics_dict) + print("Added analytics to metadata") + self.add_system_metadata() + else: + # use existing analytics dict + analytics_dict = self.grid_ensemble_results.get("metadata", {}) + + return analytics_dict + + def set_time(self, when): + """ + Function to set the timestamp at when, where when is 'start' or 'end'. + + If when == end, we also calculate the time elapsed. + """ + self.grid_options["_" + when + "_time_evolution"] = time.time() + if when == "end": + self.grid_options["_time_elapsed"] = self.time_elapsed(force=True) + + def time_elapsed(self, force=False): + """ + Function to return how long a population object has been running. + + We return the cached value if it's available, and calculate + the time elapsed if otherwise or if force is True + """ + for x in ["_start_time_evolution", "_end_time_evolution"]: + if not self.grid_options[x]: + self.grid_options[x] = time.time() + # print("{} missing : {}".format(x, self.grid_options[x])) + + if force or "_time_elapsed" not in self.grid_options: + self.grid_options["_time_elapsed"] = ( + self.grid_options["_end_time_evolution"] + - self.grid_options["_start_time_evolution"] + ) + # print( + # "set time elapsed = {} - {} = {}".format( + # self.grid_options["_end_time_evolution"], + # self.grid_options["_start_time_evolution"], + # self.grid_options["_time_elapsed"], + # ) + # ) + + return self.grid_options["_time_elapsed"] + + def CPU_time(self): + """ + Function to return how much CPU time we've used + """ + dt = self.grid_options["_time_elapsed"] + + ncpus = self.grid_options.get("num_processes", 1) + + # print("CPU time : dt={} n={} -> {}".format(dt, ncpus, dt * ncpus)) + + return dt * ncpus diff --git a/binarycpython/utils/population_extensions/cache.py b/binarycpython/utils/population_extensions/cache.py new file mode 100644 index 0000000000000000000000000000000000000000..ea744ee81aa1802133216087f66742d58690bff2 --- /dev/null +++ b/binarycpython/utils/population_extensions/cache.py @@ -0,0 +1,365 @@ +""" +File containing the class extension for the population object that contains cache functionality + +Module containing (e.g. LRU) cache functionality for binary_c-python. + +We use cachetools when possible because this allows us to set up the +cache of the appropriate size for the task in the grid_options dict. +Please see the LRU_* options in there. +""" + +# pylint: disable=E1101 + +import os +import time +import tempfile +import importlib +import getpass +import contextlib + +import cachetools + + +class cache: + """ + Class extension for the population object that contains cache functionality + """ + + def __init__(self, **kwargs): + """ + Init function for the spacing_functions class + """ + + return + + def default_cache_dir(self): + """ + Return a default cache directory path for binary_c-python, or None if we cannot find one. This is used in grid_options_defaults.py + """ + + error_string = "__*ERR*__" # string that cannot be a path + for path in [ + os.path.join(os.environ.get("HOME", error_string), ".cache"), + os.path.join(os.environ.get("TMP", error_string), "cache"), + os.path.join("var", "tmp", getpass.getuser(), "cache"), + ]: + if not error_string in path and os.path.isdir(path): + return os.path.join(path, "binary_c") + return None + + class NullCache(cachetools.Cache): + """ + A cachetools cache object that does as little as possible and never matches. + """ + + def __init__(self, *args, **kwargs): + """ + Init function for the spacing_functions class + + TODO: is this class necesarry to be defined *within* the cache class? can't it just be outside? + """ + + return None + + def popitem(self): + """ + pop function placeholder + """ + + return # do nothing + + def __getitem__(self, key): + """ + getter function placeholder + """ + + return self.__missing__(key) + + def __setitem__(self, key, value): + """ + Setter function placeholder + """ + + return + + def __delitem__(self, key): + """ + deleter function placeholder + """ + + return + + def setup_function_cache(self, vb=False, cachetype=None): + """ + Function to wrap binary_c-python's functions in function cache. + + The functions listed in self.grid_options['function_cache_functions'] are + given caches of size self.grid_options['function_cache_size'][func] + + Args: None + """ + + # add our custom NullCache to the cachetools selection + setattr(cachetools, "NullCache", self.NullCache) + + if not self.grid_options["function_cache"]: + # no function cache: set all to NullCache + # TODO: This cachetype(Nullcache) is wrong. + for func in self.grid_options["function_cache_functions"].keys(): + self.function_cache[func] = cachetype(NullCache) + + for func in self.grid_options["function_cache_functions"].keys(): + (maxsize, cachetype, testargs) = self.grid_options[ + "function_cache_functions" + ].get(func) + + # which cache should we use? + if cachetype: + # use type passed in, if given + usecachetype = cachetype + elif not self.grid_options["function_cache"]: + # function cache is disabled, use NoCache + usecachetype = "NoCache" + else: + if cachetype is None: + # use the default type + usecachetype = self.grid_options["function_cache_default_type"] + else: + # use type passed in + usecachetype = cachetype + + if vb: + print( + "Setup cache for func {func} : maxsize={maxsize}, cachetype={cachetype}, testargs={testargs}-> use {usecachetype}".format( + func=func, + maxsize=maxsize, + cachetype=cachetype, + testargs=testargs, + usecachetype=usecachetype, + ) + ) + + if usecachetype == "TTLCache": + extra_cacheargs = [self.grid_options["function_cache_TTL"]] + else: + extra_cacheargs = [] + + # detect if the function is already wrapped + x = func.split(".") + modulename = "binarycpython.utils.population_extensions." + x[0] + module = importlib.import_module(modulename) + _method = eval( + "module.{}.{}".format(x[0], x[1]) + ) # TODO: we can do this differently with some .get call instead of eval + _wrapped = getattr(_method, "__wrapped__", False) + + # if function is wrapped... + if _wrapped and id(_method) != id(_wrapped): + # save the wrapped function (this calls the cache) + if func not in self.cached_function_cache: + self.cached_function_cache[func] = _method + self.original_function_cache[func] = _wrapped + + if usecachetype == "NoCache": + # unwrap if we're after NoCache + _code = "module.{}.{} = _wrapped".format(x[0], x[1]) + exec(_code) + else: + # function isn't wrapped, which means it was previously + # unwrapped, so rewrap it if not using NoCache + if usecachetype != "NoCache" and func in self.cached_function_cache: + _code = 'module.{}.{} = self.cached_function_cache["{}"]'.format( + x[0], x[1], func + ) + exec(_code) + + # check we're not still wrapped + _method = eval("module" + "." + x[0] + "." + x[1]) + _wrapped = getattr(_method, "__wrapped__", False) + + # if NoCache (explicity use no cache), just use NullCache + # (it's never actually set) + if usecachetype == "NoCache": + cachetools_func = getattr(cachetools, "NullCache") + else: + cachetools_func = getattr(cachetools, usecachetype) + + if maxsize == 0: + maxsize = self.grid_options["function_cache_default_maxsize"] + + if vb: + print( + "Make function cache for func {func}, maxsize {maxsize}".format( + func=func, maxsize=maxsize + ) + ) + + # set up cache function args + if maxsize is None: + args = [2] + else: + args = [maxsize] + args += extra_cacheargs + + # clear any existing cache + if func in self.caches: + try: + self.caches[func].cache_clear() + except: + pass + del self.caches[func] + + # set up new cache using the appropriate cachetools function + if usecachetype != "NoCache": + self.caches[func] = cachetools_func(*args) + + def test_caches(self, dt=5.0): + """ + Function to test cache speeds of the functions that binary_c-python automatically caches. + + Args: + dt (default 5) in seconds the length of each test. Long is more accurate, but takes longer. + """ + + # loop lists + cachetypes = ("NoCache", "NullCache", "FIFOCache", "LRUCache", "TTLCache") + functions = self.grid_options["function_cache_functions"].keys() + maxsizes = (0, 1, 2, 4, 8, 16, 32, 64, 128, 256) + + self.grid_options["function_cache"] = True + for n, func in enumerate(functions): + print("Cache speed test of function {func}".format(func=func)) + print("{:18s}".format(""), end="") + for x, maxsize in enumerate(maxsizes): + print("{:>9s}".format(str(maxsize)), end="") + print("") + + best = 0 + best_type = None + best_maxsize = None + for y, type in enumerate(cachetypes): + print("{:18s}".format(type), end="") + self.grid_options["function_cache_default_type"] = type + self.setup_function_cache() + (maxsize, cachetype, testargs) = self.grid_options[ + "function_cache_functions" + ].get(func) + + # TODO: Make this part better: needs to be able to handle any depth + x = func.split(".") + modulename = "binarycpython.utils.population_extensions." + x[0] + module = importlib.import_module(modulename) + _method = eval("module.{}.{}".format(x[0], x[1])) + + if testargs: + + def _func_wrap(*args, **kwargs): + """ + wrap to return args and kwargs + + TODO: i think this function can be defined elsewhere + """ + + return (args, kwargs) + + args, kwargs = eval("_func_wrap({})".format(testargs)) + for x, maxsize in enumerate(maxsizes): + if type == "NoCache" and maxsize > 0: + continue + + # redirect stdout to prevent lots of output + with contextlib.redirect_stdout(None): + + # loop for dt seconds + tfin = dt + time.time() + count = 0 + try: + while time.time() < tfin: + _method(self, *args, **kwargs) + count += 1 + # TODO: specify the exception + except Exception as e: + print("Cache call failed:", e) + self.exit(1) + + if count < 99999: + print("{:9d}".format(count), end="") + else: + print("{:9.2e}".format(float(count)), end="") + + if count > best: + best = count + best_type = type + best_maxsize = maxsize + print("") + + print( + "Best cache type {type} with maxsize {maxsize}\n".format( + type=best_type, maxsize=best_maxsize + ) + ) + + """ +Cache speed test of function distribution_functions.powerlaw_constant + 0 1 2 4 8 16 32 64 128 256 +NoCache 6.28e+07 +NullCache 6.39e+07 6.40e+07 6.41e+07 6.39e+07 6.44e+07 6.43e+07 6.37e+07 6.40e+07 6.38e+07 6.40e+07 +FIFOCache 6.41e+07 6.37e+07 6.40e+07 6.39e+07 6.40e+07 6.37e+07 6.41e+07 6.40e+07 6.41e+07 6.40e+07 +LRUCache 6.42e+07 6.41e+07 6.42e+07 6.41e+07 6.38e+07 6.43e+07 6.41e+07 6.43e+07 6.40e+07 6.41e+07 +TTLCache 6.41e+07 6.35e+07 6.37e+07 6.39e+07 6.37e+07 6.42e+07 6.39e+07 6.38e+07 6.37e+07 6.38e+07 +Best cache type NullCache with maxsize 8 + +Cache speed test of function distribution_functions.calculate_constants_three_part_powerlaw + 0 1 2 4 8 16 32 64 128 256 +NoCache 1.44e+07 +NullCache 9.13e+06 9.18e+06 9.20e+06 9.21e+06 9.20e+06 9.12e+06 9.18e+06 9.18e+06 9.15e+06 9.12e+06 +FIFOCache 2.53e+07 2.52e+07 2.51e+07 2.50e+07 2.51e+07 2.52e+07 2.52e+07 2.52e+07 2.52e+07 2.51e+07 +LRUCache 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 +TTLCache 1.43e+07 1.43e+07 1.43e+07 1.43e+07 1.43e+07 1.44e+07 1.42e+07 1.43e+07 1.43e+07 1.43e+07 +Best cache type FIFOCache with maxsize 0 + +Cache speed test of function distribution_functions.gaussian_normalizing_const + 0 1 2 4 8 16 32 64 128 256 +NoCache 64183 +NullCache 64340 64339 64544 64260 64491 64382 64400 63974 63954 64338 +FIFOCache 2.62e+07 2.62e+07 2.62e+07 2.61e+07 2.61e+07 2.59e+07 2.61e+07 2.59e+07 2.57e+07 2.59e+07 +LRUCache 1.66e+07 1.66e+07 1.65e+07 1.66e+07 1.65e+07 1.65e+07 1.64e+07 1.65e+07 1.64e+07 1.65e+07 +TTLCache 1.42e+07 1.44e+07 1.42e+07 1.44e+07 1.43e+07 1.43e+07 1.42e+07 1.44e+07 1.42e+07 1.44e+07 +Best cache type FIFOCache with maxsize 1 + +Cache speed test of function spacing_functions.const_linear + 0 1 2 4 8 16 32 64 128 256 +NoCache 1.22e+06 +NullCache 1.05e+06 1.05e+06 1.06e+06 1.05e+06 1.05e+06 1.06e+06 1.05e+06 1.05e+06 1.05e+06 1.05e+06 +FIFOCache 2.85e+07 2.85e+07 2.86e+07 2.85e+07 2.84e+07 2.85e+07 2.84e+07 2.84e+07 2.85e+07 2.81e+07 +LRUCache 1.77e+07 1.79e+07 1.73e+07 1.73e+07 1.76e+07 1.79e+07 1.76e+07 1.74e+07 1.74e+07 1.72e+07 +TTLCache 1.46e+07 1.49e+07 1.50e+07 1.53e+07 1.51e+07 1.53e+07 1.52e+07 1.51e+07 1.47e+07 1.50e+07 +Best cache type FIFOCache with maxsize 2 + +Cache speed test of function spacing_functions.const_int + 0 1 2 4 8 16 32 64 128 256 +NoCache 4.23e+07 +NullCache 1.65e+07 1.66e+07 1.65e+07 1.64e+07 1.66e+07 1.65e+07 1.59e+07 1.59e+07 1.65e+07 1.64e+07 +FIFOCache 2.86e+07 2.86e+07 2.87e+07 2.86e+07 2.84e+07 2.86e+07 2.81e+07 2.79e+07 2.78e+07 2.85e+07 +LRUCache 1.78e+07 1.78e+07 1.77e+07 1.75e+07 1.77e+07 1.78e+07 1.78e+07 1.78e+07 1.74e+07 1.75e+07 +TTLCache 1.55e+07 1.54e+07 1.55e+07 1.54e+07 1.55e+07 1.49e+07 1.52e+07 1.51e+07 1.52e+07 1.54e+07 +Best cache type NoCache with maxsize 0 + +Cache speed test of function spacing_functions.const_ranges + 0 1 2 4 8 16 32 64 128 256 +NoCache 2.54e+05 +NullCache 2.25e+05 2.25e+05 2.24e+05 2.25e+05 2.25e+05 2.25e+05 2.25e+05 2.26e+05 2.25e+05 2.26e+05 +FIFOCache 2.58e+07 2.55e+07 2.53e+07 2.54e+07 2.56e+07 2.57e+07 2.56e+07 2.57e+07 2.58e+07 2.58e+07 +LRUCache 1.62e+07 1.63e+07 1.62e+07 1.62e+07 1.61e+07 1.62e+07 1.62e+07 1.62e+07 1.61e+07 1.63e+07 +TTLCache 1.41e+07 1.43e+07 1.42e+07 1.42e+07 1.40e+07 1.42e+07 1.42e+07 1.43e+07 1.40e+07 1.43e+07 +Best cache type FIFOCache with maxsize 128 + +Cache speed test of function spacing_functions.gaussian_zoom + 0 1 2 4 8 16 32 64 128 256 +NoCache 24703 +NullCache 24872 24935 24927 24896 24968 24964 24882 24840 24873 24913 +FIFOCache 2.54e+07 2.54e+07 2.54e+07 2.54e+07 2.53e+07 2.52e+07 2.53e+07 2.51e+07 2.52e+07 2.52e+07 +LRUCache 1.63e+07 1.63e+07 1.63e+07 1.64e+07 1.63e+07 1.64e+07 1.63e+07 1.63e+07 1.63e+07 1.63e+07 +TTLCache 1.43e+07 1.43e+07 1.42e+07 1.42e+07 1.43e+07 1.42e+07 1.43e+07 1.43e+07 1.43e+07 1.43e+07 +Best cache type FIFOCache with maxsize 0 + """ diff --git a/binarycpython/utils/population_extensions/condor.py b/binarycpython/utils/population_extensions/condor.py new file mode 100644 index 0000000000000000000000000000000000000000..04a6f8b75938fdca36b064af6b22081cd072e86d --- /dev/null +++ b/binarycpython/utils/population_extensions/condor.py @@ -0,0 +1,566 @@ +""" +The class extension for the population object that contains the Condor functionality + +TODO: there are many uses of $<variable name> in this file but this is not perl and we should replace them by actual format placeholders +""" + +# pylint: disable=E1101 + +import os +import re +import sys +import stat +import time +import subprocess + +import pathlib + +import datasize +import lib_programname +from binarycpython.utils.functions import ( + command_string_from_list, + now, +) + + +class condor: + """ + Extension for the Population class containing the code for Condor grid runs + """ + + def __init__(self, **kwargs): + """ + Init function for the condor class + """ + + return + + def condorID(self, ClusterID=None, Process=None): + """ + Function to return a Condor job ID as a string, [ClusterID].[Process]. The ClusterID and Process passed in are used if given, otherwise we default to the condor_ClusterID and condor_Process in grid_options. + """ + if ClusterID is None: + ClusterID = self.grid_options["condor_ClusterID"] + if Process is None: + Process = self.grid_options["condor_Process"] + return "{ClusterID}.{Process}".format(ClusterID=ClusterID, Process=Process) + + def condorpath(self, path, condor_dir=None): + """ + Function to return the full condor directory path. + """ + + if condor_dir is None: + condor_dir = self.grid_options["condor_dir"] + return os.path.abspath(os.path.join(condor_dir, path)) + + def condor_status_file(self, ClusterID=None, Process=None, condor_dir=None): + """ + Return the condor status file corresponding to the ClusterID and Process, which default to grid_options condor_ClusterID and condor_Process, respectively. + """ + return os.path.join( + self.condorpath("status", condor_dir=condor_dir), + self.condorID(ClusterID, Process), + ) + + def condor_check_requirements(self): + """ + Function to check whether the condor parameters in grid_options have been set appropriately. + """ + if self.grid_options["condor"] > 0 and ( + self.grid_options["condor_dir"] is None + or not os.path.isdir(self.grid_options["condor_dir"]) + ): + return ( + False, + "You have set condor={condor} but not set condor_dir ({condor_dir}) correctly. Please set it and try again.".format( + condor=self.grid_options["condor"], + condor_dir=self.grid_options["condor_dir"], + ), + ) + return (True, "") + + def condor_dirs(self): + """ + Directories associated specifically with this condor job. + """ + + return ["condor_dir"] + + def set_condor_status(self, string, condor_dir=None): + """ + Set the condor status corresponing to the self object, which should have condor_ClusterID and condor_Process set. + + Args: + string : the status string to be set + dir : the directory in which the status directory is held. If not set, this defaults to the HPC directory (e.g. slurm_dir or condor_dir). + """ + # save condor ClusterID to file + + if condor_dir is None: + condor_dir = self.grid_options["condor_dir"] + + idfile = os.path.join(condor_dir, "ClusterID") + if not os.path.exists(idfile): + with self.open(idfile, "w", encoding="utf-8") as fClusterID: + fClusterID.write( + "{ClusterID}\n".format( + ClusterID=self.grid_options["condor_ClusterID"] + ) + ) + fClusterID.close() + self.NFS_flush_hack(idfile) + + # save condor status + file = self.condor_status_file(condor_dir=condor_dir) + if file: + with self.open(file, "w", encoding="utf-8") as f: + f.write(string) + f.close() + self.NFS_flush_hack(file) + + def get_condor_status(self, ClusterID=None, Process=None, condor_dir=None): + """ + Get and return the condor status corresponing to the self object, or ClusterID.Process if they are passed in. If no status is found, returns an empty string.. + """ + if ClusterID is None: + ClusterID = self.grid_options["condor_ClusterID"] + if Process is None: + Process = self.grid_options["condor_Process"] + if ClusterID is None or Process is None: + return None + # print("get_condor_status {}.{}".format(ClusterID,Process)) + + try: + path = pathlib.Path( + self.condor_status_file( + condor_dir=condor_dir, ClusterID=ClusterID, Process=Process + ) + ) + # print("path={}".format(path)) + # print("size={}".format(path.stat().st_size)) + if path: + s = path.read_text().strip() + # print("contains {}".format(s)) + return s + # print("path empty") + return "" + + # NOTE: What is the actual exception that can occur here? + # TODO: We should specify that exception + except: + # print("read failed") + return "" + + def condor_outfile(self, condor_dir=None): + """ + return a standard filename for the condor chunk files + """ + file = "{id}.gz".format(id=self.condorID()) + if condor_dir is None: + condor_dir = self.grid_options["condor_dir"] + return os.path.abspath(os.path.join(condor_dir, "results", file)) + + def make_condor_dirs(self, condor_dir=None): + """ + Function to make the condor directories + """ + + # make the condor directories + if condor_dir is None: + condor_dir = self.grid_options["condor_dir"] + if not condor_dir: + print( + "You must set self.grid_options['condor_dir'] (or pass condor_dir=whatever to make_condor_dirs()) to a directory which we can use to set up binary_c-python's Condor files. This should be unique to your set of grids." + ) + os.exit() + + # make a list of directories, these contain the various condor + # output, status files, etc. + dirs = [] + for d in ["stdout", "stderr", "log", "results", "status", "snapshots"]: + dirs.append(self.condorpath(d, condor_dir=condor_dir)) + + # make the directories: we do not allow these to already exist + # as the condor directory should be a fresh location for each set of jobs + for d in dirs: + try: + pathlib.Path(self.condorpath(d, condor_dir=condor_dir)).mkdir( + exist_ok=False, parents=True + ) + # TODO: specify the actual exception + # TODO: is this try-except necessary? Especially having the code fail here, instead of earlier, if the directories exist already. Otherwise we can also just do exist_ok=True? + except: + print( + "Tried to make the directory {d} but it already exists. When you launch a set of binary_c jobs on Condor, you need to set your condor_dir to be a fresh directory with no contents.".format( + d=d + ) + ) + self.exit(code=1) + + # check that they have been made and exist: we need this + # because on network mounts (NFS) there's often a delay between the mkdir + # above and the actual directory being made. This shouldn't be too long... + fail = True + count = 0 + count_warn = 10 + while fail is True: + fail = False + count += 1 + if count > count_warn: + print( + "Warning: Have been waiting about {} seconds for Condor directories to be made, there seems to be significant delay...".format( + count + ) + ) + for d in dirs: + if os.path.isdir(d) is False: + fail = True + time.sleep(1) + break + + def condor_grid(self): # pragma: no cover + """ + function to be called when running grids when grid_options['condor']>=1 + + if grid_options['condor']==1, we set up the condor script and launch the jobs, then return True to exit. + if grid_options['condor']==2, we run the stars, which means we return False to continue. + if grid_options['condor']==3, we are being called from the jobs to run the grids, return False to continue. + + TODO: split this function into some parts + TODO: Comment this function better + """ + + if self.grid_options["condor"] == 3: + # joining : set the evolution type to "join" + # + # return False to continue + self.grid_options["evolution_type"] = "join" + return False + + if self.grid_options["condor"] == 2: + # run a grid of stars only, leaving the results + # in the appropriate outfile + # + # return False to actually run the stars + self.grid_options["evolution_type"] = "grid" + return False + + if self.grid_options["condor"] == 1: + # if condor=1, we should have no evolution type, we + # set up the Condor scripts and get them evolving + # in a Condor queue + self.grid_options["evolution_type"] = None + + # make dirs + self.make_condor_dirs() + + # check we're not using too much RAM + if datasize.DataSize( + self.grid_options["condor_memory"] + ) > datasize.DataSize(self.grid_options["condor_warn_max_memory"]): + print( + "WARNING: you want to use {} MB of RAM : this is unlikely to be correct. If you believe it is, set condor_warn_max_memory to something very large (it is currently {} MB)\n".format( + self.grid_options["condor_memory"], + self.grid_options["condor_warn_max_memory"], + ) + ) + self.exit(code=1) + + # get job id (might be passed in) + ClusterID = ( + self.grid_options["condor_ClusterID"] + if self.grid_options["condor_ClusterID"] != "" + else "$ClusterID" + ) + + # get job array index + Process = ( + self.grid_options["condor_Process"] + if self.grid_options["condor_Process"] != "" + else "$Process" + ) + + if self.grid_options["condor_njobs"] == 0: + print( + "binary_c-python Condor : You must set grid_option condor_njobs to be non-zero" + ) + self.exit(code=1) + + # find the path to the Python script that we are running + pyscriptpath = str(lib_programname.get_path_executed_script()) + + # set the condor initial dir to be our current working directory + if not self.grid_options["condor_initial_dir"]: + self.grid_options["condor_initial_dir"] = os.getcwd() + + # build the grid command + grid_command = ( + [ + str(self.grid_options["condor_env"]), + sys.executable, + pyscriptpath, + ] + + sys.argv[1:] + + [ + "start_at=$Process", # Process is 0,1,2... which is what we want + "modulo=" + str(self.grid_options["condor_njobs"]), + "condor_njobs=" + str(self.grid_options["condor_njobs"]), + "condor_dir=" + self.grid_options["condor_dir"], + "verbosity=" + str(self.grid_options["verbosity"]), + "num_cores=" + str(self.grid_options["num_processes"]), + ] + ) + + grid_command = command_string_from_list(grid_command) + + # make condor script paths + submit_script_path = self.condorpath("condor_submit_script") + job_script_path = self.condorpath("condor_job_script") + + # open the files + try: + submit_script = self.open(submit_script_path, "w", encoding="utf-8") + except IOError: + print( + "Could not open Condor script at {path} for writing: please check you have set {condor_dir} correctly (it is currently {condor_dir} and can write to this directory.".format( + path=submit_script_path, + condor_dir=self.grid_options["condor_dir"], + ) + ) + try: + job_script = self.open(job_script_path, "w", encoding="utf-8") + except IOError: + print( + "Could not open Condor script at {path} for writing: please check you have set {condor_dir} correctly (it is currently {condor_dir} and can write to this directory.".format( + path=job_script_path, condor_dir=self.grid_options["condor_dir"] + ) + ) + + ############################################################ + # The condor job script calls your binary_c-pthyon script + ############################################################ + condor_job_script = """#!{bash} +echo "Condor Job Args: $@" + +# first two arguments are ClusterID and Process +export ClusterID="$1" +export Process="$2" +shift 2 + +echo "Job ClusterID $ClusterID Process $Process" + +# Set binary_c startup conditions +export BINARY_C_PYTHON_ORIGINAL_CMD_LINE={cmdline} +export BINARY_C_PYTHON_ORIGINAL_WD=`{pwd}` +export BINARY_C_PYTHON_ORIGINAL_SUBMISSION_TIME=`{date}` + +# set status to \"running\" +echo \"running\" > "{condor_dir}/status/$ClusterID.$ProcessID" + +# make list of files which is checked for joining +# echo "{condor_dir}/results/$ClusterID.$Process.gz" >> "{condor_dir}/results/$ClusterID.all" + +# run grid of stars and, if this returns 0, set status to finished +{grid_command} "condor=2" "evolution_type=grid" "condor_ClusterID=$ClusterID" "condor_Process=$Process" "save_population_object={condor_dir}/results/$ClusterID.$Process.gz" && echo -n \"finished\" > "{condor_dir}/status/$ClusterID.$ProcessID" && echo """.format( + bash=self.grid_options["condor_bash"], + date=self.grid_options["condor_date"], + pwd=self.grid_options["condor_pwd"], + cmdline=repr(self.grid_options["command_line"]), + grid_command=grid_command, + condor_dir=self.grid_options["condor_dir"], + ) + + if not self.grid_options["condor_postpone_join"]: + joinfile = "{condor_dir}/results/{ClusterID}.all".format( + condor_dir=self.grid_options["condor_dir"], ClusterID=ClusterID + ) + condor_job_script += """&& echo \"Checking if we can join...\" && echo && {grid_command} "condor=3" "evolution_type=join" "joinlist={joinfile}" "condor_ClusterID=$ClusterID" "condor_Process=$Process" + """.format( + bash=self.grid_options["condor_bash"], + grid_command=grid_command, + joinfile=joinfile, + ) + + ############################################################ + # The Condor submit script is sent to condor_submit + # In here we know $(Cluster) and $(Process) which identify + # each job + ############################################################ + extra_settings = "" + if self.grid_options["condor_extra_settings"]: + for key in self.grid_options["condor_extra_settings"]: + extra_settings += "{key} = {value}\n".format( + key=key, + value=self.grid_options["condor_extra_settings"][key], + ) + + jobid = "$(Cluster).$(Process)" + condor_submit_script = """ +executable = {usr_bin_env} +arguments = {bash} {job_script_path} $(Cluster) $(Process) +universe = {universe} +getenv = {getenv} +initial_dir = {initial_dir} +output = {outfile} +error = {errfile} +log = {logfile} +stream_output = {stream_output} +stream_error = {stream_error} +request_memory = {request_memory} +request_cpus = {request_cpus} +should_transfer_files = {should_transfer_files} +when_to_transfer_output = {when_to_transfer_output} +requirements = {requirements} +JobBatchName = {batchname} +kill_sig = {kill_sig} +{extra_settings} +queue {njobs} + """.format( + usr_bin_env=self.grid_options["condor_env"], + bash=self.grid_options["condor_bash"], + job_script_path=job_script_path, + universe=self.grid_options["condor_universe"], + getenv=self.grid_options["condor_getenv"], + initial_dir=self.grid_options["condor_initial_dir"], + outfile=os.path.abspath( + os.path.join(self.grid_options["condor_dir"], "stdout", jobid) + ), + errfile=os.path.abspath( + os.path.join(self.grid_options["condor_dir"], "stderr", jobid) + ), + logfile=os.path.abspath( + os.path.join(self.grid_options["condor_dir"], "log", jobid) + ), + stream_output=self.grid_options["condor_stream_output"], + stream_error=self.grid_options["condor_stream_error"], + request_memory=self.grid_options["condor_memory"], + request_cpus=self.grid_options["num_processes"], + should_transfer_files=self.grid_options[ + "condor_should_transfer_files" + ], + when_to_transfer_output=self.grid_options[ + "condor_when_to_transfer_output" + ], + requirements=self.grid_options["condor_requirements"], + batchname=self.grid_options["condor_batchname"], + kill_sig=self.grid_options["condor_kill_sig"], + extra_settings=extra_settings, + njobs=self.grid_options["condor_njobs"], + ) + + # write the scripts, close them and make them executable by + # all (so the condor user can pick it up) + for file, contents in [ + (submit_script, condor_submit_script), + (job_script, condor_job_script), + ]: + path = file.name + file.writelines(contents) + file.close() + os.chmod( + path, + stat.S_IREAD + | stat.S_IWRITE + | stat.S_IEXEC + | stat.S_IRGRP + | stat.S_IXGRP + | stat.S_IROTH + | stat.S_IXOTH, + ) + + if not self.grid_options["condor_postpone_submit"]: + # call sbatch to launch the condor jobs + cmd = [self.grid_options["condor_submit"], submit_script_path] + with subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) as pipes: + std_out, std_err = pipes.communicate() + + if pipes.returncode != 0: + # an error happened! + err_msg = "{red}{err}\nReturn Code: {code}{reset}".format( + err=std_err.strip(), + code=pipes.returncode, + red=self.ANSI_colours["red"], + reset=self.ANSI_colours["reset"], + ) + raise Exception(err_msg) + + if len(std_err) > 0: + print( + "{red}{err}{reset}".format( + red=self.ANSI_colours["red"], + reset=self.ANSI_colours["reset"], + err=std_err.strip().decode("utf-8"), + ) + ) + + print( + "{yellow}{out}{reset}".format( + yellow=self.ANSI_colours["yellow"], + reset=self.ANSI_colours["reset"], + out=std_out.strip().decode("utf-8"), + ) + ) + else: + # just say we would have (use this for testing) + print( + "Condor script is at {path} but has not been launched".format( + path=submit_script_path + ) + ) + + # some messages to the user, then return + if self.grid_options["condor_postpone_submit"] == 1: + print( + "Condor script written, to {path}, but launching the jobs with sbatch was postponed.".format( + path=submit_script_path + ) + ) + else: + print("Condor jobs launched.") + print("All done in condor_grid().") + + # return True so we exit immediately + return True + + def condor_queue_stats(self): # pragma: no cover + """ + Return condor queue statistics for this job + """ + + _id = self.grid_options["condor_ClusterID"] + if not _id: + return None + + cmd = "{} {} 2>&1".format( + "/usr/bin/condor_q", _id # self.grid_options["condor_q"], + ) + print("Q cmd", cmd) + + with subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) as subp: + result = subp.stdout.read() + print("Q result ", result) + + if not result: + return None + + d = {} + for x in [ + "jobs", + "completed", + "removed", + "idle", + "running", + "held", + "suspended", + ]: + print("Q x ", x) + m = re.search("(\d+)\s+{}".format(x), result) + print("Q m ", m) + if m: + d[x] = m.group(0) + + print("Q d ", d) + return d diff --git a/binarycpython/utils/population_extensions/dataIO.py b/binarycpython/utils/population_extensions/dataIO.py new file mode 100644 index 0000000000000000000000000000000000000000..40d485d20004a2f746f08f43e18bce92076ca7fd --- /dev/null +++ b/binarycpython/utils/population_extensions/dataIO.py @@ -0,0 +1,813 @@ +""" +File containing the class extension for the population object that contains data input-output (IO) functions +""" + +# pylint: disable=E1101 + +import os +import bz2 +import gzip +import copy +import json +import time +import datetime +import subprocess +from typing import Union + +import msgpack +import flufl.lock +import compress_pickle + +from binarycpython.utils.ensemble import ensemble_file_type, ensemble_compression +from binarycpython.utils.dicts import ( + merge_dicts, +) +from binarycpython.utils.functions import ( + verbose_print, + now, +) + + +class dataIO: + """ + Class extension for the population object that contains data input-output (IO) functions + """ + + def __init__(self, **kwargs): + """ + Init function for the spacing_functions class + """ + + return + + def dir_ok(self, directory): + """ + Function to test if we can read and write to a directory that must exist. Return True if all is ok, False otherwise. + """ + + return os.access(directory, os.F_OK) and os.access(directory, os.R_OK | os.W_OK) + + def save_population_object( + self, + population_object=None, + filename=None, + confirmation=True, + compression="gzip", + ): + """ + Save pickled Population object to file at filename or, if filename is None, whatever is set at self.grid_options['save_population_object'] + + Args: + population_object : the object to be saved to the file. If population_object is None, use self. + filename : the name of the file to be saved. If not set, use self.grid_options['save_population_object'] + confirmation : if True, a file "filename.saved" is touched just after the dump, so we know it is finished. TODO: fix this + compression (optional, default = "gzip"): TODO: fix this + + Compression is performed according to the filename, as stated in the + compress_pickle documentation at + https://lucianopaz.github.io/compress_pickle/html/ + + Shared memory, stored in the population_object.shared_memory dict, is not saved. + """ + + if population_object is None: + # default to using self + population_object = self + + if filename is None: + # get filename from self + filename = self.grid_options["save_population_object"] + + if filename: + print( + "Save population {id}, probtot {probtot} to pickle in {filename}".format( + id=self.grid_options["_population_id"], + probtot=population_object.grid_options["_probtot"], + filename=filename, + ) + ) + + # Some parts of the population_object cannot be pickled: + # remove them, and restore them after pickling + + # remove shared memory + shared_memory = population_object.shared_memory + population_object.shared_memory = None + + # delete system generator + system_generator = population_object.grid_options["_system_generator"] + population_object.grid_options["_system_generator"] = None + + # delete _store_memaddr + _store_memaddr = population_object.grid_options["_store_memaddr"] + population_object.grid_options["_store_memaddr"] = None + + # delete persistent_data_memory_dict + persistent_data_memory_dict = population_object.persistent_data_memory_dict + population_object.persistent_data_memory_dict = None + + # add metadata if it doesn't exist + if not "metadata" in population_object.grid_ensemble_results: + population_object.grid_ensemble_results["metadata"] = {} + + # add datestamp + population_object.grid_ensemble_results["metadata"][ + "save_population_time" + ] = now() + + # add extra metadata + population_object.add_system_metadata() + + # add max memory use + try: + self.grid_ensemble_results["metadata"][ + "max_memory_use" + ] = copy.deepcopy(sum(shared_memory["max_memory_use_per_thread"])) + except Exception as e: + print("save_population_object : Error: ", e) + raise Exception(e) from e + + # dump pickle file + compress_pickle.dump(population_object, filename, pickler_method="dill") + + # restore data + population_object.shared_memory = shared_memory + population_object.grid_options["_system_generator"] = system_generator + del population_object.grid_ensemble_results["metadata"][ + "save_population_time" + ] + population_object.grid_options["store_memaddr"] = _store_memaddr + population_object.persistent_data_memory_dict = persistent_data_memory_dict + + self.NFS_flush_hack(filename) + + # touch 'saved' file + saved = filename + ".saved" + self.HPC_touch(saved) + + def load_population_object(self, filename): + """ + returns the Population object loaded from filename + """ + + self.NFS_flush_hack(filename) + if filename is None: + obj = None + else: + try: + obj = compress_pickle.load(filename, pickler_method="dill") + except Exception as e: + obj = None + print("Loading of the compressed object went wrong: {}".format(e)) + return obj + + def merge_populations(self, refpop, newpop): + """ + merge newpop's results data into refpop's results data + + Args: + refpop : the original "reference" Population object to be added to + newpop : Population object containing the new data + + Returns: + nothing + + Note: + The file should be saved using save_population_object() + """ + + # combine data + refpop.grid_results = merge_dicts(refpop.grid_results, + newpop.grid_results) + + # special cases + maxmem = 0 + if "max_memory_use" in refpop.grid_ensemble_results.get( + "metadata", {} + ) and "max_memory_use" in newpop.grid_ensemble_results.get("metadata", {}): + maxmem = max( + refpop.grid_ensemble_results["metadata"]["max_memory_use"], + newpop.grid_ensemble_results["metadata"]["max_memory_use"], + ) + + try: + # special cases: + # copy the settings + settings = None + if "settings" in newpop.grid_ensemble_results.get("metadata", {}): + settings = copy.deepcopy( + newpop.grid_ensemble_results["metadata"]["settings"] + ) + if settings: + refpop.grid_ensemble_results["metadata"]["settings"] = settings + + # Copy the Xinit + Xinit = None + if "Xinit" in newpop.grid_ensemble_results.get("ensemble", {}): + Xinit = copy.deepcopy(newpop.grid_ensemble_results["ensemble"]["Xinit"]) + if Xinit: + refpop.grid_ensemble_results["ensemble"]["Xinit"] = Xinit + + # merge the ensemble dicts + refpop.grid_ensemble_results = merge_dicts( + refpop.grid_ensemble_results, + newpop.grid_ensemble_results + ) + + # set special cases + refpop.grid_ensemble_results["metadata"]["max_memory_use"] = maxmem + + except Exception as e: + print("Error merging grid_ensemble_results:", e) + raise Exception(e) from e + + for key in ["_probtot"]: + refpop.grid_options[key] += newpop.grid_options[key] + + refpop.grid_options["_killed"] |= newpop.grid_options["_killed"] + + def merge_populations_from_file(self, refpop, filename): + """ + Wrapper for merge_populations so it can be done directly + from a file. + + Args: + refpop : the original "reference" Population object to be added to + filename : file containing the Population object containing the new data + + Note: + The file should be saved using save_population_object() + """ + + mtime = time.localtime(os.path.getmtime(filename)) + modtime = time.strftime("%a, %d %b %Y %H:%M:%S", mtime) + print( + "Load data from {filename} : size {size}, modtime {modtime}".format( + filename=filename, + size=os.path.getsize(filename), + modtime=modtime, + ) + ) + + newpop = self.load_population_object(filename) + + if "total_count" in newpop.grid_options: + n = newpop.grid_options["total_count"] + elif "_count" in newpop.grid_options: + n = newpop.grid_options["_count"] + elif ( + "metadata" in newpop.grid_ensemble_results + and "_count" in newpop.grid_ensemble_results["metadata"] + ): + n = newpop.grid_ensemble_results["metadata"]["_count"] + else: + n = -1 + + print("Loaded data from {n} stars".format(n=n)) + + # merge with refpop + self.merge_populations(refpop, newpop) + + def snapshot_filename(self): + """ + Automatically choose the snapshot filename. + """ + if self.HPC_job(): + return self.HPC_snapshot_filename() + + file = os.path.join(self.grid_options["tmp_dir"], "snapshot.gz") + return file + + def load_snapshot(self, file): + """ + Load a snapshot from file and set it in the preloaded_population placeholder. + """ + newpop = self.load_population_object(file) + + # unset the _killed flag, in case it was set + newpop.grid_options["_killed"] = False + + # set in preloaded_population for later merge + self.preloaded_population = newpop + + # set the start position for new stars + self.grid_options["start_at"] = newpop.grid_options["start_at"] + + print( + "Loaded from snapshot at {file} : {nstars} stars, start at star {nstart}".format( + file=file, + nstars=0, # self.grid_options[''], + nstart=self.grid_options["start_at"], + ) + ) + return + + def save_snapshot(self, file=None): + """ + Save the population object to a snapshot file, automatically choosing the filename if none is given. + """ + if file is None: + file = self.snapshot_filename() + + if "_count" in self.grid_options: + n = self.grid_options["_count"] + else: + n = "?" + + print("Saving snapshot containing {} stars to {}".format(n, file)) + self.save_population_object(object=self, filename=file) + + def write_ensemble( + self, + output_file, + data=None, + sort_keys=True, + indent=4, + encoding="utf-8", + ensure_ascii=False, + ): + """ + write_ensemble : Write ensemble results to a file. + + Args: + output_file : the output filename. + + If the filename has an extension that we recognise, + e.g. .gz or .bz2, we compress the output appropriately. + + The filename should contain .json or .msgpack, the two + currently-supported formats. + + Usually you'll want to output to JSON, but we can + also output to msgpack. + + data : the data dictionary to be converted and written to the file. + If not set, this defaults to self.grid_ensemble_results. + + sort_keys : if True, and output is to JSON, the keys will be sorted. + (default: True, passed to json.dumps) + + indent : number of space characters used in the JSON indent. (Default: 4, + passed to json.dumps) + + encoding : file encoding method, usually defaults to 'utf-8' + + ensure_ascii : the ensure_ascii flag passed to json.dump and/or json.dumps + (Default: False) + """ + + # get the file type + file_type = ensemble_file_type(output_file) + + # default to using grid_ensemble_results if no data is given + if data is None: + data = self.grid_ensemble_results + + if not file_type: + print( + "Unable to determine file type from ensemble filename {} : it should be .json or .msgpack.".format( + output_file + ) + ) + self.exit(code=1) + else: + if file_type == "JSON": + f = self.open(output_file, "wt", encoding=encoding) + # JSON output + f.write( + json.dumps( + data, + sort_keys=sort_keys, + indent=indent, + ensure_ascii=ensure_ascii, + ) + ) + elif file_type == "msgpack": + f = self.open( + output_file, "w" + ) # TODO: i think something is going wrong here. not sure but doing msgpack and .gz e.g gives an error about str input rather than bytes. i think this is because the self.open does not take into account that the msgpack stream requires different properties. + + # msgpack output + msgpack.dump(data, f) + + f.close() + + print( + "Thread {thread}: Wrote ensemble results to file: {colour}{file}{reset} (file type {file_type})".format( + thread=self.process_ID, + file=output_file, + colour=self.ANSI_colours["green"], + reset=self.ANSI_colours["reset"], + file_type=file_type, + ) + ) + + def write_binary_c_calls_to_file( + self, + output_dir: Union[str, None] = None, + output_filename: Union[str, None] = None, + include_defaults: bool = False, + encoding="utf-8", + ) -> None: + """ + Function that loops over the grid code and writes the generated parameters to a file. + In the form of a command line call + + Only useful when you have a variable grid as system_generator. MC wouldn't be that useful + + Also, make sure that in this export there are the basic parameters + like m1,m2,sep, orb-per, ecc, probability etc. + + On default this will write to the datadir, if it exists + + Args: + output_dir: (optional, default = None) directory where to write the file to. If custom_options['data_dir'] is present, then that one will be used first, and then the output_dir + output_filename: (optional, default = None) filename of the output. If not set it will be called "binary_c_calls.txt" + include_defaults: (optional, default = None) whether to include the defaults of binary_c in the lines that are written. Beware that this will result in very long lines, and it might be better to just export the binary_c defaults and keep them in a separate file. + + Returns: + filename: filename that was used to write the calls to + """ + + # Check if there is no compiled grid yet. If not, lets try to build it first. + if not self.grid_options["_system_generator"]: + + ## check the settings: + if self.bse_options.get("ensemble", None): + if self.bse_options["ensemble"] == 1: + if not self.bse_options.get("ensemble_defer", 0) == 1: + verbose_print( + "Error, if you want to run an ensemble in a population, the output needs to be deferred", + self.grid_options["verbosity"], + 0, + ) + raise ValueError + + # Put in check + if len(self.grid_options["_grid_variables"]) == 0: + print("Error: you haven't defined any grid variables! Aborting") + raise ValueError + + # + self._generate_grid_code(dry_run=False) + + # + self._load_grid_function() + + # then if the _system_generator is present, we go through it + if self.grid_options["_system_generator"]: + # Check if there is an output dir configured + if self.custom_options.get("data_dir", None): + binary_c_calls_output_dir = self.custom_options["data_dir"] + # otherwise check if there's one passed to the function + else: + if not output_dir: + print( + "Error. No data_dir configured and you gave no output_dir. Aborting" + ) + raise ValueError + binary_c_calls_output_dir = output_dir + + # check if there's a filename passed to the function + if output_filename: + binary_c_calls_filename = output_filename + # otherwise use default value + else: + binary_c_calls_filename = "binary_c_calls.txt" + + binary_c_calls_full_filename = os.path.join( + binary_c_calls_output_dir, binary_c_calls_filename + ) + print("Writing binary_c calls to {}".format(binary_c_calls_full_filename)) + + # Write to file + with self.open( + binary_c_calls_full_filename, "w", encoding=encoding + ) as file: + # Get defaults and clean them, then overwrite them with the set values. + if include_defaults: + # TODO: make sure that the defaults here are cleaned up properly + cleaned_up_defaults = self.cleaned_up_defaults + full_system_dict = cleaned_up_defaults.copy() + full_system_dict.update(self.bse_options.copy()) + else: + full_system_dict = self.bse_options.copy() + + for system in self.grid_options["_system_generator"](self): + # update values with current system values + full_system_dict.update(system) + + binary_cmdline_string = self._return_argline(full_system_dict) + file.write(binary_cmdline_string + "\n") + else: + print("Error. No grid function found!") + raise ValueError + + return binary_c_calls_full_filename + + def set_status(self, string, format_statment="process_{}.txt", ID=None): + """ + Function to set the status string in its appropriate file + """ + + if ID is None: + ID = self.process_ID + + if self.grid_options["status_dir"]: + path = os.path.join( + self.grid_options["status_dir"], + format_statment.format(ID), + ) + with self.open(path, "w", encoding="utf-8") as f: + f.write(string) + f.close() + self.NFS_flush_hack(path) + + # custom logging functions for HPC jobs + if self.HPC_job(): + self.HPC_set_status(string) + + def locked_close(self, file, lock): + """ + Partner function to locked_open_for_write() + + Closes and unlocks the file + """ + if file: + file.close() + if lock: + lock.unlock() + if file: + self.NFS_flush_hack(file.name) + + def wait_for_unlock(self, filename, lock_suffix=".lock"): + """ + Companion to locked_open_for_write that waits for a filename + to a) exist and b) be unlocked. + + This should work because the lock file is created before the file + is created. + """ + while not os.path.isfile(filename): + time.sleep(0.25) + while os.path.isfile(filename + lock_suffix): + time.sleep(0.25) + + def locked_open_for_write( + self, + filename, + encoding="utf-8", + lock_suffix=".lock", + lock_timeout=5, + lock_lifetime=60, + exists_ok=False, + fatal_open_errors=True, + vb=False, + **kwargs, + ): + """ + Wrapper for Python's open(filename) which opens a file at + filename for writing (mode "w") and locks it. + + We check whether the file's lockfile already exists, in which + case just return (None,None), and if we cannot obtain a + lock on the file we also return (None,None). + + If the file does not exist, we keep trying to lock until it does. + + To do the locking, we use flufl.lock which is NFS safe. + + Args: + lock_lifetime: (passed to flufl.lock.Lock()) default 60 seconds. + It should take less than this time to write the file. + lock_timeout: (passed to flufl.lock.Lock()) default 5 seconds. + This should be non-zero. + fatal_open_errors: if open() fails and fatal_open_errors is True, exit. + exists_ok: if False and the file at filename exists, return (None,None) (default False) + vb: verbose logging if True, defaults to False + + Returns: + (file_object, lock_object) tuple. + If the file was not opened, returns (None,None). + """ + + if exists_ok is False and os.path.isfile(filename): + if vb: + print("File at {} already exists: cannot write to it".format(filename)) + return (None, None) + + # set the lockfile path: this should be the same + # for all processes, so it's just the original file + # plus the lock_suffix + lockfilename = filename + lock_suffix + if vb: + print("lockfile={}".format(lockfilename)) + + while True: + # if the file exists, just return + if os.path.isfile(lockfilename): + if vb: + print( + "lockfile at {} already exists (corresponding to file at {})".format( + lockfilename, filename + ) + ) + return (None, None) + + # make the lock object by opening the lockfile + lock = flufl.lock.Lock(lockfilename, default_timeout=lock_timeout) + if vb: + print("post-lock: {}".format(lock)) + + if lock: + # we have the lockfile, so set the lifetime and try to lock it + lock.lifetime = datetime.timedelta(seconds=lock_lifetime) + try: + if vb: + print("try to lock {}".format(lock)) + lock.lock() + if vb: + if lock.is_locked: + print("locked {}".format(lock)) + else: + print("failed to lock {}".format(lock)) + except: + pass + + # if we acquired the lock, try to open the file + if lock.is_locked: + if vb: + print( + "{} is locked by {} to {}".format( + filename, lock, lockfilename + ) + ) + + if exists_ok is False and os.path.isfile(filename): + if vb: + print( + "File at {} already exists (2): cannot write to it, unlocking and returning (None,None)".format( + filename + ) + ) + lock.unlock() + return (None, None) + + # All is apparently ok: file is locked + try: + if vb: + print("Try to open file at {}".format(filename)) + f = self.open(filename, mode="w", encoding=encoding, **kwargs) + if vb: + print("Return locked file {}, {}".format(f, lock)) + return (f, lock) + + # error on open should be fatal + except Exception as e: + print("Error in locked_open_for_write() : {}".format(e)) + if fatal_open_errors: + if vb: + print("fatal exit on open") + self.exit(1) + else: + if vb: + print("unlock {}".format(lock)) + lock.unlock() + if vb: + print("unlocked {} return None,None".format(lock)) + return (None, None) + + # failed to lock this time, keep trying + # (we shouldn't lock up the CPU because the timeout is non-zero) + continue + + def NFS_flush_hack(self, filename): + """ + Use opendir()/closedir() to flush NFS access to a file. + + NOTE: this may or may not work! + + TODO: This function leads to a complaint about unclosed scandir operators. Check if that can be resolved. + """ + os.sync() + dirname = os.path.dirname(filename) + + for _ in os.scandir(dirname): + pass + + def compression_type(self, filename): + """ + Return the compression type of the ensemble file, based on its filename extension. + """ + + if filename.endswith(".bz2"): + return "bzip2" + if filename.endswith(".gz"): + return "gzip" + + return None + + def open( + self, + file, + mode="r", + buffering=-1, + encoding=None, + errors=None, + newline=None, + closefd=True, + opener=None, + compression=None, + compresslevel=None, + vb=False, + ): + """ + Wrapper for open() with automatic compression based on the file extension. + """ + + if compression is None: + compression = self.compression_type(file) + + if vb: + print( + 'open() file at "{file}" with mode = {mode}, compression {compression}, compresslevel {compresslevel}'.format( + file=file, + compression=compression, + compresslevel=compresslevel, + mode=mode, + ) + ) + + if compression: + if compresslevel is None: + compresslevel = 9 + if "b" not in mode: + # if we don't specify binary-mode, the gzip module + # defaults to binary, which isn't compatible with JSON, + # so default to text if not specified otherwise + mode += "t" + if vb: + print("open() adding text mode") + else: + encoding = None + errors = None + newline = None + if vb: + print("open() setting encoding=errors=newline=None") + if compression == "bzip2": + file_object = bz2.open( + file, + mode=mode, + compresslevel=compresslevel, + encoding=encoding, + errors=errors, + newline=newline, + ) + elif compression == "gzip": + file_object = gzip.open( + file, + mode=mode, + compresslevel=compresslevel, + encoding=encoding, + errors=errors, + newline=newline, + ) + else: + file_object = open( + file, + mode=mode, + buffering=buffering, + encoding=encoding, + errors=errors, + newline=newline, + closefd=closefd, + opener=opener, + ) + + if vb: + print("open() return file_object =", file_object) + return file_object + + def NFSpath(self, path): + """ + Test path to see if it's on an NFS mount. + + Args: + path : the path to be tested + + Returns: + True : if on an NFS mount point. + False : if not. + None : if the path does not exist. + """ + + if os.path.exists(path): + cmd = 'stat -f -L -c %T "' + path + '"' + return ( + "nfs" + in subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) + .stdout.read() + .decode() + ) + + return None diff --git a/binarycpython/utils/population_extensions/distribution_functions.py b/binarycpython/utils/population_extensions/distribution_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..774ae540c0f97aff172e6094a233f068ad786de9 --- /dev/null +++ b/binarycpython/utils/population_extensions/distribution_functions.py @@ -0,0 +1,2314 @@ +""" +Module containing the predefined distribution functions + +The user can use any of these distribution functions to +generate probability distributions for sampling populations + +To add custom functions you can take any function and add it to the class instance before running the code. +See https://stackoverflow.com/a/28060251 for some tips on how to do that + +There are distributions for the following parameters: + - mass + - period + - mass ratio + - binary fraction + +Tasks: + - TODO: make some things globally present? rob does this in his module..i guess it saves + calculations but not sure if I'm gonna do that now + - TODO: add eccentricity distribution: thermal, Mathieu eccentricity + - TODO: Add SFH distributions depending on redshift + - TODO: Add metallicity distributions depending on redshift + - TODO: Add initial rotational velocity distributions + - TODO: make an n-part power law that's general enough to fix the three part and the 4 part +""" + +# pylint: disable=E1101, R0201 + +import math +import json +from typing import Union + +import numpy as np +import cachetools + +import py_rinterpolate + +from binarycpython.utils.useful_funcs import calc_period_from_sep, calc_sep_from_period +from binarycpython.utils.functions import verbose_print +from binarycpython.utils.population_extensions.grid_options_defaults import ( + _MOE2017_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_INTERPOLATOR_LEVEL, +) +from binarycpython.utils.dicts import prepare_dict + +# Global dictinary to store values in +Moecache = {} + +### +# File containing probability distributions +# Mostly copied from the Perl modules +LOG_LN_CONVERTER = 1.0 / math.log(10.0) +distribution_constants = {} # To store the constants in + + +class distribution_functions: + """ + Extension for the Population grid object that contains the distribution functions + """ + + def __init__(self, **kwargs): + """ + Init function for the distribution_functions class + """ + + return + + def flat(self) -> float: + """ + Dummy distribution function that returns 1 + + Returns: + a flat uniform distribution: 1 + """ + + return 1.0 + + def number(self, value: Union[int, float]) -> Union[int, float]: + """ + Dummy distribution function that returns the input + + Args: + value: the value that will be returned by this function. + + Returns: + the value that was provided + """ + return value + + def const_distribution( + self, + min_bound: Union[int, float], + max_bound: Union[int, float], + val: float = None, + ) -> Union[int, float]: + """ + a constant distribution function between min=min_bound and max=max_bound. + + Args: + min_bound: lower bound of the range + max_bound: upper bound of the range + + Returns: + returns the value of 1/(max_bound-min_bound). If val is provided, it will check whether min_bound < val <= max_bound. if not: returns 0 + """ + + if val and not min_bound < val <= max_bound: + prob = 0.0 + else: + prob = 1.0 / (max_bound - min_bound) + return prob + + def powerlaw_constant_nocache( + self, + min_val: Union[int, float], + max_val: Union[int, float], + k: Union[int, float], + ) -> Union[int, float]: + """ + Function that returns the constant to normalise a power law + + TODO: what if k is -1? + + Args: + min_val: lower bound of the range + max_val: upper bound of the range + k: power law slope + + Returns: + constant to normalise the given power law between the min_val and max_val range + """ + + k1 = k + 1.0 + # print( + # "Powerlaw consts from {} to {}, k={} where k1={}".format( + # min_val, max_val, k, k1 + # ) + # ) + + powerlaw_const = k1 / (max_val ** k1 - min_val ** k1) + return powerlaw_const + + @cachetools.cachedmethod( + lambda self: self.caches[ + "population_extensions._distribution_functions.powerlaw_constant" + ] + ) + def powerlaw_constant( + self, + min_val: Union[int, float], + max_val: Union[int, float], + k: Union[int, float], + ) -> Union[int, float]: + """ + Function that returns the constant to normalise a power law + + TODO: what if k is -1? + + Args: + min_val: lower bound of the range + max_val: upper bound of the range + k: power law slope + + Returns: + constant to normalise the given power law between the min_val and max_val range + """ + + k1 = k + 1.0 + # print( + # "Powerlaw consts from {} to {}, k={} where k1={}".format( + # min_val, max_val, k, k1 + # ) + # ) + + powerlaw_const = k1 / (max_val ** k1 - min_val ** k1) + return powerlaw_const + + def powerlaw( + self, + min_val: Union[int, float], + max_val: Union[int, float], + k: Union[int, float], + x: Union[int, float], + ) -> Union[int, float]: + """ + Single power law with index k at x from min to max + + Args: + min_val: lower bound of the power law + max_val: upper bound of the power law + k: slope of the power law + x: position at which we want to evaluate + + Returns: + `probability` at the given position(x) + """ + + # Handle faulty value + if k == -1: + msg = "wrong value for k" + raise ValueError(msg) + + if (x < min_val) or (x > max_val): + print("input value is out of bounds!") + return 0 + + powerlaw_const = self.powerlaw_constant(min_val, max_val, k) + + # power law + prob = powerlaw_const * (x ** k) + return prob + + @cachetools.cachedmethod( + lambda self: self.caches[ + "distribution_functions.calculate_constants_three_part_powerlaw" + ] + ) + def calculate_constants_three_part_powerlaw( + self, + m0: Union[int, float], + m1: Union[int, float], + m2: Union[int, float], + m_max: Union[int, float], + p1: Union[int, float], + p2: Union[int, float], + p3: Union[int, float], + ) -> Union[int, float]: + """ + Function to calculate the constants for a three-part power law + + TODO: use the power law_constant function to calculate all these values + + Args: + m0: lower bound mass + m1: second boundary, between the first slope and the second slope + m2: third boundary, between the second slope and the third slope + m_max: upper bound mass + p1: first slope + p2: second slope + p3: third slope + + Returns: + array of normalisation constants + """ + + array_constants_three_part_powerlaw = [0, 0, 0] + + array_constants_three_part_powerlaw[1] = ( + ((m1 ** p2) * (m1 ** (-p1))) + * (1.0 / (1.0 + p1)) + * (m1 ** (1.0 + p1) - m0 ** (1.0 + p1)) + ) + array_constants_three_part_powerlaw[1] += ( + (m2 ** (1.0 + p2) - m1 ** (1.0 + p2)) + ) * (1.0 / (1.0 + p2)) + array_constants_three_part_powerlaw[1] += ( + ((m2 ** p2) * (m2 ** (-p3))) + * (1.0 / (1.0 + p3)) + * (m_max ** (1.0 + p3) - m2 ** (1.0 + p3)) + ) + array_constants_three_part_powerlaw[1] = 1.0 / ( + array_constants_three_part_powerlaw[1] + 1e-50 + ) + + array_constants_three_part_powerlaw[0] = array_constants_three_part_powerlaw[ + 1 + ] * ((m1 ** p2) * (m1 ** (-p1))) + array_constants_three_part_powerlaw[2] = array_constants_three_part_powerlaw[ + 1 + ] * ((m2 ** p2) * (m2 ** (-p3))) + + return array_constants_three_part_powerlaw + + def three_part_powerlaw( + self, + m: Union[int, float], + m0: Union[int, float], + m1: Union[int, float], + m2: Union[int, float], + m_max: Union[int, float], + p1: Union[int, float], + p2: Union[int, float], + p3: Union[int, float], + ) -> Union[int, float]: + """ + Generalised three-part power law, usually used for mass distributions + + Args: + m: mass at which we want to evaluate the distribution. + m0: lower bound mass + m1: second boundary, between the first slope and the second slope + m2: third boundary, between the second slope and the third slope + m_max: upper bound mass + p1: first slope + p2: second slope + p3: third slope + + Returns: + 'probability' at given mass m + """ + + three_part_powerlaw_constants = self.calculate_constants_three_part_powerlaw( + m0, m1, m2, m_max, p1, p2, p3 + ) + + if m < m0: + prob = 0.0 # Below lower bound + elif m <= m1: + prob = three_part_powerlaw_constants[0] * (m ** p1) # Between m0 and m1 + elif m <= m2: + prob = three_part_powerlaw_constants[1] * (m ** p2) # Between m1 and m2 + elif m <= m_max: + prob = three_part_powerlaw_constants[2] * (m ** p3) # Between m2 and m_max + else: + prob = 0 # Above m_max + + return prob + + @cachetools.cachedmethod( + lambda self: self.caches["distribution_functions.gaussian_normalizing_const"] + ) + def gaussian_normalizing_const( + self, + mean: Union[int, float], + sigma: Union[int, float], + gmin: Union[int, float], + gmax: Union[int, float], + ) -> Union[int, float]: + """ + Function to calculate the normalisation constant for the Gaussian + + Args: + mean: mean of the Gaussian + sigma: standard deviation of the Gaussian + gmin: lower bound of the range to calculate the probabilities in + gmax: upper bound of the range to calculate the probabilities in + + Returns: + normalisation constant for the Gaussian distribution(mean, sigma) between gmin and gmax + """ + + # First time; calculate multiplier for given mean and sigma + ptot = 0 + resolution = 1000 + d = (gmax - gmin) / resolution + + for i in range(resolution): + y = gmin + i * d + ptot += d * self.gaussian_func(y, mean, sigma) + + return ptot + + def gaussian_func( + self, x: Union[int, float], mean: Union[int, float], sigma: Union[int, float] + ) -> Union[int, float]: + """ + Function to evaluate a Gaussian at a given point, but this time without any boundaries. + + Args: + x: location at which to evaluate the distribution + mean: mean of the Gaussian + sigma: standard deviation of the Gaussian + + Returns: + value of the Gaussian at x + """ + gaussian_prefactor = 1.0 / math.sqrt(2.0 * math.pi) + + r = 1.0 / (sigma) + y = (x - mean) * r + return gaussian_prefactor * r * math.exp(-0.5 * y ** 2) + + def gaussian( + self, + x: Union[int, float], + mean: Union[int, float], + sigma: Union[int, float], + gmin: Union[int, float], + gmax: Union[int, float], + ) -> Union[int, float]: + """ + Gaussian distribution function. used for e.g. Duquennoy + Mayor 1991 + + Args: + x: location at which to evaluate the distribution + mean: mean of the Gaussian + sigma: standard deviation of the Gaussian + gmin: lower bound of the range to calculate the probabilities in + gmax: upper bound of the range to calculate the probabilities in + + Returns: + 'probability' of the Gaussian distribution between the boundaries, evaluated at x + """ + + # # location (X value), mean and sigma, min and max range + # my ($x,$mean,$sigma,$gmin,$gmax) = @_; + + if (x < gmin) or (x > gmax): + prob = 0 + else: + # normalise over given range + normalisation = self.gaussian_normalizing_const(mean, sigma, gmin, gmax) + prob = self.gaussian_func(x, mean, sigma) / normalisation + + return prob + + ##### + # Mass distributions + ##### + + def Kroupa2001( + self, m: Union[int, float], newopts: dict = None + ) -> Union[int, float]: + """ + Probability distribution function for Kroupa 2001 IMF. + + The (default) values for this is:: + + default = { + "m0": 0.1, + "m1": 0.5, + "m2": 1, + "mmax": 100, + "p1": -1.3, + "p2": -2.3, + "p3": -2.3 + } + + Args: + m: mass to evaluate the distribution at + newopts: optional dict to override the default values. + + Returns: + 'probability' of distribution function evaluated at m + """ + + # Default parameters and override them + default = { + "m0": 0.1, + "m1": 0.5, + "m2": 1, + "mmax": 100, + "p1": -1.3, + "p2": -2.3, + "p3": -2.3, + } + + value_dict = default.copy() + + if newopts: + value_dict.update(newopts) + + return self.three_part_powerlaw( + m, + value_dict["m0"], + value_dict["m1"], + value_dict["m2"], + value_dict["mmax"], + value_dict["p1"], + value_dict["p2"], + value_dict["p3"], + ) + + def ktg93(self, m: Union[int, float], newopts: dict = None) -> Union[int, float]: + """ + Probability distribution function for KTG93 IMF, where the default values to the three_part_powerlaw are: default = {"m0": 0.1, "m1": 0.5, "m2": 1, "mmax": 80, "p1": -1.3, "p2": -2.2,"p3": -2.7} + + Args: + m: mass to evaluate the distribution at + newopts: optional dict to override the default values. + + Returns: + 'probability' of distribution function evaluated at m + """ + + defaults = { + "m0": 0.1, + "m1": 0.5, + "m2": 1.0, + "mmax": 80, + "p1": -1.3, + "p2": -2.2, + "p3": -2.7, + } + value_dict = defaults.copy() + + if newopts: + value_dict.update(newopts) + + return self.three_part_powerlaw( + m, + value_dict["m0"], + value_dict["m1"], + value_dict["m2"], + value_dict["mmax"], + value_dict["p1"], + value_dict["p2"], + value_dict["p3"], + ) + + def imf_tinsley1980(self, m: Union[int, float]) -> Union[int, float]: + """ + Probability distribution function for Tinsley 1980 IMF (defined up until 80Msol): self.three_part_powerlaw(m, 0.1, 2.0, 10.0, 80.0, -2.0, -2.3, -3.3) + + Args: + m: mass to evaluate the distribution at + + Returns: + 'probability' of distribution function evaluated at m + """ + + return self.three_part_powerlaw(m, 0.1, 2.0, 10.0, 80.0, -2.0, -2.3, -3.3) + + def imf_scalo1986(self, m: Union[int, float]) -> Union[int, float]: + """ + Probability distribution function for Scalo 1986 IMF (defined up until 80Msol): self.three_part_powerlaw(m, 0.1, 1.0, 2.0, 80.0, -2.35, -2.35, -2.70) + + Args: + m: mass to evaluate the distribution at + + Returns: + 'probability' of distribution function evaluated at m + """ + return self.three_part_powerlaw(m, 0.1, 1.0, 2.0, 80.0, -2.35, -2.35, -2.70) + + def imf_scalo1998(self, m: Union[int, float]) -> Union[int, float]: + """ + From Scalo 1998 + + Probability distribution function for Scalo 1998 IMF (defined up until 80Msol): self.three_part_powerlaw(m, 0.1, 1.0, 10.0, 80.0, -1.2, -2.7, -2.3) + + Args: + m: mass to evaluate the distribution at + + Returns: + 'probability' of distribution function evaluated at m + """ + + return self.three_part_powerlaw(m, 0.1, 1.0, 10.0, 80.0, -1.2, -2.7, -2.3) + + def imf_chabrier2003(self, m: Union[int, float]) -> Union[int, float]: + """ + Probability distribution function for IMF of Chabrier 2003 PASP 115:763-795 + + Args: + m: mass to evaluate the distribution at + + Returns: + 'probability' of distribution function evaluated at m + """ + + chabrier_logmc = math.log10(0.079) + chabrier_sigma2 = 0.69 * 0.69 + chabrier_a1 = 0.158 + chabrier_a2 = 4.43e-2 + chabrier_x = -1.3 + + if m <= 0: + msg = "below bounds" + raise ValueError(msg) + + if 0 < m < 1.0: + dm = math.log10(m) - chabrier_logmc + prob = chabrier_a1 * math.exp(-(dm ** 2) / (2.0 * chabrier_sigma2)) + else: + prob = chabrier_a2 * (m ** chabrier_x) + + prob = prob / (0.1202462 * m * math.log(10)) + return prob + + ######################################################################## + # Binary fractions + ######################################################################## + + def Arenou2010_binary_fraction(self, m: Union[int, float]) -> Union[int, float]: + """ + Arenou 2010 function for the binary fraction as f(M1) + + GAIA-C2-SP-OPM-FA-054 + www.rssd.esa.int/doc_fetch.php?id=2969346 + + Args: + m: mass to evaluate the distribution at + + Returns: + binary fraction at m + """ + + return 0.8388 * math.tanh(0.688 * m + 0.079) + + def raghavan2010_binary_fraction(self, m: Union[int, float]) -> Union[int, float]: + """ + Fit to the Raghavan 2010 binary fraction as a function of + spectral type (Fig 12). Valid for local stars (Z=Zsolar). + + The spectral type is converted mass by use of the ZAMS + effective temperatures from binary_c/BSE (at Z=0.02) + and the new "long_spectral_type" function of binary_c + (based on Jaschek+Jaschek's Teff-spectral type table). + + Rob then fitted the result + + Args: + m: mass to evaluate the distribution at + + Returns: + binary fraction at m + """ + + return min( + 1.0, + max( + (m ** 0.1) * (5.12310e-01) + (-1.02070e-01), + (1.10450e00) * (m ** (4.93670e-01)) + (-6.95630e-01), + ), + ) + + ######################################################################## + # Period distributions + ######################################################################## + + def duquennoy1991(self, logper: Union[int, float]) -> Union[int, float]: + """ + Period distribution from Duquennoy + Mayor 1991. Evaluated the function self.gaussian(logper, 4.8, 2.3, -2, 12) + + Args: + logper: logarithm of period to evaluate the distribution at + + Returns: + 'probability' at self.gaussian(logper, 4.8, 2.3, -2, 12) + """ + return self.gaussian(logper, 4.8, 2.3, -2, 12) + + def sana12( + self, + M1: Union[int, float], + M2: Union[int, float], + a: Union[int, float], + P: Union[int, float], + amin: Union[int, float], + amax: Union[int, float], + x0: Union[int, float], + x1: Union[int, float], + p: Union[int, float], + ) -> Union[int, float]: + """ + distribution of initial orbital periods as found by Sana et al. (2012) + which is a flat distribution in ln(a) and ln(P) respectively for stars + * less massive than 15Msun (no O-stars) + * mass ratio q=M2/M1<0.1 + * log(P)<0.15=x0 and log(P)>3.5=x1 + and is be given by dp/dlogP ~ (logP)^p for all other binary configurations (default p=-0.55) + + arguments are M1, M2, a, Period P, amin, amax, x0=log P0, x1=log P1, p + + example args: 10, 5, sep(M1, M2, P), sep, ?, -2, 12, -0.55 + + # TODO: Fix this function! Half of the input here can be taken out and calculated within the function itself. + + Args: + M1: Mass of primary + M2: Mass of secondary + a: separation of binary + P: period of binary + amin: minimum separation of the distribution (lower bound of the range) + amax: maximum separation of the distribution (upper bound of the range) + x0: log of minimum period of the distribution (lower bound of the range) + x1: log of maximum period of the distribution (upper bound of the range) + p: slope of the distribution + + Returns: + 'probability' of orbital period P given the other parameters + """ + + res = 0 + if (M1 < 15.0) or (M2 / M1 < 0.1): + res = 1.0 / (math.log(amax) - math.log(amin)) + else: + p1 = 1.0 + p + + # For more details see the LyX document of binary_c for this distribution + # where the variables and normalisations are given + # we use the notation x=log(P), xmin=log(Pmin), x0=log(P0), ... to determine the + x = LOG_LN_CONVERTER * math.log(P) + xmin = LOG_LN_CONVERTER * math.log(calc_period_from_sep(M1, M2, amin)) + xmax = LOG_LN_CONVERTER * math.log(calc_period_from_sep(M1, M2, amax)) + + A1 = 1.0 / ( + x0 ** p * (x0 - xmin) + + (x1 ** p1 - x0 ** p1) / p1 + + x1 ** p * (xmax - x1) + ) + A0 = A1 * x0 ** p + A2 = A1 * x1 ** p + + if x < x0: + res = A0 + elif x > x1: + res = A2 + else: + res = A1 * x ** p + res *= 3.0 / 2.0 * LOG_LN_CONVERTER + return res + + def interpolate_in_mass_izzard2012( + self, M: Union[int, float], high: Union[int, float], low: Union[int, float] + ) -> Union[int, float]: + """ + Function to interpolate in mass + + TODO: fix this function. + TODO: describe the args + high: at M=16.3 + low: at 1.15 + + Args: + M: mass + high: + low: + + Returns: + + """ + + log_interpolation = False + + if log_interpolation: + return (high - low) / (math.log10(16.3) - math.log10(1.15)) * ( + math.log10(M) - math.log10(1.15) + ) + low + return (high - low) / (16.3 - 1.15) * (M - 1.15) + low + + def Izzard2012_period_distribution( + self, + P: Union[int, float], + M1: Union[int, float], + log10Pmin: Union[int, float] = -1.0, + ) -> Union[int, float]: + """ + period distribution which interpolates between + Duquennoy and Mayor 1991 at low mass (G/K spectral type <~1.15Msun) + and Sana et al 2012 at high mass (O spectral type >~16.3Msun) + + This gives dN/dlogP, i.e. DM/Raghavan's Gaussian in log10P at low mass + and Sana's power law (as a function of logP) at high mass + + TODO: fix this function + + Args: + P: period + M1: Primary star mass + log10Pmin: minimum period in base log10 (optional) + + Returns: + 'probability' of interpolated distribution function at P and M1 + + """ + + # Check if there is input and force it to be at least 1 + log10Pmin = max(-1.0, log10Pmin) + + # save mass input and limit mass used (M1 from now on) to fitted range + Mwas = M1 + M1 = max(1.15, min(16.3, M1)) + + # Calculate the normalisations + # need to normalise the distribution for this mass + # (and perhaps secondary mass) + prepare_dict(distribution_constants, ["Izzard2012", M1]) + if not distribution_constants["Izzard2012"][M1].get(log10Pmin): + distribution_constants["Izzard2012"][M1][ + log10Pmin + ] = 1 # To prevent this loop from going recursive + N = 200.0 # Resolution for normalisation. I hope 1000 is enough + dlP = (10.0 - log10Pmin) / N + C = 0 # normalisation constant. + for lP in np.arange(log10Pmin, 10, dlP): + C += dlP * self.Izzard2012_period_distribution(10 ** lP, M1, log10Pmin) + + distribution_constants["Izzard2012"][M1][log10Pmin] = 1.0 / C + + lP = math.log10(P) + # log period + + # # fits + mu = self.interpolate_in_mass_izzard2012(M1, -17.8, 5.03) + sigma = self.interpolate_in_mass_izzard2012(M1, 9.18, 2.28) + K = self.interpolate_in_mass_izzard2012(M1, 6.93e-2, 0.0) + nu = self.interpolate_in_mass_izzard2012(M1, 0.3, -1) + g = 1.0 + 1e-30 ** (lP - nu) + lPmu = lP - mu + + if (lP < log10Pmin) or (lP > 10.0): + return 0 + + return ( + distribution_constants["Izzard2012"][M1][log10Pmin] + * (math.exp(-lPmu * lPmu / (2.0 * sigma * sigma)) + K / max(0.1, lP)) + / g + ) + + ######################################################################## + # Mass ratio distributions + ######################################################################## + def flatsections(self, x: float, opts: dict) -> Union[float, int]: + """ + Function to generate flat distributions, possibly in multiple sections + + Args: + x: mass ratio value + opts: list containing the flat sections. Which are themselves dictionaries, with keys "max": upper bound, "min": lower bound and "height": value + + Returns: + probability of that mass ratio. + """ + + c = 0 + y = 0 + for opt in opts: + dc = (opt["max"] - opt["min"]) * opt["height"] + c += dc + if opt["min"] <= x <= opt["max"]: + y = opt["height"] + y /= c + return y + + ######################################################################## + # Eccentricity distributions + ######################################################################## + + ######################################################################## + # Star formation histories + ######################################################################## + + def cosmic_SFH_madau_dickinson2014(self, z): + """ + Cosmic star formation history distribution from Madau & Dickonson 2014 (https://arxiv.org/pdf/1403.0007.pdf) + + Args: + z: redshift + + Returns: + Cosmic star formation rate in Solar mass year^-1 mega parsec^-3 + """ + + CSFH = 0.015 * ((1 + z) ** 2.7) / (1 + (((1 + z) / 2.9) ** 5.6)) + return CSFH + + ######################################################################## + # Metallicity distributions + ######################################################################## + + ######################################################################## + # Moe & DiStefano 2017 functions + # + # The code below are functions that are used to set up and interpolate + # on the Moe & DiStefano 2017 data. The interpolators take the last + # known value if we try to interpolate outside of the tables. + # There are still some open tasks and improvements that can be made: + # + # TODO: Parallelize the setting up of the interpolators + # TODO: Generalise the code such that we can input other/newer tables. + ######################################################################## + + def poisson(self, lambda_val, n, nmax=None): + """ + Function that calculates the Poisson value and normalises + TODO: improve the description + """ + + cachekey = "{} {} {}".format(lambda_val, n, nmax) + + if distribution_constants.get("poisson_cache", None): + if distribution_constants["poisson_cache"].get(cachekey, None): + p_val = distribution_constants["poisson_cache"][cachekey] + return p_val + + # Poisson distribution : note, n can be zero + # + # nmax is the truncation : if set, we normalise + # correctly. + p_val = self._poisson(lambda_val, n) + + if nmax: + I_poisson = 0 + for i in range(nmax + 1): + I_poisson += self._poisson(lambda_val, i) + p_val /= I_poisson + + # Add to cache + if not distribution_constants.get("poisson_cache", None): + distribution_constants["poisson_cache"] = {} + distribution_constants["poisson_cache"][cachekey] = p_val + + return p_val + + def _poisson(self, lambda_val, n): + """ + Function to return the Poisson value + """ + return (lambda_val ** n) * np.exp(-lambda_val) / (1.0 * math.factorial(n)) + + def get_max_multiplicity(self, multiplicity_array): + """ + Function to get the maximum multiplicity + """ + max_multiplicity = 0 + for n in range(4): + if multiplicity_array[n] > 0: + max_multiplicity = n + 1 + return max_multiplicity + + def merge_multiplicities(self, result_array, max_multiplicity, verbosity=0): + """ + Function to fold the multiplicities higher than the max_multiplicity onto the max_multiplicity + + if max_multiplicity == 1: + All the multiplicities are folded onto multiplicity == 1. This will always total to 1 + if max_multiplicity == 2: + The multiplicity fractions of the triple and quadruples are folded onto that of the binary multiplicity fraction + if max_multiplicity == 3: + The multiplicity fractions of the quadruples are folded onto that of the triples + """ + + if not max_multiplicity in range(1, 5): + 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( + msg, + verbosity, + 0, + ) + raise ValueError(msg) + + # Fold multiplicities: + verbose_print( + "\tMoe and di Stefano 2017: merge_multiplicities: Merging multiplicities with initial array {} and max multiplicity {}".format( + result_array, max_multiplicity + ), + verbosity, + _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( + "\tMoe and di Stefano 2017: merge_multiplicities: Merging multiplicities to new array {}".format( + result_array + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + return result_array + + def Moe_di_Stefano_2017_multiplicity_fractions(self, options, verbosity=0): + """ + Function that creates a list of probability fractions and + normalises and merges them according to the users choice. + + TODO: make an extrapolation functionality in this. log10(1.6e1) + is quite low. + + The default result that is returned when sampling the mass outside + of the mass range is now the last known value + + Returns a list of multiplicity fractions for a given input of mass + """ + + # Use the global Moecache + global Moecache + + multiplicity_modulator_array = np.array( + options["multiplicity_modulator"] + ) # Modulator array + + # Check for length + if len(multiplicity_modulator_array) != 4: + msg = "Multiplicity modulator has to have 4 elements. Now it is {}, len: {}".format( + multiplicity_modulator_array, len(multiplicity_modulator_array) + ) + verbose_print( + msg, + verbosity, + 0, + ) + raise ValueError(msg) + + # Set up some arrays + full_fractions_array = np.zeros(4) # Meant to contain the real fractions + weighted_fractions_array = np.zeros( + 4 + ) # Meant to contain the fractions multiplied by the multiplicity modulator + + # Get max multiplicity + max_multiplicity = self.get_max_multiplicity(multiplicity_modulator_array) + + # ... it's better to interpolate the multiplicity and then + # use a Poisson distribution to calculate the fractions + # (this is more accurate) + + # Set up the multiplicity interpolator + if not Moecache.get("rinterpolator_multiplicity", None): + Moecache["rinterpolator_multiplicity"] = py_rinterpolate.Rinterpolate( + 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 - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), + ) + + if options["multiplicity_model"] == "Poisson": + multiplicity = Moecache["rinterpolator_multiplicity"].interpolate( + [np.log10(options["M_1"])] + )[0] + + # Fill the multiplicity array + for n in range(4): + full_fractions_array[n] = self.poisson(multiplicity, n, 3) + + # Normalize it so it fills to one when taking all the multiplicities: + full_fractions_array = full_fractions_array / np.sum(full_fractions_array) + + verbose_print( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: using model {}: full_fractions_array: {}".format( + "Poisson", full_fractions_array + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + elif options["multiplicity_model"] == "data": + # use the fractions calculated from Moe's data directly + # + # note that in this case, there are no quadruples: these + # are combined with triples + + # Fill with the raw values + for n in range(3): + full_fractions_array[n] = Moecache[ + "rinterpolator_multiplicity" + ].interpolate([np.log10(options["M_1"])])[n + 1] + + # Set last value + full_fractions_array[3] = 0.0 # no quadruples + verbose_print( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: using model {}: full_fractions_array: {}".format( + "data", full_fractions_array + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # Normalisation: + if options["normalize_multiplicities"] == "raw": + # Don't multiply by the multiplicity_array, but do give a fractions array + verbose_print( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Not normalising (using raw results): results: {}".format( + full_fractions_array + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + result = full_fractions_array + + elif options["normalize_multiplicities"] == "norm": + # Multiply the full_multiplicity_fraction array by the multiplicity_multiplier_array, creating a weighted fractions array + weighted_fractions_array = ( + full_fractions_array * multiplicity_modulator_array + ) + + # Normalise this so it is in total 1: + result = weighted_fractions_array / np.sum(weighted_fractions_array) + + verbose_print( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with {}. result: {}".format( + "norm", result + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + elif options["normalize_multiplicities"] == "merge": + # We first take the full multiplicity array + # (i.e. not multiplied by multiplier) and do the merging + result = self.merge_multiplicities( + full_fractions_array, max_multiplicity, verbosity=verbosity + ) + + # Then normalise to be sure + result = result / np.sum(result) + + verbose_print( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with {}, max_multiplicity={} result={}".format( + "merge", max_multiplicity, result + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + verbose_print( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: {}".format( + str(result) + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # return array reference + return result + + def build_q_table(self, options, m, p, verbosity=0): + """ + Build an interpolation table for q, given a mass and + orbital period. + + m and p are labels which determine which system(s) + to look up from Moe's data: + + m can be M1, M2, M3, M4, or if set M1+M2 etc. + p can be P, P2, P3 + + The actual values are in $opts: + + mass is in $opts->{m} + period is $opts->{p} + + 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. + If we are below the lowest value of qmin in the table we need to extrapolate the data + + Anyway, the goal of this function is to provide some extrapolated values for q when we should sample outside of the boundaries + TODO: fix description to be correct for python + """ + + # We can check if we have a cached value for this already: + # TODO: fix this cache check. + incache = False + if Moecache.get("rinterpolator_q_metadata", None): + if (Moecache["rinterpolator_q_metadata"].get(m, None)) and ( + Moecache["rinterpolator_q_metadata"].get(p, None) + ): + if (Moecache["rinterpolator_q_metadata"][m] == options[m]) and ( + Moecache["rinterpolator_q_metadata"][p] == options[p] + ): + incache = True + + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: Found cached values for m={} p={}".format( + options[m], options[p] + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + else: + verbose_print( + "\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, + _MOE2017_VERBOSITY_LEVEL, + ) + + # + if not incache: + # trim and/or expand the table to the range qmin to qmax. + + # qmin is set by the minimum stellar mass + qmin = options["Mmin"] / options["M_1"] + verbose_print( + "\tMoe and di Stefano 2017: build_q_table qmin: {}".format( + qmin, + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # qmax = maximum_mass_ratio_for_RLOF(options[m], options[p]) + # TODO: change this to the above + qmax = 1 + + # qdata contains the table that we modify: we get + # the original data by interpolating Moe's table + qdata = {} + can_renormalize = 1 + + qeps = 1e-8 # small number but such that qeps+1 != 1 + if qeps + 1 == 1.0: + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: qeps (= {}) +1 == 1. Make qeps larger".format( + qeps, + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + if qmin >= qmax: + # there may be NO binaries in this part of the parameter space: + # in which case, set up a table with lots of zero in it + + qdata = {0: 0, 1: 0} + can_renormalize = 0 + + else: + # qmin and qmax mean we'll get something non-zero + can_renormalize = 1 + + # require extrapolation sets whether we need to extrapolate + # at the low and high ends + require_extrapolation = {} + + if qmin >= 0.15: + # qmin is inside Moe's table : this is easy, + # we just keep points from qmin at the low + # end to qmax at the high end. + require_extrapolation["low"] = 0 + require_extrapolation[ + "high" + ] = 1 # TODO: shouldn't the extrapolation need to happen if qmax > 0.95 + qdata[qmin] = Moecache["rinterpolator_q"].interpolate( + [np.log10(options[m]), np.log10(options[p]), qmin] + )[0] + + for q in np.arange(0.15, 0.950001, 0.1): + if qmin <= q <= qmax: + qdata[q] = Moecache["rinterpolator_q"].interpolate( + [np.log10(options[m]), np.log10(options[p]), q] + )[0] + else: + require_extrapolation["low"] = 1 + require_extrapolation["high"] = 1 + if qmax < 0.15: + # qmax < 0.15 which is off the edge + # of the table. In this case, choose + # two points at q=0.15 and 0.16 and interpolate + # at these in case we want to extrapolate. + for q in [0.15, 0.16]: + qdata[q] = Moecache["rinterpolator_q"].interpolate( + [np.log10(options[m]), np.log10(options[p]), q] + )[0] + else: + # qmin < 0.15 and qmax > 0.15, so we + # have to generate Moe's table for + # q = 0.15 (i.e. 0.1 to 0.2) to 0.95 (0.9 to 1) + # as a function of M1 and orbital period, + # to obtain the q distribution data. + + for q in np.arange( + 0.15, np.min([0.950001, qmax + 0.0001]), 0.1 + ): + val = Moecache["rinterpolator_q"].interpolate( + [np.log10(options[m]), np.log10(options[p]), q] + )[0] + qdata[q] = val + + # just below qmin, if qmin>qeps, we want nothing + if qmin - 0.15 > qeps: + q = qmin - qeps + qdata[q] = 0 + require_extrapolation["low"] = 0 + + # just above qmax, if qmax<1, we want nothing + if qmax < 0.95: + q = qmax + qeps + qdata[q] = 0 + require_extrapolation["high"] = 0 + + # sorted list of qs + qs = sorted(qdata.keys()) + + if len(qs) == 0: + msg = "No qs found error" + raise ValueError(msg) + + if len(qs) == 1: + # only one q value : pretend there are two + # with a flat distribution up to 1.0. + if qs[0] == 1.0: + qs[0] = 1.0 - 1e-6 + qs.append(1) + qdata[qs[0]] = 1 + qdata[qs[1]] = 1 + else: + qs.append(1) + qdata[qs[1]] = qs[0] + + # We actually should do the extrapolation now. + else: + # Loop over both the lower end and the upper end + for pre in ["low", "high"]: + if require_extrapolation[pre] == 0: + continue + + sign = -1 if pre == "low" else 1 + end_index = 0 if pre == "low" else len(qs) - 1 + indices = ( + [0, 1] if pre == "low" else [len(qs) - 1, len(qs) - 2] + ) # Based on whether we do the high or low end we need to use two different indices + method = options.get( + "q_{}_extrapolation_method".format(pre), None + ) + qlimit = qmin if pre == "low" else qmax + + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: Extrapolating: Q: {} method: {}, indices: {} End index: {}".format( + pre, method, indices, end_index + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # truncate the distribution + qdata[max(0.0, min(1.0, qlimit + sign * qeps))] = 0 + + if method is None: + # no extrapolation : just interpolate between 0.10 and 0.95 + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: using no extrapolations", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + continue + if method == "flat": + # use the end value and extrapolate it + # with zero slope + qdata[qlimit] = qdata[qs[end_index]] + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: using constant extrapolation", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + elif method == "linear": + qdata[qlimit] = self.linear_extrapolation_q( + qs=qs, + indices=indices, + qlimit=qlimit, + qdata=qdata, + end_index=end_index, + verbosity=verbosity, + ) + + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: using linear extrapolation", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + if pre == "low": + below_qlimit = qlimit - qeps + if below_qlimit > 0: + qdata[below_qlimit] = 0 + qdata[0] = 0 + verbose_print( + "\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, + _MOE2017_VERBOSITY_LEVEL, + ) + + elif method == "plaw2": + qdata[qlimit] = self.powerlaw_extrapolation_q( + qs=qs, + indices=indices, + qdata=qdata, + verbosity=verbosity, + ) + + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: using powerlaw extrapolation", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + elif method == "nolowq": + newq = 0.05 + qdata[newq] = 0 + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: setting lowq to 0", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + elif method == "poly": + # TODO: consider implementing the poly method (see Perl version) + raise ValueError( + "Moe and di Stefano 2017: build_q_table: Method 'poly' not implemented" + ) + + else: + 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, + _MOE2017_VERBOSITY_LEVEL, + ) + raise ValueError(msg) + + # regenerate qs in new table. This is now the updated list of qs where we have some extrapolated numbers + tmp_table = [] + for q in sorted(qdata.keys()): + tmp_table.append([q, qdata[q]]) + + # Make an interpolation table to contain our modified data + q_interpolator = py_rinterpolate.Rinterpolate( + table=tmp_table, + nparams=1, + ndata=1, # Contains the table of data # q # + verbosity=verbosity - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), + ) + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: Created a new Q table", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + if can_renormalize: + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: Renormalising table", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # now we integrate and renormalise (if the table is not all zero) + I = self.get_integration_constant_q( + q_interpolator, tmp_table, qdata, verbosity=verbosity + ) + + if I > 0: + # normalise to 1.0 by dividing the data by 1.0/$I + q_interpolator.multiply_table_column(1, 1.0 / I) + + # test this + new_I = self.get_integration_constant_q( + q_interpolator, tmp_table, qdata, verbosity=verbosity + ) + + # fail if error in integral > 1e-6 (should be ~ machine precision) + if abs(1.0 - new_I) > 1e-6: + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: Error: > 1e-6 in q probability integral: {}".format( + I + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + # set this new table in the cache + Moecache["rinterpolator_q_given_{}_log10{}".format(m, p)] = q_interpolator + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: stored q_interpolater as {}".format( + "rinterpolator_q_given_{}_log10{}".format(m, p) + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # Store the values for which this table was set up in the dict + if not Moecache.get("rinterpolator_q_metadata", None): + Moecache["rinterpolator_q_metadata"] = {} + Moecache["rinterpolator_q_metadata"][m] = options[m] + Moecache["rinterpolator_q_metadata"][p] = options[p] + + def powerlaw_extrapolation_q(self, qdata, qs, indices): + """ + Function to do the power-law extrapolation at the lower end of the q range + """ + newq = 0.05 + + # use a power-law extrapolation down to q=0.05, if possible + if (qdata[qs[indices[0]]] == 0.0) and (qdata[qs[indices[1]]] == 0.0): + # not possible + return 0 + + else: + slope = ( + np.log10(qdata[qs[indices[1]]]) - np.log10(qdata[qs[indices[0]]]) + ) / (np.log10(qs[indices[1]]) - np.log10(qs[indices[0]])) + intercept = np.log10(qdata[qs[indices[0]]]) - slope * np.log10( + qs[indices[0]] + ) + + return slope * newq + intercept + + def linear_extrapolation_q( + self, qs, indices, qlimit, qdata, end_index, verbosity=0 + ): + """ + Function to do the linear extrapolation for q. + """ + + # linear extrapolation + dq = qs[indices[1]] - qs[indices[0]] + + if dq == 0: + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: linear dq=0", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + # No change + return qs[end_index] + + slope = (qdata[qs[indices[1]]] - qdata[qs[indices[0]]]) / dq + + intercept = qdata[qs[indices[0]]] - slope * qs[indices[0]] + qdata[qlimit] = max(0.0, slope * qlimit + intercept) + verbose_print( + "\tMoe and di Stefano 2017: build_q_table: linear Slope: {} intercept: {} dn/dq({}) = {}".format( + slope, intercept, qlimit, qdata[qlimit] + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + return max(0.0, slope * qlimit + intercept) + + def get_integration_constant_q(self, q_interpolator, tmp_table, qdata, verbosity=0): + """ + Function to integrate the q interpolator and return the integration constant + """ + + dq = 1e-3 # resolution of the integration/renormalisation + I = 0 + + # integrate: note that the value of the integral is + # meaningless to within a factor (which depends on $dq) + for q in np.arange(0, 1 + 2e-6, dq): + x = q_interpolator.interpolate([q]) + + if len(x) == 0: + msg = "\tMoe and di Stefano 2017: get_integration_constant_q: Q interpolator table interpolation failed.\n\t\ttmp_table = {}\n\t\tq_data = {}".format( + str(tmp_table), str(qdata) + ) + verbose_print( + msg, + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + raise ValueError(msg) + + I += x[0] * dq + return I + + def fill_data(self, sample_values, data_dict): + """ + Function that returns the normalised array of values for given logmass and logperiod + used for the e and q values + + TODO: make sure we do the correct thing with the dstep + """ + + data = {} + I = 0 + + dstep = float(sample_values[1]) - float(sample_values[0]) + + # Read out the data + for sample_value in sample_values: + val = data_dict[sample_value] + data[sample_value] = val + I += val + + # Normalise the data + for sample_value in sample_values: + data[sample_value] = data[sample_value] / I + + return data + + def calc_e_integral( + self, + options, + integrals_string, + interpolator_name, + mass_string, + period_string, + verbosity=0, + ): + """ + Function to calculate the e integral + + We need to renormalise this because min_per > 0, and not all periods should be included + """ + + global Moecache + min_ecc = 0 + max_ecc = 0.9999 + + mass_period_string = "{}_{}".format( + options[mass_string], options[period_string] + ) + + # Check if the dict exists + if not Moecache.get(integrals_string, None): + Moecache[integrals_string] = {} + + # Check for cached value. If it doesn't exist: calculate + if not Moecache[integrals_string].get(mass_period_string, None): + I = 0 + decc = 1e-3 + + for ecc in np.arange(min_ecc, max_ecc, decc): + # Loop over all the values in the table, between the min and max P + dp_decc = Moecache[interpolator_name].interpolate( + [ + np.log10(options[mass_string]), + np.log10(options[period_string]), + ecc, + ] + )[0] + + I += dp_decc * decc + + # Set the integral value in the dict + Moecache[integrals_string][mass_period_string] = I + verbose_print( + "\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, + interpolator_name, + mass_string, + period_string, + options[mass_string], + options[period_string], + I, + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + else: + verbose_print( + "\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, + interpolator_name, + mass_string, + period_string, + options[mass_string], + options[period_string], + Moecache[integrals_string][mass_period_string], + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + def calc_P_integral( + self, + options, + min_logP, + max_logP, + integrals_string, + interpolator_name, + mass_string, + verbosity=0, + ): + """ + Function to calculate the P integral + + We need to renormalise this because min_per > 0, and not all periods should be included + """ + + global Moecache + + # Check if the dict exists + if not Moecache.get(integrals_string, None): + Moecache[integrals_string] = {} + + # Check for cached value. If it doesn't exist: calculate + if not Moecache[integrals_string].get(options[mass_string], None): + I = 0 + dlogP = 1e-3 + + for logP in np.arange(min_logP, max_logP, dlogP): + # Loop over all the values in the table, between the min and max P + dp_dlogP = Moecache[interpolator_name].interpolate( + [np.log10(options[mass_string]), logP] + )[0] + + I += dp_dlogP * dlogP + + # Set the integral value in the dict + Moecache[integrals_string][options[mass_string]] = I + verbose_print( + "\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, + mass_string, + options[mass_string], + I, + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + else: + verbose_print( + "\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, + mass_string, + options[mass_string], + Moecache[integrals_string][options[mass_string]], + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + def calc_total_probdens(self, prob_dict): + """ + Function to calculate the total probability density + """ + + total_probdens = 1 + for key in prob_dict: + total_probdens *= prob_dict[key] + prob_dict["total_probdens"] = total_probdens + + return prob_dict + + def Moe_di_Stefano_2017_pdf(self, options, verbosity=0): + """ + Moe & diStefano function to calculate the probability density. + + takes a dictionary as input (in options) with options: + + M1, M2, M3, M4 => masses (Msun) [M1 required, rest optional] + P, P2, P3 => periods (days) [number: none=binary, 2=triple, 3=quadruple] + ecc, ecc2, ecc3 => eccentricities [numbering as for P above] + + mmin => minimum allowed stellar mass (default 0.07) + mmax => maximum allowed stellar mass (default 80.0) + """ + + verbose_print( + "\tMoe_di_Stefano_2017_pdf with options:\n\t\t{}".format( + json.dumps(options, ensure_ascii=False) + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + prob_dict = ( + {} + ) # Dictionary containing all the pdf values for the different parameters + + # 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 = "\tMoe_di_Stefano_2017_pdf: Did not find a multiplicity value in the options dictionary" + verbose_print( + msg, + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + raise ValueError(msg) + + multiplicity = options["multiplicity"] + + # Immediately return 0 if the multiplicity modulator is 0 + if options["multiplicity_modulator"][int(multiplicity) - 1] == 0: + verbose_print( + "\tMoe_di_Stefano_2017_pdf: returning 0 because of the multiplicity modulator being 0", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + return 0 + + ############################################################ + # multiplicity fraction + # Calculate the probability, or rather, fraction, of stars that belong to this mass + + multiplicity_probability = self.Moe_di_Stefano_2017_multiplicity_fractions( + options, verbosity + )[int(multiplicity) - 1] + prob_dict["multiplicity"] = multiplicity_probability + verbose_print( + "\tMoe_di_Stefano_2017_pdf: Appended multiplicity (mass1 = {}) probability ({}) to the prob dict ({})".format( + options["M_1"], prob_dict["multiplicity"], prob_dict + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + ############################################################ + # always require an IMF for the primary star + # + # NB multiply by M1 to convert dN/dM to dN/dlnM + # (dlnM = dM/M, so 1/dlnM = M/dM) + + # TODO: Create an n-part-powerlaw method that can have breakpoints and slopes. I'm using a three-part power law now. + # TODO: is this actually the correct way? putting the M1 in there? Do we sample in log space? + M1_probability = self.Kroupa2001(options["M_1"]) * options["M_1"] + prob_dict["M_1"] = M1_probability + verbose_print( + "\tMoe_di_Stefano_2017_pdf: Appended Mass (m={}) probability ({}) to the prob dict ({})".format( + options["M_1"], prob_dict["M_1"], prob_dict + ), + verbosity, + _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) + # return prob_dict + + """ + From here we go through the multiplicities. + """ + if multiplicity >= 2: + # If the multiplicity is higher than 1, we will need to construct the following tables: + # - period distribution table + # - q distribution table + # - eccentricity distribution table + + # Set up the interpolator for the periods + if not Moecache.get("rinterpolator_log10P", None): + Moecache["rinterpolator_log10P"] = py_rinterpolate.Rinterpolate( + table=Moecache[ + "period_distributions" + ], # Contains the table of data + nparams=2, # log10M, log10P + ndata=2, # binary, triple + verbosity=verbosity - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), + ) + verbose_print( + "\tMoe_di_Stefano_2017_pdf: Created new period interpolator: {}".format( + Moecache["rinterpolator_log10P"] + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # Make a table storing Moe's data for q distributions + if ( + options.get("M_2", None) + or options.get("M_3", None) + or options.get("M_4", None) + ): + if not Moecache.get("rinterpolator_q", None): + Moecache["rinterpolator_q"] = py_rinterpolate.Rinterpolate( + table=Moecache["q_distributions"], # Contains the table of data + nparams=3, # log10M, log10P, q + ndata=1, # + verbosity=verbosity + - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), + ) + verbose_print( + "\tMoe_di_Stefano_2017_pdf: Created new q interpolator: {}".format( + Moecache["rinterpolator_q"] + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # Make a table storing Moe's data for q distributions, but only if the ecc is actually sampled + if "ecc" in options: + if not options["ecc"] is None: + if not Moecache.get("rinterpolator_e", None): + Moecache["rinterpolator_e"] = py_rinterpolate.Rinterpolate( + table=Moecache[ + "ecc_distributions" + ], # Contains the table of data + nparams=3, # log10M, log10P, e + ndata=1, # + verbosity=verbosity + - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), + ) + verbose_print( + "\tMoe_di_Stefano_2017_pdf: Created new e interpolator: {}".format( + Moecache["rinterpolator_e"] + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + ############### + # Calculation for period of the binary + + if options.get("M_2", None): + # Separation of the inner binary + options["sep"] = calc_sep_from_period( + options["M_1"], options["M_2"], options["P"] + ) + # TODO: add check for min_logP with instant RLOF? + # TODO: Actually use the value above. + # Total mass inner binary: + options["M_1+M_2"] = options["M_1"] + options["M_2"] + + # Calculate P integral or use cached value + + # get the periods from the Moecahe + min_logP = float(Moecache["logperiods"][0]) + max_logP = float(Moecache["logperiods"][-1]) + + self.calc_P_integral( + options, + min_logP, + max_logP, + "P_integrals", + "rinterpolator_log10P", + "M_1", + verbosity, + ) + + # Set probabilty for P1 + p_val = Moecache["rinterpolator_log10P"].interpolate( + [np.log10(options["M_1"]), np.log10(options["P"])] + )[0] + p_val = p_val / Moecache["P_integrals"][options["M_1"]] + prob_dict["P"] = p_val + verbose_print( + "\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, + _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) + # return prob_dict + + ############################################################ + # mass ratio (0 < q = M2/M1 < qmax) + # + # we need to construct the q table for the given M1 + # subject to qmin = Mmin/M1 + + if options.get("M_2", None): + # Build the table for q + primary_mass = options["M_1"] + secondary_mass = options["M_2"] + m_label = "M_1" + p_label = "P" + + # Construct the q table + self.build_q_table(options, m_label, p_label, verbosity=verbosity) + verbose_print( + "\tMoe_di_Stefano_2017_pdf: Created q_table ({}) for m={} p={}".format( + Moecache[ + "rinterpolator_q_given_{}_log10{}".format(m_label, p_label) + ], + options[m_label], + options[p_label], + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # Add probability for the mass ratio + q_prob = Moecache[ + "rinterpolator_q_given_{}_log10{}".format(m_label, p_label) + ].interpolate([secondary_mass / primary_mass])[0] + prob_dict["q"] = q_prob + verbose_print( + "\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"], + prob_dict["q"], + prob_dict, + ), + verbosity, + _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) + # return prob_dict + + ############################################################ + # Eccentricity + # TODO: ask rob if the eccentricity requires an extrapolation as well. + + # Only do this if the eccentricity is sampled + if "ecc" in options: + if not options["ecc"] is None: + # Calculate ecc integral or use cached value + self.calc_e_integral( + options, + "ecc_integrals", + "rinterpolator_e", + "M_1", + "P", + verbosity, + ) + mass_period_string = "{}_{}".format(options["M_1"], options["P"]) + + # Set probability for ecc + ecc_val = Moecache["rinterpolator_e"].interpolate( + [ + np.log10(options["M_1"]), + np.log10(options["P"]), + options["ecc"], + ] + )[0] + ecc_val = ecc_val / Moecache["ecc_integrals"][mass_period_string] + prob_dict["ecc"] = ecc_val + verbose_print( + "\tMoe_di_Stefano_2017_pdf: Appended eccentricity (m={}, P={}, ecc={}) probability ({}) to the prob list ({})".format( + options["M_1"], + options["P"], + options["ecc"], + prob_dict["ecc"], + prob_dict, + ), + verbosity, + _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) + # return prob_dict + + # Calculations for when multiplicity is bigger than 3 + # BEWARE: binary_c does not evolve these systems actually and the code below should be revised for when binary_c actually evolves triples. + # For that reason, I would not advise to use things with multiplicity > 3 + if multiplicity >= 3: + + ############################################################ + # orbital period 2 = + # orbital period of star 3 (multiplicity==3) or + # the star3+star4 binary (multiplicity==4) + # + # we assume the same period distribution for star 3 + # (or stars 3 and 4) but with a separation that is >10*a*(1+e) + # where 10*a*(1+e) is the maximum apastron separation of + # stars 1 and 2 + + # TODO: Is this a correct assumption? + max_sep = 10.0 * options["sep"] * (1.0 + options["ecc"]) + min_P2 = calc_period_from_sep( + options["M_1+M_2"], options["mmin"], max_sep + ) + min_logP2 = math.log10(min_P2) + # max_logP2 = 10.0 + # min_logP = Moecache['logperiods'][0] + max_logP2 = float(Moecache["logperiods"][-1]) + + if options["P2"] < min_P2: + # period is too short : system is not hierarchical + prob_dict["P2"] = 0 + verbose_print( + "\tMoe_di_Stefano_2017_pdf: period2 is too short: {} < {}, system is not hierarchical. Added 0 to probability list".format( + options["P1"], min_P2 + ), + verbosity, + _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) + # return prob_dict + + else: + # period is long enough that the system is hierarchical + # hence the separation between the outer star + # and inner binary + options["sep2"] = calc_sep_from_period( + options["M_3"], options["M_1+M_2"], options["P2"] + ) + + # Check for cached value of P integral or calculate + self.calc_P_integral( + options, + min_logP2, + max_logP2, + "P2_integrals", + "rinterpolator_log10P", + "M_1+M_2", + verbosity, + ) + + # Add the probability + p_val = Moecache["rinterpolator_log10P"].interpolate( + [np.log10(options["M_1+M_2"]), np.log10(options["P2"])] + )[0] + p_val = p_val / Moecache["P2_integrals"][options["M_1+M_2"]] + prob_dict["P2"] = p_val + verbose_print( + "\tMoe_di_Stefano_2017_pdf: Appended period2 (m1={} m2={}, P2={}) probability ({}) to the prob list ({})".format( + options["M_1"], + options["M_2"], + options["P2"], + prob_dict["P2"], + prob_dict, + ), + verbosity, + _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) + # return prob_dict + + ############################################################ + # mass ratio 2 = q2 = M3 / (M1+M2) + # + # we need to construct the q table for the given M1 + # subject to qmin = Mmin/(M1+M2) + + # Set the variables for the masses and their names + primary_mass = options["M_1+M_2"] + secondary_mass = options["M_3"] + m_label = "M_1+M_2" + p_label = "P2" + + # Build q table + self.build_q_table(options, m_label, p_label, verbosity=verbosity) + verbose_print( + "\tMoe_di_Stefano_2017_pdf: Called build_q_table", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # Add the probability + q2_val = Moecache[ + "rinterpolator_q_given_{}_log10{}".format(m_label, p_label) + ].interpolate([secondary_mass / primary_mass])[0] + prob_dict["q2"] = q2_val + verbose_print( + "\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"], + secondary_mass / primary_mass, + prob_dict["q2"], + prob_dict, + ), + verbosity, + _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) + # return prob_dict + + # TODO: Implement ecc2 calculation + if multiplicity == 4: + # quadruple system. + # TODO: Ask Rob about the structure of the quadruple. Is this only double binary quadruples? + + ############################################################ + # orbital period 3 + # + # we assume the same period distribution for star 4 + # as for any other stars but Pmax must be such that + # sep3 < sep2 * 0.2 + + # TODO: fix this here + max_sep3 = 0.2 * options["sep2"] * (1.0 + options["ecc2"]) + max_per3 = calc_period_from_sep( + options["M_1+M_2"], options["mmin"], max_sep3 + ) + + # Calculate P integral or use the cached value + # TODO: Make sure we use the correct period idea here. + self.calc_P_integral( + options, + min_logP2, + max_logP2, + "P2_integrals", + "rinterpolator_log10P", + "M_1+M_2", + verbosity, + ) + + # Set probability + p_val = Moecache["rinterpolator_log10P"].interpolate( + [np.log10(options["M_1+M_2"]), np.log10(options["P2"])] + )[0] + p_val = p_val / Moecache["P2_integrals"][options["M_1+M_2"]] + prob_dict["P3"] = p_val + verbose_print( + "\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"], + prob_dict["P3"], + prob_dict, + ), + verbosity, + _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) + # return prob_dict + + ############################################################ + # mass ratio 2 + # + # we need to construct the q table for the given M1 + # subject to qmin = Mmin/(M1+M2) + # Make a table storing Moe's data for q distributions + + # Build the table for q2 + primary_mass = options["M_1+M_2"] + secondary_mass = options["M_3"] + m_label = "M_1+M_2" + p_label = "P2" + + # Calculate new q table + self.build_q_table( + options, m_label, p_label, verbosity=verbosity + ) + verbose_print( + "\tMoe_di_Stefano_2017_pdf: Created q_table ", + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + + # Add the probability + q3_prob = Moecache[ + "rinterpolator_q_given_{}_log10{}".format(m_label, p_label) + ].interpolate([secondary_mass / primary_mass])[0] + prob_dict["q3"] = q3_prob + verbose_print( + "\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"], + secondary_mass / primary_mass, + prob_dict["q3"], + prob_dict, + ), + verbosity, + _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) + # return prob_dict + + # TODO: ecc 3 + + # check for input of multiplicity + elif multiplicity not in range(1, 5): + msg = "\tMoe_di_Stefano_2017_pdf: Unknown multiplicity {}".format( + multiplicity + ) + verbose_print( + msg, + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + raise ValueError(msg) + + # Calculate total probdens: + prob_dict = self.calc_total_probdens(prob_dict) + + # Some info + if multiplicity == 1: + verbose_print( + "\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, + _MOE2017_VERBOSITY_LEVEL, + ) + elif multiplicity == 2: + verbose_print( + "\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"]), + options["ecc"] if options.get("ecc", None) else "N/A", + len(prob_dict), + str(prob_dict), + prob_dict["total_probdens"], + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + elif multiplicity == 3: + verbose_print( + "\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"]), + options["ecc"] if options.get("ecc", None) else "N/A", + options["M_3"], + np.log10(options["P2"]), + options["ecc2"] if options.get("ecc2", None) else "N/A", + len(prob_dict), + str(prob_dict), + prob_dict["total_probdens"], + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + elif multiplicity == 4: + verbose_print( + "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"]), + options["ecc"] if options.get("ecc", None) else "N/A", + options["M_3"], + np.log10(options["P2"]), + options["ecc2"] if options.get("ecc2", None) else "N/A", + options["M_4"], + np.log10(options["P3"]), + options["ecc3"] if options.get("ecc3", None) else "N/A", + len(prob_dict), + str(prob_dict), + prob_dict["total_probdens"], + ), + verbosity, + _MOE2017_VERBOSITY_LEVEL, + ) + return prob_dict diff --git a/binarycpython/utils/population_extensions/grid_logging.py b/binarycpython/utils/population_extensions/grid_logging.py new file mode 100644 index 0000000000000000000000000000000000000000..19bf96cd13d15b8368efc1f3b9bf4d8da2de7f32 --- /dev/null +++ b/binarycpython/utils/population_extensions/grid_logging.py @@ -0,0 +1,466 @@ +""" +The class extension for the population object that contains logging functionality +""" + +# pylint: disable=E1101 + +import os +import sys +import time +import logging +import strip_ansi + +import binarycpython.utils.functions + +from binarycpython.utils.functions import ( + format_number, + trem, + remove_file, + verbose_print, +) +from binarycpython.utils.population_extensions.grid_options_defaults import secs_per_day + +from binarycpython.utils.custom_logging_functions import ( + binary_c_log_code, + create_and_load_logging_function, + autogen_C_logging_code, +) + + +class grid_logging: + """ + The class extension for the population object that contains logging functionality + """ + + def __init__(self, **kwargs): + """ + Init function for the grid_logging class + """ + + return + + def _set_custom_logging(self): + """ + Function/routine to set all the custom logging so that the function memory pointer + is known to the grid. + + When the memory adress is loaded and the library file is set we'll skip rebuilding the library + """ + + # Only if the values are the 'default' unset values + if ( + self.grid_options["custom_logging_func_memaddr"] == -1 + and self.grid_options["_custom_logging_shared_library_file"] is None + ): + self.verbose_print( + "Creating and loading custom logging functionality", + self.grid_options["verbosity"], + 1, + ) + # C_logging_code gets priority of C_autogen_code + if self.grid_options["C_logging_code"]: + # Generate entire shared lib code around logging lines + custom_logging_code = binary_c_log_code( + self.grid_options["C_logging_code"], + verbosity=self.grid_options["verbosity"] + - (self._CUSTOM_LOGGING_VERBOSITY_LEVEL - 1), + ) + + # Load memory address + ( + self.grid_options["custom_logging_func_memaddr"], + self.grid_options["_custom_logging_shared_library_file"], + ) = create_and_load_logging_function( + custom_logging_code, + verbosity=self.grid_options["verbosity"] + - (self._CUSTOM_LOGGING_VERBOSITY_LEVEL - 1), + custom_tmp_dir=self.grid_options["tmp_dir"], + ) + + elif self.grid_options["C_auto_logging"]: + # Generate real logging code + logging_line = autogen_C_logging_code( + self.grid_options["C_auto_logging"], + verbosity=self.grid_options["verbosity"] + - (self._CUSTOM_LOGGING_VERBOSITY_LEVEL - 1), + ) + + # Generate entire shared lib code around logging lines + custom_logging_code = binary_c_log_code( + logging_line, + verbosity=self.grid_options["verbosity"] + - (self._CUSTOM_LOGGING_VERBOSITY_LEVEL - 1), + ) + + # Load memory address + ( + self.grid_options["custom_logging_func_memaddr"], + self.grid_options["_custom_logging_shared_library_file"], + ) = create_and_load_logging_function( + custom_logging_code, + verbosity=self.grid_options["verbosity"] + - (self._CUSTOM_LOGGING_VERBOSITY_LEVEL - 1), + custom_tmp_dir=self.grid_options["tmp_dir"], + ) + else: + self.verbose_print( + "Custom logging library already loaded. Not setting them again.", + self.grid_options["verbosity"], + 1, + ) + + def _print_info(self, run_number, total_systems, full_system_dict): + """ + Function to print info about the current system and the progress of the grid. + + # color info tricks from https://ozzmaker.com/add-colour-to-text-in-python/ + https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python + """ + + # Define frequency + if self.grid_options["verbosity"] == 1: + print_freq = 1 + else: + print_freq = 10 + + if run_number % print_freq == 0: + binary_cmdline_string = self._return_argline(full_system_dict) + info_string = "{color_part_1} \ + {text_part_1}{end_part_1}{color_part_2} \ + {text_part_2}{end_part_2}".format( + color_part_1="\033[1;32;41m", + text_part_1="{}/{}".format(run_number, total_systems), + end_part_1="\033[0m", + color_part_2="\033[1;32;42m", + text_part_2="{}".format(binary_cmdline_string), + end_part_2="\033[0m", + ) + print(info_string) + + def _set_loggers(self): + """ + Function to set the loggers for the execution of the grid + """ + + # Set log file + binary_c_logfile = self.grid_options["log_file"] + + # Create directory + os.makedirs(os.path.dirname(binary_c_logfile), exist_ok=True) + + # Set up logger + self.logger = logging.getLogger("binary_c_python_logger") + self.logger.setLevel(self.grid_options["verbosity"]) + + # Reset handlers + self.logger.handlers = [] + + # Set formatting of output + log_formatter = logging.Formatter( + "%(asctime)s - %(name)s - %(levelname)s - %(message)s" + ) + + # Make and add file handlers + # make handler for output to file + handler_file = logging.FileHandler(filename=os.path.join(binary_c_logfile)) + handler_file.setFormatter(log_formatter) + handler_file.setLevel(logging.INFO) + + # Make handler for output to stdout + handler_stdout = logging.StreamHandler(sys.stdout) + handler_stdout.setFormatter(log_formatter) + handler_stdout.setLevel(logging.INFO) + + # Add the loggers + self.logger.addHandler(handler_file) + self.logger.addHandler(handler_stdout) + + ###################### + # Status logging + + def vb1print(self, ID, now, system_number, system_dict): + """ + Verbosity-level 1 printing, to keep an eye on a grid. + + Input: + ID: thread ID for debugging (int): TODO fix this + now: the time now as a UNIX-style epoch in seconds (float) + system_number: the system number + """ + + # calculate estimated time of arrive (eta and eta_secs), time per run (tpr) + localtime = time.localtime(now) + + # calculate stats + n = self.shared_memory["n_saved_log_stats"].value + if n < 2: + # simple 1-system calculation: inaccurate + # but best for small n + dt = now - self.shared_memory["prev_log_time"][0] + dn = system_number - self.shared_memory["prev_log_system_number"][0] + else: + # average over n_saved_log_stats + dt = ( + self.shared_memory["prev_log_time"][0] + - self.shared_memory["prev_log_time"][n - 1] + ) + dn = ( + self.shared_memory["prev_log_system_number"][0] + - self.shared_memory["prev_log_system_number"][n - 1] + ) + + eta, units, tpr, eta_secs = trem( + dt, system_number, dn, self.grid_options["_total_starcount"] + ) + + # compensate for multithreading and modulo + tpr *= self.grid_options["num_processes"] * self.grid_options["modulo"] + + if eta_secs < secs_per_day: + fintime = time.localtime(now + eta_secs) + etf = "{hours:02d}:{minutes:02d}:{seconds:02d}".format( + hours=fintime.tm_hour, minutes=fintime.tm_min, seconds=fintime.tm_sec + ) + else: + d = int(eta_secs / secs_per_day) + if d == 1: + etf = "Tomorrow" + else: + etf = "In {} days".format(d) + + # modulo information + if self.grid_options["modulo"] == 1: + modulo = "" # usual case + else: + modulo = "%" + str(self.grid_options["modulo"]) + + # add up memory use from each thread + total_mem_use = sum(self.shared_memory["memory_use_per_thread"]) + + # make a string to describe the system e.g. M1, M2, etc. + system_string = "" + + # use the multiplicity if given + if "multiplicity" in system_dict: + nmult = int(system_dict["multiplicity"]) + else: + nmult = 4 + + # masses + for i in range(nmult): + i1 = str(i + 1) + if "M_" + i1 in system_dict: + system_string += ( + "M{}=".format(i1) + format_number(system_dict["M_" + i1]) + " " + ) + + # separation and orbital period + if "separation" in system_dict: + system_string += "a=" + format_number(system_dict["separation"]) + if "orbital_period" in system_dict: + system_string += "P=" + format_number(system_dict["orbital_period"]) + + # do the print + if self.grid_options["_total_starcount"] > 0: + self.verbose_print( + "{opening_colour}{system_number}/{total_starcount}{modulo} {pc_colour}{pc_complete:5.1f}% complete {time_colour}{hours:02d}:{minutes:02d}:{seconds:02d} {ETA_colour}ETA={ETA:7.1f}{units} tpr={tpr:2.2e} {ETF_colour}ETF={ETF} {mem_use_colour}mem:{mem_use:.1f}MB {system_string_colour}{system_string}{closing_colour}".format( + opening_colour=self.ANSI_colours["reset"] + + self.ANSI_colours["yellow on black"], + system_number=system_number, + total_starcount=self.grid_options["_total_starcount"], + modulo=modulo, + pc_colour=self.ANSI_colours["blue on black"], + pc_complete=(100.0 * system_number) + / (1.0 * self.grid_options["_total_starcount"]) + if self.grid_options["_total_starcount"] + else -1, + time_colour=self.ANSI_colours["green on black"], + hours=localtime.tm_hour, + minutes=localtime.tm_min, + seconds=localtime.tm_sec, + ETA_colour=self.ANSI_colours["red on black"], + ETA=eta, + units=units, + tpr=tpr, + ETF_colour=self.ANSI_colours["blue"], + ETF=etf, + mem_use_colour=self.ANSI_colours["magenta"], + mem_use=total_mem_use, + system_string_colour=self.ANSI_colours["yellow"], + system_string=system_string, + closing_colour=self.ANSI_colours["reset"], + ), + self.grid_options["verbosity"], + 1, + ) + else: + self.verbose_print( + "{opening_colour}{system_number}{modulo} {time_colour}{hours:02d}:{minutes:02d}:{seconds:02d} tpr={tpr:2.2e} {mem_use_colour}mem:{mem_use:.1f}MB {system_string_colour}{system_string}{closing_colour}".format( + opening_colour=self.ANSI_colours["reset"] + + self.ANSI_colours["yellow on black"], + system_number=system_number, + modulo=modulo, + time_colour=self.ANSI_colours["green on black"], + hours=localtime.tm_hour, + minutes=localtime.tm_min, + seconds=localtime.tm_sec, + tpr=tpr, + mem_use_colour=self.ANSI_colours["magenta"], + mem_use=total_mem_use, + system_string_colour=self.ANSI_colours["yellow"], + system_string=system_string, + closing_colour=self.ANSI_colours["reset"], + ), + self.grid_options["verbosity"], + 1, + ) + + def vb2print(self, system_dict, cmdline_string): + """ + Extra function for verbose printing + """ + + print( + "Running this system now on thread {ID}\n{blue}{cmdline}{reset}:\n\t{system_dict}\n".format( + ID=self.process_ID, + blue=self.ANSI_colours["blue"], + cmdline=cmdline_string, + reset=self.ANSI_colours["reset"], + system_dict=system_dict, + ) + ) + + def verbose_print(self, *args, **kwargs): + """ + Wrapper method for the verbose print that calls the verbose print with the correct newline + + TODO: consider merging the two + """ + + # wrapper for functions.verbose_print to use the correct newline + newline = kwargs.get("newline", self.grid_options["log_newline"]) + if newline is None: + newline = "\n" + kwargs["newline"] = newline + + # Pass the rest to the original verbose print + verbose_print(*args, **kwargs) + + def _boxed( + self, *stringlist, colour="yellow on black", boxchar="*", separator="\n" + ): + """ + Function to output a list of strings in a single box. + + Args: + list = a list of strings to be output. If these contain the separator + (see below) these strings are split by it. + separator = strings are split on this, default "\n" + colour = the colour to be used, usually this is 'yellow on black' + as set in the ANSI_colours dict + boxchar = the character used to make the box, '*' by default + + Note: handles tabs (\t) badly, do not use them! + """ + strlen = 0 + strings = [] + lengths = [] + + # make a list of strings + if separator: + for l in stringlist: + strings += l.split(sep=separator) + else: + strings = stringlist + + # get lengths without ANSI codes + for string in strings: + lengths.append(len(strip_ansi.strip_ansi(string))) + + # hence the max length + strlen = max(lengths) + strlen += strlen % 2 + header = boxchar * (4 + strlen) + + # start output + out = self.ANSI_colours[colour] + header + "\n" + + # loop over strings to output, padding as required + for n, string in enumerate(strings): + if lengths[n] % 2 == 1: + string = " " + string + pad = " " * int((strlen - lengths[n]) / 2) + out = out + boxchar + " " + pad + string + pad + " " + boxchar + "\n" + + # close output and return + out = out + header + "\n" + self.ANSI_colours["reset"] + return out + + def _get_stream_logger(self, level=logging.DEBUG): + """ + Function to set up the streamlogger + """ + + # Format + fmt = "[%(asctime)s %(levelname)-8s %(processName)s] --- %(message)s" + formatter = logging.Formatter(fmt) + + # Streamhandle + sh = logging.StreamHandler(stream=sys.stdout) + sh.setLevel(level) + sh.setFormatter(formatter) + + # Logger itself + stream_logger = logging.getLogger("stream_logger") + stream_logger.handlers = [] + stream_logger.setLevel(level) + stream_logger.addHandler(sh) + + return stream_logger + + def _clean_up_custom_logging(self, evol_type): + """ + Function to clean up the custom logging. + Has two types: + 'single': + - removes the compiled shared library + (which name is stored in grid_options['_custom_logging_shared_library_file']) + - TODO: unloads/frees the memory allocated to that shared library + (which is stored in grid_options['custom_logging_func_memaddr']) + - sets both to None + 'multiple': + - TODO: make this and design this + """ + + if evol_type == "single": + self.verbose_print( + "Cleaning up the custom logging stuff. type: single", + self.grid_options["verbosity"], + 1, + ) + + # TODO: Explicitly unload the library + + # Reset the memory adress location + self.grid_options["custom_logging_func_memaddr"] = -1 + + # remove shared library files + if self.grid_options["_custom_logging_shared_library_file"]: + remove_file( + self.grid_options["_custom_logging_shared_library_file"], + self.grid_options["verbosity"], + ) + self.grid_options["_custom_logging_shared_library_file"] = None + + if evol_type == "population": + self.verbose_print( + "Cleaning up the custom logging stuffs. type: population", + self.grid_options["verbosity"], + 1, + ) + + # TODO: make sure that these also work. not fully sure if necessary tho. + # whether its a single file, or a dict of files/mem addresses + + if evol_type == "MC": + pass diff --git a/binarycpython/utils/population_extensions/grid_options_defaults.py b/binarycpython/utils/population_extensions/grid_options_defaults.py new file mode 100644 index 0000000000000000000000000000000000000000..776a4a868aa30a5e19bb9cdb12d9d5430846d61c --- /dev/null +++ b/binarycpython/utils/population_extensions/grid_options_defaults.py @@ -0,0 +1,628 @@ +""" +Module that contains the default options for the population grid code along with the description for these options, in the form of dictionaries: + - grid_options_defaults_dict: dictionary containing the default values for all the options + - grid_options_descriptions: dictionary containing the description for these options. + +There are several other functions in this module, mostly to generate help texts or documents: + - grid_options_help: interactive function for the user to get descriptions for options + - grid_options_description_checker: function that checks that checks which options have a description. + - write_grid_options_to_rst_file: function to generate the .rst document for the docs + +With this its also possible to automatically generate a document containing all the setting names + descriptions. + +All the options starting with _ should not be changed by the user except when you really know what you're doing (which is probably hacking the code :P) + +TODO: reconsider having this all as class methods. It seems unnecessary to have all these functions as class methods. +""" + +# pylint: disable=E1101 + +import os +import shutil +import sys + +from binarycpython.utils.custom_logging_functions import temp_dir +from binarycpython.utils.functions import ( + command_string_from_list, + now, +) + +_MOE2017_VERBOSITY_LEVEL = 5 +_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL = 6 +_MOE2017_VERBOSITY_INTERPOLATOR_EXTRA_LEVEL = 7 + +secs_per_day = 86400 # probably needs to go somewhere more sensible + + +class grid_options_defaults: + """ + Class extension to Population grid containing all the functionality for the options and defaults + """ + + def __init__(self, **kwargs): + """ + Init function for the grid_options_defaults class + """ + + return + + def get_grid_options_defaults_dict(self): + """ + Function to return the default values for the grid options + """ + + # Options dict + return { + ########################## + # general (or unordered..) + ########################## + "num_cores": 1, # total number of cores used to evolve the population + "num_cores_available": None, # set automatically, not by the user + "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: Moe and di Stefano 2017 + "tmp_dir": temp_dir(), # Setting the temp dir of the program + "cache_dir": self.default_cache_dir(), # Cache location, usually $HOME/.cache + "status_dir": None, # + "_main_pid": -1, # Placeholder for the main process id of the run. + "save_ensemble_chunks": True, # Force the ensemble chunk to be saved even if we are joining a thread (just in case the joining fails) + "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 + "_commandline_input": "", + "log_runtime_systems": 0, # whether to log the runtime of the systems (1 file per thread. stored in the tmp_dir) + "_actually_evolve_system": True, # Whether to actually evolve the systems of just act as if. for testing. used in _process_run_population_grid + "max_queue_size": 0, # Maximum size of the system call queue. Set to 0 for this to be calculated automatically + "run_zero_probability_system": True, # Whether to run the zero probability systems + "_zero_prob_stars_skipped": 0, + "ensemble_factor_in_probability_weighted_mass": False, # Whether to multiply the ensemble results by 1/probability_weighted_mass + "do_dry_run": True, # Whether to do a dry run to calculate the total probability for this run + "dry_run_num_cores": 1, # number of parallel processes for the dry run (outer loop) + "dry_run_hook": None, # Function hook for the dry run: this function is called, if not None, for every star in the dry run. Useful for checking initial distributions. + "custom_generator": None, # Place for the custom system generator + "return_after_dry_run": False, # Return immediately after a dry run? + "exit_after_dry_run": False, # Exit after dry run? + "print_stack_on_exit": False, # print the stack trace on exit calls? + ##################### + # System information + ##################### + "command_line": command_string_from_list(sys.argv), + "original_command_line": os.getenv("BINARY_C_PYTHON_ORIGINAL_CMD_LINE"), + "working_diretory": os.getcwd(), + "original_working_diretory": os.getenv("BINARY_C_PYTHON_ORIGINAL_WD"), + "start_time": now(), + "original_submission_time": os.getenv( + "BINARY_C_PYTHON_ORIGINAL_SUBMISSION_TIME" + ), + ########################## + # Execution log: + ########################## + "verbosity": 0, # Level of verbosity of the simulation + "log_file": os.path.join( # not used (yet?) + temp_dir(), "binary_c_python.log" + ), # Set to None to not log to file. The directory will be created + "log_dt": 5, # time between vb=1 logging outputs + "n_logging_stats": 50, # number of logging stats used to calculate time remaining (etc.) default = 50 + "log_newline": "\n", # newline character in logs ("\n" for newlines, "\x0d" for carriage return) + ########################## + # binary_c files + ########################## + "_binary_c_executable": os.path.join(os.environ["BINARY_C"], "binary_c"), + "_binary_c_shared_library": os.path.join( + os.environ["BINARY_C"], "src", "libbinary_c.so" + ), + "_binary_c_config_executable": os.path.join( + os.environ["BINARY_C"], "binary_c-config" + ), + "_binary_c_dir": os.environ["BINARY_C"], + ########################## + # Moe and di Stefano (2017) internal settings + ########################## + "_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. + "_Moe2017_JSON_data": None, # Stores the data + ########################## + # Custom logging + ########################## + "C_auto_logging": None, # Should contain a dictionary where the keys are they headers + # and the values are lists of parameters that should be logged. + # This will get parsed by autogen_C_logging_code in custom_logging_functions.py + "C_logging_code": None, # Should contain a string which holds the logging code. + "custom_logging_func_memaddr": -1, # Contains the custom_logging functions memory address + "_custom_logging_shared_library_file": None, # file containing the .so file + ########################## + # Store pre-loading: + ########################## + "_store_memaddr": -1, # Contains the store object memory address, useful for pre loading. + # defaults to -1 and isn't used if that's the default then. + ########################## + # Log args: logging of arguments + ########################## + "log_args": 0, # unused + "log_args_dir": "/tmp/", # unused + ########################## + # Population evolution + ########################## + ## General + "evolution_type": "grid", # Flag for type of population evolution + "_evolution_type_options": [ + "grid", + "custom_generator", + ], # available choices for type of population evolution. # TODO: fill later with Monte Carlo, source file + "_system_generator": None, # value that holds the function that generates the system + # (result of building the grid script) + "source_file_filename": None, # filename for the source + "_count": 0, # count of systems + "_total_starcount": 0, # Total count of systems in this generator + "_probtot": 0, # total probability + "weight": 1.0, # weighting for the probability + "repeat": 1, # number of times to repeat each system (probability is adjusted to be 1/repeat) + "_start_time_evolution": 0, # Start time of the grid + "_end_time_evolution": 0, # end time of the grid + "_errors_found": False, # Flag whether there are any errors from binary_c + "_errors_exceeded": False, # Flag whether the number of errors have exceeded the limit + "_failed_count": 0, # number of failed systems + "_failed_prob": 0, # Summed probability of failed systems + "failed_systems_threshold": 20, # Maximum failed systems per process allowed to fail before the process stops logging the failing systems. + "_failed_systems_error_codes": [], # List to store the unique error codes + "_population_id": 0, # Random id of this grid/population run, Unique code for the population. Should be set only once by the controller process. + "_total_mass_run": 0, # To count the total mass that thread/process has ran + "_total_probability_weighted_mass_run": 0, # To count the total mass * probability for each system that thread/process has ran + "modulo": 1, # run modulo n of the grid. + "start_at": 0, # start at the first model + "skip_before" : 0, # skip models before this + ## Grid type evolution + "_grid_variables": {}, # grid variables + "gridcode_filename": None, # filename of gridcode + "symlink_latest_gridcode": True, # symlink to latest gridcode + "save_population_object": None, # filename to which we should save a pickled grid object as the final thing we do + "joinlist": None, + "do_analytics": True, # if True, calculate analytics prior to return + "save_snapshots": True, # if True, save snapshots on SIGINT + "restore_from_snapshot_file": None, # file to restore from + "restore_from_snapshot_dir": None, # dir to restore from + "exit_code": 0, # return code + "stop_queue": False, + "_killed": False, + "_queue_done": False, + ## Monte carlo type evolution + # TODO: make MC options + ## Evolution from source file + # TODO: make run from sourcefile options. + ######################################## + # function caching options + ######################################## + "function_cache": True, + "function_cache_default_maxsize": 256, + "function_cache_default_type": "NullCache", # one of LRUCache, LFUCache, FIFOCache, MRUCache, RRCache, TTLCache, NullCache, NoCache + "function_cache_TTL": 30, + "function_cache_functions": { + # key=function_name : value=(cache_size, cache_type, test_args (string)) + # + # if cache_size is 0, use function_cache_default_maxsize + # set above + # + # if cache_type is None, use function_cache_default_type + # set above + # + # if n is None, no cache is set up + "distribution_functions.powerlaw_constant": (0, "NoCache", "1,100,-2"), + "distribution_functions.calculate_constants_three_part_powerlaw": ( + 16, + "FIFOCache", + "0.1,0.5,1,100,-1.3,-2.3,-2.3", + ), + "distribution_functions.gaussian_normalizing_const": ( + 16, + "FIFOCache", + "1.0,1.0,-10.0,+10.0", + ), + "spacing_functions.const_linear": (16, "FIFOCache", "1,10,9"), + "spacing_functions.const_int": (0, None, "1,10,9"), + "spacing_functions.const_ranges": ( + 16, + "FIFOCache", + "((0.1,0.65,10),(0.65,0.85,20),(0.85,10.0,10))", + ), + "spacing_functions.gaussian_zoom": ( + 16, + "FIFOCache", + "1.0,10.0,5.0,2.0,0.9,100", + ), + }, + ######################################## + # HPC variables + ######################################## + "HPC_force_join": 0, # if True, and the HPC variable ("slurm" or "condor") is 3, skip checking our own job and force the join + "HPC_rebuild_joinlist": 0, # if True, ignore the joinlist we would usually use and rebuild it automatically + ######################################## + # Slurm stuff + ######################################## + "slurm": 0, # dont use the slurm by default, 0 = no slurm, 1 = launch slurm jobs, 2 = run slurm jobs + "slurm_ntasks": 1, # CPUs required per array job: usually only need this to be 1 + "slurm_dir": "", # working directory containing scripts output logs etc. + "slurm_njobs": 0, # number of scripts; set to 0 as default + "slurm_jobid": "", # slurm job id (%A) + "slurm_memory": "512MB", # memory required for the job + "slurm_warn_max_memory": "1024MB", # warn if we set it to more than this (usually by accident) + "slurm_postpone_join": 0, # if 1 do not join on slurm, join elsewhere. want to do it off the slurm grid (e.g. with more RAM) + "slurm_jobarrayindex": None, # slurm job array index (%a) + "slurm_jobname": "binary_c-python", # default + "slurm_partition": None, + "slurm_time": '0', # total time. 0 = infinite time + "slurm_postpone_sbatch": 0, # if 1: don't submit, just make the script + "slurm_array": None, # override for --array, useful for rerunning jobs + "slurm_array_max_jobs": None, # override for the max number of concurrent array jobs + "slurm_extra_settings": {}, # Dictionary of extra settings for Slurm to put in its launch script. + "slurm_sbatch": shutil.which("sbatch"), # sbatch command + "slurm_env": shutil.which("env"), # env location for Slurm + "slurm_bash": shutil.which("bash"), # bash location for Slurm + "slurm_pwd": shutil.which("pwd"), # pwd command location for Slurm + "slurm_date": shutil.which("date"), # bash location for Slurm + ######################################## + # Condor stuff + ######################################## + "condor": 0, # 1 to use condor, 0 otherwise + "condor_dir": "", # working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all) + "condor_njobs": 0, # number of scripts/jobs that CONDOR will run in total + "condor_ClusterID": None, # condor cluster id, equivalent to Slurm's jobid + "condor_Process": None, # condor process, equivalent to Slurm's jobarrayindex + "condor_postpone_submit": 0, # if 1, the condor script is not submitted (useful for debugging). Default 0. + "condor_postpone_join": 0, # if 1, data is not joined, e.g. if you want to do it off the condor grid (e.g. with more RAM). Default 0. + "condor_memory": 512, # in MB, the memory use (ImageSize) of the job + "condor_warn_max_memory": 1024, # in MB, the memory use (ImageSize) of the job + "condor_universe": "vanilla", # usually vanilla universe + "condor_extra_settings": {}, # Place to put extra configuration for the CONDOR submit file. The key and value of the dict will become the key and value of the line in te slurm batch file. Will be put in after all the other settings (and before the command). Take care not to overwrite something without really meaning to do so. + # snapshots and checkpoints + "condor_snapshot_on_kill": 0, # if 1 snapshot on SIGKILL before exit + "condor_stream_output": True, # stream stdout + "condor_stream_error": True, # stream stderr + "condor_should_transfer_files": "YES", + "condor_when_to_transfer_output": "ON_EXIT_OR_EVICT", + # (useful for debugging, otherwise a lot of work) + "condor_requirements": "", # job requirements + "condor_env": shutil.which("env"), # /usr/bin/env location + "condor_bash": shutil.which("bash"), # bash executable location + "condor_pwd": shutil.which("pwd"), # pwd command location for Condor + "condor_date": shutil.which("date"), # bash location for Condor + "condor_initial_dir": None, # directory from which condor is run, if None is the directory in which your script is run + "condor_submit": shutil.which("condor_submit"), # the condor_submit command + "condor_q": shutil.which("condor_q"), # the condor_submit command + "condor_getenv": True, # if True condor takes the environment at submission and copies it to the jobs. You almost certainly want this. + "condor_batchname": "binary_c-condor", # Condor batchname option + "condor_kill_sig": "SIGINT", # signal Condor should use to stop a process : note that grid.py expects this to be "SIGINT" + # ######################################## + # # GRID + # ######################################## + # control flow + "rungrid": 1, # usually run the grid, but can be 0 to skip it (e.g. for condor/slurm admin) + } + + def get_grid_options_descriptions(self): + """ + Function that returns the descriptions for all the grid options + + TODO: consider putting input types for all of them + """ + + # Grid containing the descriptions of the options + return { + "tmp_dir": "Directory where certain types of output are stored. The grid code is stored in that directory, as well as the custom logging libraries. Log files and other diagnostics will usually be written to this location, unless specified otherwise", # TODO: improve this + "status_dir": "Directory where grid status is stored", + "_binary_c_dir": "Director where binary_c is stored. This options are not really used", + "_binary_c_config_executable": "Full path of the binary_c-config executable. This options is not used in the population object.", + "_binary_c_executable": "Full path to the binary_c executable. This options is not used in the population object.", + "_binary_c_shared_library": "Full path to the libbinary_c file. This options is not used in the population object", + "verbosity": "Verbosity of the population code. Default is 0, by which only errors will be printed. Higher values will show more output, which is good for debugging.", + "log_dt": "Time between verbose logging output.", + "log_newline": "Newline character used at the end of verbose logging statements. This is \\n (newline) by default, but \\x0d (carriage return) might also be what you want.", + "n_logging_stats": "Number of logging statistics used to calculate time remaining (etc.). E.g., if you set this to 10 the previous 10 calls to the verbose log will be used to construct an estimate of the time remaining.", + "num_cores": "The number of cores that the population grid will use. You can set this manually by entering an integer great than 0. When 0 uses all logical cores. When -1 uses all physical cores. Input: int", + "num_processes": "Number of processes launched by multiprocessing. This should be set automatically by binary_c-python, not by the user.", + "_start_time_evolution": "Variable storing the start timestamp of the population evolution. Set by the object itself.", + "_end_time_evolution": "Variable storing the end timestamp of the population evolution. Set by the object itself", + "_total_starcount": "Variable storing the total number of systems in the generator. Used and set by the population object.", + "_custom_logging_shared_library_file": "filename for the custom_logging shared library. Used and set by the population object", + "_errors_found": "Variable storing a Boolean flag whether errors by binary_c are encountered.", + "_errors_exceeded": "Variable storing a Boolean flag whether the number of errors was higher than the set threshold (failed_systems_threshold). If True, then the command line arguments of the failing systems will not be stored in the failed_system_log files.", + "source_file_filename": "Variable containing the source file containing lines of binary_c command line calls. These all have to start with binary_c.", # TODO: Expand + "C_auto_logging": "Dictionary containing parameters to be logged by binary_c. The structure of this dictionary is as follows: the key is used as the headline which the user can then catch. The value at that key is a list of binary_c system parameters (like star[0].mass)", + "C_logging_code": "Variable to store the exact code that is used for the custom_logging. In this way the user can do more complex logging, as well as putting these logging strings in files.", + "_failed_count": "Variable storing the number of failed systems.", + "_evolution_type_options": "List containing the evolution type options.", + "_failed_prob": "Variable storing the total probability of all the failed systems", + "_failed_systems_error_codes": "List storing the unique error codes raised by binary_c of the failed systems", + "_grid_variables": "Dictionary storing the grid_variables. These contain properties which are accessed by the _generate_grid_code function", + "_population_id": "Variable storing a unique 32-char hex string.", + "_commandline_input": "String containing the arguments passed to the population object via the command line. Set and used by the population object.", + "_system_generator": "Function object that contains the system generator function. This can be from a grid, or a source file, or a Monte Carlo grid.", + "gridcode_filename": "Filename for the grid code. Set and used by the population object. TODO: allow the user to provide their own function, rather than only a generated function.", + "log_args": "Boolean to log the arguments.", + "log_args_dir": "Directory to log the arguments to.", + "log_file": "Log file for the population object. Unused", + "custom_logging_func_memaddr": "Memory address where the custom_logging_function is stored. Input: int", + "_count": "Counter tracking which system the generator is on.", + "_probtot": "Total probability of the population.", + "_main_pid": "Main process ID of the master process. Used and set by the population object.", + "_store_memaddr": "Memory address of the store object for binary_c.", + "failed_systems_threshold": "Variable storing the maximum number of systems that are allowed to fail before logging their command line arguments to failed_systems log files", + "parse_function": "Function that the user can provide to handle the output the binary_c. This function has to take the arguments (self, output). Its best not to return anything in this function, and just store stuff in the self.grid_results dictionary, or just output results to a file", + ############################################################ + # Condor + "condor": "Integer flag used to control HTCondor (referred to as Condor here) jobs. Default is 0 which means no Condor. 1 means launch Condor jobs. Do not manually set this to 2 (run Condor jobs) or 3 (join Condor job data) unless you know what you are doing, this is usually done for you.", + "condor_dir": "String. Working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all jobs). This directory should not exist when you launch the Condor jobs.", + "condor_njobs": "Integer. Number of jobs that Condor will run", + "condor_ClusterID": "Integer. Condor ClusterID variable, equivalent to Slurm's jobid. Jobs are numbered <ClusterID>.<Process>", + "condor_Process": "Integer. Condor Process variable, equivalent to Slurm's jobarrayindex. Jobs are numbered <ClusterID>.<Process>", + "condor_postpone_submit": "Integer. Debugging tool. If 1, the condor script is not submitted (useful for debugging). Default 0.", + "condor_postpone_join": "Integer. Use to delay the joining of Condor grid data. If 1, data is not joined, e.g. if you want to do it off the condor grid (e.g. with more RAM). Default 0.", + "condor_memory": "Integer. In MB, the memory use (ImageSize) of the job.", + "condor_warn_max_memory": "Integer. In MB, the memory use (ImageSize) of the job.", + "condor_universe": 'String. The HTCondor "universe": this is "vanilla" by default.', + "condor_extra_settings": "Dictionary. Place to put extra configuration for the CONDOR submit file. The key and value of the dict will become the key and value of the line in te slurm batch file. Will be put in after all the other settings (and before the command). Take care not to overwrite something without really meaning to do so.", + "condor_snapshot_on_kill": "Integer. If 1 we save a snapshot on SIGKILL before exit.", + "condor_stream_output": "Boolean. If True, we activate Condor's stdout stream. If False, this data is copied at the end of the job.", + "condor_stream_error": "Boolean. If True, we activate Condor's stderr stream. If False, this data is copied at the end of the job.", + "condor_should_transfer_files": 'Integer. Condor\'s option to transfer files at the end of the job. You should set this to "YES"', + "condor_when_to_transfer_output": 'Integer. Condor\'s option to decide when output files are transferred. You should usually set this to "ON_EXIT_OR_EVICT"', + "condor_requirements": "String. Condor job requirements. These are passed to Condor directly, you should read the HTCondor manual to learn about this. If no requirements exist, leave as an string.", + "condor_env": 'String. Points the location of the "env" command, e.g. /usr/bin/env or /bin/env, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.', + "condor_bash": 'String. Points the location of the "bash" command, e.g. /bin/bash, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.', + "condor_pwd": 'String. Points the location of the "pwd" command, e.g. /bin/pwd, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.', + "condor_date": 'String. Points the location of the "date" command, e.g. /usr/bin/date, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.', + "condor_initial_dir": "String. Directory from which condor scripts are run. If set to the default, None, this is the directory from which your script is run.", + "condor_submit": 'String. The Condor_submit command, usually "/usr/bin/condor_submit" but will depend on your HTCondor installation.', + "condor_q": 'String. The Condor_q command, usually "/usr/bin/condor_q" but will depend on your HTCondor installation.', + "condor_getenv": "Boolean. If True, the default, condor takes the environment at submission and copies it to the jobs. You almost certainly want this to be True.", + "condor_batchname": 'String. Condor batchname option: this is what appears in condor_q. Defaults to "binary_c-condor"', + "condor_kill_sig": 'String. Signal Condor should use to stop a process. Note that grid.py expects this to be "SIGINT" which is the default.', + ############################################################ + # Slurm options + ############################################################ + "slurm": "Integer flag used to control Slurm jobs. Default is 0 which means no Slurm. 1 means launch Slurm jobs. Do not manually set this to 2 (run Slurm jobs) or 3 (join Slurm job data) unless you know what you are doing, this is usually done for you.", + "slurm_dir": "String. Working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all jobs). This directory should not exist when you launch the Slurm jobs.", + "slurm_ntasks": "Integer. Number of CPUs required per array job: usually only need this to be 1 (the default).", + "slurm_njobs": "Integer. Number of Slurm jobs to be launched.", + "slurm_jobid": "Integer. Slurm job id. Each job is numbered <slurm_jobid>.<slurm_jobarrayindex>.", + "slurm_jobarrayindex": "Integer. Slurm job array index. Each job is numbered <slurm_jobid>.<slurm_jobarrayindex>.", + "slurm_memory": 'String. Memory required for the job. Should be in megabytes in a format that Slurm understands, e.g. "512MB" (the default).', + "slurm_warn_max_memory": 'String. If we set slurm_memory in excess of this, warn the user because this is usually a mistake. Default "1024MB".', + "slurm_postpone_join": "Integer, default 0. If 1 do not join job results with Slurm, instead you have to do it later manually.", + "slurm_jobname": 'String which names the Slurm jobs, default "binary_c-python".', + "slurm_partition": "String containing the Slurm partition name. You should check your local Slurm installation to find out partition information, e.g. using the sview command.", + "slurm_time": "String. The time a Slurm job is allowed to take. Default is 0 which means no limit. Please check the Slurm documentation for required format of this option.", + "slurm_postpone_sbatch": "Integer, default 0. If set to 1, do not launch Slurm jobs with sbatch, just make the scripts that would have.", + "slurm_array": "String. Override for Slurm's --array option, useful for rerunning jobs manually. Default None.", + "slurm_array_max_jobs": "Integer. Override for the max number of concurrent Slurm array jobs. Default None.", + "slurm_extra_settings": "Dictionary of extra settings for Slurm to put in its launch script. Please see the Slurm documentation for the many options that are available to you.", + "slurm_sbatch": 'String. The Slurm "sbatch" submission command, usually "/usr/bin/sbatch" but will depend on your Slurm installation. By default is set automatically.', + "slurm_env": 'String. Points the location of the "env" command, e.g. /usr/bin/env or /bin/env, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.', + "slurm_bash": 'String. Points the location of the "bash" command, e.g. /bin/bash, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.', + "slurm_pwd": 'String. Points the location of the "pwd" command, e.g. /bin/pwd, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.', + "slurm_date": 'String. Points the location of the "date" command, e.g. /usr/bin/date, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.', + ############################################################ + # High power computing (HPC) variables + ############################################################ + "HPC_force_join": 'Integer, default 0. If 1, and the HPC variable ("slurm" or "condor") is 3, skip checking our own job and force the join.', + "HPC_rebuild_joinlist": "Integer, default 0. If 1, ignore the joinlist we would usually use and rebuild it automatically", + ############################################################ + # Cacheing + ############################################################ + "function_cache": "Boolean, default True. If True, we use a cache for certain function calls.", + "function_cache_default_maxsize": "Integer, default 256. The default maxsize of the cache. Should be a power of 2.", + "function_cache_default_type": "String. One of the following types: LRUCache, LFUCache, FIFOCache, MRUCache, RRCache, TTLCache, NullCache, NoCache. You can find details of what these mean in the Python cachetools manual, except fo NoCache which means no cache is used at all, and NullCache is a dummy cache that never matches, used for testing overheads.", + "function_cache_functions.": "Dict. Keys are the function names that should be in the cache. The value is a tuple of (cache_size, cache_type, test_args) where cache_size used as the size of the cache, or if 0 the function_cache_default_maxsize is used. The cache_type is the function_cache_default_type if None, otherwise is the cache type (see the list defined at function_cache_default_type). The test_args are constant arguments used to call the function when testing the cache, see cache.cache_test() for details.", + ############################################################ + "weight": "Weight factor for each system. The calculated probability is multiplied by this. If the user wants each system to be repeated several times, then this variable should not be changed, rather change the _repeat variable instead, as that handles the reduction in probability per system. This is useful for systems that have a process with some random element in it.", # TODO: add more info here, regarding the evolution splitting. + "repeat": "Factor of how many times a system should be repeated. Consider the evolution splitting binary_c argument for supernovae kick repeating.", + "evolution_type": "Variable containing the type of evolution used of the grid. Multiprocessing, linear processing or possibly something else (e.g. for Slurm or Condor).", + "combine_ensemble_with_thread_joining": "Boolean 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", + "log_runtime_systems": "Whether to log the runtime of the systems . Each systems run by the thread is logged to a file and is stored in the tmp_dir. (1 file per thread). Don't use this if you are planning to run a lot of systems. This is mostly for debugging and finding systems that take long to run. Integer, default = 0. if value is 1 then the systems are logged", + "_total_mass_run": "To count the total mass that thread/process has ran", + "_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_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: 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", + "dry_run_hook": "Function hook to be called for every system in a dry run. The function is passed a dict of the system parameters. Does nothing if None (the default).", + "return_after_dry_run": "If True, return immediately after a dry run (and don't run actual stars). Default is False.", + "exit_after_dry_run": "If True, exits after a dry run. Default is False.", + "print_stack_on_exit": "If True, prints a stack trace when the population's exit method is called.", + "_Moe2017_JSON_data": "Location to store the loaded Moe&diStefano2017 dataset", # Stores the data + } + + ################################# + # Grid options functions + + # Utility functions + def grid_options_help(self, option: str) -> dict: + """ + Function that prints out the description of a grid option. Useful function for the user. + + Args: + option: which option you want to have the description of + + returns: + dict containing the option, the description if its there, otherwise empty string. And if the key doesnt exist, the dict is empty + """ + + # + grid_options_defaults_dict = self.get_grid_options_defaults_dict() + grid_options_descriptions = self.get_grid_options_descriptions() + + # + option_keys = grid_options_defaults_dict.keys() + description_keys = grid_options_descriptions.keys() + + # If the option is unknown + if option not in option_keys: + print( + "Error: This is an invalid entry. Option does not exist, please choose from the following options:\n\t{}".format( + ", ".join(option_keys) + ) + ) + return {} + + # If its not described + if option not in description_keys: + print( + "This option has not been described properly yet. Please contact on of the authors" + ) + return {option: ""} + + # If its known and described: + print(grid_options_descriptions[option]) + return {option: grid_options_descriptions[option]} + + def grid_options_description_checker(self, print_info: bool = True) -> int: + """ + Function that checks which descriptions are missing + + Args: + print_info: whether to print out information about which options contain proper descriptions and which do not + + Returns: + the number of undescribed keys + """ + + # + grid_options_defaults_dict = self.get_grid_options_defaults_dict() + grid_options_descriptions = self.get_grid_options_descriptions() + + # + option_keys = grid_options_defaults_dict.keys() + description_keys = grid_options_descriptions.keys() + + # + undescribed_keys = list(set(option_keys) - set(description_keys)) + + if undescribed_keys: + if print_info: + print( + "Warning: the following keys have no description yet:\n\t{}".format( + ", ".join(sorted(undescribed_keys)) + ) + ) + print( + "Total description progress: {:.2f}%%".format( + 100 * len(description_keys) / len(option_keys) + ) + ) + return len(undescribed_keys) + + def write_grid_options_to_rst_file(self, output_file: str) -> None: + """ + Function that writes the descriptions of the grid options to an rst file + + Args: + output_file: target file where the grid options descriptions are written to + """ + + # Get the options and the description + options = self.get_grid_options_defaults_dict() + descriptions = self.get_grid_options_descriptions() + + # Get those that do not have a description + not_described_yet = list(set(options) - set(descriptions)) + + # separate public and private options + public_options = [key for key in options if not key.startswith("_")] + private_options = [key for key in options if key.startswith("_")] + + # Check input + if not output_file.endswith(".rst"): + msg = "Filename doesn't end with .rst, please provide a proper filename" + raise ValueError(msg) + + # M&S options + moe_di_stefano_default_options = self.get_Moe_di_Stefano_2017_default_options() + moe_di_stefano_default_options_description = ( + self.get_Moe_di_Stefano_2017_default_options_description() + ) + + with self.open(output_file, "w") as f: + print("Population grid code options", file=f) + print("{}".format("=" * len("Population grid code options")), file=f) + print( + "The following chapter contains all grid code options, along with their descriptions", + file=f, + ) + print( + "There are {} options that are not described yet.".format( + len(not_described_yet) + ), + file=f, + ) + print("\n", file=f) + + # Start public options part + self.print_option_descriptions( + f, + public_options, + descriptions, + "Public options", + "The following options are meant to be changed by the user.", + ) + + # Moe & di Stefano options: + self.print_option_descriptions( + f, + moe_di_stefano_default_options, + moe_di_stefano_default_options_description, + "Moe & di Stefano sampler options", + "The following options are meant to be changed by the user.", + ) + + # Start private options part + self.print_option_descriptions( + f, + private_options, + descriptions, + "Private options", + "The following options are not meant to be changed by the user, as these options are used and set internally by the object itself. The description still is provided, but just for documentation purposes.", + ) + + def print_option_descriptions( + self, filehandle, options, descriptions, title, extra_text + ): + """ + Function to print the description of an option + """ + + # Start public options part + print("{}".format(title), file=filehandle) + print("{}".format("-" * len("{}".format(title))), file=filehandle) + print("{}".format(extra_text), file=filehandle) + print("\n", file=filehandle) + + for option in sorted(options): + if option in descriptions: + print( + "| **{}**: {}".format( + option, descriptions[option].replace("\n", "\n\t") + ), + file=filehandle, + ) + else: + print( + "| **{}**: No description available yet".format(option), + file=filehandle, + ) + print("", file=filehandle) + + def default_cache_dir(self): + """ + Return a default cache directory path, or None if we cannot find one. + """ + error_string = "__*ERR*__" # string that cannot be a path + for path in [ + os.path.join(os.environ.get("HOME", error_string), ".cache", "binary_c"), + os.path.join(os.environ.get("TMP", error_string), "cache"), + ]: + if not error_string in path and os.path.isdir(path): + return path + return None diff --git a/binarycpython/utils/population_extensions/gridcode.py b/binarycpython/utils/population_extensions/gridcode.py new file mode 100644 index 0000000000000000000000000000000000000000..a795e55a70cfae4fd0ee7057c119bbb147931934 --- /dev/null +++ b/binarycpython/utils/population_extensions/gridcode.py @@ -0,0 +1,1147 @@ +""" +Module containing the gridcode generation functions for the binarycpython package. + +This class object is an extension to the population grid object +""" + +# pylint: disable=E1101 + +import datetime +import importlib +import json +import os +from typing import Union, Any + + +_count = 0 # used for file symlinking (for testing only) +_numba = False # activate experimental numba code? + + +class gridcode: + """ + Extension to the population grid object that contains functionality to handle the metadata that will be put in the ensemble + """ + + def __init__(self, **kwargs): + """ + Init function for the gridcode class + """ + + return + + ################################################### + # Grid code functions + # + # Function below are used to run populations with + # a variable grid + ################################################### + def _gridcode_filename(self): + """ + Returns a filename for the gridcode. + """ + if self.HPC_job(): + filename = os.path.join( + self.grid_options["tmp_dir"], + "binary_c_grid_{population_id}.{jobid}.py".format( + population_id=self.grid_options["_population_id"], + jobid=self.jobID(), + ), + ) + else: + filename = os.path.join( + self.grid_options["tmp_dir"], + "binary_c_grid_{population_id}.py".format( + population_id=self.grid_options["_population_id"] + ), + ) + return filename + + def _add_code(self, *args, indent=0): + """ + Function to add code to the grid code string + + add code to the code_string + + indent (=0) is added once at the beginning + mindent (=0) is added for every line + + don't use both! + """ + + indent_block = self._indent_block(indent) + for thing in args: + self.code_string += indent_block + thing + + def _indent_block(self, n=0): + """ + return an indent block, with n extra blocks in it + """ + return (self.indent_depth + n) * self.indent_string + + def _increment_indent_depth(self, delta): + """ + increment the indent indent_depth by delta + """ + self.indent_depth += delta + + def _generate_grid_code(self, dry_run=False): + """ + Function that generates the code from which the population will be made. + + dry_run: when True, it will return the starcount at the end so that we know + what the total number of systems is. + + The phasevol values are handled by generating a second array + + Results in a generated file that contains a system_generator function. + + # TODO: make sure running systems with multiplicity 3+ is also possible. + # TODO: there is a lot of things going on in this function. Make sure to describe clearly what happens here. + """ + self.verbose_print("Generating grid code", self.grid_options["verbosity"], 1) + + total_grid_variables = len(self.grid_options["_grid_variables"]) + + self._add_code( + # Import packages + "import math\n", + "import numpy as np\n", + "from collections import OrderedDict\n", + "from binarycpython.utils.useful_funcs import *\n", + "import numba" if _numba else "", + "\n\n", + # Make the function + "def grid_code(self, print_results=True):\n", + ) + + # Increase indent_depth + self._increment_indent_depth(+1) + + self._add_code( + # Write some info in the function + "# Grid code generated on {}\n".format(datetime.datetime.now().isoformat()), + "# This function generates the systems that will be evolved with binary_c\n\n" + # Set some values in the generated code: + "# Set initial values\n", + "_total_starcount = 0\n", + "starcounts = [0 for i in range({})]\n".format(total_grid_variables + 1), + "probabilities = {}\n", + "probabilities_list = [0 for i in range({})]\n".format( + total_grid_variables + 1 + ), + "probabilities_sum = [0 for i in range({})]\n".format( + total_grid_variables + 1 + ), + "parameter_dict = {}\n", + "phasevol = 1\n", + ) + + # Set up the system parameters + self._add_code( + "M_1 = None\n", + "M_2 = None\n", + "M_3 = None\n", + "M_4 = None\n", + "orbital_period = None\n", + "orbital_period_triple = None\n", + "orbital_period_quadruple = None\n", + "eccentricity = None\n", + "eccentricity2 = None\n", + "eccentricity3 = None\n", + "\n", + # Prepare the probability + "# set probability lists\n", + ) + + for grid_variable_el in sorted( + self.grid_options["_grid_variables"].items(), + key=lambda x: x[1]["grid_variable_number"], + ): + # Make probabilities dict + grid_variable = grid_variable_el[1] + self._add_code('probabilities["{}"] = 0\n'.format(grid_variable["name"])) + + ################################################################################# + # Start of code generation + ################################################################################# + self._add_code("\n") + + # turn vb to True to have debugging output + vb = False + + # Generate code + for loopnr, grid_variable_el in enumerate( + sorted( + self.grid_options["_grid_variables"].items(), + key=lambda x: x[1]["grid_variable_number"], + ) + ): + self.verbose_print( + "Constructing/adding: {}".format(grid_variable_el[0]), + self.grid_options["verbosity"], + 2, + ) + grid_variable = grid_variable_el[1] + + #################### + # top code + if grid_variable["topcode"]: + self._add_code(grid_variable["topcode"]) + + ######################### + # Set up the for loop + # Add comment for for loop + self._add_code( + "# for loop for variable {name} gridtype {gridtype}".format( + name=grid_variable["name"], + gridtype=grid_variable["gridtype"], + ) + + "\n", + "sampled_values_{} = {}".format( + grid_variable["name"], grid_variable["samplerfunc"] + ) + + "\n", + ) + + if vb: + self._add_code( + "print('samples','{name}',':',sampled_values_{name})\n".format( + name=grid_variable["name"], + ) + ) + + if vb: + self._add_code( + "print('sample {name} from',sampled_values_{name})".format( + name=grid_variable["name"] + ) + + "\n" + ) + + # calculate number of values and starting location + # + # if we're sampling a continuous variable, we + # have one fewer grid point than the length of the + # sampled_values list + if grid_variable["gridtype"] in [ + "centred", + "centre", + "center", + "edge", + "left edge", + "left", + "right", + "right edge", + ]: + offset = -1 + elif grid_variable["gridtype"] == "discrete": + # discrete variables sample all the points + offset = 0 + + start = 0 + + # for loop over the variable + if vb: + self._add_code( + 'print("var {name} values ",sampled_values_{name}," len ",len(sampled_values_{name})+{offset}," gridtype {gridtype} offset {offset}\\n")\n'.format( + name=grid_variable["name"], + offset=offset, + gridtype=grid_variable["gridtype"], + ) + ) + + stop = "len(sampled_values_{name})+{offset}".format( + name=grid_variable["name"], offset=offset + ) + + if _numba and grid_variable["dry_parallel"]: + # Parallel outer loop + self._add_code("@numba.jit(parallel=True)\n") + self._add_code("def __parallel_func(phasevol,_total_starcount):\n") + self._increment_indent_depth(+1) + self._add_code( + "for {name}_sample_number in numba.prange({stop}):\n".format( + name=grid_variable["name"], + stop=stop, + ) + ) + self._increment_indent_depth(+1) + if start > 0: + self._add_code( + "if {name}_sample_number < {start}:\n".format( + name=grid_variable["name"], + start=start, + ) + ) + self._add_code("continue\n", indent=1) + else: + self._add_code( + "for {name}_sample_number in range({start},{stop}):\n".format( + name=grid_variable["name"], + start=start, + stop=stop, + ) + ) + self._increment_indent_depth(+1) + + # {}_this_index is this grid point's index + # {}_prev_index and {}_next_index are the previous and next grid points, + # (which can be None if there is no previous or next, or if + # previous and next should not be used: this is deliberate) + # + + if grid_variable["gridtype"] == "discrete": + # discrete grids only care about this, + # both prev and next should be None to + # force errors where they are used + self._add_code( + "{name}_this_index = {name}_sample_number ".format( + name=grid_variable["name"], + ), + ) + self._add_code( + "\n", + "{name}_prev_index = None if {name}_this_index == 0 else ({name}_this_index - 1) ".format( + name=grid_variable["name"], + ), + "\n", + ) + self._add_code( + "\n", + "{name}_next_index = None if {name}_this_index >= (len(sampled_values_{name})+{offset} - 1) else ({name}_this_index + 1)".format( + name=grid_variable["name"], offset=offset + ), + "\n", + ) + + elif grid_variable["gridtype"] in [ + "centred", + "centre", + "center", + "edge", + "left", + "left edge", + ]: + + # left and centred grids + self._add_code( + "if {}_sample_number == 0:\n".format(grid_variable["name"]) + ) + self._add_code( + "{}_this_index = 0;\n".format(grid_variable["name"]), indent=1 + ) + self._add_code("else:\n") + self._add_code( + "{name}_this_index = {name}_sample_number ".format( + name=grid_variable["name"] + ), + indent=1, + ) + self._add_code("\n") + self._add_code( + "{name}_prev_index = ({name}_this_index - 1) if {name}_this_index > 0 else None ".format( + name=grid_variable["name"] + ) + ) + self._add_code("\n") + self._add_code( + "{name}_next_index = {name}_this_index + 1".format( + name=grid_variable["name"] + ) + ) + self._add_code("\n") + + elif grid_variable["gridtype"] in ["right", "right edge"]: + + # right edged grid + self._add_code( + "if {name}_sample_number == 0:\n".format(name=grid_variable["name"]) + ) + self._add_code( + "{name}_this_index = 1;\n".format(name=grid_variable["name"]), + indent=1, + ) + self._add_code("else:\n") + self._add_code( + "{name}_this_index = {name}_sample_number + 1 ".format( + name=grid_variable["name"], + ), + indent=1, + ) + self._add_code("\n") + self._add_code( + "{name}_prev_index = {name}_this_index - 1".format( + name=grid_variable["name"] + ) + ) + self._add_code("\n") + self._add_code( + "{name}_next_index = ({name}_this_index + 1) if {name}_this_index < len(sampled_values_{name}) else None".format( + name=grid_variable["name"] + ) + ) + self._add_code("\n") + + # calculate phase volume + if grid_variable["dphasevol"] == -1: + # no phase volume required so set it to 1.0 + self._add_code( + "dphasevol_{name} = 1.0 # 666\n".format(name=grid_variable["name"]) + ) + + elif grid_variable["gridtype"] in ["right", "right edge"]: + # right edges always have this and prev defined + self._add_code( + "dphasevol_{name} = (sampled_values_{name}[{name}_this_index] - sampled_values_{name}[{name}_prev_index])".format( + name=grid_variable["name"] + ) + + "\n" + ) + elif grid_variable["gridtype"] == "discrete": + # discrete might have next defined, use it if we can, + # otherwise use prev + self._add_code( + "dphasevol_{name} = (sampled_values_{name}[{name}_next_index] - sampled_values_{name}[{name}_this_index]) if {name}_next_index else (sampled_values_{name}[{name}_this_index] - sampled_values_{name}[{name}_prev_index])".format( + name=grid_variable["name"] + ) + + "\n" + ) + else: + # left and centred always have this and next defined + self._add_code( + "dphasevol_{name} = (sampled_values_{name}[{name}_next_index] - sampled_values_{name}[{name}_this_index])".format( + name=grid_variable["name"] + ) + + "\n" + ) + + ############## + # Add phasevol check: + self._add_code( + "if dphasevol_{name} <= 0:\n".format(name=grid_variable["name"]) + ) + + # n that case we need another local variable which will prevent it from being run but will track those parameters + # Add phasevol check action: + self._add_code( + 'print("Grid generator: dphasevol_{name} <= 0! (this=",{name}_this_index,"=",sampled_values_{name}[{name}_this_index],", next=",{name}_next_index,"=",sampled_values_{name}[{name}_next_index],") Skipping current sample.")'.format( + name=grid_variable["name"] + ) + + "\n", + "continue\n", + indent=1, + ) + + if vb: + self._add_code( + "print('sample {name} from ',sampled_values_{name},' at this=',{name}_this_index,', next=',{name}_next_index)".format( + name=grid_variable["name"] + ) + + "\n" + ) + + # select sampled point location based on gridtype (left, centre or right) + if grid_variable["gridtype"] in [ + "edge", + "left", + "left edge", + "right", + "right edge", + "discrete", + ]: + self._add_code( + "{name} = sampled_values_{name}[{name}_this_index]".format( + name=grid_variable["name"] + ) + + "\n" + ) + elif grid_variable["gridtype"] in ["centred", "centre", "center"]: + self._add_code( + "{name} = 0.5 * (sampled_values_{name}[{name}_next_index] + sampled_values_{name}[{name}_this_index])".format( + name=grid_variable["name"] + ) + + "\n" + ) + else: + msg = "Unknown gridtype value {type}.".format( + type=grid_variable["gridtype"] + ) + raise ValueError(msg) + + if vb: + self._add_code( + "print('hence {name} = ',{name})\n".format( + name=grid_variable["name"] + ) + ) + + ################################################################################# + # Check condition and generate for loop + + # If the grid variable has a condition, write the check and the action + if grid_variable["condition"]: + self._add_code( + # Add comment + "# Condition for {name}\n".format(name=grid_variable["name"]), + # Add condition check + "if not {condition}:\n".format( + condition=grid_variable["condition"] + ), + indent=0, + ) + + # Add condition failed action: + if self.grid_options["verbosity"] >= 4: + self._add_code( + 'print("Grid generator: Condition for {name} not met!")'.format( + name=grid_variable["name"] + ) + + "\n", + "continue" + "\n", + indent=1, + ) + else: + self._add_code( + "continue" + "\n", + indent=1, + ) + # Add some whitespace + self._add_code("\n") + + # Add some whitespace + self._add_code("\n") + + ######################### + # Set up pre-code and value in some cases + # Add pre-code + if grid_variable["precode"]: + self._add_code( + "{precode}".format( + precode=grid_variable["precode"].replace( + "\n", "\n" + self._indent_block(0) + ) + ) + + "\n" + ) + + # Set phasevol + self._add_code( + "phasevol *= dphasevol_{name}\n".format( + name=grid_variable["name"], + ) + ) + + ####################### + # Probabilities + # Calculate probability + self._add_code( + "\n", + "# Set probabilities\n", + "dprob_{name} = dphasevol_{name} * ({probdist})".format( + name=grid_variable["name"], + probdist=grid_variable["probdist"], + ) + + "\n", + # Save probability sum + "probabilities_sum[{n}] += dprob_{name}".format( + n=grid_variable["grid_variable_number"], name=grid_variable["name"] + ) + + "\n", + ) + + if grid_variable["grid_variable_number"] == 0: + self._add_code( + "probabilities_list[0] = dprob_{name}".format( + name=grid_variable["name"] + ) + + "\n" + ) + else: + self._add_code( + "probabilities_list[{this}] = probabilities_list[{prev}] * dprob_{name}".format( + this=grid_variable["grid_variable_number"], + prev=grid_variable["grid_variable_number"] - 1, + name=grid_variable["name"], + ) + + "\n" + ) + + ############## + # postcode + if grid_variable["postcode"]: + self._add_code( + "{postcode}".format( + postcode=grid_variable["postcode"].replace( + "\n", "\n" + self._indent_block(0) + ) + ) + + "\n" + ) + + ####################### + # Increment starcount for this parameter + self._add_code( + "\n", + "# Increment starcount for {name}\n".format(name=grid_variable["name"]), + "starcounts[{n}] += 1".format( + n=grid_variable["grid_variable_number"], + ) + + "\n", + # Add value to dict + 'parameter_dict["{name}"] = {name}'.format( + name=grid_variable["parameter_name"] + ) + + "\n", + "\n", + ) + + self._increment_indent_depth(-1) + + # The final parts of the code, where things are returned, are within the deepest loop, + # but in some cases code from a higher loop needs to go under it again + # SO I think its better to put an if statement here that checks + # whether this is the last loop. + if loopnr == len(self.grid_options["_grid_variables"]) - 1: + self._write_gridcode_system_call( + grid_variable, + dry_run, + grid_variable["branchpoint"], + grid_variable["branchcode"], + ) + + # increment indent_depth + self._increment_indent_depth(+1) + + #################### + # bottom code + if grid_variable["bottomcode"]: + self._add_code(grid_variable["bottomcode"]) + + self._increment_indent_depth(-1) + self._add_code("\n") + + # Write parts to write below the part that yield the results. + # this has to go in a reverse order: + # Here comes the stuff that is put after the deepest nested part that calls returns stuff. + # Here we will have a + reverse_sorted_grid_variables = sorted( + self.grid_options["_grid_variables"].items(), + key=lambda x: x[1]["grid_variable_number"], + reverse=True, + ) + for loopnr, grid_variable_el in enumerate(reverse_sorted_grid_variables): + grid_variable = grid_variable_el[1] + + self._increment_indent_depth(+1) + self._add_code( + "#" * 40 + "\n", + "# Code below is for finalising the handling of this iteration of the parameter {name}\n".format( + name=grid_variable["name"] + ), + ) + + # Set phasevol + # TODO: fix. this isn't supposed to be the value that we give it here. discuss + self._add_code( + "phasevol /= dphasevol_{name}\n\n".format(name=grid_variable["name"]) + ) + + self._increment_indent_depth(-2) + + if _numba and grid_variable["dry_parallel"]: + self._add_code("__parallel_func(phasevol,_total_starcount)\n") + self._increment_indent_depth(-1) + + # Check the branchpoint part here. The branchpoint makes sure that we can construct + # a grid with several multiplicities and still can make the system calls for each + # multiplicity without reconstructing the grid each time + if grid_variable["branchpoint"] > 0: + + self._increment_indent_depth(+1) + + self._add_code( + # Add comment + "# Condition for branchpoint at {}".format( + reverse_sorted_grid_variables[loopnr + 1][1]["name"] + ) + + "\n", + # # Add condition check + # "if not {}:".format(grid_variable["condition"]) + # + "\n" + # Add branchpoint + "if multiplicity=={}:".format(grid_variable["branchpoint"]) + "\n", + ) + + self._write_gridcode_system_call( + reverse_sorted_grid_variables[loopnr + 1][1], + dry_run, + grid_variable["branchpoint"], + grid_variable["branchcode"], + ) + self._increment_indent_depth(-1) + self._add_code("\n") + + ############################### + # Finalise print statements + # + self._increment_indent_depth(+1) + self._add_code("\n", "#" * 40 + "\n", "if print_results:\n") + self._add_code( + "print('Grid has handled {starcount} stars with a total probability of {probtot:g}'.format(starcount=_total_starcount,probtot=self.grid_options['_probtot']))\n", + indent=1, + ) + + ################ + # Finalise return statement for dry run. + # + if dry_run: + self._add_code("return _total_starcount\n") + + self._increment_indent_depth(-1) + ################################################################################# + # Stop of code generation. Here the code is saved and written + + # Save the grid code to the grid_options + self.verbose_print( + "Save grid code to grid_options", self.grid_options["verbosity"], 1 + ) + + self.grid_options["code_string"] = self.code_string + + # Write to file + gridcode_filename = self._gridcode_filename() + + self.grid_options["gridcode_filename"] = gridcode_filename + + self.verbose_print( + "{blue}Write grid code to {file} [dry_run = {dry}]{reset}".format( + blue=self.ANSI_colours["blue"], + file=gridcode_filename, + dry=dry_run, + reset=self.ANSI_colours["reset"], + ), + self.grid_options["verbosity"], + 1, + ) + + with self.open(gridcode_filename, "w", encoding="utf-8") as file: + file.write(self.code_string) + + # perhaps create symlink + if not self.HPC_job() and self.grid_options["symlink_latest_gridcode"]: + global _count + symlink = os.path.join( + self.grid_options["tmp_dir"], "binary_c_grid-latest" + str(_count) + ) + _count += 1 + try: + os.unlink(symlink) + except: + pass + + try: + os.symlink(gridcode_filename, symlink) + self.verbose_print( + "{blue}Symlinked grid code to {symlink} {reset}".format( + blue=self.ANSI_colours["blue"], + symlink=symlink, + reset=self.ANSI_colours["reset"], + ), + self.grid_options["verbosity"], + 1, + ) + except OSError: + print("symlink failed") + + def _write_gridcode_system_call( + self, grid_variable, dry_run, branchpoint, branchcode + ): + """ + Function to write the block of code (as string) that handles the setting the final probability, taking into account the weight and repeat settings, incrementing the total starcount and total probability. + + Then if the run is a dry run we implement the dry_run_hook or pass depending on the settings. If it is not a dry run we yield the system dict + """ + + self._increment_indent_depth(+1) + self._add_code("#" * 40 + "\n") + + if branchcode: + self._add_code( + "# Branch code\nif {branchcode}:\n".format(branchcode=branchcode) + ) + + if branchpoint: + self._add_code( + "# Code below will get evaluated for every system at this level of multiplicity (last one of that being {name})\n".format( + name=grid_variable["name"] + ) + ) + else: + self._add_code( + "# Code below will get evaluated for every generated system\n" + ) + + # Factor in the custom weight input + self._add_code( + "\n", + "# Weigh the probability by a custom weighting factor\n", + 'probability = self.grid_options["weight"] * probabilities_list[{n}]'.format( + n=grid_variable["grid_variable_number"] + ) + + "\n", + # Take into account the multiplicity fraction: + "\n", + "# Factor the multiplicity fraction into the probability\n", + "probability *= self._calculate_multiplicity_fraction(parameter_dict)" + + "\n", + # Divide by number of repeats + "\n", + "# Divide the probability by the number of repeats\n", + 'probability /= self.grid_options["repeat"]' + "\n", + # Now we yield the system self.grid_options["repeat"] times. + "\n", + "# Loop over the repeats\n", + 'for _ in range(self.grid_options["repeat"]):' + "\n", + ) + self._add_code( + "_total_starcount += 1\n", + # set probability and phasevol values into the system dict + 'parameter_dict["{p}"] = {p}'.format(p="probability") + "\n", + 'parameter_dict["{v}"] = {v}'.format(v="phasevol") + "\n", + # Increment total probability + "self._increment_probtot(probability)\n", + indent=1, + ) + + if not dry_run: + # Handle what is returned, or what is not. + self._add_code("yield(parameter_dict)\n", indent=1) + + # If its a dry run, dont do anything with it + else: + # run the hook function, only if given + if self.grid_options["dry_run_hook"]: + self._add_code( + "self.grid_options['dry_run_hook'](self, parameter_dict)\n", + indent=1, + ) + else: + # or pass + self._add_code("pass\n", indent=1) + + self._add_code("#" * 40 + "\n") + + self._increment_indent_depth(-1) + + return self.code_string + + def _load_grid_function(self): + """ + Function that loads the grid code from file + """ + + # Code to load the + self.verbose_print( + message="Load grid code function from {file}".format( + file=self.grid_options["gridcode_filename"] + ), + verbosity=self.grid_options["verbosity"], + minimal_verbosity=1, + ) + + spec = importlib.util.spec_from_file_location( + "binary_c_python_grid", + os.path.join(self.grid_options["gridcode_filename"]), + ) + grid_file = importlib.util.module_from_spec(spec) + spec.loader.exec_module(grid_file) + generator = grid_file.grid_code + + self.grid_options["_system_generator"] = generator + + self.verbose_print("Grid code loaded", self.grid_options["verbosity"], 1) + + def _last_grid_variable(self): + """ + Function that returns the last grid variable (i.e. the one with the highest grid_variable_number) + + TODO: this function does not require this structure and can be simplified + """ + + number = len(self.grid_options["_grid_variables"]) + for grid_variable in self.grid_options["_grid_variables"]: + if ( + self.grid_options["_grid_variables"][grid_variable][ + "grid_variable_number" + ] + == number - 1 + ): + return grid_variable + + def update_grid_variable(self, name: str, **kwargs) -> None: + """ + Function to update the values of a grid variable. + + Args: + name: + name of the grid variable to be changed. + **kwargs: + key-value pairs to override the existing grid variable data. See add_grid_variable for these names. + """ + + if name in self.grid_options["_grid_variables"]: + grid_variable = self.grid_options["_grid_variables"][name] + + # Set the value and print + for key, value in kwargs.items(): + grid_variable[key] = value + self.verbose_print( + "Updated grid variable: {}".format( + json.dumps(grid_variable, indent=4, ensure_ascii=False) + ), + self.grid_options["verbosity"], + 1, + ) + else: + msg = "Unknown grid variable {} - please create it with the add_grid_variable() method.".format( + name + ) + raise KeyError(msg) + + def delete_grid_variable( + self, + name: str, + ) -> None: + """ + Function to delete a grid variable with the given name. + + Args: + name: + name of the grid variable to be deleted. + """ + + if name in self.grid_options["_grid_variables"]: + del self.grid_options["_grid_variables"][name] + self.verbose_print( + "Deleted grid variable: {}".format(name), + self.grid_options["verbosity"], + 1, + ) + else: + msg = "Failed to remove grid variable {}: please check it exists.".format( + name + ) + raise ValueError(msg) + + def rename_grid_variable(self, oldname: str, newname: str) -> None: + """ + Function to rename a grid variable. + + note: this does NOT alter the order + of the self.grid_options["_grid_variables"] dictionary. + + The order in which the grid variables are loaded into the grid is based on their + `grid_variable_number` property + + Args: + oldname: + old name of the grid variable + newname: + new name of the grid variable + """ + + if oldname in self.grid_options["_grid_variables"]: + self.grid_options["_grid_variables"][newname] = self.grid_options[ + "_grid_variables" + ].pop(oldname) + self.grid_options["_grid_variables"][newname]["name"] = newname + self.verbose_print( + "Rename grid variable: {} to {}".format(oldname, newname), + self.grid_options["verbosity"], + 1, + ) + else: + msg = "Failed to rename grid variable {} to {}.".format(oldname, newname) + raise ValueError(msg) + + def add_grid_variable( + self, + name: str, + parameter_name: str, + longname: str, + valuerange: Union[list, str], + samplerfunc: str, + probdist: str, + dphasevol: Union[str, int] = -1, + gridtype: str = "centred", + branchpoint: int = 0, + branchcode: Union[str, None] = None, + precode: Union[str, None] = None, + postcode: Union[str, None] = None, + topcode: Union[str, None] = None, + bottomcode: Union[str, None] = None, + condition: Union[str, None] = None, + index: Union[int, None] = None, + dry_parallel: Union[bool, None] = False, + ) -> None: + """ + Function to add grid variables to the grid_options. + + The execution of the grid generation will be through a nested for loop. + Each of the grid variables will get create a deeper for loop. + + The real function that generates the numbers will get written to a new file in the TMP_DIR, + and then loaded imported and evaluated. + beware that if you insert some destructive piece of code, it will be executed anyway. + Use at own risk. + + Args: + name: + name of parameter used in the grid Python code. + This is evaluated as a parameter and you can use it throughout + the rest of the function + + Examples:: + + name = 'lnM_1' + + parameter_name: + name of the parameter in binary_c + + This name must correspond to a Python variable of the same name, + which is automatic if parameter_name == name. + + Note: if parameter_name != name, you must set a + variable in "precode" or "postcode" to define a Python variable + called parameter_name + + longname: + Long name of parameter + + Examples:: + + longname = 'Primary mass' + + range: + Range of values to take. Does not get used really, the samplerfunc is used to + get the values from + + Examples:: + + range = [math.log(m_min), math.log(m_max)] + + samplerfunc: + Function returning a list or numpy array of samples spaced appropriately. + You can either use a real function, or a string representation of a function call. + + Examples:: + + samplerfunc = "self.const_linear(math.log(m_min), math.log(m_max), {})".format(resolution['M_1']) + + precode: + Extra room for some code. This code will be evaluated within the loop of the + sampling function (i.e. a value for lnM_1 is chosen already) + + Examples:: + + precode = 'M_1=math.exp(lnM_1);' + + postcode: + Code executed after the probability is calculated. + + probdist: + Function determining the probability that gets assigned to the sampled parameter + + Examples:: + + probdist = 'self.Kroupa2001(M_1)*M_1' + + dphasevol: + part of the parameter space that the total probability is calculated with. Put to -1 + if you want to ignore any dphasevol calculations and set the value to 1 + + Examples:: + + dphasevol = 'dlnM_1' + + condition: + condition that has to be met in order for the grid generation to continue + + Examples:: + + condition = "self.grid_options['binary']==1" + + gridtype: + Method on how the value range is sampled. Can be either 'edge' (steps starting at + the lower edge of the value range) or 'centred' + (steps starting at ``lower edge + 0.5 * stepsize``). + + dry_parallel: + If True, try to parallelize this variable in dry runs. + + topcode: + Code added at the very top of the block. + + bottomcode: + Code added at the very bottom of the block. + """ + + # check parameters + # if False and dphasevol != -1.0 and gridtype == "discrete": + if dphasevol != -1.0 and gridtype == "discrete": + print( + "Error making grid: you have set the phasevol to be not -1 and gridtype to discrete, but a discrete grid has no phasevol calculation. You should only set the gridtype to discrete and not set the phasevol in this case." + ) + + self.exit(code=1) + + # Add grid_variable + grid_variable = { + "name": name, + "parameter_name": parameter_name, + "longname": longname, + "valuerange": valuerange, + "samplerfunc": samplerfunc, + "precode": precode, + "postcode": postcode, + "probdist": probdist, + "dphasevol": dphasevol, + "condition": condition, + "gridtype": gridtype, + "branchpoint": branchpoint, + "branchcode": branchcode, + "topcode": topcode, + "bottomcode": bottomcode, + "grid_variable_number": len(self.grid_options["_grid_variables"]), + "dry_parallel": dry_parallel, + } + + # Check for gridtype input + allowed_gridtypes = [ + "edge", + "right", + "right edge", + "left", + "left edge", + "centred", + "centre", + "center", + "discrete", + ] + + if gridtype not in allowed_gridtypes: + msg = "Unknown gridtype {gridtype}. Please choose one of: ".format( + gridtype=gridtype + ) + ",".join(allowed_gridtypes) + raise ValueError(msg) + + # Load it into the grid_options + self.grid_options["_grid_variables"][grid_variable["name"]] = grid_variable + + self.verbose_print( + "Added grid variable: {}".format( + json.dumps(grid_variable, indent=4, ensure_ascii=False) + ), + self.grid_options["verbosity"], + 2, + ) diff --git a/binarycpython/utils/population_extensions/metadata.py b/binarycpython/utils/population_extensions/metadata.py new file mode 100644 index 0000000000000000000000000000000000000000..dd10a24d513c9a3b7b4faa6735cd2f022786c2af --- /dev/null +++ b/binarycpython/utils/population_extensions/metadata.py @@ -0,0 +1,140 @@ +""" +Module containing the metadata functions for the binarycpython package. + +This class object is an extension to the population grid object +""" + +# pylint: disable=E1101 + +import json +import platform + +from binarycpython.utils.dicts import ( + multiply_values_dict, +) +from binarycpython.utils.ensemble import ( + binaryc_json_serializer, +) +from binarycpython.utils.functions import ( + now, +) + + +class metadata: + """ + Extension to the population grid object that contains functionality to handle the metadata that will be put in the ensemble + """ + + def __init__(self, **kwargs): + """ + Init function for the metadata class + """ + + return + + def add_system_metadata(self): + """ + Add system's metadata to the grid_ensemble_results, and add some system information to metadata. + """ + + # add metadata if it doesn't exist + if not "metadata" in self.grid_ensemble_results: + self.grid_ensemble_results["metadata"] = {} + + # add date + self.grid_ensemble_results["metadata"]["date"] = now() + + # add platform and build information + self.grid_ensemble_results["metadata"]["platform"] = platform.platform() + self.grid_ensemble_results["metadata"]["platform_uname"] = list( + platform.uname() + ) + self.grid_ensemble_results["metadata"]["platform_machine"] = platform.machine() + self.grid_ensemble_results["metadata"]["platform_node"] = platform.node() + self.grid_ensemble_results["metadata"]["platform_release"] = platform.release() + self.grid_ensemble_results["metadata"]["platform_version"] = platform.version() + self.grid_ensemble_results["metadata"][ + "platform_processor" + ] = platform.processor() + self.grid_ensemble_results["metadata"]["platform_python_build"] = " ".join( + platform.python_build() + ) + self.grid_ensemble_results["metadata"][ + "platform_python_version" + ] = platform.python_version() + + # Get hostname + self.grid_ensemble_results["metadata"]["hostname"] = platform.uname()[1] + + # Calculate time elapsed + self.grid_ensemble_results["metadata"]["duration"] = self.time_elapsed() + + # Calculate cpu time + self.grid_ensemble_results["metadata"]["CPU_time"] = self.CPU_time() + + def add_ensemble_metadata(self, combined_output_dict): + """ + Function to add metadata to the grid_ensemble_results and grid_options + """ + + self.grid_ensemble_results["metadata"] = {} + + self.grid_ensemble_results["metadata"]["population_id"] = self.grid_options[ + "_population_id" + ] + self.grid_ensemble_results["metadata"][ + "total_probability_weighted_mass" + ] = combined_output_dict["_total_probability_weighted_mass_run"] + self.grid_ensemble_results["metadata"][ + "factored_in_probability_weighted_mass" + ] = False + if self.grid_options["ensemble_factor_in_probability_weighted_mass"]: + multiply_values_dict( + self.grid_ensemble_results["ensemble"], + 1.0 + / self.grid_ensemble_results["metadata"][ + "total_probability_weighted_mass" + ], + ) + self.grid_ensemble_results["metadata"][ + "factored_in_probability_weighted_mass" + ] = True + self.grid_ensemble_results["metadata"]["_killed"] = self.grid_options["_killed"] + + # Add settings of the populations + all_info = self.return_all_info( + include_population_settings=True, + include_binary_c_defaults=True, + include_binary_c_version_info=True, + include_binary_c_help_all=True, + ) + self.grid_ensemble_results["metadata"]["settings"] = json.loads( + json.dumps(all_info, default=binaryc_json_serializer, ensure_ascii=False) + ) + + ############################## + # Update grid options + for x in self._metadata_keylist(): + self.grid_options[x] = combined_output_dict[x] + self.grid_options["_failed_systems_error_codes"] = list( + set(combined_output_dict["_failed_systems_error_codes"]) + ) + + def _metadata_keylist(self): + """ + Function that returns the list of metadata keys + + TODO: Consider just setting this list as a property of the object in the init + """ + return [ + "_failed_count", + "_failed_prob", + "_errors_exceeded", + "_errors_found", + "_probtot", + "_count", + "_total_mass_run", + "_total_probability_weighted_mass_run", + "_zero_prob_stars_skipped", + "_killed", + ] diff --git a/binarycpython/utils/population_extensions/slurm.py b/binarycpython/utils/population_extensions/slurm.py new file mode 100644 index 0000000000000000000000000000000000000000..1baf701d0337f5b864b29a8078fe4331c23b06e3 --- /dev/null +++ b/binarycpython/utils/population_extensions/slurm.py @@ -0,0 +1,464 @@ +""" +Module containing the Slurm functions for the binarycpython package. + +This class object is an extension to the population grid object +""" + +# pylint: disable=E1101 + +import os +import sys +import time +import stat +import pathlib +import subprocess + +import datasize +import lib_programname +from binarycpython.utils.functions import ( + command_string_from_list, + now, +) + + +class slurm: + """ + Extension for the Population class containing the code for Slurm grid simulations + """ + + def __init__(self, **kwargs): + """ + Init function for the slurm class + """ + + return + + def slurmID(self, jobid=None, jobarrayindex=None): + """ + Function to return a Slurm job ID as a string, [jobid].[jobarrayindex]. The jobid and jobarrayindex passed in are used if given, otherwise we default to the jobid and jobarrayindex in grid_options. + """ + if jobid is None: + jobid = self.grid_options["slurm_jobid"] + if jobarrayindex is None: + jobarrayindex = self.grid_options["slurm_jobarrayindex"] + return "{jobid}.{jobarrayindex}".format( + jobid=jobid, jobarrayindex=jobarrayindex + ) + + def slurmpath(self, path, slurm_dir=None): + """ + Function to return the full slurm directory path. + """ + if slurm_dir is None: + slurm_dir = self.grid_options["slurm_dir"] + + return os.path.abspath(os.path.join(slurm_dir, path)) + + def slurm_status_file(self, jobid=None, jobarrayindex=None, slurm_dir=None): + """ + Return the slurm status file corresponding to the jobid and jobarrayindex, which default to grid_options slurm_jobid and slurm_jobarrayindex, respectively. + """ + return os.path.join( + self.slurmpath("status", slurm_dir=slurm_dir), + self.slurmID(jobid=jobid, jobarrayindex=jobarrayindex), + ) + + def slurm_check_requirements(self): + """ + Function to check whether the slurm parameters in grid_options have been set appropriately. + """ + + if self.grid_options["slurm"] > 0 and ( + self.grid_options["slurm_dir"] is None + or not os.path.isdir(self.grid_options["slurm_dir"]) + ): + return ( + False, + "You have set slurm={slurm} but not set slurm_dir ({slurm_dir}) correctly. Please set it and try again.".format( + slurm=self.grid_options["slurm"], + slurm_dir=self.grid_options["slurm_dir"], + ), + ) + return (True, "") + + def slurm_dirs(self): + """ + Directories associated specifically with this slurm job. + """ + return ["slurm_dir"] + + def set_slurm_status(self, string, slurm_dir=None): + """ + Set the slurm status corresponing to the self object, which should have slurm_jobid and slurm_jobarrayindex set. + + Args: + string : the status string to be set + slurm_dir : the directory in which the status directory is held. If not set, this defaults to the HPC directory (e.g. slurm_dir or condor_dir). + """ + # save slurm jobid to file + if slurm_dir is None: + slurm_dir = self.grid_options["slurm_dir"] + + idfile = os.path.join(slurm_dir, "jobid") + if not os.path.exists(idfile): + with self.open(idfile, "w", encoding="utf-8") as fjobid: + fjobid.write("{jobid}\n".format(jobid=self.grid_options["slurm_jobid"])) + fjobid.close() + self.NFS_flush_hack(idfile) + + # save slurm status + status_file = self.slurm_status_file(slurm_dir=slurm_dir) + if status_file: + with self.open(status_file, "w", encoding="utf-8") as f: + f.write(string) + f.close() + self.NFS_flush_hack(status_file) + + print("Have set status in",status_file,"to",string) + with self.open(status_file,"r",encoding="utf-8") as f: + print("Contents") + print(f.readlines()) + f.close() + + def get_slurm_status(self, jobid=None, jobarrayindex=None, slurm_dir=None): + """ + Get and return the slurm status string corresponing to the self object, or jobid.jobarrayindex if they are passed in. If no status is found, returns an empty string. + """ + if jobid is None: + jobid = self.grid_options["slurm_jobid"] + if jobarrayindex is None: + jobarrayindex = self.grid_options["slurm_jobarrayindex"] + if jobid is None or jobarrayindex is None: + return None + try: + + path = pathlib.Path( + self.slurm_status_file( + slurm_dir=slurm_dir, jobid=jobid, jobarrayindex=jobarrayindex + ) + ) + if path: + self.NFS_flush_hack(path) + return path.read_text().strip() + return "" + # TODO: Fix bare exception + except: + return "" + + def slurm_outfile(self, slurm_dir=None): + """ + return a standard filename for the slurm chunk files + """ + file = "{id}.gz".format( + id=self.slurmID(), + ) + if slurm_dir is None: + slurm_dir = self.grid_options["slurm_dir"] + return os.path.abspath(os.path.join(slurm_dir, "results", file)) + + def make_slurm_dirs(self, slurm_dir=None): + """ + Function to create the necessary slurm directories + """ + + # TODO: replace the code block below with a function call to slurmpath + # make the slurm directories + if slurm_dir is None: + slurm_dir = self.grid_options["slurm_dir"] + + if not slurm_dir: + print( + "You must set self.grid_options['slurm_dir'] (or pass slurm_dir=whatever to make_slurm_dirs()) to a directory which we can use to set up binary_c-python's Slurm files. This should be unique to your set of grids." + ) + os.exit() + + # make a list of directories, these contain the various slurm + # output, status files, etc. + dirs = [] + for slurm_subdir in ["stdout", "stderr", "results", "status", "snapshots"]: + dirs.append(self.slurmpath(slurm_subdir)) + + # make the directories: we do not allow these to already exist + # as the slurm directory should be a fresh location for each set of jobs + for d in dirs: + try: + pathlib.Path(self.slurmpath(d, slurm_dir=slurm_dir)).mkdir( + exist_ok=False, parents=True + ) + # TODO: fix this bare exception + except: + print( + "Tried to make the directory {d} but it already exists. When you launch a set of binary_c jobs on Slurm, you need to set your slurm_dir to be a fresh directory with no contents.".format( + d=d + ) + ) + self.exit(code=1) + + # check that they have been made and exist: we need this + # because on network mounts (NFS) there's often a delay between the mkdir + # above and the actual directory being made. This shouldn't be too long... + fail = True + count = 0 + count_warn = 10 + while fail is True: + fail = False + count += 1 + if count > count_warn: + print( + "Warning: Have been waiting about {count} seconds for Slurm directories to be made, there seems to be significant delay...".format( + count=count + ) + ) + for d in dirs: + if os.path.isdir(d) is False: + fail = True + time.sleep(1) + break + + def slurm_grid(self): # pragma: no cover + """ + function to be called when running grids when grid_options['slurm']>=1 + + if grid_options['slurm']==1, we set up the slurm script and launch the jobs, then return True to exit. + if grid_options['slurm']==2, we run the stars, which means we return False to continue. + if grid_options['slurm']==3, we are being called from the jobs to run the grids, return False to continue. + + TODO: split this function into some parts + TODO: Comment this function better + """ + + if self.grid_options["slurm"] == 2: + # run a grid of stars only, leaving the results + # in the appropriate outfile + return False + + if self.grid_options["slurm"] == 3: + # joining : set the evolution type to "join" and return + # False to continue + self.grid_options["evolution_type"] = "join" + return False + + if self.grid_options["slurm"] == 1: + # if slurm=1, we should have no evolution type, we + # set up the Slurm scripts and get them evolving + # in a Slurm array + self.grid_options["evolution_type"] = None + + # make dirs + self.make_slurm_dirs() + + # check we're not using too much RAM + if datasize.DataSize(self.grid_options["slurm_memory"]) > datasize.DataSize( + self.grid_options["slurm_warn_max_memory"] + ): + print( + "WARNING: you want to use {slurm_memory} MB of RAM : this is unlikely to be correct. If you believe it is, set slurm_warn_max_memory to something very large (it is currently {slurm_warn_max_memory} MB)\n".format( + slurm_memory=self.grid_options["slurm_memory"], + slurm_warn_max_memory=self.grid_options[ + "slurm_warn_max_memory" + ], + ) + ) + self.exit(code=1) + + # set up slurm_array + if not self.grid_options["slurm_array_max_jobs"]: + self.grid_options["slurm_array_max_jobs"] = self.grid_options[ + "slurm_njobs" + ] + slurm_array = self.grid_options[ + "slurm_array" + ] or "1-{njobs}%{max_jobs}".format( + njobs=self.grid_options["slurm_njobs"], + max_jobs=self.grid_options["slurm_array_max_jobs"], + ) + + # get job id (might be passed in) + # TODO: is this variable used? + jobid = ( + self.grid_options["slurm_jobid"] + if self.grid_options["slurm_jobid"] != "" + else "$SLURM_ARRAY_JOB_ID" + ) + + # get job array index + jobarrayindex = self.grid_options["slurm_jobarrayindex"] + if jobarrayindex is None: + jobarrayindex = "$SLURM_ARRAY_TASK_ID" + + if self.grid_options["slurm_njobs"] == 0: + print( + "binary_c-python Slurm : You must set grid_option slurm_njobs to be non-zero" + ) + self.exit(code=1) + + # build the grid command + grid_command = ( + [ + str(self.grid_options["slurm_env"]), + sys.executable, + str(lib_programname.get_path_executed_script()), + ] + + sys.argv[1:] + + [ + "start_at=$((" + str(jobarrayindex) + "-1))", + "modulo=" + str(self.grid_options["slurm_njobs"]), + "slurm_njobs=" + str(self.grid_options["slurm_njobs"]), + "slurm_dir=" + self.grid_options["slurm_dir"], + "verbosity=" + str(self.grid_options["verbosity"]), + "num_cores=" + str(self.grid_options["num_processes"]), + ] + ) + + # wrap command arguments in quotes + grid_command = command_string_from_list(grid_command) + + # make slurm script + scriptpath = self.slurmpath("slurm_script") + try: + script = self.open(scriptpath, "w", encoding="utf-8") + except IOError: + print( + "Could not open Slurm script at {path} for writing: please check you have set {slurm_dir} correctly (it is currently {slurm_dir} and can write to this directory.".format( + path=scriptpath, slurm_dir=self.grid_options["slurm_dir"] + ) + ) + + slurmscript = """#!{bash} +# Slurm launch script created by binary_c-python + +# Slurm options +#SBATCH --error={slurm_dir}/stderr/%A.%a +#SBATCH --output={slurm_dir}/stdout/%A.%a +#SBATCH --job-name={slurm_jobname} +#SBATCH --partition={slurm_partition} +#SBATCH --time={slurm_time} +#SBATCH --mem={slurm_memory} +#SBATCH --ntasks={slurm_ntasks} +#SBATCH --array={slurm_array} +#SBATCH --cpus-per-task={ncpus} +""".format( + bash=self.grid_options["slurm_bash"], + slurm_dir=self.grid_options["slurm_dir"], + slurm_jobname=self.grid_options["slurm_jobname"], + slurm_partition=self.grid_options["slurm_partition"], + slurm_time=self.grid_options["slurm_time"], + slurm_ntasks=self.grid_options["slurm_ntasks"], + slurm_memory=self.grid_options["slurm_memory"], + slurm_array=slurm_array, + ncpus=self.grid_options["num_processes"], + ) + + for key in self.grid_options["slurm_extra_settings"]: + slurmscript += "#SBATCH --{key} = {value}\n".format( + key=key, value=self.grid_options["slurm_extra_settings"][key] + ) + + slurmscript += """ + +export BINARY_C_PYTHON_ORIGINAL_CMD_LINE={cmdline} +export BINARY_C_PYTHON_ORIGINAL_WD=`{pwd}` +export BINARY_C_PYTHON_ORIGINAL_SUBMISSION_TIME=`{date}` + +# set status to \"running\" +echo \"running\" > "{slurm_dir}/status/$SLURM_ARRAY_JOB_ID.$SLURM_ARRAY_TASK_ID" + +# make list of files which is checked for joining +# echo "{slurm_dir}/results/$SLURM_ARRAY_JOB_ID.$SLURM_ARRAY_TASK_ID.gz" >> "{slurm_dir}/results/$SLURM_ARRAY_JOB_ID.all" + +# run grid of stars and, if this returns 0, set status to finished +{grid_command} "slurm=2" "evolution_type=grid" "slurm_jobid=$SLURM_ARRAY_JOB_ID" "slurm_jobarrayindex=$SLURM_ARRAY_TASK_ID" "save_population_object={slurm_dir}/results/$SLURM_ARRAY_JOB_ID.$SLURM_ARRAY_TASK_ID.gz" && echo -n \"finished\" > "{slurm_dir}/status/$SLURM_ARRAY_JOB_ID.$SLURM_ARRAY_TASK_ID" && echo """.format( + slurm_dir=self.grid_options["slurm_dir"], + grid_command=grid_command, + cmdline=repr(self.grid_options["command_line"]), + date=self.grid_options["slurm_date"], + pwd=self.grid_options["slurm_pwd"], + ) + + if not self.grid_options["slurm_postpone_join"]: + slurmscript += """&& echo \"Checking if we can join...\" && echo && {grid_command} "slurm=3" "evolution_type=join" "joinlist={slurm_dir}/results/$SLURM_ARRAY_JOB_ID.all" "slurm_jobid=$SLURM_ARRAY_JOB_ID" "slurm_jobarrayindex=$SLURM_ARRAY_TASK_ID" + """.format( + slurm_dir=self.grid_options["slurm_dir"], + grid_command=grid_command, + ) + else: + slurmscript += "\n" + + # write to script, close it and make it executable by + # all (so the slurm user can pick it up) + script.write(slurmscript) + script.close() + os.chmod( + scriptpath, + stat.S_IREAD + | stat.S_IWRITE + | stat.S_IEXEC + | stat.S_IRGRP + | stat.S_IXGRP + | stat.S_IROTH + | stat.S_IXOTH, + ) + + if not self.grid_options["slurm_postpone_sbatch"]: + # call sbatch to launch the jobs + cmd = [self.grid_options["slurm_sbatch"], scriptpath] + + with subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) as pipes: + + std_out, std_err = pipes.communicate() + if pipes.returncode != 0: + # an error happened! + err_msg = "{red}{err}\nReturn Code: {code}{reset}".format( + err=std_err.strip(), + code=pipes.returncode, + red=self.ANSI_colours["red"], + reset=self.ANSI_colours["reset"], + ) + raise Exception(err_msg) + + if len(std_err): + print( + "{red}{err}{reset}".format( + red=self.ANSI_colours["red"], + reset=self.ANSI_colours["reset"], + err=std_err.strip().decode("utf-8"), + ) + ) + + print( + "{yellow}{out}{reset}".format( + yellow=self.ANSI_colours["yellow"], + reset=self.ANSI_colours["reset"], + out=std_out.strip().decode("utf-8"), + ) + ) + else: + # just say we would have (use this for testing) + print( + "Slurm script is at {path} but has not been launched".format( + path=scriptpath + ) + ) + + # some messages to the user, then return + if self.grid_options["slurm_postpone_sbatch"] == 1: + print( + "Slurm script written, but launching the jobs with sbatch was postponed." + ) + else: + print("Slurm jobs launched") + print("All done in slurm_grid().") + + # return True so we exit immediately + return True + + def slurm_queue_stats(self): # pragma: no cover + """ + Function to XXX + + TODO + """ + + return None diff --git a/binarycpython/utils/population_extensions/spacing_functions.py b/binarycpython/utils/population_extensions/spacing_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..36edd02e41f009195db45af17274ab93cfbde615 --- /dev/null +++ b/binarycpython/utils/population_extensions/spacing_functions.py @@ -0,0 +1,687 @@ +""" +Module containing the spacing functions for the binarycpython package. Very under-populated at the moment, but more are likely to come soon + +This class object is an extension to the population grid object + +Tasks: + TODO: add more spacing functions to this module. +""" + +# pylint: disable=E1101 + +import sys +import math +import json +import functools +from typing import Union +import traceback + +import numpy as np +import cachetools +import diskcache + + + +import py_rinterpolate + + +class spacing_functions: + """ + Extension for the Population class containing the code for spacing functions + """ + + def __init__(self, **kwargs): + """ + Init function for the spacing_functions class + """ + + return + + @cachetools.cachedmethod(lambda self: self.caches["spacing_functions.const_linear"]) + def const_linear( + self, min_bound: Union[int, float], max_bound: Union[int, float], steps: int + ) -> list: + """ + Samples a range linearly. Uses numpy linspace, and returns an array of floats. Do NOT use this for integers. + + Args: + min_bound: lower bound of range + max_bound: upper bound of range + steps: number of segments between min_bound and max_bound + + Returns: + np.linspace(min_bound, max_bound, steps) + """ + return np.linspace(min_bound, max_bound, steps) + + @cachetools.cachedmethod(lambda self: self.caches["spacing_functions.const_int"]) + def const_int( + self, min_bound: Union[int, float], max_bound: Union[int, float], steps: int + ) -> list: + """ + Samples an integer range linearly. Returns a list of ints. + + Args: + min_bound: lower bound of range, must be an integer (is converted to int) + max_bound: upper bound of range, must be an integer (is converted to int) + steps: number of segments between min_bound and max_bound + + Returns: + range(min_bound,max_bound,step) + + where step is int((int(max_bound)-int(min_bound))/steps) + """ + + step = int((int(max_bound) - int(min_bound)) / max(1, steps - 1)) + if steps <= 1: + return [int(min_bound)] + return range(int(min_bound), int(max_bound + step), step) + + ############################################################ + @cachetools.cachedmethod(lambda self: self.caches["spacing_functions.const_ranges"]) + def const_ranges(self, ranges) -> list: + """ + Samples a series of ranges linearly. + + Args: + ranges: a tuple of tuples passed to the self.const_linear() spacing function. + + Returns: + numpy array of masses + + Example: + The following allocates 10 stars between 0.1 and 0.65, 20 stars between 0.65 + and 0.85, and 10 stars between 0.85 and 10.0 Msun:: + + samplerfunc="const_ranges((({},{},{}),({},{},{}),({},{},{})))".format( + 0.1, 0.65, 10, + 0.65, 0.85, 20, + 0.85, 10.0, 10 + ) + + """ + + masses = np.empty(0) + for valuerange in ranges: + masses = np.append(masses, self.const_linear(*valuerange)) + return np.unique(masses) + + ############################################################ + def peak_normalized_gaussian_func( + self, x: Union[int, float], mean: Union[int, float], sigma: Union[int, float] + ) -> Union[int, float]: + """ + Function to evaluate a Gaussian at a given point, note + that the normalization is such that the peak is always 1.0, + not that the integral is 1.0 + + Args: + x: location at which to evaluate the distribution + mean: mean of the Gaussian + sigma: standard deviation of the Gaussian + + Returns: + value of the Gaussian at x + """ + + gaussian_prefactor = 1.0 # / math.sqrt(2.0 * math.pi) + + r = 1.0 / sigma + y = (x - mean) * r + return gaussian_prefactor * math.exp(-0.5 * y ** 2) + + ############################################################ + @cachetools.cachedmethod( + lambda self: self.caches["spacing_functions.gaussian_zoom"] + ) + def gaussian_zoom( + self, + min_bound: Union[int, float], + max_bound: Union[int, float], + zoom_mean: Union[int, float], + zoom_dispersion: Union[int, float], + zoom_magnitude: Union[int, float], + steps: int, + ) -> list: + """ + Samples such that a region is zoomed in according to a 1-Gaussian function + + Args: + min_bound: lower bound of range + max_bound: upper bound of range + zoom_mean: mean of the Gaussian zoom location + zoom_dispersion: dispersion of the Gaussian + zoom_magnitude: depth of the Gaussian (should be 0<= zoom_magntiude <1) + steps: number of segments between min_bound and max_bound assuming a linear step + this is what you'd normally call "resolution" + + Returns: + Numpy array of sample values + """ + + # linear spacing: this is what we'd have + # in the absence of a Gaussian zoom + linear_spacing = (max_bound - min_bound) / (steps - 1) + + # make the list of values + x = min_bound + array = np.array([]) + while x <= max_bound: + array = np.append(array, x) + g = self.peak_normalized_gaussian_func(x, zoom_mean, zoom_dispersion) + f = 1.0 - zoom_magnitude * g + dx = linear_spacing * f + x = x + dx + + # force the last array member to be max_bound if it's not + if array[-1] != max_bound: + array[-1] = max_bound + + return np.unique(array) + + def const_dt(self, cachedir=None, usecache=True, **kwargs): + """ + const_dt returns a list of masses spaced at a constant age difference + + Args: + dt: the time difference between the masses (1000.0 Myr, used when logspacing==False) + dlogt : the delta log10(time) difference between masses (0.1 dex, used when logspacing==True) + mmin: the minimum mass to be considered in the stellar lifetime interpolation table (0.07 Msun) + mmax: the maximum mass to be considered in the stellar lifetime interpolation table (100.0 Msun) + nres: the resolution of the stellar lifetime interpolation table (100) + logspacing: whether to use log-spaced time, in which case dt is actually d(log10(t)) + tmin: the minimum time to consider (Myr, default 3.0 Myr) + tmax: the maximum time to consider (Myr, default None which means we use the grid option 'max_evolution_time') + max_evolution_time: overrides bse_options['max_evolution_time'] if set + mindm: a tuple of tuples containing a mass range and minimum mass spacing in that range. The default is ((0.07,1.0,0.1),(1.0,300.0,1.0)) allocated a minimum dm of 0.1Msun in the mass range 0.07 to 1.0 Msun and 1.0Msun in the range 1.0 to 300.0 Msun. Anything you set overrides this. Note, if you use only one tuple, you must set it with a trailing comma, thus, e.g. ((0.07,1.0,0.1),). (default None) + maxdm: a list of tuples similar to mindm but specifying a maximum mass spacing. In the case of maxdm, if the third option in each tuple is negative it is treated as a log step (its absolute value is used as the step). (default None) + fsample: a global sampling (Shannon-like) factor (<1) to improve resolution (default 1.0, set to smaller to improve resolution) + factor: all masses generated are multiplied by this after generation + showtable: if True, the mass list and times are shown to stdout after generation + showlist: if True, show the mass list once generated + logmasses: if True, the masses are logged with math.log() + log10masses: if True, the masses are logged with math.log10() + usecache: if True (the default) uses cached results if they are saved (in cachedir) and cachedir is not None + cachedir: where the cache is stored. if None, defaults to grid_options['cache_dir']+'/const_dt_cache' + vb : verbose logging flag (default False) + + Returns: + Array of masses. + + Example: + these are lines set as options to Population.add_grid_value(...):: + + # linear time bins of 1Gyr + samplerfunc="self.const_dt(self,dt=1000,nres=100,mmin=0.07,mmax=2.0,showtable=True)" + + # logarithmic spacing in time, generally suitable for Galactic chemical evolution yield grids. + samplerfunc="self.const_dt(self,dlogt=0.1,nres=100,mmin=0.07,mmax=80.0,maxdm=((0.07,1.0,0.1),(1.0,10.0,1.0),(10.0,80.0,2.0)),showtable=True,logspacing=True,fsample=1.0/4.0)" + + """ + + if usecache: + if cachedir is None: + cachedir = self.grid_options["cache_dir"] + + if cachedir is not None: + cachedir += "/const_dt_cache" + cache = diskcache.Cache(cachedir) + print( + "Use const_dt cache in {} [cache object {}]".format(cachedir, cache) + ) + else: + print("const_dt uses no cache") + cache = None + + def _const_dt_wrapper( + cachedir=None, + num_cores=None, + bse_options=None, + dt=1000.0, + dlogt=0.1, + mmin=0.07, + mmax=100.0, + nres=1000, + logspacing=False, + tmin=3.0, # start at 3Myr + tmax=None, # use max_evolution_time by default + max_evolution_time=None, + mindm=None, # tuple of tuples + maxdm=((0.07, 1.0, 0.1), (1.0, 300.0, 1.0)), # tuple of tuples + fsample=1.0, + factor=1.0, + logmasses=False, + log10masses=False, + showlist=False, + showtable=False, + usecache=True, + vb=False, + ): + """ + Wrapper function for the const_dt funtion which handles verbose logging and filtering of arguments + """ + + print( + "call _const_dt num_cores={} dt={} dlogt={} mmin={} mmax={} nres={} logspacing={} tmin={} mindm={} maxdm={} fsample={} factor={} logmasses={} log10masses={} showlist={} usecache={} [cache={} vb={}]".format( + num_cores, + dt, + dlogt, + mmin, + mmax, + nres, + logspacing, + tmin, + mindm, + maxdm, + fsample, + factor, + logmasses, + log10masses, + showlist, + usecache, + cache, + vb, + ) + ) + + if vb: + traceback.print_stack() + + # strip bse_options of options that will not affect + # _const_dt + bse_stripped = bse_options.copy() + + del_keys = ["multiplicity"] + for del_key in del_keys: + if del_key in bse_stripped: + del bse_stripped[del_key] + + # make a JSON string of the options (this can be + # used to check the cache) + bse_options_json = json.dumps( + bse_stripped, sort_keys=True, ensure_ascii=False + ) + if vb: + print("BSE options JSON:", bse_options_json) + + return _const_dt( + cachedir=cachedir, + num_cores=num_cores, + bse_options_json=bse_options_json, + dt=dt, + dlogt=dlogt, + mmin=mmin, + mmax=mmax, + nres=nres, + logspacing=logspacing, + tmin=tmin, + tmax=tmax, + max_evolution_time=max_evolution_time, + mindm=mindm, + maxdm=maxdm, + fsample=fsample, + logmasses=logmasses, + log10masses=log10masses, + showlist=showlist, + showtable=showtable, + usecache=usecache, + ) + + # if we want to use the cache, set the __decorator + # to just be the cache.memoize function, otherwise + # make it a wrapped function that just returns the + # _const_dt function acting on its arguments + def __dummy_decorator(func): + """ + Placeholder decorator function + """ + + @functools.wraps(func) + def wrapped(*args, **kwargs): + """ + Dummy wrapper function + """ + + return func(*args, **kwargs) + + return wrapped + + if cache is not None: + __decorator = cache.memoize + else: + __decorator = __dummy_decorator + + #@cache.memoize() + @__decorator() # note: () works with python3.9+, maybe not for 3.8 + def _const_dt( + cachedir=None, + num_cores=None, + bse_options_json=None, # JSON string + dt=1000.0, + dlogt=0.1, + mmin=0.07, + mmax=100.0, + nres=1000, + logspacing=False, + tmin=3.0, # start at 3Myr + tmax=None, # use max_evolution_time by default + max_evolution_time=None, + mindm=None, # tuple of tuples + maxdm=((0.07, 1.0, 0.1), (1.0, 300.0, 1.0)), # tuple of tuples + fsample=1.0, + factor=1.0, + logmasses=False, + log10masses=False, + showlist=False, + showtable=False, + usecache=True, + ): + """ + first thing to do is make a stellar lifetime table + + we should use the bse_options_json passed in + so our lifetime_population uses the same physics + as the main grid + + TODO: Describe this function better with arguments and + """ + + # convert bse_options to dict + bse_options = json.loads(bse_options_json) + + # perhaps override max_evolution_time + if max_evolution_time: + bse_options["max_evolution_time"] = max_evolution_time + + from binarycpython.utils.grid import Population + lifetime_population = Population() + lifetime_population.bse_options = bse_options + + # we only want to evolve the star during nuclear burning, + # we don't want a dry run of the grid + # we want to use the right number of CPU cores + lifetime_population.set( + do_dry_run=False, + num_cores=num_cores, + max_stellar_type_1=10, + save_ensemble_chunks=False, + symlink_latest_gridcode=False, + modulo=1, + start_at=0, + slurm=0, + condor=0, + multiplicity=1, + ensemble=0, + ensemble_dt=1e3, + ensemble_logdt=0.1, + # for debugging + verbosity=1, + log_dt=1, + ) + + # make a grid in M1 + lifetime_population.add_grid_variable( + name="lnM_1", + parameter_name="M_1", + longname="log Primary mass", # == single-star mass + valuerange=[math.log(mmin), math.log(mmax)], + samplerfunc="self.const_linear(math.log({mmin}),math.log({mmax}),{nres})".format( + mmin=mmin, mmax=mmax, nres=nres + ), + probdist="1", # dprob/dm1 : we don't care, so just set it to 1 + dphasevol="dlnM_1", + precode="M_1=math.exp(lnM_1)", + condition="", # Impose a condition on this grid variable. Mostly for a check for yourself + gridtype="edge", + ) + + # set up the parse function + def _parse_function(self, output): + """ + Parse function for the const_dt binary_c calls + """ + + if output: + for line in output.splitlines(): + data = line.split() + if data[0] == "SINGLE_STAR_LIFETIME": + # append (log10(mass), log10(lifetime)) tuples + logm = math.log10(float(data[1])) + logt = math.log10(float(data[2])) + # print(line) + # print("logM=",logm,"M=",10.0**logm," -> logt=",logt) + self.grid_results["interpolation table m->t"][logm] = logt + self.grid_results["interpolation table t->m"][logt] = logm + + lifetime_population.set( + parse_function=_parse_function, + ) + + # run to build the interpolation table + print( + "Running population to make lifetime interpolation table, please wait" + ) + lifetime_population.evolve() + # print("Data table",lifetime_population.grid_results['interpolation table t->m']) + + if ( + "interpolation table t->m" not in lifetime_population.grid_results + or len( + lifetime_population.grid_results["interpolation table t->m"].keys() + ) + == 0 + ): + print( + "\n\n\nError: The t->m lifetime table is empty. One usual cause for this is that the tmax or max_evolution_time option (currently passed in to const_dt as {tmax}) is too short for there to be any entries in the table before the first timestep. Try increasing tmax and max_evolution_time, shorten the timestep or, if using log times, set tstart to be closer to 0.\n".format( + tmax=tmax + ) + ) + sys.exit() + + # convert to nested lists for the interpolator + # + # make time -> mass table + data_table_time_mass = [] + times = sorted( + lifetime_population.grid_results["interpolation table t->m"].keys() + ) + for time in times: + mass = lifetime_population.grid_results["interpolation table t->m"][ + time + ] + # we have to make sure the time is monotonic (not guaranteed at high mass) + if len(data_table_time_mass) == 0: + data_table_time_mass.append([time, mass]) + elif mass < data_table_time_mass[-1][1]: + data_table_time_mass.append([time, mass]) + + # make mass -> time table + data_table_mass_time = [] + masses = sorted( + lifetime_population.grid_results["interpolation table m->t"].keys() + ) + for mass in masses: + time = lifetime_population.grid_results["interpolation table m->t"][ + mass + ] + data_table_mass_time.append([mass, time]) + + # set up interpolators + interpolator_time_mass = py_rinterpolate.Rinterpolate( + table=data_table_time_mass, + nparams=1, + ndata=1, + verbosity=0, # mass # lifetime + ) + interpolator_mass_time = py_rinterpolate.Rinterpolate( + table=data_table_mass_time, + nparams=1, + ndata=1, + verbosity=0, # lifetime # mass + ) + + def _mass_from_time(linear_time): + """ + Function to get a mass given a time, calculated by using the interpolator_time_mass + """ + + return ( + 10.0 + ** interpolator_time_mass.interpolate([math.log10(linear_time)])[0] + ) + + def _time_from_mass(mass): + """ + Function to get a time given a mass, calculated by using the interpolator_time_mass + """ + + return 10.0 ** interpolator_mass_time.interpolate([math.log10(mass)])[0] + + def _uniq(_list): + """ + Function to return a list containing only unique elements + + TODO: move this to the functions file + """ + + return sorted(list(set(_list))) + + def _format(_list): + """ + Function to format a list of numbers as %g strings + """ + + return [float("{x:g}".format(x=x)) for x in _list] + + # construct mass list, always include the min and max + mass_list = [mmin, mmax] + + # first, make sure the stars are separated by only + # maxdm + if maxdm: + for x in maxdm: + range_min = x[0] + range_max = x[1] + dm = x[2] + if dm < 0.0: + # use log scale + dlogm = -dm + logm = math.log(mmin) + logmmax = math.log(mmax) + logrange_min = math.log(range_min) + logrange_max = math.log(range_max) + while logm <= logmmax: + if logrange_min <= logm <= logrange_max: + mass_list.append(math.exp(logm)) + logm += dlogm + else: + # use linear scale + m = mmin + while m <= mmax: + if range_min <= m <= range_max: + mass_list.append(m) + m += dm + + # start time loop at tmax or max_evolution_time + t = tmax if tmax else bse_options["max_evolution_time"] + + # set default mass list + if logspacing: + logt = math.log10(t) + logtmin = math.log10(tmin) + while logt > logtmin: + m = _mass_from_time(10.0 ** logt) + mass_list.append(m) + logt = max(logtmin, logt - dlogt * fsample) + else: + while t > tmin: + m = _mass_from_time(t) + mass_list.append(m) + t = max(tmin, t - dt * fsample) + + # make mass list unique + mass_list = _uniq(mass_list) + + if mindm: + for x in mindm: + range_min = x[0] + range_max = x[1] + mindm = x[2] + # impose a minimum dm: if two masses in the list + # are separated by < this, remove the second + for index, mass in enumerate(mass_list): + if index > 0 and range_min <= mass <= range_max: + dm = mass_list[index] - mass_list[index - 1] + if dm < mindm: + mass_list[index - 1] = 0.0 + mass_list = _uniq(mass_list) + if mass_list[0] == 0.0: + mass_list.remove(0.0) + + # apply multiplication factor if given + if factor and factor != 1.0: + mass_list = [m * factor for m in mass_list] + + # reformat numbers + mass_list = _format(mass_list) + + # show the mass<>time table? + if showtable: + twas = 0.0 + logtwas = 0.0 + for i, m in enumerate(mass_list): + t = _time_from_mass(m) + logt = math.log10(t) + if twas > 0.0: + print( + "{i:4d} m={m:13g} t={t:13g} log10(t)={logt:13g} dt={dt:13g} dlog10(t)={dlogt:13g}".format( + i=i, + m=m, + t=t, + logt=logt, + dt=twas - t, + dlogt=logtwas - logt, + ) + ) + else: + print( + "{i:4d} m={m:13g} t={t:13g} log10(t)={logt:13g}".format( + i=i, m=m, t=t, logt=logt + ) + ) + twas = t + logtwas = logt + sys.exit() + + # return the mass list as a numpy array + mass_array = np.unique(np.array(mass_list)) + + # perhaps log the masses + if logmasses: + mass_array = np.log(mass_array) + if log10masses: + mass_array = np.log10(mass_array) + + return mass_array + + # call _const_dt and return the mass_list + # + # Note: because _const_dt is cached to disk, calling it may + # use the cached result. + # + # Note: we send a sorted JSON string instead of the + # bse_options dict to make sure the order is preserved + + mass_list = _const_dt_wrapper( + cachedir=cachedir, + num_cores=self.grid_options["num_cores"], + bse_options=self.bse_options, + **kwargs, + ) + if cache: + cache.close() + + if kwargs.get("showlist", True): + print("const_dt mass list ({} masses)\n".format(len(mass_list)), mass_list) + + return mass_list diff --git a/binarycpython/utils/population_extensions/version_info.py b/binarycpython/utils/population_extensions/version_info.py new file mode 100644 index 0000000000000000000000000000000000000000..2bc09d228e2ad8c141d65600ff9eded507729aa4 --- /dev/null +++ b/binarycpython/utils/population_extensions/version_info.py @@ -0,0 +1,433 @@ +""" +File containing the class object containing the functions to handle binary_c version info. + +This class will be used to extend the population object + +NOTE: could these functions not just be normal functions rather than class methods? I see hardly any use of the self +""" + +# pylint: disable=E0203 + +import copy +import os + +from typing import Union + +from binarycpython import _binary_c_bindings +from binarycpython.utils.functions import isfloat + + +class version_info: + """ + Class object containing the functions to handle binary_c version info. + + This class will be used to extend the population object + """ + + def __init__(self, **kwargs): + """ + Init function for the version_info class + """ + + return + + ######################################################## + # version_info functions + ######################################################## + def return_binary_c_version_info(self, parsed: bool = True) -> Union[str, dict]: + """ + Function that returns the version information of binary_c. This function calls the function + _binary_c_bindings.return_version_info() + + Args: + parsed: Boolean flag whether to parse the version_info output of binary_c. default = False + + Returns: + Either the raw string of binary_c or a parsed version of this in the form of a nested + dictionary + """ + + found_prev = False + if "BINARY_C_MACRO_HEADER" in os.environ: + # the env var is already present. lets save that and put that back later + found_prev = True + prev_value = os.environ["BINARY_C_MACRO_HEADER"] + + # + os.environ["BINARY_C_MACRO_HEADER"] = "macroxyz" + + # Get version_info + raw_version_info = _binary_c_bindings.return_version_info().strip() + + # delete value + del os.environ["BINARY_C_MACRO_HEADER"] + + # put stuff back if we found a previous one + if found_prev: + os.environ["BINARY_C_MACRO_HEADER"] = prev_value + + # parse if wanted + if parsed: + parsed_version_info = self.parse_binary_c_version_info(raw_version_info) + return parsed_version_info + + return raw_version_info + + def parse_binary_c_version_info(self, version_info_string: str) -> dict: + """ + Function that parses the binary_c version info. Long function with a lot of branches + + Args: + version_info_string: raw output of version_info call to binary_c + + Returns: + Parsed version of the version info, which is a dictionary containing the keys: 'isotopes' for isotope info, 'argpairs' for argument pair info (TODO: explain), 'ensembles' for ensemble settings/info, 'macros' for macros, 'elements' for atomic element info, 'DTlimit' for (TODO: explain), 'nucleosynthesis_sources' for nucleosynthesis sources, and 'miscellaneous' for all those that were not caught by the previous groups. 'git_branch', 'git_build', 'revision' and 'email' are also keys, but its clear what those contain. + """ + + version_info_dict = {} + + # Clean data and put in correct shape + splitted = version_info_string.strip().splitlines() + cleaned = {el.strip() for el in splitted if not el == ""} + + ########################## + # Network: + # Split off all the networks and parse the info. + + networks = {el for el in cleaned if el.startswith("Network ")} + cleaned = cleaned - networks + + networks_dict = {} + for el in networks: + network_dict = {} + split_info = el.split("Network ")[-1].strip().split("==") + + network_number = int(split_info[0]) + network_dict["network_number"] = network_number + + network_info_split = split_info[1].split(" is ") + + shortname = network_info_split[0].strip() + network_dict["shortname"] = shortname + + if not network_info_split[1].strip().startswith(":"): + network_split_info_extra = network_info_split[1].strip().split(":") + + longname = network_split_info_extra[0].strip() + network_dict["longname"] = longname + + implementation = ( + network_split_info_extra[1].strip().replace("implemented in", "") + ) + if implementation: + network_dict["implemented_in"] = [ + i.strip("()") for i in implementation.strip().split() + ] + + networks_dict[network_number] = copy.deepcopy(network_dict) + version_info_dict["networks"] = networks_dict if networks_dict else None + + ########################## + # Isotopes: + # Split off + isotopes = {el for el in cleaned if el.startswith("Isotope ")} + cleaned -= isotopes + + isotope_dict = {} + for el in isotopes: + split_info = el.split("Isotope ")[-1].strip().split(" is ") + + isotope_info = split_info[-1] + name = isotope_info.split(" ")[0].strip() + + # Get details + mass_g = float( + isotope_info.split(",")[0].split("(")[1].split("=")[-1][:-2].strip() + ) + mass_amu = float( + isotope_info.split(",")[0].split("(")[-1].split("=")[-1].strip() + ) + mass_mev = float( + isotope_info.split(",")[-3].split("=")[-1].replace(")", "").strip() + ) + A = int(isotope_info.split(",")[-1].strip().split("=")[-1].replace(")", "")) + Z = int(isotope_info.split(",")[-2].strip().split("=")[-1]) + + # + isotope_dict[int(split_info[0])] = { + "name": name, + "Z": Z, + "A": A, + "mass_mev": mass_mev, + "mass_g": mass_g, + "mass_amu": mass_amu, + } + version_info_dict["isotopes"] = isotope_dict if isotope_dict else None + + ########################## + # Arg pairs: + # Split off + argpairs = {el for el in cleaned if el.startswith("ArgPair")} + cleaned -= argpairs + + argpair_dict = {} + for el in sorted(argpairs): + split_info = el.split("ArgPair ")[-1].split(" ") + + if not argpair_dict.get(split_info[0], None): + argpair_dict[split_info[0]] = {split_info[1]: split_info[2]} + else: + argpair_dict[split_info[0]][split_info[1]] = split_info[2] + + version_info_dict["argpairs"] = argpair_dict if argpair_dict else None + + ########################## + # ensembles: + # Split off + ensembles = {el for el in cleaned if el.startswith("Ensemble")} + cleaned -= ensembles + + ensemble_dict = {} + ensemble_filter_dict = {} + for el in ensembles: + split_info = el.split("Ensemble ")[-1].split(" is ") + + if len(split_info) > 1: + if not split_info[0].startswith("filter"): + ensemble_dict[int(split_info[0])] = split_info[-1] + else: + filter_no = int(split_info[0].replace("filter ", "")) + ensemble_filter_dict[filter_no] = split_info[-1] + + version_info_dict["ensembles"] = ensemble_dict if ensemble_dict else None + version_info_dict["ensemble_filters"] = ( + ensemble_filter_dict if ensemble_filter_dict else None + ) + + ########################## + # macros: + # Split off + macros = {el for el in cleaned if el.startswith("macroxyz")} + cleaned -= macros + + param_type_dict = { + "STRING": str, + "FLOAT": float, + "MACRO": str, + "INT": int, + "LONG_INT": int, + "UINT": int, + } + + macros_dict = {} + for el in macros: + split_info = el.split("macroxyz ")[-1].split(" : ") + param_type = split_info[0] + + new_split = "".join(split_info[1:]).split(" is ") + param_name = new_split[0].strip() + param_value = " is ".join(new_split[1:]) + param_value = param_value.strip() + + # print("macro ",param_name,"=",param_value," float?",isfloat(param_value)," int?",isint(param_value)) + + # If we're trying to set the value to "on", check that + # it doesn't already exist. If it does, do nothing, as the + # extra information is better than just "on" + if param_name in macros_dict: + # print("already exists (is ",macros_dict[param_name]," float? ",isfloat(macros_dict[param_name]),", int? ",isint(macros_dict[param_name]),") : check that we can improve it") + if macros_dict[param_name] == "on": + # update with better value + store = True + elif ( + isfloat(macros_dict[param_name]) is False + and isfloat(param_value) is True + ): + # store the number we now have to replace the non-number we had + store = True + else: + # don't override existing number + store = False + + # if store: + # print("Found improved macro value of param",param_name,", was ",macros_dict[param_name],", is",param_value) + # else: + # print("Cannot improve: use old value") + else: + store = True + + if store: + # Sometimes the macros have extra information behind it. + # Needs an update in outputting by binary_c (RGI: what does this mean David???) + try: + macros_dict[param_name] = param_type_dict[param_type](param_value) + except ValueError: + macros_dict[param_name] = str(param_value) + + version_info_dict["macros"] = macros_dict if macros_dict else None + + ########################## + # Elements: + # Split off: + elements = {el for el in cleaned if el.startswith("Element")} + cleaned -= elements + + # Fill dict: + elements_dict = {} + for el in elements: + split_info = el.split("Element ")[-1].split(" : ") + name_info = split_info[0].split(" is ") + + # get isotope info + isotopes = {} + if not split_info[-1][0] == "0": + isotope_string = split_info[-1].split(" = ")[-1] + isotopes = { + int(split_isotope.split("=")[0]): split_isotope.split("=")[1] + for split_isotope in isotope_string.split(" ") + } + + elements_dict[int(name_info[0])] = { + "name": name_info[-1], + "atomic_number": int(name_info[0]), + "amt_isotopes": len(isotopes), + "isotopes": isotopes, + } + version_info_dict["elements"] = elements_dict if elements_dict else None + + ########################## + # dt_limits: + # split off + dt_limits = {el for el in cleaned if el.startswith("DTlimit")} + cleaned -= dt_limits + + # Fill dict + dt_limits_dict = {} + for el in dt_limits: + split_info = el.split("DTlimit ")[-1].split(" : ") + dt_limits_dict[split_info[1].strip()] = { + "index": int(split_info[0]), + "value": float(split_info[-1]), + } + + version_info_dict["dt_limits"] = dt_limits_dict if dt_limits_dict else None + + ############################## + # Units + + units = {el for el in cleaned if el.startswith("Unit ")} + cleaned -= units + units_dict = {} + for el in units: + split_info = el.split("Unit ")[-1].split(",") + s = split_info[0].split(" is ") + + if len(s) == 2: + long, short = [i.strip().strip('"') for i in s] + elif len(s) == 1: + long, short = None, s[0] + else: + print("Warning: Failed to split unit string {}".format(el)) + + to_cgs = (split_info[1].split())[3].strip().strip('"') + code_units = split_info[2].split() + code_unit_type_num = int(code_units[3].strip().strip('"')) + code_unit_type = code_units[4].strip().strip('"') + code_unit_cgs_value = code_units[9].strip().strip('"').strip(")") + units_dict[long] = { + "long": long, + "short": short, + "to_cgs": to_cgs, + "code_unit_type_num": code_unit_type_num, + "code_unit_type": code_unit_type, + "code_unit_cgs_value": code_unit_cgs_value, + } + + # Add the list of units + units = {el for el in cleaned if el.startswith("Units: ")} + cleaned -= units + for el in units: + el = el[7:] # removes "Units: " + units_dict["units list"] = el.strip("Units:") + + version_info_dict["units"] = units_dict + + ########################## + # Nucleosynthesis sources: + # Split off + nucsyn_sources = {el for el in cleaned if el.startswith("Nucleosynthesis")} + cleaned -= nucsyn_sources + + # Fill dict + nucsyn_sources_dict = {} + for el in nucsyn_sources: + split_info = el.split("Nucleosynthesis source")[-1].strip().split(" is ") + nucsyn_sources_dict[int(split_info[0])] = split_info[-1] + + version_info_dict["nucleosynthesis_sources"] = ( + nucsyn_sources_dict if nucsyn_sources_dict else None + ) + + ########################## + # miscellaneous: + # All those that I didn't catch with the above filters. Could try to get some more out though. + + misc_dict = {} + + # Filter out git revision + git_revision = [el for el in cleaned if el.startswith("git revision")] + misc_dict["git_revision"] = ( + git_revision[0].split("git revision ")[-1].replace('"', "") + ) + cleaned -= set(git_revision) + + # filter out git url + git_url = [el for el in cleaned if el.startswith("git URL")] + misc_dict["git_url"] = git_url[0].split("git URL ")[-1].replace('"', "") + cleaned -= set(git_url) + + # filter out version + version = [el for el in cleaned if el.startswith("Version")] + misc_dict["version"] = str(version[0].split("Version ")[-1]) + cleaned -= set(version) + + git_branch = [el for el in cleaned if el.startswith("git branch")] + misc_dict["git_branch"] = ( + git_branch[0].split("git branch ")[-1].replace('"', "") + ) + cleaned -= set(git_branch) + + build = [el for el in cleaned if el.startswith("Build")] + misc_dict["build"] = build[0].split("Build: ")[-1].replace('"', "") + cleaned -= set(build) + + email = [el for el in cleaned if el.startswith("Email")] + misc_dict["email"] = email[0].split("Email ")[-1].split(",") + cleaned -= set(email) + + other_items = {el for el in cleaned if " is " in el} + cleaned -= other_items + + for el in other_items: + split = el.split(" is ") + key = split[0].strip() + val = " is ".join(split[1:]).strip() + if key in misc_dict: + misc_dict[key + " (alt)"] = val + else: + misc_dict[key] = val + + misc_dict["uncaught"] = list(cleaned) + + version_info_dict["miscellaneous"] = misc_dict if misc_dict else None + return version_info_dict + + def minimum_stellar_mass(self): + """ + Function to return the minimum stellar mass (in Msun) from binary_c. + """ + if not self._minimum_stellar_mass: + self._minimum_stellar_mass = self.return_binary_c_version_info(parsed=True)[ + "macros" + ]["BINARY_C_MINIMUM_STELLAR_MASS"] + return self._minimum_stellar_mass diff --git a/binarycpython/utils/run_system_wrapper.py b/binarycpython/utils/run_system_wrapper.py index 51559f62c95101fdf2d83577cf8d1fccf303ba23..b222b85ae34f55b4478216071b7b2df4253b5585 100644 --- a/binarycpython/utils/run_system_wrapper.py +++ b/binarycpython/utils/run_system_wrapper.py @@ -28,8 +28,8 @@ def run_system(**kwargs): - run_system(M_1=10, parse_function=fancy_parsing_function) Tasks: - - TODO: Expand functionality. - TODO: Notify user when an unknown keyword is passed. + - TODO: Centralise the input checking routines here, abstract them and have the population object and this one use the same All the arguments known to binary_c can be passed to this function as kwargs. Several extra arguments can be passed through the kwargs: @@ -65,19 +65,18 @@ def run_system(**kwargs): binary_c_args = {} # Check which binary_c arguments have been passed and put them into a dict - for key in kwargs: + for key, value in kwargs.items(): if key in available_binary_c_arg_keywords: - binary_c_args[key] = kwargs[key] + binary_c_args[key] = value elif any( - [ - True - if (key.startswith(param[:-2]) and len(param[:-2]) < len(key)) - else False - for param in special_keywords - ] + bool((key.startswith(param[:-2]) and len(param[:-2]) < len(key))) + # True + # if (key.startswith(param[:-2]) and len(param[:-2]) < len(key)) + # else False + for param in special_keywords ): - binary_c_args[key] = kwargs[key] + binary_c_args[key] = value # Notify user when this key wont be used else: diff --git a/binarycpython/utils/spacing_functions.py b/binarycpython/utils/spacing_functions.py deleted file mode 100644 index ac4b7554e9354d491dec9fa92c90c49a76d8db72..0000000000000000000000000000000000000000 --- a/binarycpython/utils/spacing_functions.py +++ /dev/null @@ -1,399 +0,0 @@ -""" -Module containing the spacing functions for the binarycpython package. Very under-populated at the moment, but more are likely to come soon - -Tasks: - TODO: add more spacing functions to this module. -""" - -from typing import Union -import functools -import math -import numpy as np -import py_rinterpolate -import sys -from binarycpython.utils.grid import Population - - -@functools.lru_cache(maxsize=16) -def const( - min_bound: Union[int, float], max_bound: Union[int, float], steps: int -) -> list: - """ - Samples a range linearly. Uses numpy linspace. - - Args: - min_bound: lower bound of range - max_bound: upper bound of range - steps: number of segments between min_bound and max_bound - - Returns: - np.linspace(min_bound, max_bound, steps+1) - """ - return np.linspace(min_bound, max_bound, steps + 1) - - -############################################################ -@functools.lru_cache(maxsize=16) -def const_ranges(ranges) -> list: - """ - Samples a series of ranges linearly. - - Args: - ranges: a tuple of tuples passed to the const() spacing function. - - Returns: - numpy array of masses - - Example: - The following allocates 10 stars between 0.1 and 0.65, 20 stars between 0.65 - and 0.85, and 10 stars between 0.85 and 10.0 Msun. - - samplerfunc="const_ranges((({},{},{}),({},{},{}),({},{},{})))".format( - 0.1,0.65,10, - 0.65,0.85,20, - 0.85,10.0,10 - ), - - """ - - masses = np.empty(0) - for range in ranges: - masses = np.append(masses, const(*range)) - return np.unique(masses) - - -############################################################ -def peak_normalized_gaussian_func( - x: Union[int, float], mean: Union[int, float], sigma: Union[int, float] -) -> Union[int, float]: - """ - Function to evaluate a Gaussian at a given point, note - that the normalization is such that the peak is always 1.0, - not that the integral is 1.0 - - Args: - x: location at which to evaluate the distribution - mean: mean of the Gaussian - sigma: standard deviation of the Gaussian - - Returns: - value of the Gaussian at x - """ - gaussian_prefactor = 1.0 # / math.sqrt(2.0 * math.pi) - - r = 1.0 / sigma - y = (x - mean) * r - return math.exp(-0.5 * y ** 2) - - -############################################################ -@functools.lru_cache(maxsize=16) -def gaussian_zoom( - min_bound: Union[int, float], - max_bound: Union[int, float], - zoom_mean: Union[int, float], - zoom_dispersion: Union[int, float], - zoom_magnitude: Union[int, float], - steps: int, -) -> list: - """ - Samples such that a region is zoomed in according to a 1-Gaussian function - - Args: - min_bound: lower bound of range - max_bound: upper bound of range - zoom_mean: mean of the Gaussian zoom location - zoom_dispersion: dispersion of the Gaussian - zoom_magnitude: depth of the Gaussian (should be 0<= zoom_magntiude <1) - steps: number of segments between min_bound and max_bound assuming a linear step - this is what you'd normally call "resolution" - - Returns: - Numpy array of sample values - """ - - # linear spacing: this is what we'd have - # in the absence of a Gaussian zoom - linear_spacing = (max_bound - min_bound) / (steps - 1) - - # make the list of values - x = min_bound - array = np.array([]) - while x <= max_bound: - array = np.append(array, x) - g = peak_normalized_gaussian_func(x, zoom_mean, zoom_dispersion) - f = 1.0 - zoom_magnitude * g - dx = linear_spacing * f - x = x + dx - - # force the last array member to be max_bound if it's not - if array[-1] != max_bound: - array[-1] = max_bound - - return np.unique(array) - - -@functools.lru_cache(maxsize=16) -def const_dt( - self, - dt=1000.0, - dlogt=0.1, - mmin=0.07, - mmax=100.0, - nres=1000, - logspacing=False, - tmin=3.0, # start at 3Myr - tmax=None, # use max_evolution_time by default - mindm=None, # tuple of tuples - maxdm=((0.07, 1.0, 0.1), (1.0, 300.0, 1.0)), # tuple of tuples - fsample=1.0, - factor=1.0, - logmasses=False, - log10masses=False, - showlist=False, - showtable=False, -): - """ - const_dt returns a list of masses spaced at a constant age difference - - Args: - dt: the time difference between the masses (1000.0 Myr, used when logspacing==False) - dlogt : the delta log10(time) difference between masses (0.1 dex, used when logspacing==True) - mmin: the minimum mass to be considered in the stellar lifetime interpolation table (0.07 Msun) - mmax: the maximum mass to be considered in the stellar lifetime interpolation table (100.0 Msun) - nres: the resolution of the stellar lifetime interpolation table (100) - logspacing: whether to use log-spaced time, in which case dt is actually d(log10(t)) - tmin: the minimum time to consider (Myr, default 3.0 Myr) - tmax: the maximum time to consider (Myr, default None which means we use the grid option 'max_evolution_time') - mindm: a tuple of tuples containing a mass range and minimum mass spacing in that range. The default is ((0.07,1.0,0.1),(1.0,300.0,1.0)) allocated a minimum dm of 0.1Msun in the mass range 0.07 to 1.0 Msun and 1.0Msun in the range 1.0 to 300.0 Msun. Anything you set overrides this. Note, if you use only one tuple, you must set it with a trailing comma, thus, e.g. ((0.07,1.0,0.1),). (default None) - maxdm: a list of tuples similar to mindm but specifying a maximum mass spacing. In the case of maxdm, if the third option in each tuple is negative it is treated as a log step (its absolute value is used as the step). (default None) - fsample: a global sampling (Shannon-like) factor (<1) to improve resolution (default 1.0, set to smaller to improve resolution) - factor: all masses generated are multiplied by this after generation - showtable: if True, the mass list and times are shown to stdout after generation - showlist: if True, show the mass list once generated - logmasses: if True, the masses are logged with math.log() - log10masses: if True, the masses are logged with math.log10() - - Returns: - Array of masses. - - Example: - # these are lines set as options to Population.add_grid_value(...) - - # linear time bins of 1Gyr - samplerfunc="const_dt(self,dt=1000,nres=100,mmin=0.07,mmax=2.0,showtable=True)" - - # logarithmic spacing in time, generally suitable for Galactic - # chemical evolution yield grids. - samplerfunc="const_dt(self,dlogt=0.1,nres=100,mmin=0.07,mmax=80.0,maxdm=((0.07,1.0,0.1),(1.0,10.0,1.0),(10.0,80.0,2.0)),showtable=True,logspacing=True,fsample=1.0/4.0)" - - """ - - # first, make a stellar lifetime table - # - # we should use the bse_options from self - # so our lifetime_population uses the same physics - lifetime_population = Population() - lifetime_population.bse_options = dict(self.bse_options) - - # we only want to evolve the star during nuclear burning, - # we don't want a dry run of the grid - # we want to use the right number of CPU cores - lifetime_population.set( - do_dry_run=False, - num_cores=self.grid_options["num_cores"], - max_stellar_type_1=10, - save_ensemble_chunks=False, - ) - - # make a grid in M1 - lifetime_population.add_grid_variable( - name="lnM_1", - parameter_name="M_1", - longname="log Primary mass", # == single-star mass - valuerange=[math.log(mmin), math.log(mmax)], - samplerfunc="const(math.log({mmin}),math.log({mmax}),{nres})".format( - mmin=mmin, mmax=mmax, nres=nres - ), - probdist="1", # dprob/dm1 : we don't care, so just set it to 1 - dphasevol="dlnM_1", - precode="M_1=math.exp(lnM_1)", - condition="", # Impose a condition on this grid variable. Mostly for a check for yourself - gridtype="edge", - ) - - # set up the parse function - def _parse_function(self, output): - if output: - for line in output.splitlines(): - data = line.split() - if data[0] == "SINGLE_STAR_LIFETIME": - # append (log10(mass), log10(lifetime)) tuples - logm = math.log10(float(data[1])) - logt = math.log10(float(data[2])) - # print(line) - # print("logM=",logm,"M=",10.0**logm," -> logt=",logt) - self.grid_results["interpolation table m->t"][logm] = logt - self.grid_results["interpolation table t->m"][logt] = logm - - lifetime_population.set( - parse_function=_parse_function, - ) - - # run to build the interpolation table - print("Running population to make lifetime interpolation table, please wait") - lifetime_population.evolve() - # print("Data table",lifetime_population.grid_results['interpolation table t->m']) - - # convert to nested lists for the interpolator - # - # make time -> mass table - data_table_time_mass = [] - times = sorted(lifetime_population.grid_results["interpolation table t->m"].keys()) - for time in times: - mass = lifetime_population.grid_results["interpolation table t->m"][time] - # we have to make sure the time is monotonic (not guaranteed at high mass) - if len(data_table_time_mass) == 0: - data_table_time_mass.append([time, mass]) - elif mass < data_table_time_mass[-1][1]: - data_table_time_mass.append([time, mass]) - - # make mass -> time table - data_table_mass_time = [] - masses = sorted(lifetime_population.grid_results["interpolation table m->t"].keys()) - for mass in masses: - time = lifetime_population.grid_results["interpolation table m->t"][mass] - data_table_mass_time.append([mass, time]) - - # set up interpolators - interpolator_time_mass = py_rinterpolate.Rinterpolate( - table=data_table_time_mass, nparams=1, ndata=1, verbosity=0 # mass # lifetime - ) - interpolator_mass_time = py_rinterpolate.Rinterpolate( - table=data_table_mass_time, nparams=1, ndata=1, verbosity=0 # lifetime # mass - ) - - # function to get a mass given a time (Myr) - def _mass_from_time(linear_time): - return 10.0 ** interpolator_time_mass.interpolate([math.log10(linear_time)])[0] - - # function to get a time given a mass (Msun) - def _time_from_mass(mass): - return 10.0 ** interpolator_mass_time.interpolate([math.log10(mass)])[0] - - # return a unique list - def _uniq(_list): - return sorted(list(set(_list))) - - # format a whole list like %g - def _format(_list): - return [float("{x:g}".format(x=x)) for x in _list] - - # construct mass list, always include the min and max - mass_list = [mmin, mmax] - - # first, make sure the stars are separated by only - # maxdm - if maxdm: - for x in maxdm: - range_min = x[0] - range_max = x[1] - dm = x[2] - if dm < 0.0: - # use log scale - dlogm = -dm - logm = math.log(mmin) - logmmax = math.log(mmax) - logrange_min = math.log(range_min) - logrange_max = math.log(range_max) - while logm <= logmmax: - if logm >= logrange_min and logm <= logrange_max: - mass_list.append(math.exp(logm)) - logm += dlogm - else: - # use linear scale - m = mmin - while m <= mmax: - if m >= range_min and m <= range_max: - mass_list.append(m) - m += dm - - # start time loop at tmax or max_evolution_time - t = tmax if tmax else self.bse_options["max_evolution_time"] - - # set default mass list - if logspacing: - logt = math.log10(t) - logtmin = math.log10(tmin) - while logt > logtmin: - m = _mass_from_time(10.0 ** logt) - mass_list.append(m) - logt = max(logtmin, logt - dlogt * fsample) - else: - while t > tmin: - m = _mass_from_time(t) - mass_list.append(m) - t = max(tmin, t - dt * fsample) - - # make mass list unique - mass_list = _uniq(mass_list) - - if mindm: - for x in mindm: - range_min = x[0] - range_max = x[1] - mindm = x[2] - # impose a minimum dm: if two masses in the list - # are separated by < this, remove the second - for index, mass in enumerate(mass_list): - if index > 0 and mass >= range_min and mass <= range_max: - dm = mass_list[index] - mass_list[index - 1] - if dm < mindm: - mass_list[index - 1] = 0.0 - mass_list = _uniq(mass_list) - if mass_list[0] == 0.0: - mass_list.remove(0.0) - - # apply multiplication factor if given - if factor and factor != 1.0: - mass_list = [m * factor for m in mass_list] - - # reformat numbers - mass_list = _format(mass_list) - - # show the mass<>time table? - if showtable: - twas = 0.0 - logtwas = 0.0 - for i, m in enumerate(mass_list): - t = _time_from_mass(m) - logt = math.log10(t) - if twas > 0.0: - print( - "{i:4d} m={m:13g} t={t:13g} log10(t)={logt:13g} dt={dt:13g} dlog10(t)={dlogt:13g}".format( - i=i, m=m, t=t, logt=logt, dt=twas - t, dlogt=logtwas - logt - ) - ) - else: - print( - "{i:4d} m={m:13g} t={t:13g} log10(t)={logt:13g}".format( - i=i, m=m, t=t, logt=logt - ) - ) - twas = t - logtwas = logt - exit() - - # return the mass list as a numpy array - mass_list = np.unique(np.array(mass_list)) - - # perhaps log the masses - if logmasses: - mass_list = np.log(mass_list) - if log10masses: - mass_list = np.log10(mass_list) - - if showlist: - print("const_dt mass list ({} masses)\n".format(len(mass_list)), mass_list) - - return mass_list diff --git a/binarycpython/utils/useful_funcs.py b/binarycpython/utils/useful_funcs.py index 546d8b9c75d41463a61504706f9baa141b7f3a06..95c6eabab1ea7991b8876d621ba57198e7dd8672 100644 --- a/binarycpython/utils/useful_funcs.py +++ b/binarycpython/utils/useful_funcs.py @@ -9,14 +9,13 @@ Functions: - rzams(m, z) gives you the ZAMS radius of a star - ZAMS_collision(m1, m2, e, sep, z) returns 1 if stars collide on the ZAMS - roche_lobe(q): returns roche lobe radius in units of separation - - ragb(m, z): radius at first thermal pulse + - ragb(m): radius at first thermal pulse - minimum_period_for_RLOF(M1, M2, metallicity, store_memaddr=-1): function to calculate the minimum period that leads to RLOF on ZAMS - minimum_separation_for_RLOF(M1, M2, metallicity, store_memaddr=-1): function to calculate the minimum period that leads to RLOF on ZAMS - maximum_mass_ratio_for_RLOF(M1, orbital_period, store_memaddr=None): Function to calculate the maximum mass ratio that leads to RLOF on ZAMS Tasks: - TODO: check whether these functions are correct - - TODO: add unit test for maximum_mass_ratio_for_RLOF """ import math @@ -204,11 +203,11 @@ def roche_lobe(q: Union[int, float]) -> Union[int, float]: return 0.49 * p * p / (0.6 * p * p + math.log(1.0 + p)) -def ragb(m: Union[int, float], z: Union[int, float]) -> Union[int, float]: +def ragb(m: Union[int, float]) -> Union[int, float]: """ Function to calculate radius of a star in units of solar radii at first thermal pulse as a function of mass (Z=0.02 only, but also good for Z=0.0001) - TODO: ask rob about this function + TODO: ask rob about this function. Do we still need this? Can we make something better? (i.e. upon installation of the code run a grid of systems and get the data from there?) Args: m: mass of star in units of solar mass diff --git a/generate_docs.sh b/commands/generate_docs.sh similarity index 70% rename from generate_docs.sh rename to commands/generate_docs.sh index 111ee2f7762b5dd6fd5cebdda76e703d509b5618..af952955d5f3b139081f71bb891f94e6b6d82ada 100755 --- a/generate_docs.sh +++ b/commands/generate_docs.sh @@ -1,13 +1,18 @@ #!/bin/bash - # Script to generate the docs + +# NAME_CURRENT_FILE="`realpath \"$0\"`" DIRNAME_CURRENT_FILE=$(dirname $NAME_CURRENT_FILE) -DOCS_DIR="$DIRNAME_CURRENT_FILE/docs/" +DIRNAME_PROJECT_ROOT=$(dirname $DIRNAME_CURRENT_FILE) +# +DOCS_DIR="$DIRNAME_PROJECT_ROOT/docs/" +# # echo "$NAME_CURRENT_FILE" # echo "$DIRNAME_CURRENT_FILE" +# echo "$DIRNAME_PROJECT_ROOT" # echo "$DOCS_DIR" # Generate docs diff --git a/generate_reports.sh b/commands/generate_reports.sh similarity index 84% rename from generate_reports.sh rename to commands/generate_reports.sh index 627b6867ae3171764a04f4a8aff65494619eada3..5c3e7ef862fde155919fd939ed505a6cce5cf483 100755 --- a/generate_reports.sh +++ b/commands/generate_reports.sh @@ -1,15 +1,20 @@ #!/bin/bash - # Script to generate the docstring coverage + +# NAME_CURRENT_FILE="`realpath \"$0\"`" DIRNAME_CURRENT_FILE=$(dirname $NAME_CURRENT_FILE) -TESTS_DIR="$DIRNAME_CURRENT_FILE/binarycpython/tests" -REPORTS_DIR="$DIRNAME_CURRENT_FILE/reports" -BADGE_DIR="$DIRNAME_CURRENT_FILE/badges" +DIRNAME_PROJECT_ROOT=$(dirname $DIRNAME_CURRENT_FILE) # +TESTS_DIR="$DIRNAME_PROJECT_ROOT/binarycpython/tests" +REPORTS_DIR="$DIRNAME_PROJECT_ROOT/reports" +BADGE_DIR="$DIRNAME_PROJECT_ROOT/badges" + + # echo "$NAME_CURRENT_FILE" # echo "$DIRNAME_CURRENT_FILE" +# echo "$DIRNAME_PROJECT_ROOT" # echo "$TESTS_DIR" # echo "$REPORTS_DIR" # echo "$BADGE_DIR" @@ -39,6 +44,6 @@ cd $TEST_COV_DIR coverage run --source=binarycpython "$TESTS_DIR/main.py" coverage html coverage-badge > "$TEST_COV_DIR/test_coverage.svg" -cd $DIRNAME_CURRENT_FILE +cd $DIRNAME_PROJECT_ROOT cp "$TEST_COV_DIR/test_coverage.svg" "$BADGE_DIR/test_coverage.svg" -echo "Done" \ No newline at end of file +echo "Done" diff --git a/install_with_pip.sh b/commands/install_with_pip.sh similarity index 77% rename from install_with_pip.sh rename to commands/install_with_pip.sh index 01b88a2af98a9fd65a83f106a04a628319557a7b..c00e27d5e29401fc30c0ce48dca867512474fc95 100755 --- a/install_with_pip.sh +++ b/commands/install_with_pip.sh @@ -1,4 +1,5 @@ #!/bin/bash +# NOTE: this script needs revision. Does not work properly currently # Script to install binarycpython in the current venv using the pip commands @@ -9,4 +10,4 @@ echo "installing binarcpython version $VERSION_NUMBER" # pip uninstall binarycpython # python setup.py build --force # python setup.py sdist -pip install -v . \ No newline at end of file +pip install -v . diff --git a/install_with_pip_without_dependencies.sh b/commands/install_with_pip_without_dependencies.sh similarity index 82% rename from install_with_pip_without_dependencies.sh rename to commands/install_with_pip_without_dependencies.sh index 798c5c9521a88e56cbf66f9f5be4ff699e64ed91..db28e679de5f3511872251375e88091fa6355cd5 100755 --- a/install_with_pip_without_dependencies.sh +++ b/commands/install_with_pip_without_dependencies.sh @@ -1,4 +1,5 @@ #!/bin/bash +# NOTE: this script needs revision. Does not work properly currently # Script to install binarycpython in the current venv using the pip commands diff --git a/commands/install_without_dependencies.sh b/commands/install_without_dependencies.sh new file mode 100755 index 0000000000000000000000000000000000000000..bfabd775d161bc5bc6436f10fc68c204531222e5 --- /dev/null +++ b/commands/install_without_dependencies.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# NOTE: this script needs revision. Does not work properly currently + +# Script to install binarycpython in the current venv +VERSION_NUMBER=$(cat "VERSION") +echo "installing binarcpython version $VERSION_NUMBER" + +# Clean up all the stuff from before +python setup.py clean --all + +# Go into a directory that doesnt contain 'binarycpython' so pip will uninstall the one in the venv, not the local one. +cd src +pip uninstall -y binarycpython +cd ../ + +# Create build, sdist and install it into the venv +python setup.py build --force +python setup.py sdist +pip install --ignore-installed --no-dependencies -v dist/binarycpython-$VERSION_NUMBER.tar.gz diff --git a/upload_to_pypi.sh b/commands/upload_to_pypi.sh similarity index 89% rename from upload_to_pypi.sh rename to commands/upload_to_pypi.sh index db8bb43d3ed5f702c3e78529df10800a5b891936..227ff46a8945b82c9694940733030c4d0f2c6fc3 100755 --- a/upload_to_pypi.sh +++ b/commands/upload_to_pypi.sh @@ -1,4 +1,5 @@ #!/bin/bash +# NOTE: this script needs revision. Does not work properly currently # Get current version VERSION_NUMBER=$(cat "VERSION") diff --git a/development_requirements.txt b/development_requirements.txt index 4f93d477aed1b6d0d997d745f0c2334e77ea70bf..a3f69b0a43f1e4ee9a73e23ef1e0924ad271a079 100644 --- a/development_requirements.txt +++ b/development_requirements.txt @@ -4,3 +4,10 @@ sphinx sphinx_autodoc_typehints nbsphinx twine +docstr-coverage +coverage +coverage-badge +hawkmoth +clang +sphinx_rtd_theme +ipython diff --git a/docs/build/doctrees/binary_c_parameters.doctree b/docs/build/doctrees/binary_c_parameters.doctree index c39633c98a36fb807e0f542f94243b89ea89b411..ea119159cba8648e00796f867bea340c973657f3 100644 Binary files a/docs/build/doctrees/binary_c_parameters.doctree and b/docs/build/doctrees/binary_c_parameters.doctree differ diff --git a/docs/build/doctrees/custom_logging_functions.doctree b/docs/build/doctrees/custom_logging_functions.doctree index 2cf586ba5669b3fe96e8c9ae909ccfa1d1472fed..2c517641cdd46769c9f1e070f541e2c5504c7acf 100644 Binary files a/docs/build/doctrees/custom_logging_functions.doctree and b/docs/build/doctrees/custom_logging_functions.doctree differ diff --git a/docs/build/doctrees/dicts.doctree b/docs/build/doctrees/dicts.doctree new file mode 100644 index 0000000000000000000000000000000000000000..73bd9dfdef3d9d15b888a15661d1b042d210652a Binary files /dev/null and b/docs/build/doctrees/dicts.doctree differ diff --git a/docs/build/doctrees/distribution_functions.doctree b/docs/build/doctrees/distribution_functions.doctree deleted file mode 100644 index 9953ca2339213e87b3a6ba7bea23112617031650..0000000000000000000000000000000000000000 Binary files a/docs/build/doctrees/distribution_functions.doctree and /dev/null differ diff --git a/docs/build/doctrees/ensemble.doctree b/docs/build/doctrees/ensemble.doctree new file mode 100644 index 0000000000000000000000000000000000000000..aca01ab77a30e8aa5d169a896169808212d81c2c Binary files /dev/null and b/docs/build/doctrees/ensemble.doctree differ diff --git a/docs/build/doctrees/environment.pickle b/docs/build/doctrees/environment.pickle index 6936a688243b5c6336584da003271108ce29cdca..4033797eae174a13a45ac3c3f9773bed7e6a1bba 100644 Binary files a/docs/build/doctrees/environment.pickle and b/docs/build/doctrees/environment.pickle differ diff --git a/docs/build/doctrees/example_notebooks.doctree b/docs/build/doctrees/example_notebooks.doctree index 0ab96e4a2d0c0f64d340eab011927aef5793ad2d..96a34cd089374ce7525c733a4bef83b68fbd4d35 100644 Binary files a/docs/build/doctrees/example_notebooks.doctree and b/docs/build/doctrees/example_notebooks.doctree differ diff --git a/docs/build/doctrees/examples/notebook_BHBH.doctree b/docs/build/doctrees/examples/notebook_BHBH.doctree index 87d1089f58c156d520f02167f2953443b0c2a5a2..49899739ffbd1bb76a33b0b39006368bade0a0a8 100644 Binary files a/docs/build/doctrees/examples/notebook_BHBH.doctree and b/docs/build/doctrees/examples/notebook_BHBH.doctree differ diff --git a/docs/build/doctrees/examples/notebook_HRD.doctree b/docs/build/doctrees/examples/notebook_HRD.doctree index 926ff29530b8a05ae9ffea69e1eb488ceaa229e3..b347b8f2e26d56d726c438e6781076b664b9b85a 100644 Binary files a/docs/build/doctrees/examples/notebook_HRD.doctree and b/docs/build/doctrees/examples/notebook_HRD.doctree differ diff --git a/docs/build/doctrees/examples/notebook_api_functionality.doctree b/docs/build/doctrees/examples/notebook_api_functionality.doctree index 684826e9184082c3149350b122c147becd697e78..a1d3f569f8bc392d28b99424594928f3bcf22042 100644 Binary files a/docs/build/doctrees/examples/notebook_api_functionality.doctree and b/docs/build/doctrees/examples/notebook_api_functionality.doctree differ diff --git a/docs/build/doctrees/examples/notebook_common_envelope_evolution.doctree b/docs/build/doctrees/examples/notebook_common_envelope_evolution.doctree index c5b8bc5085038a43018ddf8f5871fdafa5632c42..8bf5430bfdf30e2441f00c7db843f14fecbf1b2f 100644 Binary files a/docs/build/doctrees/examples/notebook_common_envelope_evolution.doctree and b/docs/build/doctrees/examples/notebook_common_envelope_evolution.doctree differ diff --git a/docs/build/doctrees/examples/notebook_custom_logging.doctree b/docs/build/doctrees/examples/notebook_custom_logging.doctree index d64124b4407bff166a9c6d2377d0dca16050b9e5..3f1c382b2c59a7aaf072f51b8bb5491a7dff45e5 100644 Binary files a/docs/build/doctrees/examples/notebook_custom_logging.doctree and b/docs/build/doctrees/examples/notebook_custom_logging.doctree differ diff --git a/docs/build/doctrees/examples/notebook_ensembles.doctree b/docs/build/doctrees/examples/notebook_ensembles.doctree new file mode 100644 index 0000000000000000000000000000000000000000..1507d4df753754be784e95396a465d4b0eaeab0b Binary files /dev/null and b/docs/build/doctrees/examples/notebook_ensembles.doctree differ diff --git a/docs/build/doctrees/examples/notebook_extra_features.doctree b/docs/build/doctrees/examples/notebook_extra_features.doctree index f61a55866eb232d41c7e0071ce1582a46c42dbf5..ff9995732e568d0a968a65cccf17c5772c88b56f 100644 Binary files a/docs/build/doctrees/examples/notebook_extra_features.doctree and b/docs/build/doctrees/examples/notebook_extra_features.doctree differ diff --git a/docs/build/doctrees/examples/notebook_individual_systems.doctree b/docs/build/doctrees/examples/notebook_individual_systems.doctree index e67858541c311d86f97d1371dafa52a3963d287f..1d42db911dfab0b6e7a9fe4ff516a610666910ec 100644 Binary files a/docs/build/doctrees/examples/notebook_individual_systems.doctree and b/docs/build/doctrees/examples/notebook_individual_systems.doctree differ diff --git a/docs/build/doctrees/examples/notebook_luminosity_function_binaries.doctree b/docs/build/doctrees/examples/notebook_luminosity_function_binaries.doctree index 53566badc2f81499d9a727d25450ddd668e39d85..0c75e5f9f46ca5b3e28063345806a8145f829f70 100644 Binary files a/docs/build/doctrees/examples/notebook_luminosity_function_binaries.doctree and b/docs/build/doctrees/examples/notebook_luminosity_function_binaries.doctree differ diff --git a/docs/build/doctrees/examples/notebook_luminosity_function_single.doctree b/docs/build/doctrees/examples/notebook_luminosity_function_single.doctree index ea877efa9980675d64db311a5be47cdbeaae2ebc..20f3e55a10a47b90967f2e0d33e517cd44006ad3 100644 Binary files a/docs/build/doctrees/examples/notebook_luminosity_function_single.doctree and b/docs/build/doctrees/examples/notebook_luminosity_function_single.doctree differ diff --git a/docs/build/doctrees/examples/notebook_massive_remnants.doctree b/docs/build/doctrees/examples/notebook_massive_remnants.doctree index b4ab5e7ae17cd0d2675f4966a58b794ed723bb92..1b014e5877a7766dc85a44b7fe33a673438e7620 100644 Binary files a/docs/build/doctrees/examples/notebook_massive_remnants.doctree and b/docs/build/doctrees/examples/notebook_massive_remnants.doctree differ diff --git a/docs/build/doctrees/examples/notebook_population.doctree b/docs/build/doctrees/examples/notebook_population.doctree index 0305266b6d228df0f843644d247d6a9a7930e940..324baf9bdf19aa7cb2698c96905eff11b648fc95 100644 Binary files a/docs/build/doctrees/examples/notebook_population.doctree and b/docs/build/doctrees/examples/notebook_population.doctree differ diff --git a/docs/build/doctrees/examples/notebook_solar_system.doctree b/docs/build/doctrees/examples/notebook_solar_system.doctree index 56c3375ce9c83cbcb3e6f93e97283c2061c596e3..5eda105c54773162bb3917d21de69469636ae7dc 100644 Binary files a/docs/build/doctrees/examples/notebook_solar_system.doctree and b/docs/build/doctrees/examples/notebook_solar_system.doctree differ diff --git a/docs/build/doctrees/examples/old/basic_example.doctree b/docs/build/doctrees/examples/old/basic_example.doctree index 63c9b29f85a533e1fb840314daa3a24e8039fd88..298c401abed0b2b7c113fecac31b2486913a7d08 100644 Binary files a/docs/build/doctrees/examples/old/basic_example.doctree and b/docs/build/doctrees/examples/old/basic_example.doctree differ diff --git a/docs/build/doctrees/examples/old/workshop_example_notebook.doctree b/docs/build/doctrees/examples/old/workshop_example_notebook.doctree index a3b9462409aeda6860fb26ddfeec3446f72723e4..b5a25bff62dde63b58b08fa4fe6f7e4a6d65ee7f 100644 Binary files a/docs/build/doctrees/examples/old/workshop_example_notebook.doctree and b/docs/build/doctrees/examples/old/workshop_example_notebook.doctree differ diff --git a/docs/build/doctrees/functions.doctree b/docs/build/doctrees/functions.doctree index 259e486b3671fb0d37a1f68e4c3921ecda42ca81..22e36022d016e2936aaaa79a8515727e001aad6f 100644 Binary files a/docs/build/doctrees/functions.doctree and b/docs/build/doctrees/functions.doctree differ diff --git a/docs/build/doctrees/grid.doctree b/docs/build/doctrees/grid.doctree index 079027dc5bf4fb8475751d8f3101f793f226e73b..d5b59734b33c2904d9cf0e0cab343b630255c8c5 100644 Binary files a/docs/build/doctrees/grid.doctree and b/docs/build/doctrees/grid.doctree differ diff --git a/docs/build/doctrees/grid_options_defaults.doctree b/docs/build/doctrees/grid_options_defaults.doctree deleted file mode 100644 index 88a3e5bb5df55e3626dcad647d2017461848ad32..0000000000000000000000000000000000000000 Binary files a/docs/build/doctrees/grid_options_defaults.doctree and /dev/null differ diff --git a/docs/build/doctrees/grid_options_descriptions.doctree b/docs/build/doctrees/grid_options_descriptions.doctree index 7db237f861daea53cce725eef02c55680e3f14c3..bda4b2f9376dafcecfbd2c7998177cd056c08e4d 100644 Binary files a/docs/build/doctrees/grid_options_descriptions.doctree and b/docs/build/doctrees/grid_options_descriptions.doctree differ diff --git a/docs/build/doctrees/hpc_functions.doctree b/docs/build/doctrees/hpc_functions.doctree deleted file mode 100644 index 20382401584393647d2ff617d3a41467bc5ac240..0000000000000000000000000000000000000000 Binary files a/docs/build/doctrees/hpc_functions.doctree and /dev/null differ diff --git a/docs/build/doctrees/index.doctree b/docs/build/doctrees/index.doctree index fb94731c24a523515ee4672bf486e210db46eac2..f2b6238237316b5831e8933238b916756bf62080 100644 Binary files a/docs/build/doctrees/index.doctree and b/docs/build/doctrees/index.doctree differ diff --git a/docs/build/doctrees/modules.doctree b/docs/build/doctrees/modules.doctree index a3a49172753426fe960a5fec4d10be45e2be407a..11585987b1979afcd675a57eaca1c63fa0bdbd83 100644 Binary files a/docs/build/doctrees/modules.doctree and b/docs/build/doctrees/modules.doctree differ diff --git a/docs/build/doctrees/nbsphinx/examples/notebook_api_functionality.ipynb b/docs/build/doctrees/nbsphinx/examples/notebook_api_functionality.ipynb index 504ae4b16880946428716c496c81cbf82eea63a8..49d6f8d3db7beacc8770e2b86b21b4636bbf8e7a 100644 --- a/docs/build/doctrees/nbsphinx/examples/notebook_api_functionality.ipynb +++ b/docs/build/doctrees/nbsphinx/examples/notebook_api_functionality.ipynb @@ -105,7 +105,7 @@ " Function that contains random snippets. Do not expect this to remain available, or reliable. i.e. dont use it.\n", "\n", "FILE\n", - " /home/izzard/.local/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so\n", + " /home/david/.pyenv/versions/binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so\n", "\n", "\n" ] @@ -166,7 +166,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "<capsule object \"STORE\" at 0x146f912dbc60>\n", + "<capsule object \"STORE\" at 0x7fc1f0c3ff00>\n", "SINGLE_STAR_LIFETIME 10 28.4838\n", "\n" ] @@ -270,586 +270,13 @@ "M_2 : The initial mass of star two (in solar units, internally this is star index 1). : (null)\n", "M_3 : The initial mass of star three (in solar units, internally this is star index 2). : (null)\n", "M_4 : The initial mass of star four (in solar units, internally this is star index 3). : (null)\n", - "vrot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot2,3,4. : (null)\n", - "vrot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,3,4. : (null)\n", - "vrot3 : The initial equatorial rotational velocity of star three (in km/s, internally this is star index 2). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,4. : (null)\n", - "vrot4 : The initial equatorial rotational velocity of star four (in km/s, internally this is star index 3). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,3. : (null)\n", - "Prot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). See also Prot2,3,4. : (null)\n", - "Prot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). See also Prot1,3,4. : (null)\n", - "Prot3 : The initial equatorial rotational period of star three (in days, internally this is star index 2). See also Prot1,2,4. : (null)\n", - "Prot4 : The initial equatorial rotational period of star four (in days, internally this is star index 3). See also Prot1,2,3. : (null)\n", - "inclination1 : The initial inclination of star one (in degrees). : (null)\n", - "inclination2 : The initial inclination of star two (in degrees). : (null)\n", - "inclination3 : The initial inclination of star three (in degrees). : (null)\n", - "inclination4 : The initial inclination of star four (in degrees). : (null)\n", - "B_1 : The initial magnetic field of star one (in Gauss, internally this is star index 0). : (null)\n", - "B_2 : The initial magnetic field of star two (in Gauss, internally this is star index 1). : (null)\n", - "B_3 : The initial magnetic field of star three (in Gauss, internally this is star index 2). : (null)\n", - "B_4 : The initial magnetic field of star four (in Gauss, internally this is star index 3). : (null)\n", - "B_inclination1 : The initial inclination of the magnetic field of star one (in degrees). : (null)\n", - "B_inclination2 : The initial inclination of the magnetic field of star two (in degrees). : (null)\n", - "B_inclination3 : The initial inclination of the magnetic field of star three (in degrees). : (null)\n", - "B_inclination4 : The initial inclination of the magnetic field of star four (in degrees). : (null)\n", - "stellar_type_1 : Set the stellar type of star 1 (internal index 0), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_2 : Set the stellar type of star 2 (internal index 1), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_3 : Set the stellar type of star 3 (internal index 2), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_4 : Set the stellar type of star 4 (internal index 3), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "max_stellar_type_1 : The maximum stellar type of star 1 (internal index 0). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value. \n", - " : (null)\n", - "max_stellar_type_2 : The maximum stellar type of star 2 (internal index 1). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "max_stellar_type_3 : The maximum stellar type of star 3 (internal index 2). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "max_stellar_type_4 : The maximum stellar type of star 4 (internal index 3). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "probability : The probability is a weighting applied to the star based on, say, the initial mass function. When running a grid of stars to simulate *all* stars, the summed probability of all the stars should be 1.0. : (null)\n", - "phasevol : The system's phase volume, used by binary_grid. : (null)\n", - "stellar_structure_algorithm : Set the stellar structure algorithm. 0=modified BSE (default), 1=none, 2=external function (must be defined by the calling code), 3=binary_c (not yet implemented). : (null)\n", - "solver : The type of solver. Default is the Forward-Euler (0), but could be RK2 (1), RK4 (2) or a predictor-corretor (3). : (null)\n", - "max_evolution_time : Set the maximum age for the stars (Myr). : (null)\n", - "max_model_number : Set the maximum number of models, ignored if 0 (default is 0). : (null)\n", - "monte_carlo_kicks : Turn on Monte-Carlo SN kicks. On (True) by default, and indeed other algorithms are probably broken. : (null)\n", - "disable_debug : Disables debug output. Only has an effect when DEBUG is 1, which probably requires a rebuild. Default FALSE. : (null)\n", - "timestep_logging : Turn on timestep logging (default is False). : (null)\n", - "rejects_in_log : Show timestep rejections in the main log (default is False). : (null)\n", - "vandenHeuvel_logging : Turn on van den Heuvel logging (default is False). : (null)\n", - "evolution_splitting : If True, turn on splitting of an evolutionary run if splitpoint (e.g. supernova) occurs. : (null)\n", - "disable_events : Whether to disable the new events code (defaults to False, so we use events by default)\n", - " : (null)\n", - "evolution_splitting_sn_eccentricity_threshold : Threshold eccentricity above which evolution splitting happens in a system with no SN kick. (0.01) : (null)\n", - "evolution_splitting_sn_n : Number of runs to split into when a SN occurs. : (null)\n", - "evolution_splitting_maxdepth : Max number of splits in an evolutionary run. : (null)\n", - "equation_of_state_algorithm : Set the equation of state algorithm. 0 = Paczynski. : (null)\n", - "opacity_algorithm : Set the opacity algorithm. 0 = Paczynski, 1 = Ferguson/Opal. : (null)\n", - "wind_mass_loss : Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018). : 0\n", - "gbwind : Wind prescription for first red giant branch stars. 0=Reimers (Hurley et al 2000/2002; choose gb_reimers_eta=0.5 for their mass loss rate), 1=Schroeder+Cuntz 2005 (set gb_reimers_eta=1.0 for their mass loss rate). : (null)\n", - "postagbwind : Apply special post-(A)GB prescription. Default is POSTAGB_WIND_USE_GIANT which means we just use whatever is prescribed on the giant branch. Other options include: POSTAGB_WIND_NONE = 1 (no wind on the post (A)GB), POSTAGB_WIND_KRTICKA2020 = 2 which uses Krticka, Kubát and Krticková (2020, A&A 635, A173). : (null)\n", - "Teff_postAGB_min : The minimum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_max. (6000 K) : (null)\n", - "Teff_postAGB_max : The maximum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_min. (120000 K) : (null)\n", - "mattsson_Orich_tpagbwind : Experimental : turns on Mattsson's TPAGB wind when the star is oxygen rich. Requires MATTSSON_MASS_LOSS. : (null)\n", - "magnetic_braking_factor : Multiplier for the magnetic braking angular momentum loss rate. : (null)\n", - "magnetic_braking_gamma : gamma factor in Rappaport style magnetic braking expression. : (null)\n", - "magnetic_braking_algorithm : Algorithm for the magnetic braking angular momentum loss rate. 0 = Hurley et al. 2002, 1 = Andronov, Pinnsonneault and Sills 2003, 2 = Barnes and Kim 2010 : (null)\n", - "helium_flash_mass_loss : Mass to be lost at the helium flash. : (null)\n", - "gb_reimers_eta : First red giant branch wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) : (null)\n", - "gbwindfac : Multiplier for the giant branch wind mass loss rate : (null)\n", - "tpagbwindfac : Multiplier for the TPAGB wind mass loss rate : (null)\n", - "eagbwindfac : Multiplier for the EAGB wind mass loss rate : (null)\n", - "nieuwenhuijzen_windfac : Multiplier for the Nieuwenhuijzen & de Jager wind mass loss rate : (null)\n", - "tpagbwind : Wind prescription during the TPAGB. 0=Karakas 2002 (a modified Vassiliadis and Wood 1993), 1=Hurley et al 2000/2002 (Vassiliadis and Wood 1993), 2=Reimers, 3=Bloecker, 4=Van Loon, 5=Rob's C-wind (broken?), 6,7=Vassiliadis and Wood 1993 (Karakas,Hurley variants respectively) when C/O>1, 8=Mattsson, 9 = Goldman et al. (2017), 10 = Beasor et al. (2020). : (null)\n", - "eagbwind : Wind prescription during the EAGB. 0=BSE (Hurley+2002, based on VW93), 1 = Goldman et al. (2017), 2 = Beasor et al. (2020). : (null)\n", - "wind_gas_to_dust_ratio : Gas to dust ratio used in wind calculations (e.g. Goldman et al. 2017). Typically 200 (Milky Way)-500 (Magellanic Clouds). Default is 200, approximately as in MW stars. : (null)\n", - "vwind_multiplier : Multiplier for the stellar wind velocity. : (null)\n", - "vwind_beta : Beta for stellar wind speed calculations, where vwind=sqrt(beta) * escape velocity. Default 0.125 (from BSE, Hurley et al. 2002). : (null)\n", - "superwind_mira_switchon : In the Vassiliadis and Wood (1993) AGB wind prescription, the superwind is turned on at a given Mira period, usually 500 days. You can vary when this switch-on happens with this parameter. : (null)\n", - "vw93_mira_shift : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate depends on the Mira period plus this offset. Requires VW93_MIRA_SHIFT. : (null)\n", - "vw93_multiplier : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate is multiplied by this factor. Requires VW93_MULTIPLIER. : (null)\n", - "tpagb_reimers_eta : TPAGB Reimers wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) Note that Reimers is not the default TPAGB wind prescription. See also tpagbwind. : (null)\n", - "Tout_Pringle_1992_multiplier : Multiplier for the Tout & Pringle (1992) magnetic wind. (0.0) : (null)\n", - "artificial_mass_accretion_rate%d : Constant mass accretion rate for star <n>. : (null)\n", - "artificial_mass_accretion_rate_by_stellar_type%d : Constant mass accretion rate for stellar type <n>. : (null)\n", - "artificial_angular_momentum_accretion_rate%d : Constant angular momentum accretion for star <n>. : (null)\n", - "artificial_orbital_angular_momentum_accretion_rate : Constant angular momentum accretion rate on the orbit. : (null)\n", - "artificial_accretion_start_time : Time at which artificial accretion stars. Ignored if <0 (default is -1). : (null)\n", - "artificial_accretion_end_time : Time at which artificial accretion ends. Ignored if <0 (default is -1). : (null)\n", - "wr_wind : Massive-star (WR) wind prescription. 0 = Hurley et al 2000/2002, 1=Maeder and Meynet, 2=Nugis and Lamers, 3=John Eldridge's version of Vink's early-2000s wind (See Lynnette Dray's thesis, or John Eldridge's thesis) : (null)\n", - "wr_wind_fac : Massive-star (WR) wind multiplication factor. : (null)\n", - "wrwindfac : Massive-star (WR) wind multiplication factor. Synonymous with wr_wind_fac (which you should use instead). : (null)\n", - "BH_prescription : Black hole mass prescrition: relates the mass of a newly formed black hole to its progenitor's (CO) core mass. BH_HURLEY2002 = 0 = Hurley et al 2000/2002, BH_BELCZYNSKI = 1 = Belczynski (early 2000s), BH_SPERA2015 = Spera+ 2015, BH_FRYER12_DELAYED = 3 = Fryer et al. (2012) delayed prescription, BH_FRYER12_RAPID = 4 = Fryer et al. (2012) rapid prescription, BH_FRYER12_STARTRACK = 5 = Fryer et al. (2012) startrack prescription. : (null)\n", - "sn_kick_distribution_II : Set the distribution of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_ECAP : Set the distribution of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_NS_NS : Set the distribution of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IBC : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_GRB_COLLAPSAR : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_TZ : Set the distribution of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_AIC_BH : Set the distribution of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_BH_BH : Set the distribution of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_BH_NS : Set the distribution of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD : Set the distribution of speeds applied to any survivor of a hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD_subluminous : Set the distribution of speeds applied to any survivor of a subluminous hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_II : Set the dispersion of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_ECAP : Set the dispersion of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_NS_NS : Set the dispersion of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IBC : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_GRB_COLLAPSAR : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_TZ : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_AIC_BH : Set the dispersion of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_BH_BH : Set the dispersion of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_BH_NS : Set the dispersion of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD : Set the dispersion of speeds applied to the survivor of a SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD_subluminous : Set the dispersion of speeds applied to the survivor of a subluminous SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_companion_IA_He : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia He supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_ELD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia ELD (sub-Mch) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_CHAND : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_AIC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an accretion induced collapse (supernova) occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_ECAP : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an electron capture supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_He_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia helium merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_CHAND_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_NS_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron-star neutron-star merger. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_GRB_COLLAPSAR : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a GRB Collapsar (rapidly rotating SN Ibc) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_HeStarIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a He-star Ia supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IBC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type Ib/c supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_II : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type II supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type IIa supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_WDKICK : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a WD is kicked. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_TZ : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Thorne-Zytkow object is formed. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_AIC_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron star collapses to a black hole. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_BH_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when two black holes merge. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_BH_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a black hole merges with a neutron star. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_Hybrid_HeCOWD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_Hybrid_HeCOWD_subluminous : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a subluminous hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "wd_sigma : Set the speed at which white dwarfs are kicked when they form, in km/s. Default is zero (i.e. no kick). Requires WD_KICKS. : (null)\n", - "wd_kick_direction : Set the direction of white dwarf kicks. 0 = random, 1 = up, 2 = forward, 3 = backward, 4 = inward, 5 = outward. Requires WD_KICKS. : (null)\n", - "wd_kick_when : Decide when to kick a white dwarf. 0=at birth, 1=at first RLOF, 2=at given pulse number (see wd_kick_pulse_number), 3 at every pulse Requires WD_KICKS. : (null)\n", - "wd_kick_pulse_number : Apply a kick to a star at a desired pulse number on the TPAGB (i.e. pre-WD). Requires WD_KICKS. : (null)\n", - "minimum_helium_ignition_core_mass : Minimum helium core mass required to ignite helium in the case that the hydrogen envelope is stripped on the giant branch, e.g. to make an sdB or sdO star. Typically 0.4, if 0.0 then the BSE algorithm (based on the total mass) is used. : (null)\n", - "minimum_CO_core_mass_for_carbon_ignition : Minimum CO core mass for carbon ignition, assuming Mc,bagb>1.6Msun. Typically around 1.08Msun (Pols+1998). : (null)\n", - "minimum_CO_core_mass_for_neon_ignition : Minimum CO core mass for neon ignition. Typically around 1.42Msun. Stars that have cores that ignite carbon, but not neon explode in electon-capture supernovae. : (null)\n", - "minimum_mcbagb_for_nondegenerate_carbon_ignition : Minimum Mc,bagb (core mass at the base of the AGB) for non-degenerate carbon ignition. Typically around 2.25Msun (Pols+1998). : (null)\n", - "maximum_mcbagb_for_degenerate_carbon_ignition : Maximum Mc,bagb (core mass at the base of the AGB) for degenerate carbon ignition. Typically around 1.6Msun (Pols+1998). : (null)\n", - "max_neutron_star_mass : Maximum mass of a neutron star before it collapses to a black hole. Typically around 2Msun. : (null)\n", - "chandrasekhar_mass : The Chandrasekhar mass, usually 1.44Msun : (null)\n", - "delta_mcmin : A parameter to reduce the minimum core mass for third dredge up to occur on the TPAGB. As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null)\n", - "lambda_min : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. See also lambda_multiplier. : (null)\n", - "lambda_multiplier : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null)\n", - "minimum_envelope_mass_for_third_dredgeup : The minimum envelope mass for third dredge up on the TPAGB. Early, solar metallicity models by Straniero et al suggested 0.5Msun is typical. However, circumstantial evidence (Izzard et al 2009) as well as newer models by Stancliffe and Karakas suggest that at low metallicity a value nearer zero is more appropriate. : (null)\n", - "mass_of_pmz : The mass in the partial mixing zone of a TPAGB star, using the Karakas 2012 tables. Ask Carlo Abate for more details, or see the series of papers Abate et al 2012, 2013, 2014. Requires NUCSYN and USE_TABULAR_INTERSHELL_ABUNDANCES_KARAKAS_2012. : (null)\n", - "c13_eff : The \"efficiency\" of partial mixing in a TPAGB star intershell region, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null)\n", - "mc13_pocket_multiplier : Multiplies the mass in the partial mixing zone of a TPAGB star, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null)\n", - "tides_convective_damping : Tidal convective damping algorithm. 0=TIDES_HURLEY2002 Zahn 197x timescales + Hut, as in Hurley et al (2002), 1 = TIDES_ZAHN1989 : Zahn 1989 lambdas + Hut. : (null)\n", - "E2_prescription : Choose how to calculate the E2 structural parameter (used in tidal timescale calculations). 0=Hurley 1=Izzard (see Siess et al 2013). : (null)\n", - "dtfac : A parameter to decrease the timestep ONLY during the TPAGB phase. : (null)\n", - "hbbtfac : A parameter to modulate the temperature at the base of the hot-bottom burning zone in TPAGB stars. (Works only if NUCSYN is defined) : (null)\n", - "wind_multiplier_%d : Wind multiplier for the stellar type specified by the intger %d. By default these are all 1.0. : (null)\n", - "wind_type_multiplier_%d : Wind multiplier for different types of wind (MS, GB, AGB, WR, LBV, OTHER), given by the integer %d. By default these are all 1.0. : (null)\n", - "pre_main_sequence : Set to True to turn on pre-main sequence evolution. Currently this is not a special stellar type, rather the first (small) fraction of the main sequence has increased radii to match the Railton et al 2014 fits to Tout's pre-main sequence stars. Requires PRE_MAIN_SEQUENCE. See also pre_main_sequence_fit_lobes. : (null)\n", - "pre_main_sequence_fit_lobes : Set to True force a pre-main sequence star into its Roche lobe. This is done by artificially aging it. Requires PRE_MAIN_SEQUENCE : (null)\n", - "small_envelope_method : Choose the method used to determine the stellar radius when the envelope mass is very thin. 0 = Hurley et al. (2002), 1 = Miller Bertolami et al. (2016+) for GB and AGB stars only. : (null)\n", - "timestep_modulator : Multiplier applied to the global timestep. Requires TIMESTEP_MODULATION. : (null)\n", - "timestep_multiplier%d : Multiplier applied to timestep limit <n>. : (null)\n", - "maximum_timestep : The maximum timestep (MYr). : (null)\n", - "zoomfac_multiplier_decrease : When a timestep is rejected, decrease the timestep by this factor (0.5). : (null)\n", - "zoomfac_multiplier_increase : When a timestep is rejected, zooms, then succeeds, increase the timestep by this factor (1.2). : (null)\n", - "maximum_timestep_factor : The maximum factor between two subsequent timesteps (1.2). : (null)\n", - "maximum_nuclear_burning_timestep : The maximum timestep (MYr) in any nuclear burning phase. : (null)\n", - "nova_retention_method : Algorithm used to calculate the amount of mass retained during a nova explosion. 0=use nova_retention_fraction. (other methods pending) : (null)\n", - "MINT_metallicity : This sets the metallicity for MINT. It is ignored if set to -1.0, the default, in which case the normal metallicity parameter is used. : (null)\n", - "gaia_Teff_binwidth : log10(Effective temperature) bin width used to make Gaia-like HRDs\n", - " : (null)\n", - "gaia_L_binwidth : log10(luminosity) bin width used to make Gaia-like HRDs\n", - " : (null)\n", - "gaia_colour_transform_method : Use this to select the method used to transform to Gaia colours from other colour schemes. GAIA_CONVERSION_UBVRI_UNIVARIATE_JORDI2010 = 0 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_UBVRI_BIVARIATE_JORDI2010 = 1 Jordi et al.'s bivariate UBVRI fits, GAIA_CONVERSION_ugriz_UNIVARIATE_JORDI2010 = 2 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_ugriz_BIVARIATE_JORDI2010 = 3 Jordi et al.'s univariate ugriv fits, GAIA_CONVERSION_UBVRI_UNIVARIATE_EVANS2018 = 4 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_ugriz_UNIVARIATE_EVANS2018 = 5 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_UBVRI_RIELLO2020 = 6 Riello et al. (2020, DR3) fits, GAIA_CONVERSION_ugriz_RIELLO2020 = 7 Riello et al. (2020, DR3) fits. : (null)\n", - "rotationally_enhanced_mass_loss : Set to 1 to enable rotationally enhanced mass loss rate algorithms: 0= none, 1=formula cf. Langer models (=ROTATIONALLY_ENHANCED_MASSLOSS_LANGER_FORMULA), 2=limit accretion rate before wind loss is applied, 3 = both 1 and 2. See also rotationally_enhanced_exponent : (null)\n", - "AGB_core_algorithm : Algorithm to use for calculating AGB core masses. 0=Hurley et al. 2002 if no NUCSYN, Karakas 2002 if NUCSYN is defined; 1=Hurley et al. 2002 (overshooting models); 1=Karakas 2002 (non-overshooting models). : (null)\n", - "AGB_radius_algorithm : Algorithm to use for calculating radii on the TPAGB. : (null)\n", - "AGB_luminosity_algorithm : Algorithm to use for calculating luminosities on the TPAGB. : (null)\n", - "AGB_3dup_algorithm : Algorithm to use for calculating third dredge up efficiency on the TPAGB. : (null)\n", - "overspin_algorithm : Algorithm to determine what we do when a star is rotating at its breakup velocity. OVERSPIN_BSE (0) conservatively transfers the angular momentum back to the orbit. OVERSPIN_MASSLOSS uses the rotationally_enhanced_massloss parameter to lose mass which carries away the angular momentum. : (null)\n", - "rotationally_enhanced_exponent : The exponent (power) by which rotationally enhanced mass loss is raised. Requires ROTATIONALLY_ENHANCED_MASS_LOSS. See also rotationally_enhanced_mass_loss. : (null)\n", - "batchmode : Set the batchmode control variable. Use only if you know what you are doing! : (null)\n", - "speedtests : If True, turns on speedtests during version information (off by default). : (null)\n", - "use_fixed_timestep_%d : Set to True to use fixed timestep <n>, False to turn off. Fixed timesteps are on (this is True) by default. : (null)\n", - "task%d : Control tasks to be performed by binary_c. By default, these are all TRUE. For more information see binary_c_macros.h, particularly the BINARY_C_TASK_* macros. : (null)\n", - "orbiting_object : Usage: --orbiting_object mass,spinrate,central_object,period. : 1.0\n", - "orbiting_objects_log : If True, turn on orbiting-object log. : (null)\n", - "orbiting_objects_log : If True, turn on orbiting-object log. : (null)\n", - "orbiting_objects_wind_accretion_multiplier : Multiplier for wind accretion on orbiting objects. Hurley et al 2002 use 1.5, which is the default. : (null)\n", - "orbiting_objects_close_pc_threshold : How close are orbiting objects allowed to be? Set this to be the absolute percentage difference minimum. : (null)\n", - "orbiting_objects_tides_multiplier : Multiplier for tidal torques on orbiting objects. : (null)\n", - "evaporate_escaped_orbiting_objects : If True, evaporate orbiting objects that have escaped the system. : (null)\n", - "RLOF_transition_objects_escape : If True, objects that escape their Roche lobe are ejected from the system, otherwise they are placed just outside the minimum stable orbit. : (null)\n", - "PN_resolve : If True, the timestep will be shortened to resolve better the PN phase (FALSE). : (null)\n", - "PN_resolve_minimum_luminosity : The luminosity above which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_resolve_maximum_envelope_mass : The envelope mass below which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_resolve_minimum_effective_temperature : The minimum effective temperature above which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_fast_wind : If True, thin-envelope PNe will have fast winds (FALSE). : (null)\n", - "PN_fast_wind_dm_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null)\n", - "PN_fast_wind_mdot_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null)\n", - "PN_fast_wind_dm_AGB : The envelope mass below which fast wind used during the AGB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null)\n", - "PN_fast_wind_mdot_AGB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null)\n", - "HeWD_HeWD_ignition_mass : HeWD-HeWD mergers above this mass reignite helium. (0.3) : (null)\n", - "wind_Nieuwenhuijzen_luminosity_lower_limit : Above this luminosity we activate the Nieuwenhuijzen and de Jager wind (4e3 Lsun). : (null)\n", - "wind_LBV_luminosity_lower_limit : Above this luminosity we activate the LBV wind (6e5 Lsun). : (null)\n", - "colour%d : Sets colour %d (0 to NUM_ANSI_COLOURS-1) to the extended ANSI set colour you choose (1-255, 0 means ignore). The colour numbers are defined in src/logging/ansi_colours.h : (null)\n", - "apply_Darwin_Radau_correction : Apply Darwin-Radau correction to the moment of inertia to take rotation into account? : (null)\n", - "degenerate_core_merger_nucsyn : If TRUE, assume that in a degnerate core merger, energy is generated from nucleosynthesis of the whole core, and that this can disrupt the core. The BSE algorithm (Hurley et al. 2002) assumes this to be TRUE, but binary_c assumes FALSE by default. (FALSE) : (null)\n", - "degenerate_core_helium_merger_ignition : If TRUE, assume that when there is a degenerate helium core merger, the star reignites helium. This is required to make R-type carbon stars. (TRUE) : (null)\n", - "degenerate_core_merger_dredgeup_fraction : If non-zero, mix this fraction of the degenerate core during a merger.(0.0). : (null)\n", - "\n", - "############################################################\n", - "##### Section Binary\n", - "############################################################\n", - "separation : Set the orbital separation (actually the semi-major axis) of the binary (internal index 0, stellar indices 0 and 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "separation_triple : Set the orbital separation (actually the semi-major axis) of the triple (internal index 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "separation_quadruple : Set the orbital separation (actually the semi-major axis) of the quadruple (internal index 2) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "orbital_period : Set the initial orbital period of the binary, stars 1 and 2 (internal indices 0 and 1) in days. See also separation. : (null)\n", - "orbital_period_triple : Set the initial orbital period of the triple in days. See also separation. : (null)\n", - "orbital_period_quadruple : Set the orbital period of the outer binary in a quadrulple (stars 3 and 4, internal indices 2 and 3) in days. See also separation. : (null)\n", - "eccentricity : Set the initial eccentricity of the binary orbit (stars 1 and 2, internal indices 0 and 1). : (null)\n", - "eccentricity_triple : Set the initial eccentricity of the triple orbit. : (null)\n", - "eccentricity_quadruple : Set the initial eccentricity of the outer binary of a quadruple (stars 3 and 4, internal indices 2 and 3). : (null)\n", - "incliniation : Set the initial orbital_inclination of the binary relative to zero. : (null)\n", - "incliniation_triple : Set the initial orbital_inclination of the triple orbit relative to zero. : (null)\n", - "incliniation_quadruple : Set the initial orbital_inclinationy of the quadruple orbit relative to zero. : (null)\n", - "orbital_phase : Set the initial orbital phase of the binary orbit. : (null)\n", - "orbital_phase_triple : Set the initial orbital phase of the triple orbit. : (null)\n", - "orbital_phase_quadruple : Set the initial orbital phase of the quadruple orbit. : (null)\n", - "argument_of_periastron : Set the initial argument of periastron of the binary orbit. : (null)\n", - "argument_of_periastron_triple : Set the initial argument of periastron of the triple orbit. : (null)\n", - "argument_of_periastron_quadruple : Set the initial argument of periastron of the quadruple orbit. : (null)\n", - "disc_timestep_factor : Factor that multiplies the natural timestep of a disc. : (null)\n", - "white_dwarf_cooling_model : White dwarf cooling model, relates age to luminosity. WHITE_DWARF_COOLING_MESTEL = 0 is Mestel's model, WHITE_DWARF_COOLING_MESTEL_MODIFIED = 1 is Hurley's modified Mestel model, WHITE_DWARF_COOLING_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null)\n", - "white_dwarf_radius_model : White dwarf radius model, radius to mass (and perhaps age). WHITE_DWARF_RADIUS_NAUENBERG1972 = 0 Nauenberg (1972), WHITE_DWARF_RADIUS_MU = 1 mu-dependent variant, WHITE_DWARF_RADIUS_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null)\n", - "cbdisc_mass_loss_inner_viscous_accretion_method : Chooses where the mass that is accreted from the inner edge of a circumbinary disc goes, i.e. to which star. 0 = Young and Clarke 2015, 1 = Gerosa et al 2015, 2 = 50:50 (i.e. not dependence on mass). : (null)\n", - "cbdisc_inner_edge_stripping : If True, allow inner edge mass stripping. : (null)\n", - "cbdisc_end_evolution_after_disc : If True, stop evolution when a disc evaporates. : (null)\n", - "cbdisc_no_wind_if_cbdisc : If True, disable stellar winds when there is a circumbinary disc. : (null)\n", - "cbdisc_outer_edge_stripping : If True, allow outer edge mass stripping. : (null)\n", - "disc_n_monte_carlo_guesses : Number of monte carlo guesses to try in the disc solver if the normal list of guesses fails (0). : (null)\n", - "disc_log : If 1, turn on the disc log. Requires DISC_LOG to be defined on build. : (null)\n", - "disc_log2d : If 1, turn on the 2d disc log. Requires DISC_LOG to be defined on build. : (null)\n", - "disc_log_dt : If non-zero, only allows disc log output every disc_log_dt Myr. : (null)\n", - "disc_log_directory : Directory into which disc logging is sent (must exist!). : /tmp/\n", - "post_ce_adaptive_menv : If TRUE, and if post_ce_objects_have_envelopes is TRUE, then the envelope mass of a post-CE star is such that it sits just inside its Roche lobe. If FALSE then a fixed (thin) envelope mass is applied that depends on the stellar type (see macros POST_CE_ENVELOPE_DM_GB, POST_CE_ENVELOPE_DM_EAGB and POST_CE_ENVELOPE_DM_TPAGB). : (null)\n", - "post_ce_objects_have_envelopes : If TRUE then post-common-envelope objects have thin envelopes. You need this if you are to have post-CE post-AGB stars. Note that this *may* be unstable, i.e. you may end up having many CEEs. The mass in the envelope is controlled by post_ce_adaptive_menv. TRUE by default. : (null)\n", - "PN_comenv_transition_time : post-common envelope transition time in years (1e2). This is the time taken to move from CEE ejection to Teff > 30e4 K. Hall et al. (2013) suggest ~100 years. : (null)\n", - "minimum_time_between_PNe : The minimum time (Myr) between planetary nebula detections. This prevents multiple, fast common envelopes triggering two PNe (0.1). : (null)\n", - "PN_Hall_fading_time_algorithm : In stars with low mass (<0.45Msun) cores, you can choose to set the PN fading time to either the minimum (PN_HALL_FADING_TIME_ALGORITHM_MINIMUM) or maximum (PN_HALL_FADING_TIME_ALGORITHM_MAXIMUM) as shown in Fig. 6 of Hall et al. (2013). : (null)\n", - "PPN_envelope_mass : Desired pre-planetary nebula (post-AGB) envelope mass. : (null)\n", - "cbdisc_eccentricity_pumping_method : Select from various eccentricity-pumping methods when there is a circumbinary disc. Requires DISCS. 0 = off. : (null)\n", - "cbdisc_viscous_photoevaporative_coupling : Set to 1 to turn on viscous-photoevaporative coupling in circumbinary discs. Requires DISCS. 0 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_NONE = off, 1 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_INSTANT instant, 2 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_VISCOUS slow, viscous wind. : (null)\n", - "cbdisc_inner_edge_stripping_timescale : Defines the timescale for mass loss from by inner edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_in. : (null)\n", - "cbdisc_outer_edge_stripping_timescale : Defines the timescale for mass loss from by outer edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_out. : (null)\n", - "cbdisc_viscous_L2_coupling : Set to 1 to turn on viscous-L2-loss coupling in circumbinary discs. Requires DISCS. 0 = off. : (null)\n", - "gravitational_radiation_model : Model for gravitational radiation from the system. 0=Hurley et al 2002 (Landau and Lifshitz 1951). 1 = as 0 but only when there is no RLOF. 2 = none. : (null)\n", - "nova_irradiation_multiplier : Multiplier for nova-radiative induced mass loss. (Shara+1986) : (null)\n", - "gravitational_radiation_modulator_J : Modulator for gravitational wave radiation angular momentum loss rate (1.0). : (null)\n", - "gravitational_radiation_modulator_e : Modulator for gravitational wave radiation eccentricity pumping rate (1.0). : (null)\n", - "nova_faml_multiplier : Nova friction-induced angular momentum loss multiplier. (Shara+1986) : (null)\n", - "RLOF_angular_momentum_transfer_model : Choose angular momentum transfer model in RLOF. 0=BSE (with discs), 1=conservative : (null)\n", - "post_SN_orbit_method : Method by which the post-SN orbit is calculated. 0=BSE, 1=Tauris&Taken 1998. : (null)\n", - "multiplicity : Multiplicity: 1=single star, 2=binary, 3=triple, 4=quadruple. : (null)\n", - "accretion_limit_eddington_steady_multiplier : Steady accretion is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_steady_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_eddington_LMMS_multiplier : Accretion from a low-mass, convective, main_sequence star is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_LMMS_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_eddington_WD_to_remnant_multiplier : Accretion from a WD onto a remnant star (e.g. another white dwarf, neutron star or black hole) is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_WD_to_remnant_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_thermal_multiplier : Mass transfer onto a MS, HG or CHeB star is limited by the accretor's thermal rate times this multiplier. : (null)\n", - "accretion_limit_dynamical_multiplier : Mass transfer is limited by the accretor's dynamical rate times this multiplier. : (null)\n", - "donor_limit_envelope_multiplier : Mass transfer by RLOF is limited by this fraction of the donor's envelope mass per timestep : (null)\n", - "donor_limit_thermal_multiplier : Mass transfer by RLOF is limited by the accretor's thermal rate times this multiplier. : (null)\n", - "donor_limit_dynamical_multiplier : Mass transfer by RLOF is limited by the donor's dynamical rate times this multiplier. : (null)\n", - "Bondi_Hoyle_accretion_factor : Wind accretion rate, as calculated by the Bondi-Hoyle-Littleton formula, multiplcation factor. Hurley et al 2002 use 1.5, which is the default. : (null)\n", - "tidal_strength_factor : A modulator for the tidal strength. If this factor > 1 then tides are stronger, i.e. tidal timescales are reduced. : (null)\n", - "hachisu_qcrit : Critical q=Maccretor/Mdonor above which Hachisu's disk wind turns on. : (null)\n", - "hachisu_disk_wind : Set to True to turn on Hachisu's disk wind when material accretes too fast onto a white dwarf. This helps to make more SNeIa. See also hachisu_qcrit. : (null)\n", - "mass_accretion_for_eld : The mass that must be accreted onto a COWD for it to ignite as an edge-lit detonation SNIa. : (null)\n", - "WDWD_merger_algorithm : Algorithm to be used when merging two white dwarfs. 0 = Hurley et al. (2002), 1 = Perets+ (2019), 2 = Chen+ (2016, todo) : (null)\n", - "type_Ia_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from Chandrasekhar-mass exploders. 0 = DD7 (Iwamoto 1999), 1 = Seitenzahl 2013 3D hydro yields (you must also set Seitenzahl2013_model) : (null)\n", - "Seitenzahl2013_model : Which of Seitenzahl et al. 2013's models to use? One of N1,N3,N5,N10,N20,N40,N100L,N100,N100H,N150,N200,N300C,N1600,N1600C,N100_Z0.5,N100_Z0.1,N100_Z0.01 (defaults to N100). : N1\n", - "type_Ia_sub_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from sub-Chandrasekhar-mass exploders. (Currently unused.) : (null)\n", - "max_HeWD_mass : The maximum mass a HeWD can have before it ignites helium (0.7). : (null)\n", - "merger_mass_loss_fraction : Fraction of the total mass which is lost when stars merge. : (null)\n", - "merger_angular_momentum_factor : When two stars merge the resulting single star retains a fraction of the total system angular momentum (or the critical spin angular momentum, if it is smaller) multiplied by this factor. : (null)\n", - "wind_angular_momentum_loss : Prescription for losing angular momentum in a stellar wind. 0=Hurley et al 2002 ('Tout') prescription, 1=lw i.e. a factor multiplying the specific orbital angular momentum, 2=lw hybrid for fast winds. Set wind_djorb_fac to the desired factor.. : (null)\n", - "wind_djorb_fac : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=0 (the Tout/Hurley et al 2002 prescription). See wind_angular_momentum_loss. : (null)\n", - "lw : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=1,2 (the 'lw' prescription). See wind_angular_momentum_loss. : (null)\n", - "VW93_EAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null)\n", - "VW93_TPAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null)\n", - "use_periastron_Roche_radius : Set this to True to use the Roche lobe radius at periastron, rather than (the default to) assume a circular orbit. This will be useful one day when we treat RLOF in eccentric orbits properly, hopefully. : (null)\n", - "qcrit_LMMS : Apply critical q=Mdonor/Maccretor value for low-mass main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_LMMS : Apply critical q=Mdonor/Maccretor value for (low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "mass_for_Hestar_Ia_upper : Only helium stars below this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_lower. : (null)\n", - "mass_for_Hestar_Ia_lower : Only helium stars above this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_upper. : (null)\n", - "alphaCB : Circumbinary disk viscosity parameter, alpha. : (null)\n", - "minimum_donor_menv_for_comenv : Minimum donor envelope mass for common envelope evolution to be triggered (Msun). Default 0. : (null)\n", - "comenv_prescription : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null)\n", - "comenv_prescription%d : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null)\n", - "comenv_ejection_spin_method : When a common envelope is ejected, we need to decide how fast the stars are left spinning. COMENV_EJECTION_SPIN_METHOD_DO_NOTHING (0) is the default, this just leaves the stars/stellar cores spinning with the same spin rate (omega = angular velocity) with which they entered the common envelope phase. COMENV_EJECTION_SPIN_METHOD_SYCHRONIZE instead tidally synchronizes the stars with their new orbital angular velocity. : (null)\n", - "comenv_merger_spin_method : When a common envelope binary merges, we need to decide how fast the resulting single star is left spinning. COMENV_MERGER_SPIN_METHOD_SPECIFIC (0) is the default, this preserves angular momentum but limits the specific angular momentum of the merged star to the specific angular momentum of the system at the onset of common envelope evolution. COMENV_MERGER_SPIN_METHOD_CONSERVE_ANGMOM (1) sets the merger's angular momentum to be that of the system at the onset of common envelope evolution (which means the star may be rotating supercritically). COMENV_MERGER_SPIN_METHOD_CONSERVE_OMEGA (2) sets the spin rate (angular frequency = omega) of the merged star to be that of the orbit just at the onset of common envelope evolution. : (null)\n", - "comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null)\n", - "comenv_ms_accretion_fraction : Experimental. During common envelope evolution, a main sequence may accrete a fraction of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_mass. : (null)\n", - "comenv_ns_accretion_mass : Experimental. During common envelope evolution, a neutron star may accrete some of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_fraction. : (null)\n", - "comenv_ns_accretion_fraction : Experimental. During common envelope evolution, a neutron star may accrete a fraction of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_mass. : (null)\n", - "alpha_ce : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null)\n", - "alpha_ce%d : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null)\n", - "lambda_ce : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to LAMBDA_CE_DEWI_TAURIS == -1 binary_c uses the Dewi and Tauris fits instead, LAMBDA_CE_WANG_2016 == -2 uses the formalism of Wang, Jia and Li (2016), if LAMBDA_CE_POLYTROPE == -3 then a polytropic formalism is used (see also comenv_splitmass) and if LAMBDA_CE_KLENCKI_2020 == -4 use Klencki et al. (2020). : (null)\n", - "lambda_ce%d : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to -1 binary_c uses the Dewi and Tauris fits instead, -2 uses the formalism of Wang, Jia and Li (2016) and if -3 then a polytropic formalism is used (see also comenv_splitmass). : (null)\n", - "comenv_splitmass : When lambda_ce=-2, the envelope binding energy, lambda, is calculated using a polytropic formalism. The comenv_splitmass defines the point, in the units of the core mass, above which material is ejected. : (null)\n", - "nelemans_recalc_eccentricity : If True, recalculate the eccentricity after angular momentum is removed. : (null)\n", - "comenv_post_eccentricity : Eccentricity remaining after common envelope ejection. : (null)\n", - "nelemans_gamma : Set the fraction of the orbital specific angular momentum that is used to eject the common envelope according to the Nelemans and Tout prescription. See also nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null)\n", - "nelemans_minq : Only activate the Nelemans and Tout common envelope prescription for q>nelemans_minq. See also nelemans_gamma, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null)\n", - "nelemans_max_frac_j_change : Maximum fractional angular momentum change in the Nelemans and Tout common envelope prescription. See also nelemans_gamma, nelemans_minq, nelemans_n_comenvs. : (null)\n", - "nelemans_n_comenvs : Set the maximum number of common envelope ejections allowed to follow the Nelemans and Tout prescription, after which the standard alpha prescription is used. : (null)\n", - "lambda_ionisation : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null)\n", - "lambda_ionisation%d : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null)\n", - "lambda_enthalpy : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null)\n", - "lambda_enthalpy%d : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null)\n", - "cbdisc_albedo : Circumbinary-disc albedo. Requires DISCS. : (null)\n", - "cbdisc_gamma : Circumbinary disc gamma (equation of state) parameter. Requires DISCS. : (null)\n", - "cbdisc_alpha : Circumbinary disc alpha (viscosity) parameter. Requires DISCS. : (null)\n", - "cbdisc_kappa : Circumbinary disc kappa (opacity) parameter. Requires DISCS. : (null)\n", - "cbdisc_minimum_evaporation_timescale : Circumbinary disc minimum evaporation timescale (years). If (slow, not edge stripped) mass loss would evaporate the disc on a timescale less than this, simply evaporate the disc immediated. Usually set to 1y, ignore if zero. Requires DISCS. : (null)\n", - "cbdisc_torquef : Circumbinary disc binary torque multiplier. Requires DISCS. : (null)\n", - "cbdisc_max_lifetime : Circumbinary disc maximum lifetime (years, ignored if 0). Requires DISCS. : (null)\n", - "cbdisc_init_dM : On cbdisc start, reduce mass by a fraction dM if it won't converge. Requires DISCS. : (null)\n", - "cbdisc_init_dJdM : On cbdisc start, reduce angular momentum by a fraction dJ/dM*dM if it won't converge. Requires DISCS. : (null)\n", - "cbdisc_mass_loss_constant_rate : Circumbinary disc constant mass loss rate (Msun/year). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_FUV_multiplier : Circumbinary disc FUV mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_Xray_multiplier : Circumbinary disc X-ray mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_ISM_ram_pressure_multiplier : Circumbinary disc interstellar medium ram pressure stripping mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_ISM_pressure : Circumbinary disc interstellar medium ram pressure in units of Boltzmann constant per Kelvin (I think...). Requires DISCS. Typically 3000.0. See e.g. http://www.astronomy.ohio-state.edu/~pogge/Ast871/Notes/Intro.pdf page 15 or https://arxiv.org/pdf/0902.0820.pdf Fig. 1 (left panel). : (null)\n", - "cbdisc_mass_loss_inner_viscous_multiplier : Circumbinary disc inner edge viscous mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_inner_viscous_angular_momentum_multiplier : Circumbinary disc inner edge viscous angular momentum multiplier (no units). The inner edge angular momentum Requires DISCS. : (null)\n", - "cbdisc_resonance_multiplier : Circumbinary disc resonant interaction multiplier, affects eccentricity pumping and angular momentum rates. Requires DISCS. : (null)\n", - "cbdisc_resonance_damping : Circumbinary disc resonant interaction damping: should be on (True) to damp the l=1, m=2 resonance when the disc inner edge lies outside the resonance location. Requires DISCS. : (null)\n", - "cbdisc_fail_ring_inside_separation : If True, while converging on a structure, circumbinary discs with Rring < the binary separation are immediately failed. : (null)\n", - "cbdisc_mass_loss_inner_L2_cross_multiplier : Circumbinary disc inner edge L2-crossing mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_minimum_luminosity : Circumbinary disc minimum luminosity. If the disc becomes dimmer than this, the disc is evaporated instantly. Requires DISCS. : (null)\n", - "cbdisc_minimum_mass : Circumbinary disc minimum mass. If the disc becomes less massive than this, the disc is evaporated instantly. Requires DISCS. : (null)\n", - "cbdisc_minimum_fRing : Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = |Rout/Rin-1| < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS. : (null)\n", - "comenv_disc_angmom_fraction : If >0 Fraction of the common envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the moments of inertia to calculate (deprecated), if -2 use the common envelope's specific angular momentum, if -3 uses the L2 point at the end of the common envelope to set the angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null)\n", - "comenv_disc_mass_fraction : Fraction of the common envelope's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null)\n", - "wind_disc_angmom_fraction : If >0 Fraction of the wind envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the L2 point's specific angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null)\n", - "wind_disc_mass_fraction : Fraction of the stellar wind's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null)\n", - "WRLOF_method : Choose whether and how to apply wind-Roche-lobe-overflow. 0=none, 1=q-dependent, 2=quadratic See Abate et al 2013/14 for details. Requires WRLOF_MASS_TRANSFER. : (null)\n", - "minimum_timestep : The minimum timestep (Myr). : (null)\n", - "timestep_solver_factor : Factor applied in timestep_limits, e.g. to prevent X changing too fast by comparing to X/dX/dt, which is usually 1 but can be higher to lengthen timesteps when using an alternative solver. : (null)\n", - "RLOF_mdot_factor : Multiplier applied to the mass transfer rate during Roche-lobe overflow. Requires RLOF_MDOT_MODULATION. : (null)\n", - "RLOF_f : Factor to enlarge a Roche lobe, nominally because of radiation pressure (see Dermine et al paper). Requires RLOF_RADIATION_CORRECTION. : (null)\n", - "minimum_separation_for_instant_RLOF : If True, instead of evolving the system just report the minimum separation (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_orbital_period_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null)\n", - "minimum_orbital_period_for_instant_RLOF : If True, instead of evolving the system just report the minimum orbital period (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_separation_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null)\n", - "maximum_mass_ratio_for_instant_RLOF : If True, instead of evolving the system just report the maximum mass ratio (on the zero-age main sequence) that would lead to instant RLOF, given M1 and orbital period. Used by binary_grid. See also minimum_separation_for_instant_RLOF and minimum_orbital_period_for_instant_RLOF. : (null)\n", - "RLOF_method : Use RLOF_method to choose the algorithm you use for Roche-lobe overflow mass loss rate calculations. 0=Hurley et al 2002, 1=Adaptive (for radiative stars) R=RL method, 2=Ritter (probably broken), 3=Claeys etal 2014 variant on Hurley et al 2002. : (null)\n", - "RLOF_interpolation_method : When a star overflows its Roche lobe, it always has R>RL because of the limited time resolution of the simulation. Binary_c then uses an algorithm to get back to when R~RL (within a desired tolerance, set in RLOF_ENTRY_THRESHOLD which is usually 1.02, i.e. overflow of 2%). You can choose algorithm 0, the Hurley et al 2002 method which reverses time (i.e. uses a Newton-like scheme), or 1 to use the binary_c method which rejects a timestep (and hence does no logging on that timestep) and repeats with half the timestep until R~RL. The latter is now the default, because this means there are no negative timesteps which break various other algorithms (e.g. nucleosynthesis). : (null)\n", - "nova_retention_fraction : The mass accreted during a nova as fraction of mass transferred : (null)\n", - "beta_reverse_nova : The fraction of mass ejected in a nova explosion which is accreted back onto the companion star. Set to -1 to automatically calculate based on a geometric argument, or 0 or positive to set the value. : (null)\n", - "WD_accretion_rate_novae_upper_limit_hydrogen_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is hydrogen rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_novae_upper_limit_helium_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is helium rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_novae_upper_limit_other_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is neither hydrogen nor helium rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_hydrogen_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a hydrogen-rich donor. Below this mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_helium_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a helium-rich donor. Below this mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_other_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope when the donor is neither hydrogen nor helium rich. Below this mass transfer leads to stable burning. : (null)\n", - "CRAP_parameter : Tidally enhanced mass loss parameter. See Tout and Eggleton's paper on the subject. (Was the parameter bb). : (null)\n", - "individual_novae : If individual_novae is True, novae are resolved such that each explosion is performed separtaely. : (null)\n", - "nova_timestep_accelerator_num : The nova timestep is accelerated if the nova number exceeds nova_timestep_accelerator_num. If zero or negative, acceleration is off. See also nova_timestep_accelerator_index and nova_timestep_accelerator_max. Only used if individual_novae is on.\n", - " : (null)\n", - "nova_timestep_accelerator_index : The index at which the nova timestep is accelerated. A larger value gives longer timesteps. See also nova_timestep_accelerator_num and nova_timestep_accelerator_max. Only used if individual_novae is on.\n", - " : (null)\n", - "nova_timestep_accelerator_max : The nova timestep is accelerated by a factor that is capped at nova_timestep_accelerator_max. This parameter is ignored if it is zero or negative. See also nova_timestep_accelerator_num and nova_timestep_accelerator_index. Only used if individual_novae is on.\n", - " : (null)\n", - "nonconservative_angmom_gamma : Mass lost from the system (but NOT from a stellar wind) takes a fraction gamma of the orbital angular momentum with it. Set to -1 to take the specific angular momentum of the donor star. Set to -2 to take super-Eddington, nova and disk-wind angular momenta as if a wind from the accretor. : (null)\n", - "max_stellar_angmom_change : Maxmimum fractional change in stellar angular momentum allowed before a timestep is rejected (0.05). : (null)\n", - "comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null)\n", - "\n", - "############################################################\n", - "##### Section Nucsyn\n", - "############################################################\n", - "third_dup : If True, enables third dredge up. Requires NUCSYN and NUCSYN_THIRD_DREDGE_UP. : (null)\n", - "third_dup_multiplier : Usage: --third_dup_multiplier <i> <f>. Multiplies the abundance of element <i> by <f> during third dredge up. : 1.0\n", - "NeNaMgAl : Enables NeNaMgAl reaction network. Requires NUCSYN and NUCSYN_HBB. : Ignore\n", - "nucsyn_network%d : Usage: --nucsyn_network%d <boolean>. Turn a nuclear network on or off. : (null)\n", - "nucsyn_network_error%d : Usage: --nucsyn_network_error%d <f>. Threshold error in nuclear network solver for network %d. : (null)\n", - "nucreacmult%d : Usage: --nucreacmult%d <f>. Multiply nuclear reaction given by the integer %d (integer) by f (float). : (null)\n", - "nucsyn_metallicity : This sets the metallicity of the nucleosynthesis algorithms, i.e. the amount (by mass) of matter which is not hydrogen or helium. Usually you'd just set this with the metallicity parameter, but if you want the nucleosynthesis to be outside the range of the stellar evolution algorithm (e.g. Z=0 or Z=0.04) then you need to use nucsyn_metallicity. That said, it's also outside the range of some of the nucleosynthesis algorithms as well, so you have been warned! : (null)\n", - "nucsyn_solver : Choose the solver used in nuclear burning. 0 = KAPS_RENTROP is a Kaps-Rentrop scheme (fast, not great for stiff problems), 1 = LSODA (Adams/BSF switcher), 2 = CVODE library (https://computing.llnl.gov/projects/sundials. Default 0. : 0\n", - "initial_abundance_mix : initial abundance mixture: 0=AG89, 1=Karakas 2002, 2=Lodders 2003, 3=Asplund 2005 (not available?), 4=Garcia Berro, 5=Grevesse Noels 1993 : 0\n", - "init_abund : Usage: --init_abund <i> <X>. Sets the initial abundance of isotope number <i> to mass fraction <X>. : 0.02\n", - "init_abund_mult : Usage: --init_abund_mult <i> <f>. Multiplies the initial abundance of isotope number <i> by <f>. : 1.0\n", - "init_abund_dex : Usage: --init_abund_dex <i> <f>. Changes the initial abundance of isotope number <i> by <f> dex. : 0.0\n", - "init_abunds_only : If True, outputs only the initial abundances, then exits. : (null)\n", - "initial_abunds_only : If True, outputs only the initial abundances, then exits. : (null)\n", - "no_thermohaline_mixing : If True, disables thermohaline mixing. : (null)\n", - "lithium_GB_post_Heflash : Sets the lithium abundances after the helium flash. Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "lithium_GB_post_1DUP : Sets the lithium abundance after first dredge up. Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "lithium_hbb_multiplier : Multiplies the lithium abundances on the AGB during HBB (based on Karakas/Fishlock et al models).Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "angelou_lithium_decay_function : Functional form which describes Li7 decay. Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Choices are : 0 expoential (see angelou_lithium_decay_time). : (null)\n", - "angelou_lithium_LMMS_time : Time at which lithium manufacture is triggered in a low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_time : Time at which lithium manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_time : Time at which lithium manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_time : Time at which lithium manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_time : Time at which lithium manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_time : Time at which lithium manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_time : Time at which lithium manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_LMMS_decay_time : Decay time for surface lithium abundance during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_decay_time : Decay time for surface lithium abundance on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_decay_time : Decay time for surface lithium abundance on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_decay_time : Decay time for surface lithium abundance on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_decay_time : Decay time for surface lithium abundance during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_decay_time : Decay time for surface lithium abundance on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_decay_time : Decay time for surface lithium abundance on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_LMMS_massfrac : Lithium mass fraction when its manufacture is triggered during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_massfrac : Lithium mass fraction when its manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_massfrac : Lithium mass fraction when its manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_massfrac : Lithium mass fraction when its manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_massfrac : Lithium mass fraction when its manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_vrot_trigger : Equatorial rotational velocity at which lithium manufacture is triggered (km/s). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0.\n", - " : (null)\n", - "angelou_lithium_vrotfrac_trigger : Fraction of Keplerian (breakup) equatorial rotational velocity at which lithium manufacture is triggered (must be <1, ignored if 0). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0.\n", - " : (null)\n", - "\n", - "############################################################\n", - "##### Section Output\n", - "############################################################\n", - "cf_amanda_log : Enable logging to compare to Amanda's models. : (null)\n", - "float_overflow_checks : Turn on to enable floating-point overflow checks at the end of each timestep, if they are available. 0=off, 1=warn (stderr) on failure, 2=exit on failure (0) : (null)\n", - "save_pre_events_stardata : Enable this to save a copy of stardata to stardata->pre_events_stardata just before an event. : (null)\n", - "disable_end_logging : Disable the logging that happens at the end of the evolution. : (null)\n", - "ensemble : Turn on ensemble calculations and output. : (null)\n", - "ensemble_filters_off : Sets all ensemble filters to be off (FALSE) - these can then be enabled one-by-one with --ensemble_filter_[...] TRUE. : (null)\n", - "ensemble_filter_%d : Turn on or off ensemble filter <n>. For a list of filters, see ensemble_macros.h. : (null)\n", - "ensemble_legacy_ensemble : Turn on ensemble legacy population output. : (null)\n", - "legacy_yields : Turn on ensemble legacy yield output. : (null)\n", - "ensemble_defer : Defer ensemble output. : (null)\n", - "ensemble_dt : When doing ensemble calculations, data are stored and/or output every ensemble_dt Myr. See also ensemble, ensemble_logdt, ensemble_startlogtime. : (null)\n", - "ensemble_logdt : When doing ensemble calculations, and when logensembletimes is set, the ensemble is stored/output every ensemble_logdt Myr. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null)\n", - "ensemble_startlogtime : Start log ensemble data storage/calculations/output at ensemble_startlogtime. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null)\n", - "ensemble_logtimes : When doing ensemble calculations/output, set this to act at log times rather than linear times. : (null)\n", - "postagb_legacy_logging : Turn on post-AGB legacy logging. : (null)\n", - "disc_legacy_logging : Turn on disc legacy logging. : (null)\n", - "EMP_logg_maximum : Maximum logg that EMP stars are allowed to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_minimum_age. : (null)\n", - "EMP_minimum_age : Minimum age that EMP stars are required to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum. : (null)\n", - "EMP_feh_maximum : Maximum [Fe/H] that an EMP stars may have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default -2.0. : (null)\n", - "CEMP_cfe_minimum : Minimum [C/Fe] that CEMP stars are required to have. See Izzard et al 2009. See also NEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 0.7. : (null)\n", - "NEMP_cfe_minimum : Minimum [N/Fe] that NEMP stars are required to have. See Izzard et al 2009, Pols et al. 2012. See also CEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 1.0. : (null)\n", - "thick_disc_start_age : Lookback time for the start of the thick disc star formation, e.g. 13e3 Myr. Units = Myr. : (null)\n", - "thick_disc_end_age : Lookback time for the end of the thick disc star formation, e.g. 4e3 Myr. Units = Myr. : (null)\n", - "thick_disc_logg_min : Minimum logg for thick disc giants to be logged. : (null)\n", - "thick_disc_logg_max : Maximum logg for thick disc giants to be logged. : (null)\n", - "escape_velocity : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 1e9 km/s. See also escape_fraction. : (null)\n", - "escape_fraction : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 0.0. See also escape_velocity. : (null)\n", - "colour_log : If set to True, thelog is coloured with ANSI colour formatting. Requires FILE_LOG to be defined. : \n", - "log_filename : Location of the output logging filename. If set to \"/dev/null\" then there is no logging. : \n", - "log_arrows : Add arrows to the output log to show whether values are increasing or decreasing. : \n", - "stopfile : File which, when it exists, will stop the current binary_c repeat run. : \n", - "stardata_dump_filename : Location of the stardata dump file. : \n", - "stardata_load_filename : Location of the stardata file to load. : \n", - "api_log_filename_prefix : Location of the output logging filename prefix for the API. If set to \"/dev/null\" then there is no logging. : 0\n", - "hrdiag_output : Set to True to output high time-resolution Hertzstrpung-Russell diagram information. Requires HRDIAG. : (null)\n", - "internal_buffering : Experimental. Set to non-zero values to implement internal buffering prior to output. For use with binary_grid, you shouldn't really be playing with this. : (null)\n", - "eccentric_RLOF_model : Chooses which model is used to handle eccentric RLOF. Default is RLOF_ECCENTRIC_AS_CIRCULAR, i.e. ignore the eccentricity. Note: requires force_corotation_of_primary_and_orbit to be FALSE.\n", - " : (null)\n", - "force_circularization_on_RLOF : If True forces circularization of stars and orbit when RLOF starts, this is as in the BSE algorithm. (True) : (null)\n", - "wtts_log : If True, enables log file output for WTTS2. : (null)\n", - "fabian_imf_log_time : Time at which to output for Fabian Schneider's IMF project. Requires FABIAN_IMF_LOG : Ignore\n", - "fabian_imf_log_timestep : Timestep for Fabian Schneider's IMF project logging. Requires FABIAN_IMF_LOG : Ignore\n", - "version : Display binary_c version and build information. Also performs timing tests. : Ignore\n", - "dumpversion : Display binary_c version number (short format). : Ignore\n", - "version_only : Display binary_c version number and build information, but do not perform timing tests or anything that requires stardata to be non-NULL. : Ignore\n", - "tides_diagnosis_log : Enable logging to test MINT tides. Requires MINT. Choices are: 0 disabled, 1 enable lambda test. : Ignore\n", - "\n", - "############################################################\n", - "##### Section Input\n", - "############################################################\n", - "MINT_dir : Location of MINT algorithm data. : \n", - "MINT_data_cleanup : Activate checks on incoming data to try to account for problems. Will make data-loading slower, but may fix a few things. : \n", - "MINT_MS_rejuvenation : Turn on or off (hydrogen) main-sequence rejuvenation. : \n", - "MINT_remesh : Turn on or off MINT's remeshing. : \n", - "MINT_use_ZAMS_profiles : Use chemical profiles at the ZAMS if MINT_use_ZAMS_profiles is TRUE, otherwise set homogeneous abundances. (Default is TRUE, so we use the profiles if they are available.) : \n", - "MINT_fallback_to_test_data : If TRUE, use the MINT test_data directory as a fallback when data is unavailable. (FALSE) : \n", - "MINT_disable_grid_load_warnings : Use this to explicitly disable MINT's warnings when loading a grid with, e.g., missing or too much data. : \n", - "MINT_Kippenhahn : Turn on or off MINT's Kippenhahn diagrams. If 0, off, if 1, output star 1 (index 0), if 2 output star 2 (index 1). Default 0. : \n", - "MINT_nshells : Set the initial number of shells MINT uses in each star when doing nuclear burning. Note: remeshing can change this. If MINT_nshells is 0, shellular burning and other routines that require shells will not be available. (200) : \n", - "MINT_maximum_nshells : Set the maximum number of shells MINT uses in each star when doing nuclear burning. Note that this will be limited to MINT_HARD_MAX_NSHELLS. (1000) : \n", - "MINT_minimum_nshells : Set the minimum number of shells MINT uses in each star when doing nuclear burning. Note that this will be greater than or equal to MINT_HARD_MIN_NSHELLS, which is 0 by default. (0) : \n", - "MINT_Kippenhahn_stellar_type : Stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for which Kippenhahn plot data should be output. : \n", - "MINT_Kippenhahn_companion_stellar_type : Companion stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for the companion for which Kippenhahn plot data should be output. : \n", - "MINT_nuclear_burning : Turn on or off MINT's nuclear burning algorithm. : \n", - "MINT_minimum_shell_mass : Minimum shell mass in MINT's nuclear burning routines. : \n", - "MINT_maximum_shell_mass : Maximum shell mass in MINT's nuclear burning routines. : \n", - "\n", - "############################################################\n", - "##### Section I/O\n", - "############################################################\n", - "go : batchmode control command : Ignore\n", - "gogo : batchmode control command : Ignore\n", - "reset_stars : Reset the star structures. Used in batchmode : Ignore\n", - "reset_stars_defaults : Reset the star structures and set defaults. Used in batchmode : Ignore\n", - "defaults : Reset all defaults. Used in batchmode : Ignore\n", - "echo : Activate batchmode command echoing, i.e. when you enter a command, binary_c repeats the command then executes it. : Ignore\n", - "noecho : Deactivate batchmode command echoing. See 'echo'. : Ignore\n", - "noechonow : Deactivate batchmode command echoing. See 'echo'. : Ignore\n", - "bye : Quit binary_c. Used in batchmode. : Ignore\n", - "fin : batchmode control command : Ignore\n", - "reset_prefs : Reset preferences struct. Used in batchmode : Ignore\n", - "status : Output batchmode status information. : Ignore\n", - "\n", - "############################################################\n", - "##### Section Algorithms\n", - "############################################################\n", - "repeat : If > 1, repeats the system as many times as required. Handy if you're using Monte-Carlo kicks and want to sample the parameter space well. Also, if you are running speed tests this is good to give a statistically more reasonable result. (See e.g. 'tbse pgo'). : (null)\n", - "random_systems : Experimental. Use this to apply random initial system parameters (masses, separations, etc.). Useful for testing only. : (null)\n", - "\n", - "############################################################\n", - "##### Section Misc\n", - "############################################################\n", - "random_seed : Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null)\n", - "random_systems_seed : Random number seed for the generation of random systems. See random_systems and random_seed. : (null)\n", - "random_skip : Skip the first <random_seed> random numbers that are generated. Usually this is 0 so they are all used. : (null)\n", - "idum : [NB: deprecated, please use 'random_seed' instead.] Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null)\n", - "reverse_time : Make time go backwards. To be considered very experimental! : (null)\n", - "start_time : Start time for the simulation. : (null)\n", - "warmup_cpu : Uses the CPU at maximum power the given number of seconds, prior to running normal stellar evolution. : Ignore\n", - "help : Display help pages. Usage: --help <help topic>. : Ignore\n", - "argopts : Display argument options. Usage: --argopts <argument>. : Ignore\n", - "help_all : Display all help pages. : Ignore\n", - "list_args : Display list of arguments with their default values. Useful for batchmode. : Ignore\n", - "\n" + "(abridged)\n" ] } ], "source": [ - "print(_binary_c_bindings.return_help_all())" + "print('\\n'.join(_binary_c_bindings.return_help_all().splitlines()[:10]))\n", + "print(\"(abridged)\")" ] }, { @@ -873,12 +300,14 @@ "__ARG_BEGIN\n", "metallicity = 0.02\n", "effective_metallicity = -1\n", - "M_1 = 0\n" + "M_1 = 0\n", + "(abridged)\n" ] } ], "source": [ - "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))" + "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))\n", + "print(\"(abridged)\")" ] }, { @@ -966,7 +395,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -980,7 +409,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/doctrees/nbsphinx/examples/notebook_custom_logging.ipynb b/docs/build/doctrees/nbsphinx/examples/notebook_custom_logging.ipynb index 8dfb85034dd77e1b0ae790c475a1e52bd70d0227..8627ffb4751bfea37ebfc00c67e763a79463eba0 100644 --- a/docs/build/doctrees/nbsphinx/examples/notebook_custom_logging.ipynb +++ b/docs/build/doctrees/nbsphinx/examples/notebook_custom_logging.ipynb @@ -23,7 +23,7 @@ " create_and_load_logging_function,\n", ")\n", "from binarycpython.utils.run_system_wrapper import run_system\n", - "from binarycpython.utils.grid import Population" + "from binarycpython import Population" ] }, { @@ -461,11 +461,19 @@ "# print (abridged) output\n", "print(\"\\n\".join(output.splitlines()[-2:]))" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c708268f-0b0c-48ea-9155-ec632a0acc3a", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -479,7 +487,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/doctrees/nbsphinx/examples/notebook_ensembles.ipynb b/docs/build/doctrees/nbsphinx/examples/notebook_ensembles.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..cc9a3ad9f4cfc1efc4c1327878f01b87bad9e8e5 --- /dev/null +++ b/docs/build/doctrees/nbsphinx/examples/notebook_ensembles.ipynb @@ -0,0 +1,42 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d1d00572-29aa-4f27-a59c-f9f05889da7d", + "metadata": {}, + "source": [ + "# Tutorial: Generating and handling ensemble data\n", + "TODO: coming soon!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e8d9fca3-dd16-4c2c-a180-14d9a6b533ed", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docs/build/doctrees/nbsphinx/examples/notebook_extra_features.ipynb b/docs/build/doctrees/nbsphinx/examples/notebook_extra_features.ipynb index 44c19c11274fbd39732e34e03e7a14a371ff9d7c..a0f0fc0d9c66207de88d4c38672d257f9af522c2 100644 --- a/docs/build/doctrees/nbsphinx/examples/notebook_extra_features.ipynb +++ b/docs/build/doctrees/nbsphinx/examples/notebook_extra_features.ipynb @@ -18,11 +18,11 @@ "metadata": {}, "outputs": [], "source": [ + "from binarycpython import Population\n", "from binarycpython.utils.functions import (\n", " get_help,\n", " get_help_all,\n", " get_help_super,\n", - " return_binary_c_version_info,\n", " get_defaults\n", ")\n", "# help(binarycpython.utils.functions)" @@ -116,8 +116,7 @@ "metadata": {}, "source": [ "## Build information of binary_c\n", - "Sometimes we want to know with which settings binary_c has been built. We can use the function `return_binary_c_version_info` for this.\n", - "This function will parse the version info of binary_c and return a dictionary with all the settings." + "It can be useful to fetch the information with which the current version of binary_c has been configured with. We can do that through the Population object, by calling the instance method `return_binary_c_version_info`. This function will parse the version info of binary_c and return a dictionary with all the settings." ] }, { @@ -130,13 +129,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'nucleosynthesis_sources', 'miscellaneous'])\n" + "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'units', 'nucleosynthesis_sources', 'miscellaneous'])\n" ] } ], "source": [ - "version_info_dict = return_binary_c_version_info(parsed=True)\n", - "print(version_info_dict.keys())" + "version_info = Population().return_binary_c_version_info(parsed=True)\n", + "print(version_info.keys())" ] }, { @@ -168,27 +167,11 @@ "\n", "TODO:" ] - }, - { - "cell_type": "markdown", - "id": "b3c259ef-9f89-4b26-9ce3-45af625bc398", - "metadata": {}, - "source": [ - "## Getting help\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bf3c1e28-1662-47a7-abab-aa6fb0ef0882", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -202,7 +185,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/doctrees/nbsphinx/examples/notebook_individual_systems.ipynb b/docs/build/doctrees/nbsphinx/examples/notebook_individual_systems.ipynb index deb72fc55ba3785c9c829ab83ba0846cd9b86867..d752fc66ed4fdff229a1bab5d1f5e48921ea8e77 100644 --- a/docs/build/doctrees/nbsphinx/examples/notebook_individual_systems.ipynb +++ b/docs/build/doctrees/nbsphinx/examples/notebook_individual_systems.ipynb @@ -62,7 +62,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "SINGLE_STAR_LIFETIME 1 12461.2\n", + "SINGLE_STAR_LIFETIME 1 12461.1\n", "\n" ] } @@ -90,17 +90,17 @@ "name": "stdout", "output_type": "stream", "text": [ - " TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=62172 RANDOM_COUNT=0\n", + " TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=22065 RANDOM_COUNT=0\n", " 0.0000 1.000 0.000 1 15 -1 -1 -1.00 0.000 0.000 \"INITIAL \"\n", " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 \"OFF_MS\"\n", " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 11582.2424 1.000 0.000 3 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 12325.1085 0.817 0.000 4 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 12457.1301 0.783 0.000 5 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"shrinkAGB\"\n", - " 12461.1627 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 15000.0000 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", + " 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", + " 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"shrinkAGB\"\n", + " 12461.1490 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", + " 15000.0000 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", "\n" ] } @@ -236,13 +236,13 @@ "4 0.000002 1.0 1.0 1.0\n", "5 0.000003 1.0 1.0 1.0\n", "... ... ... ... ...\n", - "1345 12461.080763 0.71617 1.0 6.0\n", - "1346 12461.162734 0.644553 1.0 11.0\n", - "1347 13461.162734 0.644553 1.0 11.0\n", - "1348 14461.162734 0.644553 1.0 11.0\n", - "1349 15000.0 0.644553 1.0 11.0\n", + "1250 12461.061259 0.718593 1.0 6.0\n", + "1251 12461.149038 0.678026 1.0 11.0\n", + "1252 13461.149038 0.678026 1.0 11.0\n", + "1253 14461.149038 0.678026 1.0 11.0\n", + "1254 15000.0 0.678026 1.0 11.0\n", "\n", - "[1349 rows x 4 columns]\n" + "[1254 rows x 4 columns]\n" ] } ], @@ -299,10 +299,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options\n", - "adding: M_1=10 to BSE_options\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", "SINGLE_STAR_LIFETIME 10 28.4838\n", "\n" @@ -360,9 +358,9 @@ ");\n", " to grid_options\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", - "Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_dafa15d2b1e64e19972ac0e9eb5c9a55.so\n", + "Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_34a350b8f15c4d149deab88632948c99.so\n", "EXAMPLE_MASSLOSS 0.000000000000e+00 10 0 10 1\n", "EXAMPLE_MASSLOSS 0.000000000000e+00 10 10 10 1\n", "EXAMPLE_MASSLOSS 1.000000000000e-06 10 10 10 1\n", @@ -381,7 +379,7 @@ "\n", " stardata->star[0].stellar_type //5\n", ");\n", - "\"\"\" \n", + "\"\"\"\n", "\n", "example_pop.set(C_logging_code=custom_logging_print_statement)\n", "\n", @@ -397,7 +395,7 @@ "source": [ "Lastly we can add a parse_function to handle parsing the output again. \n", "\n", - "Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be (self, output). Returning the data is useful when running evolve_single(), but won't be used in a population evolution." + "Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be `(self, output)`. Returning the data is useful when running evolve_single(), but won't be used in a population evolution." ] }, { @@ -464,13 +462,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function object_parse_function at 0x149c2e81ec10> to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to custom_options >>>>\n", - "adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options\n", + "adding: parse_function=<function object_parse_function at 0x7f35b603e9d0> to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-david/notebooks/notebook_individual_systems to custom_options >>>>\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", - "Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_0639ee205c7d4782b4a27378f5d890bd.so\n", + "Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_446fe4cddfa94946bcafd55591ef3730.so\n", "[['time', 'mass', 'initial_mass', 'stellar_type'], [0.0, 10.0, 0.0, 10.0, 1.0], [0.0, 10.0, 10.0, 10.0, 1.0], [1e-06, 10.0, 10.0, 10.0, 1.0]]\n", "dict_keys(['time', 'mass', 'initial_mass', 'stellar_type'])\n" ] @@ -570,7 +567,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -584,7 +581,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/doctrees/nbsphinx/examples/notebook_luminosity_function_single.ipynb b/docs/build/doctrees/nbsphinx/examples/notebook_luminosity_function_single.ipynb index 93e041531422571b1a499b0089f9e4e465d4a0f3..0a19202d3d6b54cc27b089c742e1a194a226587a 100644 --- a/docs/build/doctrees/nbsphinx/examples/notebook_luminosity_function_single.ipynb +++ b/docs/build/doctrees/nbsphinx/examples/notebook_luminosity_function_single.ipynb @@ -54,8 +54,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: max_evolution_time=0.1 to BSE_options\n", - "adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_luminosity to grid_options\n", + "adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_luminosity to grid_options\n", "verbosity is 1\n" ] } @@ -104,28 +103,6 @@ "# help(population.add_grid_variable)" ] }, - { - "cell_type": "markdown", - "id": "bd75cebe-2152-4025-b680-dc020b80889b", - "metadata": {}, - "source": [ - "All the distribution functions that we can use are stored in the `binarycpython.utils.distribution_functions` or `binarycpython/utils/distribution_functions.py` on git. If you uncomment the help statement below you can see which functions are available now:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "048db541-3e92-4c5d-a25c-9c5a34b9c857", - "metadata": { - "scrolled": true, - "tags": [] - }, - "outputs": [], - "source": [ - "import binarycpython.utils.distribution_functions\n", - "# help(binarycpython.utils.distribution_functions)" - ] - }, { "cell_type": "markdown", "id": "2a9104fc-4136-4e53-8604-f24ad52fbe56", @@ -141,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "id": "aba3fe4e-18f2-4bb9-8e5c-4c6007ab038b", "metadata": {}, "outputs": [], @@ -165,22 +142,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "id": "47979841-2c26-4b26-8945-603d013dc93a", "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "add_grid_variable() got an unexpected keyword argument 'resolution'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/tmp/ipykernel_519112/518757914.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mtmp_dir\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mTMP_DIR\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m )\n\u001b[0;32m----> 6\u001b[0;31m population.add_grid_variable(\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"M_1\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mlongname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"Primary mass\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mTypeError\u001b[0m: add_grid_variable() got an unexpected keyword argument 'resolution'" - ] - } - ], + "outputs": [], "source": [ "# Mass\n", "population = Population()\n", @@ -191,8 +156,16 @@ " name=\"M_1\",\n", " longname=\"Primary mass\",\n", " valuerange=massrange,\n", - " samplerfunc=\"const({min}, {max}, {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", - " probdist=\"{probtot}/({max} - {min})\".format(probtot = total_probability, min = massrange[0], max = massrange[1]), # dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)\n", + " samplerfunc=\"self.const_linear({min}, {max}, {res})\".format(\n", + " min=massrange[0],\n", + " max=massrange[1],\n", + " res=resolution[\"M_1\"]\n", + " ),\n", + " probdist=\"{probtot}/({max} - {min})\".format(\n", + " probtot=total_probability,\n", + " min=massrange[0],\n", + " max=massrange[1]\n", + " ), # dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)\n", " dphasevol=\"dM_1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -214,7 +187,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "0c986215-93b1-4e30-ad79-f7c397e9ff7d", "metadata": {}, "outputs": [], @@ -258,10 +231,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "fd197154-a8ce-4865-8929-008d3483101a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "adding: parse_function=<function parse_function at 0x7f6920fd2430> to grid_options\n" + ] + } + ], "source": [ "# import the bin_data function so we can construct finite-resolution probability distributions\n", "# import the datalinedict to make a dictionary from each line of data from binary_c\n", @@ -279,18 +260,15 @@ " for line in output.splitlines():\n", " # obtain the line of data in dictionary form \n", " linedata = datalinedict(line,parameters)\n", - " \n", + "\n", " # Check the header and act accordingly\n", " if linedata['header'] == \"ZERO_AGE_MAIN_SEQUENCE_STAR\":\n", - " \n", + "\n", " # bin the log10(luminosity) to the nearest 0.1dex\n", " binned_log_luminosity = bin_data(math.log10(linedata['luminosity']),\n", " binwidth['luminosity'])\n", - " \n", " # append the data to the results_dictionary \n", " self.grid_results['luminosity distribution'][binned_log_luminosity] += linedata['probability'] \n", - " \n", - " #print (self.grid_results)\n", " \n", " # verbose reporting\n", " #print(\"parse out results_dictionary=\",self.grid_results)\n", @@ -316,12 +294,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "8ea376c1-1e92-45af-8cab-9d7fdca564eb", "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "adding: verbosity=0 to grid_options\n", + "Do dry run? True\n", + "Doing dry run to calculate total starcount and probability\n", + "Grid has handled 39 stars with a total probability of 1\n", + "**************************\n", + "* Dry run *\n", + "* Total starcount is 39 *\n", + "* Total probability is 1 *\n", + "**************************\n", + "\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", + "**********************************************************\n", + "* Population-f9b28e4ed6ec4a67b17cd86c5a43c41c finished! *\n", + "* The total probability is 1. *\n", + "* It took a total of 3.99s to run 39 systems on 2 cores *\n", + "* = 7.98s of CPU time. *\n", + "* Maximum memory use 343.570 MB *\n", + "**********************************************************\n", + "\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" + ] + } + ], "source": [ "# set number of threads\n", "population.set(\n", @@ -329,7 +337,7 @@ " verbosity=0,\n", " # set number of threads (i.e. number of CPU cores we use)\n", " num_cores=2,\n", - " )\n", + ")\n", "\n", "# Evolve the population - this is the slow, number-crunching step\n", "analytics = population.evolve() \n", @@ -348,20 +356,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "e1f0464b-0424-4022-b34b-5b744bc2c59d", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'population_id': 'f9b28e4ed6ec4a67b17cd86c5a43c41c', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.9999999999999999, 'total_count': 39, 'start_timestamp': 1655508316.7679594, 'end_timestamp': 1655508320.7581806, 'time_elapsed': 3.9902212619781494, 'total_mass_run': 1951.365, 'total_probability_weighted_mass_run': 50.035, 'zero_prob_stars_skipped': 0}\n" + ] + } + ], "source": [ "print(analytics)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "05c6d132-abee-423e-b1a8-2039c8996fbc", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[None]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaMAAAEdCAYAAAChVQjxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAA9vklEQVR4nO3dd3hUVfrA8e/MpJNAQu81cOhNihB6ExUVVMTeXcva19V1ddfuqj93bWtvgLoqKLZdBAKCoqEjHY4K0gMpJEAgdWZ+f9xJmCSTZCbM5M5M3s/z5Enm3jt33twk8+ace857LE6nEyGEEMJMVrMDEEIIISQZCSGEMJ0kIyGEEKaTZCSEEMJ0koyEEEKYLsLsAEJUNDAYSAfsJscihBChwga0AtYAhe47JBnVzmBgudlBCCFEiBoJ/Oi+QZJR7aQD5OScwOEI7DytJk3iyc7OC+hr1FdybQNHrm3ghPK1tVotJCU1ANd7qDtJRrVjB3A4nAFPRqWvIwJDrm3gyLUNnDC4tpVub8gABiGEEKaTZCSEEMJ0koyEEEKYTpKREEII00kyEkIIYToZTReC8vNPkJeXi91eYnYoIS0jw4rD4TA7jLAk19Z7hcUOrBaIjPCubRCM19ZmiyA+PpHY2Aa1PockoxCTn3+C48dzSExsRmRkFBaLxeyQQlZEhJWSkuD6ow4Xcm29c6KgmIKcfOwWC62aNSDCVnNCCrZr63Q6KS4uIjc3E6DWCUm66UJMXl4uiYnNiIqKlkQkRIg7frLY+MLpJL8wNHs6LBYLUVHRJCY2Iy8vt9bnkWQUYuz2EiIjo8wOQwhxmkrsDgrcElB+UWiXuYyMjDqtWweSjEKQtIiECH0n8ovLPS4oLMHpDN3KCqf7viTJSAgh6pjT6SSvQjJyOJwUB9G9oLomyUgIIepYUYmjLPE0iI0s2x7qXXWnQ5KREAFw8cXn8dRTj5ry2rff/gduv/0Pprx2qYMHDzJixCDmz//GlNdPT6/8+k899SgXX3yeaa89efKYssfuraKk+GhsrlF0BX4YxODp9UOBDO0WpkpPP8j06efXeNxf//oI55xT/o0kOzuLCy88F4fDwdy539CyZctKz7v99j+wYcN6OnXqzAcfzKm0/7vvFvP3v/8FgJdffoOBAweV7du4cQOzZ7/Hzp2/cuzYURITk0hO7saECWcxadJkX7/Vem/lyjS2bt3MDTfcbHYoXtuyZTOrVqVxySWXk5CQ4JdzOp3OsvtFMVERRERYiYmycSLfQUGRHafT6dX9l1C8ntWRZCRMlZiYxN/+9rjHfQ6Hg1deeYH8/JN07aoq7V+yZBExMTHYbBEsXryAK6+81uN5oqKi+P33Xfz2268kJ3ctty81dQFRUdEUFZVbdJLvvlvMI488SNeu3Zg+/VISEhqSnn6QDRvW8803XwR1MnrhhVfNDoFWrVqxZMlPRESceotZtWoFc+d+bNqb5wMPPOzzZNFt2zbz/vtvc84553mdjFq2rPy9u8svLClbAiI+1jgmNtrGifxinE4nhcV2YqJqfmuu6nrW9PrBKrSiFWEnNjaWs846x+O+d999k2PHjnL77XfTtWu3SvtTUxcwYsRooqKiSE1dWGUyat++IydPnmDx4oXlklFe3nFWrUpj2LAUvv9+abnnvPfeW3Tu3IU335xJZGRkuX05OUd8/C7rVsV4zWCxWIiOjjY7jHIC/eZst9ux2+1ERUVV+73n5RtdcRaLhbgY42flnnwKirxLRlUJxmvvDblnJILShg3rmT37PYYNS2HGjCsq7d+3by/bt29j/PhJjB8/iZ07f2XXrp1Vnm/8+EksWbKo3NDZpUuXYLFYGDlyTKXjDx7cT8+evT2+sSclNfb5+3n33TcZMWJQpe3z53/DiBGDSE8/WLbt4ovP48EH/8SaNSu5/vorGDcuheuvv4Jt27YA8O23/+XSSy9k3Ljh3H77Hzh48EC5c1a8Z7R+/VpGjBjE999/x8yZ7zB16tmMGzecu+66lf3791WKacmSRVx33eWMGzecKVMm8o9/PE5ubm65Y/bt28tDD/2Z888/i3HjhjNt2jk88siD5OUZK5BWvGf01FOPMnfuxwCMGDGo7OPkyZNMmDCCF198vlIc+/btZcSIQcybN7faa3v8+HGeeupRzjprNJMnj+HJJx8hL+94peM83TNavHgh119/JRMnjmLSpNFcffUM5swx4nz33Td5+eV/ATB9+vllMZf+rEaMGMRLL/2Tb7/9L5dffhHjxg1ny5ZN1d6z2bN3D39/6G5uuPIc7rxlBh9/PBuACJuVyAgr27ZuYMrkFNavX1vueRXPWdX19HRsqbVrV3PrrdczfnwKkyeP5eGHH6j0u1N6b+vw4UM88MA9TJw4kilTJvDvf7+I3R7YwRXSMhJB59ixozz++N9ISmrMQw895rH/PDV1AQkJDRky5EwsFguNGzchNXUBN9/8R4/nnDhxMh988D5btmyiT59+ACxatJDhw0cSF1e5fEmLFi1Zu3Y1mZkZNGvW3L/foBf27NnNk08+wtSpFzNpUiwffjiL+++/h1tu+SMffTSbCy64kJMnT/DRR7N49tkneeml12s856xZ72K12rj88qs5fvwYH3/8AY899jBvvz2r7Jj587/h6acfo1evPtx6651kZBzm888/Zfv2rbz99myio6MpLi7m3nvvwGazMmPG5TRq1IjDhw+TlvYjeXnHiY+Pr/TaF1xwIdnZ2axevaJct2xcXByjRo1l6dJU7rjjHmw2W9m+RYu+JSIigvHjJ1b5PTmdTh588E9s2rSBqVMvokOHjvzwwzKefPLRGq/HmjUrefTRhxg9eiznnz8Nu93O7t2/s3nzRi655DJGjx7HwYP7WbjwW+68814aNUoEjK5l93N8990ipk2bTkJCAk2bNq3y9UpKSrjvvjtJ7tabS6/8A9s2reb1118B4IorrinXGqppulFV17Pq73UV9913J+3adeDGG2/l5MkTzJ37MbfeegMzZ35MUtKp76mkpIR7772dPn368cc/3sWaNav45JMPadOmLdOmXVzja9WWJCMRdP7xjyfIysrkxRdfIzEx0eMxqakLGDVqTFnXy5gx41i8eCF/+MNtHpNX585d6NIlmdTUBfTp04/s7CzWr1/L448/4/H8V1xxDc888wQzZkylT59+9O3bn8GDh9K7d1+s1sB3KOzdu4e33ppJz569AWjWrAWPPPIgr776Mp98Mq/sjbGkpIQPPnifw4cP0aJF5QEc7kpKSnjvvVll16xhw0a89NLz7Nr1G507J1NSUsLrr79CcnI3XnnlTaKijEofSnXn0Ucf4ptvvuDiiy9l9+5dpKcf4O23Z9GjR6+y81d3L6h377506NCR1atXVOqWPeusc1i06FvWr1/D4MFnlm1PTV3A0KHDyr5XT3788Xs2bFjPHXfcU9aCnjr1Yu6885ZqrwVAWtpPdOrUmaee+j+P+5OTu6JUDxYu/JaRI8fQqlXrSsfs27eXDz6YQ/v2Hcq2ubdy3RUUFHDG4BQuvfIWbDYr1199BffeewczZ77LtGnTiYk+1QovLqm+FVLd9fTktddeIjExkddff7fs3tfQocO55Zbr+PDDmdxxxz3l4pw8+Vyuuuo6wLie119/Bf/971eSjET1dh08xjc//U6ByXMUYqJsnJfSic6tG9b6HJ9/Pofly5dx7bU3lhvZ5m7Hjm3s27eXe+65v2zb+PFnMW/eXDZv3kjfvv09Pm/ChLOYM+dj7rrrPr77bjGxsbEMG5bCypVplY6dMuUCmjVrzqeffsT69WtZt24N77//Nm3atOVvf3uC3r371Pp79EaXLl3LEhFAr17G1yNGjCr35tyzp5EM0tMP1piMzj33/HL3Tfr16w/AwYMH6Nw5mR07tpGTc4Sbbrq1LBEBjBs3kVdffYm0tJ+4+OJLadDAaPn89NNykpO7nfY9qkGDhtCkSVMWLVpQloy2bdvC/v37uOmm26p97ooVPxEZGckFF1xUts1ms3HRRTPYuPHnap8bHx9PRsZhtm7dUnZ9fTVw4KByiagm4yYaI0cbxEZgs9mYNu0i1q1bzaZNGxg85FQiLiz2399yVlYWv/76C1dddV25QRi9e/ehV68+rFjxY7lkBEbLy13fvgNYuHC+32LyRJJRGEhdu4+NO7PNDgOA2OgI/nB+r5oP9GDnzt949dWX6NdvANddd1OVxy1a9C1xcQ1o2bJl2T2Pxo0bk5iYyKJFC6pMRuPHT+LNN19l7drVpKYuYPToseXedCsaOnQYQ4cOo6CgAK23s2TJIr76ah733383H330WbmuDX+rmFhKE0Dz5i08bj9+/JjP50xIaOh6rnF/5dChdIBKb65Wq5W2bdtx+LCxv3XrNsyYcQUzZ77Dp5/+hwEDBjJ8+EgmTZrsscuzJjabjYkTJ/PNN19w330PEh0dzaJFC2jQoAEjRoys9rmHDh2iadPmxMTElNvuTYK48MLpLF26mJtvvpZWrdowePAQxo6dwODBQ72O3VNrqSo2m42mzYyfQbxr4ELbtu0BOHToIDarlUjXfKOiYv9VYqjq5wrQoUNHFi9eVG5bbGwcDRs2KrctISHBq9+x0yHJKAxMHNSOgsKSoGgZTRzcrlbPLSws4JFH/kpMTAyPPPJkuXsH7hwOB0uWpHLy5Akuv7xyl8GyZYu5++77PI6cat26Db169eGDD95n27Yt3HzzrV7FFhMTQ79+A+jXbwCNGiXy/vtvs3LlT5x99hSvv7+q5o04HJ5/ZrYqlhKoqovQm5JmVqvna1qbemh33HEP5557HsuXf8/q1Sv517+eZfbs93jzzfdrdY9t8uRz+eSTD0lLW86oUWP57rtURo8eR3R0TM1PrqWkpMa8//5/WL16JStXprFyZRpff/0F5557Pg8++HevzuFtfO7XOCrSRlSk559FdJSxvdjuwO5wYHP9vOty/aKqfvcCTZJRGOjcuiF3Te9ndhin5cUX/8nu3bt45pl/Vvrv3926dWvIzs7i5ptvp23btuX2ZWZm8PLL/2L16pUMHz7C4/MnTjyLF198nqSkxgwaNMSrN3F33bv3BIyuD1+4t0Lcu0oOHTrkWwAB1LJlK8C4X9W//8Cy7U6nk/3799GpU5dyx3funEznzslcc80NbN26hZtvvpYvv/ycm27ynOSrm8eZnNyVLl26smjRAuLiGnDkSDaTJp3tRcwt+fnntRQUFJRrHe3du6fG54IxDD4lZSQpKSNxOp288MJzzJs3l6uvvp42bdoC/ilK7HA4sdvtZGUeonvXzmXb9+/fC0CLFsa1b5KUCMDJE3kUFNppEGskhtLWjTtv65K6/1wr2rt3j8fJ4maQod3CdEuXLnbdHJ/BiBGjqz02NXUB8fHxXHbZlYwdO6Hcx/Tpl5GU1JjU1AVVPn/8+LO47rqbuOee+6tsfYExDNaTFSt+ArzrBnJnvLHBxo3ry7bl5+fz7bf/9ek8gdS9e0+Skhrz5ZefUVx8qlzN0qVLyMzMYPjwFABOnMijpKR82ZrOnbtgs9koKiqq8vwxMbHAqW7BiiZPPpdVq9L44ou5NG3arMp7hu6GDUuhuLiYr776vGyb3W7n888/rfG5R4/mlntssVjo0sWYh1ZYaEyCjo01YvY0VNwXxXajZZO68CsaxBhtAIfDwRdffE5sbCz9+g0AoF3btlitVnZs21Sup+OLLyoPb6/pepZq2rQpXbt2Y/78b8qG3oNxX27Llk0MG+b5H7e6Ji0jYaqsrEyeffYpYmPjSE7uWuVN0jZt2tK1q+KHH5YyePCZHrvhLBYLw4alsHTpYvLz88veSNwlJSV5VQHgwQf/RKtWrUlJGUWbNm3Izy9g7dpV/PTTcnr06ElKSvX3MioaMuRMWrRoyTPPPMFll+3GarXxv/99TWJiEocPB0frKCIigltvvYOnn36MO+64mQkTJpGRcZjPPvuUzp27cN550wBYt24tL7zwHGPGjKd9+w44HHYWLvwWi8XC6NHjqjy/Uj0AePHF/2Po0GFYrVYmTDirbP/EiZN5441X+PHHH7j00iu9GrWYkjKKPn368eqrL3HgwH46dOjEDz8sLfemW5VnnnmS48ePMXDgIJo3b87hw8b32rVrNzp27OSKuTsAb731GuPHTyIiIoKUlFEef7eq4nA4KbE7iY6O4ee1aTz77BMo1YO0tB9Zt241N998O3FxcQA0bJjAsJSxpC74ApvNikruRFracnJyciqdt6br6e622+7ivvvu5NZbr+fcc8/nxIkTzJ37CU2aNK1ysnhdk2QkTLV3756y/zqfeebJKo87++wppKSMJC8vr8ouOICUlJHMn/8Ny5d/f1olex544GGWL/+e775LJSsrE6fTuOd09dXXc+WV1/g8mz8iIoKnn36ef/7zGd555w0aN27CJZdcRkJCQ55++rFax+lv55xzHlFRUXz00SxeffUlGjRowMSJk7nlljvKZvUnJ3dlyJAzSUtbzldfzSMmJobk5K48//zL1Y4yHDlyNNOnX0Zq6gIWLfoWp9NZ7s2zadOmnHHGENdw5Zq76MC4h/bss//ipZf+ycKF87FYLKSkjOL22+/muusqT5Z2d9ZZZ/P111/wxRefkZd3nMaNmzBu3ASuv/4PZYmwW7fu3HzzH5k3by6rVq1w1UH82qdkdLKwBJzGAIann3mB1155niVLFpGQ0JCbb76dq666ttzxt91+L0VFxSxe+DU/LI1i3LgJ3HbbXVx99Yxyx9V0Pd0NHjyU559/mXfffZO33nqdqKhIBg0awm233RXQgTi+sITyYk4m6gj8np2dV1ZjKlCaNUsgM/NUM/zQoT20bOlbF5HwLCLCSkk9Xj8mkGp7be+//x7S0w94LGobqg4dOUlBYQlWq4V2zeNrLIJaUFTCoeyTADRtFEN8XPkRn8H8e1vT+5PVaqFJk3iATsDucvsCGpkQQngpI+Mwq1aleTWJM1S4Ly3eICbSq2rc0ZE2LFbjuPq0vpF00wkhTHXw4AE2b97IV1/NIyoqmilTppodkt+4Ly0eH+vd5GCLxUJMpI38whIKikq8XlIi1EnLSAhhqg0b1vPEE38nI+MwDz/8WJUloEKN+9LikRFWoiK9f7uNjTbaCXa7s2wkXriTlpEQwlTnnHNepYUTw0HFpcV9ad3ERJ2adlBQaCcqouppCOFCWkZCCBEAebXooisVGWHFVnbf6PSXIg8FkoyEEMLPyi0tHh1BhI8ldiwWCzGurrpC11Lk4U6SUQiqD7+YQoQyT0uL+6q0q87hcPq1cGqgnO77kiSjEGOzRVBcXHXJFSGE+Uq76CwWC3HRtVtiI9Ztsb1Q6KorLi7CZqv9MASvn6mUagI011pvd9vWCbgXaAzM1lovrHUkwivx8Ynk5maSmNiMyMioejHkU4hQYnc4jKoLQFxMBFZr7f5GIyKsZRNcza7IXx2n00lxcRG5uZkkJNS+moMvaewloBswBEApFQ8sB0oX9JihlBqntf6h1tGIGsXGGuvFHD2ahd0e/P8tBTOr1Vqnpfnrk/p8bfML7ZwoMFpGNnsUhwpq3wFVkF9MQZGdE4CzMAaLJTivrc0WQUJCUtn7U234koyGAR+4PZ6BkYjOATYAqcD9gCSjAIuNbXBaP3RhqFhqSfhPfb62T85ey66Dx2jSMJpnbx2O9TR6L9bsyOD1L7cA8OfLBtCjQ1LYXltfUnYLYJ/b47OBtVrrBVrrQ8BMYIAfYxNCiJCSnn2CXQeNFVGH9W55WokIoHv7xLKvt+85clrnCna+JKNiwL1U7Wjge7fHuUATP8QkhBAhacXWU8uBDOt1+ovWJcRF0b65sbT89t2Vl5EIJ74ko1+Ai5RSFqXU+RiDFpa47W8HhHfqFkKIKjicTlZsMZJR59YNadXEP13pPToagwJ+Tz/OyYLwvU/sSzJ6FaM1lAN8BuyifDIaCWz2X2hCCBE69N5cso8ZK8Sm9PbfUt49OjQGjGSn94Vv68jrZKS1ng1cg5GAPgTO1loXQ9mw70QgfBYhEUIIH6RtTgcgwmZhcI8Wfjtvt3aNykoDhXNXnVej6ZRSNqAN8D+t9QcV92uts4Ez/BybEEKEhMIiO2t1JgD9kpv6XIuuOjFREXRp3ZBf9h9l+57wTUbetowiMbrlbghgLEIIEZLW/ZJBYbExMXW4H7voSvXoaHTVHcg6Qc6xAr+fPxh4lYy01gVAFnAisOEIIUToSXMNXIiPjaRPZ/8PKu7R4VRlg42/Zfn9/MHAlwEM84EpgQpECCFC0ZFjBWX3cs7s2cLnCt3e6Ny6IdGRRuHUTb9m+v38wcCXq3Y/0EopNUsp1UcpFROooIQQIlSs2HqI0nrVw/v4v4sOIMJmpVu7RAA2/poZlpX7fSkHlAE4gX7AlQBKqYrHOLXWsnqsEKJecDqdZV10bZo2oEOLhIC9Vo8OSWzelU1GTj6Zufk0T4oL2GuZwZfEMRsIv3QshBC1tPvQcdKzTwLGwIVAVtHv2fHUfaNte3LqbzLSWl8bwDiEECLkpG02WkUWC5zph/I/1WnbPJ742Ejy8ovZtjuHMf3bBPT16posrieEELVQYnewavthAHp2bExSQnRAX89qsZSNqtuxJwdHmN03qtX9HddaRol4SGZa672nGZMQQgS9TTuzy1Z09Wf5n+r06JjEmh0Z5OUXsz8jj/YBvEdV13xKRkqpS4GHgR7VHGY7rYiEECIElA5ciImyMaBbszp5zZ5u84227c4Jq2TkdTedUmoq8B+MBPYmYAE+BuZiLC+xDnjc/yEKIURwycsvLpt8Oqh787I5QIHWLDGW5knGSj7hVhrIl3tG9wHbgf7A313b3tNaXwoMAhTGiq9CCBHWVm07jN1h3LOpqy46AIvFQr+uRivsl325lNiDa/nx0+FLMuoLzHKVBiq9AjYArfUW4C3gQf+GJ4QQwSdti1Ghu0nDGLq6JqPWlb6uZFRYbC9bVTYc+JKMbEC26+t81+dGbvs10NsfQQkhRLA6mHWC39OPA8bcotNdWtxX/ZKbln0dTl11viSj/UAHAK11PkZFBvdlIxRSSFUIEebclxYPRIXumiQ1jKFNU2MV2e27w2dxbV9G06UBEzh1v+hr4G6lVD5GUvsj8I1/wxNCiODhcJwq/5PcphEtGptTBaFHhyQOZJ1g58FjFBSVEBMV+lXYfGkZvQYsU0rFuh4/hNE19yhGgtqJMchBCCHC0o69OeQcN5YWN6NVVKqna30ju8PJL/uOmhaHP/lSDmgNsMbtcSbQXynVF7AD27XW4TO0QwghKvjJVf4nwmZlcI/mpsWh2iditVhwOJ1s33OEvl38v4ZSXfNlntEopVSlmV1a601a661AY6XUKL9GJ4QQQaKgqIR1v2QA0L9rUxrE+G9pcV/FRkfQqZUx4bV0LaVQ50s33VJgYjX7x7uOEUKIsLNOZ1JUbHT+mNlFV6qHq4r33ow8jp8sMjma0+dLMqpp/KKNU/OPhBAirJQOXGgYF0nvTo1NjgZ6dDgVw469ueYF4ie+Vu2urkzscCA8F2cXQtRr+zPy2OGa0zO0Z8uALC3uq+Q2DYmMMOIIhyHe1Q5gUErdBdzltulFpdRTHg5NAhoC7/kxNiGECApzl+3EibGMw5gBrc0OB4DICBtd2zZi2+4ctoXB5NeaRtPlAntcX3fEqMBwuMIxTmALsBJ4wY+xCSGE6bbvPsLmXUbxmVH9WtGqSQOTIzqlR4cktu3OISMnn+yjBTRpFGN2SLVWbTLSWs8CZgEopX4H/qK1/rouAhNCCLM5nE7mLNsJQHSkjQtGdDI5ovJ6dmzM59/vAmDbniOM7Bscrbba8GWeUXD9FIQQIsBWbz/MnkNGHbqzhrSjUXxgV3P1VYcWCcRFR3CysITtu3PqRzJSSjUBmmutt7tt6wTcCzQGZmutF/o/RCGEqHvFJQ7muVodDeMiOWtIe5MjqsxqtdC9QxLrf8lk+54cnE4nljou3OovvgwJeQlXlx2ULT2+HKMm3WXA/2TSqxAiXCz9+QBZRwsAOH9EJ2Kjg7P+Ww/X6q9HTxRxMCt0a1X7koyGAfPdHs8AWgPnuD5vB+73X2hCCGGOkwXF/DdtNwAtkmIZ1S94u796dnRbijyER9X5koxaAPvcHp8NrNVaL9BaHwJmAgP8GJsQQphi/sq95OUXA3DR6C5BMa+oKi0bx5EYHwWEdmkgX65wMRDr9ng08L3b41wg9Kv1CSHqtSPHCkhda/zf3aV1Q86oXJIzqFgslrJqDHpfDnZHaBbC8SUZ/QJcpJSyKKXOxxi0sMRtfzsg9KcBCyHqtS+X/05xifGGPn1sckgMCCjtqssvtLPbNfov1PiSjF7FaA3lAJ8BuyifjEYCm/0XmhBC1K39GXn8tCUdgAFdm9KtXaK5AXmpdBADhG5XndfJSGs9G7gGIwF9CJyttS6GsmHficCcAMQohBB14rPvd+J0gsVi3CsKFY0bxpStOrs9RAcx+DRWUWv9AfCBh+3ZwBn+CkoIIera9j05bNpZWvanNa2bBk/ZH2/07JjE4SMn+XX/UYqK7URF2swOySfBO0RECCHqiMPpZO7S3wCIirQGXdkfb/R0ddWV2B38eiD0liKXZCSEqPfW7sgou/F/1uD2JAZZ2R9vqPZJZYvOheJ9I0lGQoh6rcTu4PPvjWKoCXGRTB4afGV/vBEfG0n7lq6lyPeE3sBmSUZCiHpt6c8HyMx1lf1JCd6yP94o7arbfeg4JwuKTY7GN5KMhBD11smCEr75aTcAzZNiGd0/eMv+eKOHa76R0xl6S5FXmYyUUrtck1tLH/9dKdW7bsISQojA+3bVnrKyPxcHedkfb3Rtm0iEzbhzFGr3jaq78u2BBLfHjwJ9AxqNEELUkZzjhaSuMcr+dA6Bsj/eiI600aV1I8BYbC+UVJeMDgB9KmxzBjAWIYSoM18u30VRadmfMV1CouyPN0q76tKzT5JzvNDkaLxX3Z26r4D7lVKTOVVz7mGl1E3VPMeptR7vt+iEECIADmTm8eNmo+xP/+SmqPZJNTwjdPTs2Jgvl/8OwI49OQzr3dLkiLxTXTJ6AKMO3QSgA0arqBkQVwdxCSFEwHy2zK3sz5jQKfvjjU6tEoiJslFQZGfb7iOhn4y01vnAI64PlFIO4G6t9X/qKDYhhPA7vTeHja6yPyP7tqJNiJX9qYnNaqVbu0Q27cwOqUoMvgwduQ5IC1QgQggRaE6nkzmlZX8irFwworPJEQVGowbGYnulS2GEAq9nd2mtZ5V+7arSXVq86XdXoVQhhAhqa3Zk8Hu6UfZn0pB2JCWEXtmfcOXTVGOlVD/gZWBEhe3LgTu11pv8GJsQQvhNid3BvO93AUbpnLOHdjA5IuHO62TkmvD6IxCDMdJuq2tXL+A8YLlSarjWemsVpxBCCNMs+/kAGbn5AJyf0jGky/6EI19+Go8DxUBKxRaQK1H94DrmIv+FJ4QQpy+/sISvS8v+JMYyZkAbcwMSlfgygGEU8Kqnrjit9RbgNYxlyYUQIqi4l/25cHTnkC/7E458+Yk0AA5Vsz/ddYwQQgSNnOOFLFptlP3p1CqBwd2bmxyR8MSXZLQLmFLN/imuY4QQImh89eOpsj+XjE0Om7I/4caXe0azgX8opf4DPAXscG3vATwITAL+4t/whBCi9g5knWD5JqPsT78uTcKq7E+48SUZPQ8MBC4FZgCls6msgAWYA/zTr9EFiFLqMWA60B24XGv9ickhCSEC4HO3sj8Xh1nZn3Djy6RXOzBDKfUOMJVTk153AV9qrRf7P7yA+RW4C3jC7ECEEIGh9+aw4bcsAEb0aUWbZvEmRySq4/NAe611KpAagFjqjNb6QwCl1ENmxyKE8D+n08ncZTsBo+zP1JHhWfYnnJg660sp1QqjhTIUGATEA2O11ss8HBuNMY/pKiAJ2Ag8pLVeUmcBCyFCwjqdya6DxwCYOFjK/oQCswfbK4ylKtoCNZUSmgncA3yIkcAcwLdKqWGBDFAIEVpK7A4++95oFUnZn9Bhdj2MdUBTrXW2Umoq8IWng5RSQzAGTtyjtX7RtW02sAV4FmNCbumxy6h68u2ftdbP+yt4IUTw+X7DQTJyjLI/5w3vSFyM2W9zwhum/pS01se9PPRijFJE77g9t0Ap9S7wlFKqldY63bV9jN8DFUKEhBK7g/+t2A1As8QYxg6Usj+hIlT+ZRgA7NBa51XYvhpjWHl/jAoQXlFKRQI2jG7KSKVUDFCktQ6dxT+EEJWs2ZFBbl4RAFOGdZSyPyHEq2SklIrFmJejtdarAhuSR62AAx62lyag1j6e723gGtfXIzEm9I4FlvlykiZN6maoaLNmCXXyOvWRXNvAqetr63Q6WbrhIACJ8dFMGZ1MVKStTmOoKzVd25iYSACsVkvI/I572zIqxHgDvwswIxnFumKoqMBtv9e01tcC155eSJCdnYfD4Tzd01SrWbMEMjO97c0UvpBrGzhmXNtf9uXy275cAEb1a8XR3JN1+vp1xZtrW1BgFIV1OJxB9TtutVqq/Cfeqzasq/tqH9DQj3H5Ih/wNDYzxm2/EKIeS11jFEONsFkYO7CtydEIX/nSoToLuMo136eupWN01VVUuu1gHcYihAgymbn5rP81E4ChPVvQqEGUyREJX/kygCENuBDYoJR6DaOkTqV2sNb6Bz/F5m4DcJdSKr7CIIahrs8bA/CaQogQsWTdfpyuHvOJg9qZG4yoFV+SkXsJoJeAijdLLK5tgbhj+BlwH3Aj8CKUVWS4DvhJay0tIyHqqfzCEn7YaLwFdG+fSPsWoXHDXpTnSzK6LhABKKUedn3Zw/X5KqXUCCBXa/1vAK31KqXUXOA5VwmhnRij4Trgh4EIQojQ9eOmdAqK7ABMGtze5GhEbflStXtWgGKoWDn7etfnPcC/3bZf7Tr2aozadJuAc7TWPwUoLiFEkHM4nKSuNQYuNE+KpW9yE5MjErVl+qRXrbVXyy5qrQuAP7s+hBCCDb9lkXXUmOExcVA7rLKKa8jyKRkppdoBj2Gs6tocmKy1/k4p1QyjRtzrWus1/g9TCCEqW+Qazh0bHUFKn5YmRyNOh9dDu5VSnYC1wEXAVtwGKmitMzGWgLjR3wEKIYQnew4d5xfXJNfR/VoTE2V6R484Db789J7CWLahN8Yk04wK++cD5/kpLiGEqFZpq8hqsTD+DJnkGup8mfQ6AXhNa72PysO6wRhwIL8RQoiAy80rZPX2wwCcoZrRpFFMDc8Qwc6XZNSQ6itjRxEEAyKEEOHvu/UHsLvqQk4cLJNcq+J0BrZ2pj/5koz2Ab2q2X8m8NvphSOEENUrKraz7GejiH/n1g1JbtPI5IiCTygOKvQlGc0DrldK9Xbb5gRQSl2EscTEHD/GJoQQlazYeoi8fKMq9SRpFYUNX5LRU8B+jCUkPsRIRH9RSq3ASEIbgX/6PUIhhHBxOp2krt0PQFJCNAO7NTM5IuEvXicjrfUxYBjG0t+DMGrRTQQU8Bow1jUxVQghAmLr7iMczDoBwIQz2spKrmHEpwEHroR0F0YF7WYYCSlTax06d8mEECErdY3RKoqKtDKqv68LPItgVuvRb66JrkIIUScOZp1g865sAFL6tKKBa2ltER58TkZKqUuAaUBn16ZdwBdaaxm8IIQImMWugqggaxaFI6+TkVKqAfAlMA6jey7XtWswcIlS6mbgfK31CT/HKISo5/Lyi0nbcgiAvl2a0LJxnMkRCX/zdTTdeOAVoLXWurHWujHQ2rVtrOsYIYTwq+83HKCoxAHIcO5w5Us33Qxgrtb6bveNWutDwN1KqTauY+6u/FQhhKidEruDJeuMgQttmzWgR4ckkyMSgeBrOaCl1ez/znWMEEL4zdodGeTmFQHGvSJLKJYXEDXyJRltArpWs78rsPn0whFCiFOcTmdZde6EuEjO7NXC5IhEoPiSjB4GblJKVVomQil1AcZaRn/1V2BCCPHbgaPsPnQcgLED2hAZYavhGSJUVXnPSCn1nofNvwNfKqU0sN21rQdGFYbNwBUY3XVCCHHaSltFETYLYwfKCjXhrLoBDNdWs6+768NdX6APcMNpxiSEEGTm5rP+F2Nu/dCeLWjUIMrkiEQgVZmMtNZS9EkIYZol6/ZTuhyPTHINf5JwhBBBJ7+whOWbDgLQvX0i7VskmByRCDRJRkKIoPPj5nTyC+0ATBrc3uRoRF3wqTadUmo48EeMYdxNMMoCuXNqrbv4KTYhRD3kcDjL6tA1T4qlb3ITkyMSdcGX2nQ3AW8ARYAG9gYqKCFE/bXhtywyc42l0SYOaodVJrnWC760jP4KbADO0lpnBSYcIUR9l+oazh0bHUFKn5YmRyPqii/3jFoA70oiEkIEyp5Dx9H7cgEY3a81MVG1XnJNhBhfktF2QCoUCiECJtV1r8hqsTD+DJnkWp/4uoTEbUopWetXCOF3uXmFrNp2GICBqhlNGsWYHJGoS163gbXW85RSccA2pdRXwG7AXuEwp9b6CT/GJ4SoJ75bfwC7w5jlKmsW1T++jKbrBjyOsUzEVVUc5gQkGQkhfFJUbGfZzwcA6Ny6IcltGpkckahrvtwdfA1oDtwFLAdyAhKREKLeWbntMHn5xYCU/qmvfElGw4D/01q/EqhghBD1j9PpLBvOnZQQzRmqmckRCTP4MoDhKJAZqECEEPXTtt05HMg6AcD4M9oSYZMqZfWRLz/1OcCFgQpECFE/la5ZFBVpZXR/GaxbX/nSTfcmMEsp9SXwMsZCexVH06G1ljJBQgivpGefYPOubABS+rSiQUykyRGFF6fZAfjAl2S0FeN7GwRUWnrcjawLLITwSura/WVfT5BJrn4UevX8fElGjxNaiVYI4SdZR/PJchUv9caho4Xk5p6s9pgSh4O0zekA9O3ShFZNGpxWjCK0+TLp9dEAxiGECFJ7Dx/niVlryyakBoJMchUybEUIUa35K/cENBF1adOQHh2k7GV950sFhlHeHKe1/qH24QghgsmRYwWs3WHM6Oif3NTrFkxiYlyN3XQAVquFDi0TsMiaRfWeL/eMluHdPSMZwCBEmFiyfj8Op/Fnf15KRzq1aujV85o1SyAz83ggQxNhxpdkdF0Vz+8CXItROPXN0w9JCBEMCovs/LDhIABd2zbyOhEJURu+DGCYVdU+pdT/Aev9EpEQIiikbUnnREEJIPXiROD5ZQCD1joHeAe43x/nE0KYy+F0ssg1B6hpoxgGdpN6cSKw/DmaLgfo7MfzCSFMsnlnNoePGAMQxp/RFqtVBhiIwPJLMlJKxWCscXTIH+cTQpirdPnv6CgbI/tKvTgReL4M7X6vil2NMZaXaAb82R9BCSHMsz8jj227jeXKRvZtRVyML+OchKgdX37Lrq1i+xHgF+AerfV/TjsiIYSpSltFFqRenKg7voymk2oNQoS5YyeKWLH1MAD9uzaleVKcyRGJ+kISjBCizLKfD1BidwBSL07ULUlGQggAikscfPfzAQDat4inW7tEcwMS9Uq13XRKqa99PJ9Ta33BacQjhDDJ6u2HOXaiCDBaRVIvTtSlmu4ZTfHxfLLekRAhyOl0kupa/rtRgyiG9GhhckSivqk2GXkzaEEpNRp4DhgMpPspLiFEHdJ7c9mbkQfAuIFtiLBJD76oW7WeQKCU6g08C0wGjgN/A/7lp7iEEHVokatVFBlhZfSANiZHI+ojn5ORUqod8ARwBWAHXgae1Fpn+zk2IUQdOJxzko2/ZQEwrFcLGsZFmRyRqI98qcCQBDwE3AZEAx8DD2utdwcmNCFEXVi8dn/ZzV6pzi3MUmMyUkpFA3cDDwCJQCrwgNZ6QyADE0IE3smCYn7cZNzq7dUxiTbN4k2OSNRXNQ3tvgF4FGiNsV7RX7TWS+ogLiFEHfhhYzqFxXYAJg5ub3I0oj6rqWX0NsZw7bXAHKCfUqpfNcc7tdYv+Cs4IUTg2B0OlqwzBi60ahJH786NTY5I1Gfe3DOyYAzbHuzFsU5AkpEQIeDnX7LIPlYIwIRB7bDKJFdhopqS0dg6iUIIUedKh3M3iIlgeO+WJkcj6ruaJr1+X1eBCCHqzq6Dx/jtwFEAxgxoQ3SkzeSIRH0n06yFqIdK1yyyWS2MGyhrFgnzSTISop45cqyAtTsyABjcvTlJCdEmRySEJCMh6p3v1h/A7jCmuU6UNYvCWwiVrpZkJEQ9Ulhk5/sNxppFyW0b0alVQ5MjEoEQigMjJRkJUY+kbUnnREEJAJOk9I8IIpKMhKgnHE4nqWv3A9CkYQwDujU1OSIhTpFkJEQ9sWVXNoeOnARgwqC22Kzy5y+Ch/w2ClFPlK7kGh1lY2Tf1iZHI0R5koyEqAf2Z+axdXcOACP7tCIuptbragoREJKMhKgHSltFFowuOiGCjSQjIcLcsZNFrNh6GID+XZvSPCnO5IiEqEySkRBhbtnPByixOwCYJJNcRZCSZCREGCsucbB0vTHJtX2LeLq1SzQ3ICGqIMlIiDC2evthjp4oAmDioHZYQnFqvqgXJBkJEaacTmfZwIVGDaIY0qOFyREJUTVJRkKEqV/25bI3Iw+AsQPbEBkhf+4ieMlvpxBhqnQl1wiblTED2pgcjRDVk2QkRBg6nHOSDb9mATC8dwsaxkWZHJEQ1ZNkJEQYWrJ2f9lSNhOkOrcIAZKMhAgzJwtKWL45HYBeHZNo2yze5IiEqJkkIyHCzPJNBykssgOykqsIHZKMhAgjdoeDxa41i1o2jqN35yYmRySEdyQZCRFGfv4li+xjBYDRKrLKJFcRIiQZhYEjxwp4ce7GsgmOwn8ycvN5Yc5Glv18wOxQvLJorfE70CAmguG9WpocjRDek2QUBt757zY27czm4yW/4nA4a36C8Npr8zazeVc2sxdqs0OpUWGxnd/2HwUgpU8roqNsJkckhPckGYUBvS/X7BDCVmkFg1Dg/o9IUkK0iZEI4TtJRkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTRZgdQIiyAVitdVNqpabXaZ4Ui9N56ti6iisceHNtvT3WbDabtSzeBrGRpsdr9uuHs5qubcMGUTRPiiU+Liqofg5usVSakW1xOmXGfi2MAJabHYQQQoSokcCP7hskGdVONDAYSAfsJscihBChwga0AtYAhe47JBkJIYQwnQxgEEIIYTpJRkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSW26IKSUigYeB64CkoCNwENa6yWmBhbilFKDgWuBsUAHIBtIAx7WWv9mYmhhRyl1P/AssFFr3d/kcMKC6/f3UWA4EAnsBF7QWs80MSy/kZZRcJoJ3AN8CNwFOIBvlVLDzAwqDDwAXAgsxriubwFjgJ+VUj1MjCusKKVaAg8DJ8yOJVwopc4GfsJIQn8D/oTxe9zOzLj8SVpGQUYpNQS4FLhHa/2ia9tsYAvGf5qjzIsu5P0LuFxrXVS6QSn1KbAZI1Fda1Jc4eYZYC3GP7uJ5oYS+pRSjTD+QX1da32XyeEEjLSMgs/FQDHwTukGrXUB8C4wQinVyqzAQp3WOs09Ebm2/QpsBaRl5Aeuf6auBO41O5YwcjlGUv87gFIqQSkVPOtC+Ikko+AzANihtc6rsH01YAH613lEYcz1R90CyDI7llDnupavALO01htMDiecTAB2AOcopfYBx4AjSqlnlFKV1gUKVdJNF3xaAQc8bE93fW5dh7HUB1cAbYCHzA4kDFwN9ASmmhxHuEnGuDc0E3gO+BmYgtG1HAPcbVZg/iTJKPjEUmGdD5cCt/3CD5RS3YFXMRb5+sDkcEKaUioB417RM1rr9JqOFz6JxxhV+xet9bOubfOUUvHAbUqpJ7XWId+yl2664JOPsXhfRTFu+8Vpco34+h+QA0zXWjtMDinUPQwUYQwSEf5V+jf/cYXtH2GMrhtSt+EEhrSMgk86RlddRaXbDtZhLGHJNTrpW6ARkKK1PmRySCHNNajmbowhxy2UUqW7YoAopVRH4KjWOseUAENfOtALOFxhe+njpLoNJzCkZRR8NgDdXU1wd0NdnzfWbTjhRSkVA3wDdAOmaK21ySGFgxZAFMbUg9/dPoZijFL8HeP+hqidda7PbSpsb+v6nFmHsQSMJKPg8xlG0/vG0g2uigzXAT9praVlVEuukUefAsMwuuZWmhxSuPgdmObhYyuw2/X1bLOCCwNzXZ9vKN3gGrl4I8bE4rD4PbY4nU6zYxAVKKXmYIxIegGj5Mc1wGBgrNb6JxNDC2lKqRcxKi98A8ypsDtPa/1lXccUzpRSy4BEKQd0+pRSszDKg70LrAfOdX3cr7X+PzNj8xe5ZxScrgaecH1OAjYB50giOm39XZ/Pc3242wN8WZfBCOGDm4C9GP+YXgPsAm7RWr9palR+JC0jIYQQppN7RkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSTISQghhOklGQgghTCfJSIQUpdQYpZRTKXWt2bGcLqVUb6VUiVJqotmx1AdKqQuUUkVKqa5mxyIqk2QkhHn+hVGJPdV9o1KqsSvhfmtSXAGjlPq3UuqAq+p0VceU/sNxnz9fW2v9FbAZY6kLEWQkGQlhAqXUMGAinldGHej6vL7uIgo8VwKaCnyltTarKOZLwDSlVC+TXl9UQZKREOa4DcgC5nvYF5bJCGMZlDaYWx19HnASuMXEGIQHsoSECAtKqabAY8D5GCuPHga+Bv6utc6ucGxH4J8YLROApRjLZi8FdmutxwQ41giMFsJ/tdbFHg4J12Q0DcjFuM6m0FrnKaWWAxcDd5gVh6hMWkYi5CmlGgFpwK3AQozEssD1+EelVILbsU2A5RjrGc3EWA77BMYbZIM6CvkMIB5YXcX+gUCO1vr3OoqnrkwD5leRgOvSCqClUqq7yXEIN9IyEuHgfqAr8Eet9WulG5VSG4B/u/b/zbX5AaAtcKXW+iPXtteVUs8Bf66jeHu6Pu+suMOVOJMxsfUQCEqpHoACHjY7Fk5d917ADjMDEadIMhLhYBqQCbxVYfubwCOu/aXJ6DwgHfi4wrHPU3fJqJnr8xEP+wYAFsKvi24qUIDRYvUrpVRLjFWRuwMZwFyt9bpqnlLabdvc37GI2pNkJMJBJ2Ct1rrEfaPWukQp9Qun7sGUHrtaa+2ocGyGUirXfZtS6hLgTozlyrO01h0r7I/AuPd0FUaX9+cYrbOCGuItHUnmaXjzGa7PVSYjpdRIwNOw7yjAprW2VTj+NYwuy+Fa6xUV9i0DRmMsa/+t2/ZLgE+B/2mtp7i2dQOeA1KAGFz35bTW91YVq5tpwGKtdZ4Xx3pNKXURMA54F3gFI8FcrpS6GPhrFaP2Sq+7LHMdRCQZCVG1HIxuvhbAPR72/xUYC/QBijAGTDyHkcCqk+n63NjDvhoHL2itl2PccyqjlGoNrHXF6749FrgcoxV2I8b9kop2ADdQPsHdSOUurP9hjEa7EmNEWheMxFQtpVRbYBBwU03H+kIp1RvoqLX+o9vmPcA/lFJnYoyYe93DU0uve6aHfcIkMoBBhINdgHK1VMq4Hndz7S+1G0hWSlkrHNscSHTfprVO1Vp/gvEG58mNwNNa6wNa60zgUeBapZStiuNLbXF99lQJYCCQB/xSwznKKKWiMZLEj1rrpyvsng44MAZ1XKKUiqeyOcA4pVQz1/k6YLQGv3R7jaYY97Le0Frnaa0dWutftdYzvQhxKkYr5GtvvycvXYjneVporVcCTSv+Trgkuz5v8bBPmESSkQgHX2Lch7mxwvabXNu/cNv2DdAKuKzCsT7N9ldKJQLtgA1um9cDCUDHGp7+M3AMOLPCOeMwbvJv8HFS6BsY3WbXeth3I/AJRsIpBi71cMxxjGt0tevxDcB/gMLSA7TWWcB24D2l1KVKqS4+xDcNI1H6uyVysvQ6KaWGKaWylFLuAyTWYfwzUtGZwGGttfZzPOI0SDedCAfPYbQAXlVKDcR4sx+A8aaqXftLPYvRbfW+UmoIRlfUSGA4xiRUb5NA6XDxXLdtuRX2eaS1tiul5gFTlVLRWuvSN/1+gA2IUUr9xcNT87TWFbvh7gSmAIO11icr7OuG8b39WWtdqJT6BOOavOPh3O8C7yilXsRIaucCF1U4ZgxG0v4r0FMptRf4i9Z6TlXfq1KqMTAKY0Sjr8YrpWI8bM/SWr9RYVs/oAnluw2PUeFn4WoZjgTeq0U8IoCkZSRCntb6KMab0JvAOcDLrs9vACO01sfdjs0CRgD/Ba7HSE4NMO79WIB8L1+29JyN3LYlVthXndddx09x21Z6v2gQ8A8PH9PdT6CUGuuKf7rWereH17gR2KG1XuV6PBM401MpHK11Gsb3/yhwSGu92cMxGVrr+7XWfTHuu7wG/KeG+TpTMP7p/aKaY6oyGXjCw8fdrv2xbse+g9ECu8ZtWz/g1wrnvAiIw/hdEUFEWkYipGitl+FhFJqrC+g210dN5/gd435DGddk2CbAXi/jyFVK7cO4t1La3TMAIxHt9uL5q5VSpRN0P3dtexV41ZvXd1WRmIPR6lnmYX8kRrdbI6XUoQq7bwA8jYB7F6MVeasX8R8DnldKPUj183WmARurSJZVnXsZnkcaVrRbKTVca53mGkn5ZekO10TojlrrisPn7wK+0FrL/aIgI8lI1DtKqVitdcUWUGm3WKrbcTYg0vVhcXUZOd261d4BHnSVlynGaFXM1FrbvQzlT8BGpdQkrfUiH+KPw3jj/bpit52b84AkjATp/oZ8JfCAUuovWuuiCs95C+MeWJqH10zCmIf1EcbgCitGd14cxr2ZqqwA3q72G6q9D4GXlFIN3CufK6U6YbSgyiVcpdRUoDcwI0DxiNMgyUjUR/OVUnswBhxYgfEY3UlplC/ieRXwvtvjfIyRdR1dj58GmgJbXef5DKPCg1e01lup3d/gRRhdUN2UUp7eWHtidNF9rLXe5r5DKfUG8BDGCLdy93pcrZ3FVbxmEdASY0RcC4zBDVuB86tr9Witn6tq3+nSWjuVUncDtyulbsQYNWjFmNR8V8WahFrrLzHmYokgZHE6Zd6XqF+UUn/C6MLqiHHfYT/G0OjH3O8vCSHqjiQjIYQQppPRdEIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSTISQghhuv8HejwwbWv8RfwAAAAASUVORK5CYII=\n", + "text/plain": [ + "<Figure size 432x288 with 1 Axes>" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "# make a plot of the luminosity distribution using Seaborn and Pandas\n", "import seaborn as sns\n", @@ -412,7 +451,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "1f37d2c0-1108-4ab9-a309-20b1e6b6e3fd", "metadata": {}, "outputs": [], @@ -420,16 +459,45 @@ "# Update the probability distribution to use the three-part power law IMF \n", "population.update_grid_variable(\n", " name=\"M_1\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)\",\n", ")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "6f4463e8-1935-45f2-8c5f-e7b215f8dc47", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Do dry run? True\n", + "Doing dry run to calculate total starcount and probability\n", + "Grid has handled 39 stars with a total probability of 0.211729\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 39 *\n", + "* Total probability is 0.211729 *\n", + "**********************************\n", + "\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", + "**********************************************************\n", + "* Population-1d1d556abeae4549aa28f9740807dc84 finished! *\n", + "* The total probability is 0.211729. *\n", + "* It took a total of 3.90s to run 39 systems on 2 cores *\n", + "* = 7.80s of CPU time. *\n", + "* Maximum memory use 519.211 MB *\n", + "**********************************************************\n", + "\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" + ] + } + ], "source": [ "# Clean and re-evolve the population \n", "population.clean()\n", @@ -441,10 +509,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "id": "cfe45a9e-1121-43b6-b6b6-4de6f8946a18", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[None]" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEdCAYAAABDiROIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAABEJElEQVR4nO3dd3hUVfrA8e+kBxJIgAAhIC3wgoCA0nsVxQYKYl97Wxu7lnV1f3ZXXfvaK7ZVwYoFpYnSq3Q80msCAUIJJJAyvz/uJEySSTITZnJnkvfzPDyTnHvmzjuXyX3nnHvuOQ6n04lSSilltzC7A1BKKaVAE5JSSqkgoQlJKaVUUNCEpJRSKihoQlJKKRUUIuwOIERFA92BNCDf5liUUipUhAPJwGLgWMmNmpAqpzsw2+4glFIqRPUH5pQs1IRUOWkAmZlHKCgI7H1c9evHsW9fVkBfo6bSYxs4emwDJ5SPbViYg8TE2uA6h5akCaly8gEKCpwBT0iFr6MCQ49t4OixDZxqcGw9XurQQQ1KKaWCgiYkpZRSQUETklJKqaCgCUkppVRQ0ISklFIqKOgouxCUnX2ErKwD5OfnFZXl5hWQX+AkOjIch8PG4ELInj1hFBQU2B1GtaTHNnCC8diGhYUTERFFfHwCkZFRld6PJqQQk519hMOHM0lISCIyMgqHw0FBgZNtuw9DONSuG0OdWpX/QNQkERFh5OUF1x92daHHNnCC7dg6nU4KCvI5diybzMw9xMcnEhtbu1L70i67EJOVdYCEhCSioqJxuJpCefknPpyHjxy3KzSlVA3kcDgID4+gVq14EhIacOTIwUrvSxNSiMnPzzupJrFSSgVKZGQ0eXm5lX6+JqQQ5NCLREqpIHSy5yZNSEoppYKCJiSllFJBQROSUgEyZsx5PPHEw7a89m233chtt91oy2sXSkvbRb9+3fjxx++C5vWfeOJhxow5z7bXPuusQQF/7bJePxTU2GHfIvIIMBZoB1xmjPnM5pBqrLS0XYwde36F9f75z4cYObL4yWTfvr1ceOE5FBQUMGnSdzRu3LjU82677UaWL19Gy5at+OijiaW2z5w5nf/7v38A8PLLb3D66d2Ktq1YsZwPP3yPjRvXc+jQQRISEklNbcuwYSM488yzfH2rNd6CBfNYs2YV1113k92heG316lUsXDiPiy++jPj4eLvDKSYUj2d5amxCAtYDdwKP2R1ITZeQkMi//vWox20FBQX8978vkJ19lDZtpNT2GTOmEhMTQ3h4BNOn/8QVV1ztcT9RUVFs3ryJDRvWk5rapti2adN+IioqmuPHiy9gOXPmdB566H7atGnL2LGXEB9fh7S0XSxfvozvvvs6qBPSCy+8ancING6czIwZc4mIOHGaWbhwPpMmfWrbCfS++x70+abStWtX8f77bzNy5HleJyRP7z0QyjqeVfX6/hZa0fqRMeZjABF5wO5YarrY2FhGjBjpcdu7777JoUMHue22u2jTpm2p7dOm/US/fgOJiopi2rSfy0xIp5zSgqNHjzB9+s/FElJWVhYLF86jd+++/PrrL8We8957b9GqVWvefHMCkZGRxbZlZu738V1WrZLx2sHhcBAdHW13GMUE+gSdn59Pfn4+UVFRtr73YDz23rD9GpKIJIvIUyLyi4gcFhGniAwqo260iDwtIrtEJFtEFojI0CoOWVWR5cuX8eGH79G7d1/Gjbu81Pbt27exbt1ahg49k6FDz2TjxvVs2rSxzP0NHXomM2ZMxek8sbjZrFkzcDgc9O8/qFT9Xbt2cOqpHT2e3BMT6/n8ft5990369etWqvzHH7+jX79upKXtKiobM+Y87r//7yxevIBrr72cIUP6cu21l7N27WoApkz5nksuuZAhQ/pw2203smvXzmL7LHkNadmyJfTr141ff53JhAnvMGrU2QwZ0oc777yFHTu2l4ppxoypXHPNZQwZ0odzzx3Ov//9KAcOHChWZ/v2bTzwwD2cf/4Ihgzpw+jRI3noofvJyrJWMy15HeOJJx5m0qRPAejXr1vRv6NHjzJsWD9efPHZUnFs376Nfv268dVXk8o9tocPH+aJJx5mxIiBnHXWIB5//CGysg6XqufpGtL06T9z7bVXMHz4AM48cyBXXTWOiROtON99901efvl5AMaOPb8o5sL/q379uvHSS88xZcr3XHbZRQwZ0ofVq1eWew1nx47t3HXXrQwb1o8LLzyHTz75oNj2wv+rZcuWFCsv3Of3308u93i61y35+kuWLOKWW65l6NC+nHXWYB588L5Sn53Ca127d6dz333jGT68P+eeO4xXXnmR/HyP6+r5TTC0kAS4D9gArAT6lFN3AnAR8KKr/tXAFBEZaIyZH9AoVZU6dOggjz76LxIT6/HAA494vL9h2rSfiI+vQ48evXA4HNSrV59p037ippv+6nGfw4efxUcfvc/q1Svp1KkzYJ2M+vTpT61apac6adSoMUuWLCIjYw9JSQ39+wa9sHXrFh5//CFGjRrDmWfG8vHHH3DvveO5+ea/8sknH3LBBRdy9OgRPvnkA55++nFeeun1Cvf5wQfvEhYWzmWXXcXhw4f49NOPeOSRB3n77RMnxR9//I4nn3yEDh06ccstd7Bnz26+/PJz1q1bw9tvf0h0dDS5ubn87W+3Ex4exrhxl1G3bl12797NvHlzyMo6TEJCnVKvfcEFF7Jv3z4WLZpfrIu2Vq1aDBgwmF9+mcbtt48nPDy8aNvUqVOIiIhg6NDhZb4np9PJ/ff/nZUrlzNq1EU0b96C336bxeOPP1zh8Vi8eAEPP/wAAwcO5vzzR5Ofn8+WLZtZtWoFF198KQMHDmHXrh38/PMU7rjjb9StmwBY3czu+5g5cyqjR48lPj6eBg0alPl6eXl5/P3vt9O5c1duueUO5s2bw+uv/xeAyy//S4XxuivreJb9Xhdy99130KxZc66//haOHj3CpEmfcsst1zFhwqckJp54T3l5efztb7fRqVNn/vrXO1m8eCGfffYxKSlNGT16jE9x+iIYEtJSoIExZp+IjAK+9lRJRHoAlwDjjTEvuso+BFYDTwMD3OrOAgaW8Xr3GGNKfxVTQeXf/36MvXszePHF10hISPBYZ9q0nxgwYFBRN8ygQUOYPv1nbrzxVo8JrFWr1rRuncq0aT/RqVNn9u3by++/L+XRR5/yuP/LL/8LTz31GOPGjaJTp86cdloXunfvSceOpxEWFvjOhW3btvLWWxM49dSOACQlNeKhh+7n1Vdf5rPPvio6Oebl5fHRR++ze3c6jRqVHtThLi8vj/fe+6DomNWpU5eXXnqWTZs20KpVKnl5ebz++n9JTW3Lf//7JlFR1qwgIu14+OEH+O67rxkz5hK2bNlEWtpO3n77A9q371C0//KuDXXseBrNm7dg0aL5pbpoR4wYydSpU1i2bDHdu/cqKp827Sd69uxd9F49mTPnV5YvX8btt48vakmPGjWGO+64udxjATBv3lxatmzFE0/8x+P21NQ2iLTn55+n0L//IJKTm5Sqs337Nj76aCKnnNK8qMy9tesuJyeHfv0Gcvvt4wEYPXoM48ffxoQJ7zJ69Fhq1apVYcyFyjuenrz22kskJCTw+uvvFl0L69mzDzfffA0ffzyhKKbCOM866xyuvPIawDqe1157Od9//231TkjGmNLtas/GALnAO27PzRGRd4EnRCTZGJPmKh/k90CD3M6MLH5bmUZuXgHRkeEVPyFAYqLCOa9vS1o1Kf0N2VtffjmR2bNncfXV1xcb8ebujz/Wsn37NsaPv7eobOjQEXz11SRWrVrBaad18fi8YcNGMHHip9x5591Mnz6N2NhYevfuy4IF80rVPffcC0hKasjnn3/CsmVLWLp0Me+//zYpKU35178eo2PHTpV+j95o3bpNUTIC6NDB+rlfvwHFTtCnnmolhLS0XRUmpHPOOb/YdZTOnbsAsGvXTlq1SuWPP9aSmbmfG264pSgZAQwZMpxXX32JefPmMmbMJdSuHQfA3LmzSU1te9LXrLp160H9+g2YOvWnooS0du1qduzYzg033Fruc+fPn0tkZCQXXHBRUVl4eDgXXTSOFSt+L/e5cXFx7NmzmzVrVhcdX1+dfnq3YsmoIhdeOLbo57CwMEaPvoilSxexcuVyevUqr4Oo8vbu3cv69X9y5ZXXFBuY0bFjJzp06MT8+XOKJSSwWmDuTjutKz///GNA4itke0LyQVfgD2NMVonyRYAD6AKkebszEYkEwrGuo0WKSAxw3BgTPNPo+mDhuj2s31H5SQ39KTY6ghvP71BxRQ82btzAq6++ROfOXbnmmhvKrDd16hRq1apN48aNi66B1KtXj4SEBKZO/anMhDR06Jm8+earLFmyiKlTpzBgwOBiJ96SevbsTc+evcnJycGYdcyYMZVvv/2Ke++9i08++aJYN4e/lUwuhUmgYcNGHssPHz7k8z7j4+u4nmt9L0xPt/6ESp5gw8LCaNq0Gbt3W9ubNElh3LjLmTDhHT7//H907Xo6ffr058wzz/LY/VmR8PBwhg8/i++++5q7776f6Ohopk79idq1a9OvX/9yn5uenk6DBg2JiYkpVu5NkrjwwrH88st0brrpapKTU+jevQeDBw+je/eeXsfuqdVUlvDw8FL1mzY9BYD0dM+tKn8o6/8VoHnzFkyfPrVYWWxsLerUqVusLD4+3qvP2MkIpYSUDOz0UF6YhLz/VFjeBgo7bfsDHwKDgVmVCc5uPds35FhuflC0kIZ3b1ap5x47lsNDD/2TmJgYHnro8WLXEtwVFBQwY8Y0jh49wmWXle4+mDVrOnfddbfHEVVNmqTQoUMnPvrofdasWc1111XcrQMQExND585d6dy5K3XrJvD++2+zYMFczj77XK/fX1nzfBUUeL5QHB7uuVuwrO5Ct7EaZQoL83xMnd48uYTbbx/POeecx+zZv7Jo0QKef/5pPvzwPd58832Sk8tvqXly1lnn8NlnHzNv3mwGDBjMzJnTGDhwCNHRMRU/uZISE+vx/vv/Y9GiBSxYMI8FC+YxefLXnHPO+dx///95tQ9/x1f256TqviuX9dkLtFBKSLHAMQ/lOW7bvWaMuRprUESl1a8fdzJP91pS0okm9p49YUREFP+w5DudpCTFcenQNkRFhnNK4+C6ec9b//nPc2zZsolnnnmBJk2Sy6y3aNFi9u3by6233k7TpsWT3549u3nxxedYunQhffta36wdDgcOB0XHbcSIs3n++WdITKxHz549CQ8PIzzcOgmEh5c+viV16GC1/jIz91VY1+FwFNWpW9f6xpmdfaRYt8mePbs9vrb7c+FE/GFhxcsLTx7h4SfKC09qhb97quNeXrjPlBTre92OHdvo1u1Ed6nT6WTHju20bt262PPbtm1L27Ztue66G1i9ehXXX/8XJk/+iptuurXUvgtf3z0ud+3aCampbZg+/Wfi4+PYv38fZ589ssJj3KRJMr//voS8vGPExJw4Dezcua3U65c8LtbP0QwcOJCBAwfidDp57rmn+eKLiVxzzXU0bdrM7dh5/myEhZV+P57eu8PhID8/n4yMdFJSmhbV3bVrh+t9pBAREUZCwonPift+MzLS3WIu/3iWfP2mTU/8v5asu337VpKTk8s9RoX78lRe+niEFTtn+SKUElI24GlgfYzb9iq1b18WBQW+f7P0RVJSPBkZJy6zFRQUlFqcK9/td6fTGVSLd3nrl1+m8+23XzNmzDj69Olf7nv46acfiYuL4+KLLy/VCnI6nXzwwfv89NMUevbsW1TmdFK0z8GDh5OZmUlqaipOp4O8vALy863/x/z8E8d3yZJFdOvWo9Trz5kzB4CUlFMqPNbu/x/JySkALF26hH79rDE32dnZ/PDDd6Veu+Rz4UT8BQXFy/Nd62Hl558oL2zxFP7uqY57eeE+27RpT2JiPb76ahIjRpxTdG1o5szpZGTs4fLLryIvr4AjR7KIjo4pdvybN29FeHg4OTnHPO4bICrK+nPNzDzo8SbTESPO4e23XyM/P58GDZLo3PmMCo9xz559+Oabr/jyyy+KBjXk5+czceJnpV6/5HE5ePBAqQETLVumAnD0aA55eQVFMR88eJCGDUu3/AoKKP036eG9F772xImfF12vKSgo4MsvJxEbG0vHjp3JyysgKakx4eHhLFu2lL59T4zN+uKLE7OMVHQ8S75+QkJ92rRpy/ffT+bSS68iLs76Mr127WpWrVrJuHGXl3mMTrxPz+Wlj0dBsXOWu7AwR7lf5EMpIaVhdduVVFgWuA5YFVB792bw9NNPEBtbi9TUNmVeOE1JaUqbNsJvv/1C9+69PHbJORwOevfuyy+/TCc7O5vY2NIN58TERK677qYKV968//6/k5zchL59B5CSkkJ2dg5Llixk7tzZtG9/alELzFs9evSiUaPGPPXUY1x66RbCwsL54YfJJCQksnt3esU7qAIRERHccsvtPPnkI9x++00MG3Yme/bs5osvPqdVq9acd95owEqqL7zwDIMGDeWUU5pTUJDPzz9PweFwMHDgkDL3L9IegBdf/A89e/YmLCyMYcNGFG0fPvws3njjv8yZ8xuXXHKFV6MZ+/YdQKdOnXn11ZfYuXMHzZu35Lfffim6H6o8Tz31OIcPH+L007vRsGFDdu+23mubNm1p0aKlK+Z2ALz11msMHXomERER9O07wONnqyIxMTHMmfMrhw8fQqQ98+bNYenSRdx0021FI+zi4uIYNGgoX3zxOeAgJaUp8+bNJjMzs9T+Kjqe7m699U7uvvsObrnlWs4553yOHDnCpEmfUb9+gzJvKK9qoZSQlgN3ikhciYENhVcfV1R9SMoftm3bWnQT41NPPV5mvbPPPpe+ffuTlZVFnz79yqzXt29/fvzxO2bP/vWkpve5774HmT37V2bOnMbevRk4nVa3ylVXXcsVV/zF57v+IyIiePLJZ3nuuad45503qFevPhdffCnx8XV48slHKh2nv40ceR5RUVF88skHvPrqS9SuXZvhw8/i5ptvL7r7PzW1DT169GLevNl8++1XxMTEkJrahmeffbnc0Yf9+w9k7NhLmTbtJ6ZOnYLT6Sx2Am3QoAFnnNHDNZT5bK/iDQsL4+mnn+ell57j559/xOFw0LfvAG677S6uuab0DdXuRow4m8mTv+brr78gK+sw9erVZ8iQYVx77Y1FybBt23bcdNNf+eqrSSxcON81b+LkSiWkiIgInnvuvzz77L+ZMWMq8fF1uOmm27jyyquL1Rs//l7y8/P49tsviYyMYsiQYdx6651cddW4YvUqOp7uunfvybPPvsy7777JW2+9TlRUJN269eDWW+8M6OAcXzgqczEzUNzuQxpsjJlVYltPYAHF70OKxroPabcxpuwzlP+1ADbb0WWXnr6Vxo2Lj5Q5npvPrr1HAIiMCCMlqWqubYW6ilpIqvJO5tjee+940tJ2epwIVwX/59bTOaqQW5ddS2BLye1B0UISkQddP7Z3PV4pIv2AA8aYVwCMMQtFZBLwjIgkAxuxRsk15yQHJyilgsOePbtZuHAeN9xwi92hKBsERUKi9Izb17oetwKvuJVf5ap7FZCINdXQSGPM3IBHqJQKmF27drJq1Qq+/fYroqKiOffcUXaHpGwQFAnJGOPVQuzGmBzgHtc/pVQ1sXz5Mp588hEaN07mwQcfKXO6KFW9BUVCUkrVbCNHnldq8UVV89i+/IRSSikFmpCUUkoFCU1IISiYhuorpVShkz03aUIKMeHhEeTmHrc7DKWUKiU39xgREZVfisTrQQ0iUh9oaIxZ51bWEvgbUA/40Bjzc6UjUV6Ji0vgwIEMEhKSiIyMKnNmYKWUqgpOp5OCgnxycrI5cuQg8fGVn/XBl1F2LwFtgR4AIhIHzObEsg/jRGSIMea3SkejKhQba601c/DgXvLz8wDIy3eSlWVNaBkR5iA939MctKqksLCwKp3SvybRYxs4wXhsw8LCiYyMIjGxIZGRZa8vVhFfElJv4CO338dhJaORWPPMTQPuBTQhBVhsbO2ixASwfU8Wz3+9CICUpNo8dp33i4vVZCWnZVL+o8c2cKrzsfXlGlIjYLvb72cDS4wxPxlj0oEJWKu6qiqmnXZKqerAl4SUS/FF8AYCv7r9fgCo74eYlFJK1UC+dNn9CVwkIq8C52ENZJjhtr0ZsN+PsSmllKpBfElIr2J1y2UCtYBNFE9I/YFVfotMKaVUjeJ1l50x5kOs5R5mAB8DZxtjcqFoSHgCoAuYKKWUqhSvWkgiEg6kAD8YYz4qud0Ysw84w8+xKaWUqkG8bSFFYnXRXRfAWJRSStVgXiUk1zpEe4EjgQ1HKaVUTeXLsO8fgXMDFYiqPJ1qVSlVHfiSkO4FkkXkAxHpJCIxgQpKVZ7eJKuUClW+DPveg/VlvDNwBYCIlKzjNMboKrQ20taSUipU+ZI8PkTPd0FJW0VKqerA64RkjLk6gHEopZSq4XSBPqWUUkGhUtd7XGshJeAhoRljtp1kTEoppWognxKSiFwCPAi0L6da+ElFpJRSqkbyustOREYB/8NKYm9iXUv/FJiEtTTFUuBR/4eolFKqJvDlGtLdwDqgC/B/rrL3jDGXAN0AwVo5VimllPKZLwnpNOAD1zRChQu6hwMYY1YDbwH3+zc85Q0di6+Uqg58SUjhwD7Xz9mux7pu2w3Q0R9BqcrTe5KUUqHKl4S0A2gOYIzJxpq5wX3JCUEnX7WdtpaUUqHKl1F284BhnLh+NBm4S0SysRLbX4Hv/Bue8oa2ipRS1YEvLaTXgFkiEuv6/QGsbrqHsZLURqyBD0oppZTPfJk6aDGw2O33DKCLiJwG5APrjDEFZT1fKaWUKo8v9yENEJGkkuXGmJXGmDVAPREZ4NfolFJK1Ri+dNn9AgwvZ/tQVx2llFLKZ74kpIqunYdz4v4kpaqVAqeOX1Qq0Hyd7bu8v8o+wN6TiEVVkp4qA8fpdPKfT3/nntfmkXn4mN3hKFWtlTuoQUTuBO50K3pRRJ7wUDURqAO858fYVCXoEHD/2rTrEOu2ZgLw6fQ/uXV0J5sjUqr6qmiU3QFgq+vnFlgzNewuUccJrAYWAC/4MTalbHc870QvdFZ2ro2RKFX9lZuQjDEfAB8AiMhm4B/GmMlVEZiqHO2+U0qFKl/uQ2oZyECqkohEA29gjRqMB5YBt7mGr4cc7aZTSlUHXickEakPNDTGrHMrawn8DagHfGiM+dn/IQZEBLAJ6AWkYV0n+wZoY2NMSilVo/kyl91LQFugBxQtYz4baOLaPk5EhhhjfvNviP5njDkCPFb4u4i8AjwrIvWNMfvKfqZSSqlA8SUh9QY+cvt9HFYyGom1MN804F7Ap4QkIslYLZSeWAv9xQGDjTGzPNSNxlqV9kqskX0rgAeMMTN8eU0PegN7NBkppZR9fLkPqRGw3e33s4ElxpifjDHpwASgayViEOA+oCmwsoK6E4DxwMdYSawAmCIivSvxutaLiyRgLS74z8ruQyml1MnzpYWUC8S6/T4QK0EUOgDUr0QMS4EGxph9IjIK+NpTJRHpAVwCjDfGvOgq+xBryPnTwAC3urNc8XlyjzHmWVe9GOBb4HtjjN5DpZRSNvIlIf0JXCQirwLnYQ1kcO8qawbs9zUAY8xhL6uOwUqK77g9N0dE3gWeEJFkY0yaq3xQRTsTkXDgM6xWX0gvm6FDvZVS1YEvCelVrBZRJlALa5Sae0LqD6zyW2SldQX+MMZklShfhDXyuQvWiDlvvQ3EAGONMdXmnK5DwJVSocqX+5A+FBEnMAo4CDxpjMmFoiHhCViL+AVKMrDTQ3lhEmriYZtHItIcuAbIATJFpHDT2caY2d7up379OG+rnpSkpPhyt2flnphNICIivML66oSKjlXawZyinyMjI/TY+kCPVeBU12PrSwsJY8xHFB9pV1i+DzjDX0GVIRbwNLtljtt2rxhjtuKHxsS+fVkUFAS2cZWUFE9GRvm9mpmZR4t+zsvLr7C+snhzbA8cyC76OTc3T4+tl7w5tqpyQvnYhoU5yv0i7+ts33bKBqI9lMe4ba/xqk3fo1KqxgmlhJSG1W1XUmHZriqMJajodSOlVHUQSglpOdDONUOEu56uxxVVG45SSil/CqWE9AUQCVxfWOCaueEaYK4xpsa2kJRSqjrwaVBDoIjIg64f27serxSRfsABY8wrAMaYhSIyCXjGNd3QRuAvQHPg6ioOWSmllJ+VmZBEZBNwV+H6RyLyf8BXxpjVAYjjsRK/X+t63Aq84lZ+lavuVVhz2a0ERhpj5gYgJqWUUlWovBbSKVhrBRV6GNiANVWPXxljvLoub4zJAe5x/VMuOrIugJx6dJWqKuVdQ9oJdCpRpn+dQU5H3CmlQlV5LaRvgXtF5CxOzFH3oIjcUM5znMaYoX6LTimlVI1RXkK6D2veumFYAwecQBLWPHZK1QwObXMqVVXKTEjGmGzgIdc/RKQAa5DD/6ooNlUJ2qeqlApVvtyHdA0wL1CBqMrT7/BKqerAl9m+Pyj82TW7d0vXr5t16W+llFIny6cbY0WkM/Ay0K9E+WzgDmNMRUuQK6WUUh55nZBEpCMwB2t27W+BNa5NHbBWkJ0tIn2MMWvK2IVSKsD+3H6Aj6f+SZMGtejVoTEdW9YjIjyUZghTNZkvLaRHsZYQ71uyJeRKVr+56lzkv/CUUr6YvWIXOzKy2JGRxaJ1e4iLjaRH+4b06tCY1k3q4NBRgyqI+ZKQBgCveuqWM8asFpHXgJv9Fpnymo6sC6AQm6khr8SCkVnZucxctpOZy3aSlBBDr1Mb06tDI5Lr17YpQqXK5ktCqg2kl7M9zVVH2Ui//yqA+nWiuXBAa+avTWfN5v04nZBxIIfv5m3hu3lbaNE4nt4dGtPj1EbUrR1ld7hKAb4lpE3AucCrZWw/11VHKWWziPAwendsTO+OjTmYdYxF6/awYG06m9Ospa+3pB9mS/phPp+5gVNbJNK7Q2O6tm1ATFRQLACgaihfPn0fAv8Wkf8BTwB/uMrbA/cDZwL/8G94StmsGlxzqRsXzfDuzRjevRlp+46wYM1uFqxNJ+NADgVOJ6s372f15v1ERYZxepskenVoTIeWiYSH6WAIVbV8SUjPAqcDlwDjgAJXeRhWT9FE4Dm/RqeU8qvk+rUZPaAVo/q3ZOOuQyxYk86idXvIys7leG4BC9buZsHa3cTXiqRH+0b06tCIVsk6GEJVDV9ujM0HxonIO8AoTtwYuwn4xhgz3f/hKV+F1iV4ZReHw0FqSl1SU+pyydA2rN68nwVr0vl9/V5y8wo4fDSXGUt3MGPpDhomxtLr1Eb07tiYRok6laUKHJ87jI0x04BpAYhFVZJ+d1UnIyI8jC6pDeiS2oDsY3ks+zODBWvSWbs1E6cT9mRmM3nuFr6bu4Wxg1M5q+cpdoesqim9gqmUKhIbHUHfTsn07ZTMgaxjLFq7m/lrdrN192GcwMRfNhATHc6gLil2h6qqIU1ISimPEuKiObPHKZzZ4xQ2px3i+c+XcyQnj49+MtSKjqBH+0Z2h6iqGR1Go1Q14gzQjbwtk+sw/uIuREeG4wTe/m4tqzbpnMrKvzQhVQM6kCGAQmymhkBq1aQOt1/UiYhwB/kFTl79ahXrdxywOyxVjWhCqmZ0gIMCAnb/1Kkt6nHzBR1xOOB4XgEvTlrJtt2HA/JaqubxKiGJSKyIXCUiPQMdkFIquJ3eNolrR7YHIPtYHs9/vpz0/UdtjkpVB962kI4BbwNdAxiLUipE9O2UzKVD2wBw6Gguz332O/sP5dgclQp1XiUkY0wBsB2oE9hwlAoyOkNBmYZ3b8b5fVsAsO/QMZ77fDmHjh63NygV0ny5hvQBcKWIRAcqGHXy9BK8qkoX9GvJ0DOaApC27ygvTFxB9rE8m6NSocqX+5DmARcCy11rH60HSnUcG2N+81Nsykv6HV7ZxeFwcOmwNhzNyWP+mnS2ph/m5S9W8sRf+9kdmgpBviQk9+mCXqL0l3GHqyz8ZINSSoWOMIeDa0a2I/tYHss37MVsP8DTHy7mhnPa6/Lpyie+JKRrAhaFUiqkRYSHccuoDrwwcQV/bDvA4rW7CXfA9eeeSpheh1Ne8mW27w8CGYhSKrRFRoRz+0Wn8Z9Pf2dL+mEWrNlNregILh/eVpevUF7R9nQ1oAMZAkhnavBJbHQE4y/uTLNGcQDMXLaTb2ZvtjkqFSp8Skgi0kxE3hORHSJyXESGuMqTXOXdAxOm8pZ+D1Vg7+cgvlYUj97Yh/p1YgD4bt4Wpi7aZmNEKlR4nZBEpCWwBLgIWIPb4AVjTAbQDbje3wEqpUJPg4RY7r60C3VqRwHw2cwNzF6xy+aoVLDzpYX0BNay5R2Byyn9JexHQMd6KqUAaJRYi7+P60KtaOtS9YSf/mCp2WNzVCqY+ZKQhgGvGWO24/myxVagqV+iUipY6MX4k9KsYRx3je1MVGQYTie8OXkNa7bstzssFaR8SUh1gLRytkehC/7ZTi/Bq2CT2rQut43uRHiYg7x8J698uYqNOw/aHZYKQr4kpO1Ah3K29wI2nFw4qjL0O7wKdh1b1efG8zvgcMCx3HxenLSCHXuy7A5LBRlfEtJXwLUi0tGtzAkgIhcBY4GJfoxNKVWNdG/XkL+c1Q6AIzl5PPf5cvZk6rIV6gRfBzXsABYCH2Mlo3+IyHysRLQCeM7vESqlqo0BnZswdnBrAA4eOc6zny0n8/Axm6NSwcLrhGSMOQT0Bt7BGuLtAIYDArwGDDbG6IIoStkoFO7jPbtnc87p3RyAvQdzePqTZXwzexOrN+/jaI7OFF6T+TQIwZWU7gTuFJEkrKSUYYwJgT+DE0TkdWAUUBtrdOD9xpjvbQ3qJITUwQ81oXCGD0EXDmjFkZw8Zv2+kz0Hspk8dwtgnVBSkmqTmlKX1il1SW1al4YJsTr1UA1R6VFxrpthQ9VLwHhjTI6IdAOmi0hLY0ym3YGdLP2zVRD8o9UdDgdXDG9LQu0oFq7bTdo+61qSE9iRcYQdGUeYtdy6kTa+ViSpKXWLklSLxvFEReqiAtWRzwlJRC4GRgOtXEWbgK+NMSEzoMEY80eJomggGQj5hKRUqAgLc3B+v5ac368lWdm5bNx5kA07D7Jx50E2pR3ieG4BAIeP5vL7+r38vn4vAOFhDpo3ji+WpBLjdd3Q6sDrhCQitYFvgCFYX8QPuDZ1By4WkZuA840xR3zYZzJWF2BPrOtScVjXomZ5qBsNPApcCSRiDaJ4wBgzw9vXK7G/17CW1IgBvgfWVWY/SqmTFxcbSefUBnRObQBAXn4BOzKy2LDjRJLad8ga/JBf4GTTrkNs2nWIqYu3A9CgbsyJbr6UujRtWJvwMJ07OtT40kJ6AhgKvAw8ZYxJBxCRxsA/gDtcde7yYZ8C3Id1/9JKoE85dSdgzaP3oqv+1cAUERlojJnvw2sCYIy5VURuBwYDHULtOphS1VlEeBgtGtehReM6DOvWDID9h3LYuOtQUZLatvsw+QXWn+3egznsPZjDgrW7AYiODKdrmwZcOLAVDerG2vY+lG98SUjjgEnGmLvcC12J6S4RSXHVuav0U8u0FGhgjNknIqOArz1VEpEewCVY131edJV9CKwGngYGuNWdBQws4/XuMcY86xZ7Ptb1oztF5A9jzM8+xK5qgmC/GFOD1KsTQ706MXRv1xCA47n5bEk/zIadB4uSVFZ2LmDdfLtg7W6W/pnB2T1P4exezYnW605Bz5eEVAf4pZztM4GRvry4Meawl1XHALlYQ84Ln5sjIu8CT4hIsjEmzVU+yJcYXCKA1pV4XtDRZp6qKaIiw2nbLIG2zRIAcDqd7MnMZsPOgyzfsJelJoPcvAImz93CnFVpXDw4le7tGuqIvSDmS0JaCbQpZ3sbYNXJhVOmrsAfxpiSc40swrqe1YXy59krIiJxWEO+vwFygAuwuu3u9U+oVU//vJSyRu41qleLRvVq0bdTMn9uP8Cn09ezdfdh9h86xhvfrmHmsp1cNqwNpzSKtztc5YEvCelB4GsRmWWM+c59g4hcgLUW0ig/xuYuGdjpobwwCTXxYV9O4FrgFaxz+QbgUmOMz8m0fv04X59SKUlJ5f/xHMk70S6KCA+rsL46oaJjlXbwxL3ekZERQX9so11LPYQHwecgGF6/V5emTF+0jY+mrOVg1nH+3H6ARycs5sxeLbjirHbUjQvN0Xl2H9tAKTMhich7Hoo3A9+IiOHEqLT2WIMTVmGtkzTT30ECsYCn+UVy3LZ7xTUKcIg/gtq3L4uCgsB2kiUlxZORUX7PZub+EwMb8/ILKqyvLN4c2wMHsot+zs3NC/pjm3PMmukg3+bPgTfHtqqc3roe7a7vyeS5W5ixdAf5BU5+mr+F35bt4IJ+LRl8egoR4aEzIi+Yjq2vwsIc5X6RL6+FdHU529q5/rk7DegEXOdtcD7IxrpXqKQYt+01ll43CiCdqaFaqBUTySVD2zCgcxM+m7Ge1Zv3c/RYHp/OWM+vK3Zx6dA2dGhZz+4wa7wyE5IxJpi+MqRhdduVVFimayO76PUkpcrWpEFtxl/cmRUb9vHZjPXsOZDNrr1HeO7z5XRt04BxQ1JpmFjL7jBrrGBKOuVZDrRzDUhw19P1uKJqw1FKhSqHw0GXNg147PqejB3Umugoazj47+v38uA7C/ny143kHNdJXu0QKgnpCyASa+AEUDRzwzXAXGOMtpCUUj6JjAjj7F7N+feNvejbsTEAeflOfpi/lX++tYD5q9NxapdtlfJpLjsR6QP8FWuId31K9xA5jTE+3c8jIg+6fmzverxSRPoBB4wxrwAYYxaKyCTgGdd0QxuBvwDNKf9al1JKlSshLprrzj2VQaen8L9p69mcdogDWcd5+/u1zPx9B5cNa0vL5Dp2h1kj+DKX3Q3AG8BxwADb/BTDYyV+v9b1uBVraHahq1x1r8Kay24lMNIYM9dPcSilarDWTerywFVnMH91Ol/M2sjBI8fZuPMQj32whH6dkrloYKuQHSYeKnxpIf0T61rOCGPMXn8FYIzx6jq8a/G/e1z/VBm0g8HP9K7+GiXM4aBvp2ROb5vE9/O2MHXxdvILnMxZlcYSs4fz+7ZkWLemITVMPJT4clQbAe/6Mxkp/9BTplL+FRsdwdjBqTx+fU+6uGYgzzmez8RfNvDPtxYwZ2Ua+QUFNkdZ/fiSkNZhdZUppVSN0KheLe4Ycxp/u7gzyfWt4eB7D+bw3o/r+Nc7i1i0bjcFOvDBb3xJSE8At4qIL9P0qCqgfw6qiJ4cA6Jjq/o8cm0PrhwhJMRFAZC+/yhvfLuGR95fzPL1e3VEnh94fQ3JGPOViNQC1orIt8AWIL9ENacxpuQgBVWFtPvOz/Qko1wiwsMY3DWFvh0bM+v3nfywYCuHj+ayfU8WL3+5klZN6jB6QCtObZ6oM4pXki+j7NpirdhaB2vVVk+clB41p5SqYnpCDJyoyHDO7HEKA7o0YdqSHfy0cBvZx/LYtOsQz322HGmWwIUDW9GmaYLdoYYcX0bZvQY0xFpyfDaQGZCIlFIqBMRERXBenxYMOT2FnxdtY9riHRzLzcdsP8C/P15Gp1b1GT2gJS0a6z1M3vIlIfUG/mOM+W+gglFKqVBTOyaSCwe0Zli3Zvw4fyszl+0kL7+AVZv2sWrTPs5om8So/i1JSaqa5WpCmS8J6SCQEahAlFIqlNWpFcUlQ9swoscpfD9vC7+t2EV+gZOlf2aw7M8MenZoxAX9WtJIJ28tky+j7CYCFwYqEKWUqg4S46O5coTw5I296NupMQ6HdXF9wZrdPPDWQiZM+YP9h3Iq3E9N5EsL6U3gAxH5BngZa7G+kqPsMMb4a0ohVQk6JszPdHCAqqSkhFiuO+dURvZqzjezN7P4jz0UOJ38tmIX81anMahLCuf0aUHd2lF2hxo0fElIa7DOd92A88qpF35SESmf6SlTqeCVXL82t4zqyDm7D/PN7M0s37CXvHwn05fu4LeVuxh6RlPO7tmcuNhIu0O1nS8J6VH0C7hSSlXKKY3iuWPMaWzcdZCvf9vE2i2ZHM8tYMqCbcz6fRd/H9eFVk1q9og8X26MfTiAcaiToN8SAijEbowNrWhrptZN6nL3JV35Y2smX/22iQ07D5J9LI+JM9fzjyvOsDs8W+mUtdWMdt8pFRraNU/k/itOZ9gZTQH4c8dBtqYftjkqe/kyU8MAb+oZY36rfDhKKX/QLyahweFwcGaPZsxYtgOnE6Yv2c51555qd1i28eUa0iy86xHQQQ1KKeWlBnVjOaNtEktMBgvX7WbM4NQaO/LOl4R0TRnPb421jPgWrKHhSimlfDCsWzOWmAzy8p38+vtOzu/X0u6QbOHLoIYPytomIv8BlvklIqWUqmHaNK1L80bxbN19mF9+38nI3s1r5Kq0fnnHxphM4B3gXn/sTymlahKHw8GwbtbghoNHjrN43R6bI7KHP1NwJtDKj/tTSqkao0f7RtRxXTuatmR7jVzwzy8JSURisNZISvfH/lTl1byPcIDp1EGqikRGhDGoi7Ug95b0w2zcecjmiKqeL8O+3ytjUz2spSmSgHv8EZTyjZ4ylaoeBndN4Yf5W8kvcDJtyXZSm9a1O6Qq5csou6vLKN8P/AmMN8b876QjUj7TVlEAhVq3SYiFq4qrGxdNj/aNmL8mnaUmg/2HcqhXJ8busKqML6Psat6QjxCkrSUF6AchhA3v3pT5a9IpcDqZuWwnYwa1tjukKqNJRimlgkiLxnWKuup+Xb6TY7mlVvmptjQhKaVUkBnerRkAR3LyWLCm5owVK7fLTkQm+7g/pzHmgpOIRymlarzT2zagXp1o9h86xvQlOxjQuQmOGjDis6JrSOf6uD+9pKqUUicpPCyMIac35YtZG9m59whrt2bSoUU9u8MKuHITkjcDGURkIPAM0B1I81NcSilVow3o3ITJczZzPK+A6Yu314iEVOlrSCLSUUR+AGYCAvwLaOOvwJRSqiaLi42kd8fGAKzcuI/dmUdtjijwfE5IItJMRCYAvwNDgZeB1saYJ4wx2X6OT/lI+0z9rAb026vgVbh4nxOYsWSHvcFUAV9makgEHgBuBaKBT4EHjTFbAhOa8paeMpWqnlKS4ji1RSJrt2QyZ1UaowdU7+lCK0xIIhIN3AXcByQA04D7jDHLAxmY8p62igIoxGZqCK1olTeGdWvG2i2Z5BzPZ87KNC5rmmh3SAFTbpediFwHbACeBDYCw40xIzQZBS9tLSnQz0F1clrr+jRMjAVgxtId5BdU368dFbWQ3sb60rUEmAh0FpHO5dR3GmNe8FdwSilV04U5HAw9oymfTl/PngPZLF23m5YNa9sdVkB4cw3JgTWku7sXdZ2AJiSllPKjfp2S+fq3TeQcz2fy7I3cedFpdocUEBUlpMFVEoVSSqkyxUZH0O+0ZKYv2cGK9XvZkZFF06Q4u8Pyu4pujP21qgJRSilVtmFnNGXGkh04gelLdnD12e3sDsnvdHJVpZQKAQ0Ta9E5tQEA89ekk5Wda3NE/lejE5KI9BaRAhH5h92xKKVURYZ3s26Uzc0r4NflO22Oxv9qbEISkTCsARiL7Y7Fn6rvgFClVLvmiTRvHA/AzGU7ycsvsDki/6qxCQm4EVgIrLM7kJOl95wEkE4dpIKIw+HgvP7WCrKZh4+x7M8MmyPyL6+nDgoEEUkG7gR6At2AOGCwMWaWh7rRwKPAlUAisAJ4wBgzoxKvWx9r9olewIuViz54aKsogEJtpoYQi1f5btAZTZnw/RqysnOZvmQHPdo3sjskv7G7hSRYUxI1BVZWUHcCMB74GCuJFQBTRKR3JV73CeBFY8yBSjw3qOn3eWXRT0J1FR0ZzsAuTQDYsPMgm9MO2RyR/9jaQgKWAg2MMftEZBTwtadKItIDuAQYb4x50VX2IbAaeBoY4FZ3FjCwjNe7B5iBdZPvX/3yDpRSqooN7prClAXbKHA6mb5kOzec18HukPzC1oRkjDnsZdUxQC7wjttzc0TkXeAJEUk2xqS5ygeVtyMRuQurZbZTRADqAnki0sIYc7PPb0IppapYvToxdGuXxKJ1e1i0bg9jB6eSEBdtd1gnze4uO291Bf4wxmSVKF+E1TfRxYd9vQWkup7TBZgMvITVdaiUUiFhWLdmAOQXOJn1e/UYAm53l523kgFPR7xwyfQm3u7IGHMUKFp6UUSygSxjzEFfg6pfv2qm7khKii93e1buiaGfERHhFdZXJ1R0rHYdyCn6OSoqIuiPbXS09ScdERFme6x2v351lpQUT4MGcbSZtZH12w/w24o0rj6/I5ER4XaHdlJCJSHFAsc8lOe4ba8UY8zVlX3uvn1ZFAR4KvikpHgyMsrv2cx0W9o4Ly+/wvrK4s2xPXjgxLE9fjwv6I/tsWN5AOTlFdgaqzfHVlWO+7Ed1KUJ67cf4EDWMX74bSN9OyXbHF35wsIc5X6RD5Uuu2ysVWpLinHbrpRSNUr3dg2pGxcFwLQl20N+2H+oJKQ0rG67kgrLdlVhLEopFRQiwsMY3DUFgG27s1i/w+crD0ElVBLScqCdiJRs6/V0Pa6o2nCCV2h/PwpCOlODCnKDuqQQEW59Tqct2W5zNCcnVBLSF0AkcH1hgWvmhmuAucYYbSGpwAjxLhBV/dWpHUXPU63ZGpb9mcHeg6F7BcP2QQ0i8qDrx/auxytFpB9wwBjzCoAxZqGITAKecU03tBH4C9AcuLqKQw5q+n1egTbsaprh3Zoxd1U6Tqc16erFg1PtDqlSbE9IwGMlfr/W9bgVeMWt/CpX3auw5rJbCYw0xswNeIRKKRXETmkUT9tmCfy5/QC/Ld/FBX1bEh0VekPAbU9IxhivvssZY3Kwpv65J7ARKaVU6BnerSl/bj/A0WN5zFuTXjTYIZSEyjUkpZRS5ejaJon6daw7YaaH6BBwTUhKKVUNhIU5GHqGtaJs2r6jrNmy3+aIfKcJSSmlqon+nZOJirRO69OX7LA5Gt9pQlJKqWqidkwkfTta8wWs3LiPtH1HbI7IN5qQlFKqGhnWrWnRzzOWhlYrSRNSNRN6lzGVUv6UXL82HVvWA2DuqnSO5uTZHJH3NCEpVY2E4MAqFQCDT7eGfB/LzWfjrtCZ304TUjWjN+gr0M9BTee+emx+gJfI8SdNSEoppYKCJiSllFJBQROSUkqpoKAJSSmlVFDQhKSUUiooaEJSSikVFDQhKaWUCgq2r4cUosLBml23KlT0OlGR4TRMjAWgXt2YKourOqjoWEVHnTi2ifHRQX9sE+KjaZgYS7069n8O7H796syXc0JMVETQ/F+4xeFx9UBHKK6ZEQT6AbPtDkIppUJUf2BOyUJNSJUTDXQH0oB8m2NRSqlQEQ4kA4uBYyU3akJSSikVFHRQg1JKqaCgCUkppVRQ0ISklFIqKGhCUkopFRQ0ISmllAoKmpCUUkoFBU1ISimlgoImJKWUUkFB57ILQiISDTwKXAkkAiuAB4wxM2wNLMSJSHfgamAw0BzYB8wDHjTGbLAxtGpJRO4FngZWGGO62BxOyHN9fh8G+gCRwEbgBWPMBBvD8ittIQWnCcB44GPgTqAAmCIive0Mqhq4D7gQmI51XN8CBgG/i0h7G+OqdkSkMfAgcMTuWKoDETkbmIuViP4F/B3rc9zMzrj8TVtIQUZEegCXAOONMS+6yj4EVmN92xxgX3Qh73ngMmPM8cICEfkcWIWVrK62Ka7q6ClgCdaX3gR7QwltIlIX60vq68aYO20OJ6C0hRR8xgC5wDuFBcaYHOBdoJ+IJNsVWKgzxsxzT0ausvXAGkBbSH7i+lJ1BfA3u2OpJi7DSur/ByAi8SISHOtJ+JkmpODTFfjDGJNVonwR4AC6VHlE1ZjrD7sRsNfuWKoD1/H8L/CBMWa5zeFUF8OAP4CRIrIdOATsF5GnRMTjukKhSrvsgk8ysNNDeZrrsUkVxlITXA6kAA/YHUg1cRVwKjDK5jiqk1Ssa0UTgGeA34FzsbqZY4C77ArM3zQhBZ9YPKwTAuS4bVd+ICLtgFexFgr7yOZwQp6IxGNdO3rKGJNWUX3ltTis0bb/MMY87Sr7SkTigFtF5HFjTLVo4WuXXfDJxloAsKQYt+3qJLlGgf0AZAJjjTEFNodUHTwIHMcaPKL8p/Bv/tMS5Z9gjbrrUbXhBI62kIJPGla3XUmFZbuqMJZqyTVqaQpQF+hrjEm3OaSQ5xpscxfWkORGIlK4KQaIEpEWwEFjTKYtAYa2NKADsLtEeeHviVUbTuBoCyn4LAfauZrj7nq6HldUbTjVi4jEAN8BbYFzjTHG5pCqi0ZAFNatCZvd/vXEGsG4Geuah/LdUtdjSonypq7HjCqMJaA0IQWfL7Ca4dcXFrhmbrgGmGuM0RZSJblGJH0O9Mbqpltgc0jVyWZgtId/a4Atrp8/tCu4EDfJ9XhdYYFrNOP1WDceV5vPscPpdNodgypBRCZijVJ6AWt6kL8A3YHBxpi5NoYW0kTkRawZGr4DJpbYnGWM+aaqY6ruRGQWkKBTB50cEfkAayqxd4FlwDmuf/caY/5jZ2z+pNeQgtNVwGOux0RgJTBSk9FJ6+J6PM/1z91W4JuqDEYpH9wAbMP6cvoXYBNwszHmTVuj8jNtISmllAoKeg1JKaVUUNCEpJRSKihoQlJKKRUUNCEppZQKCpqQlFJKBQVNSEoppYKCJiSllFJBQROSUkqpoKAJSSmlVFDQhKRCiogMEhGniFxtdywnS0Q6ikieiAy3O5aaQEQuEJHjItLG7liUZ5qQlLLP81gzuE9zLxSReq6kO8WmuAJGRF4RkZ2u2arLqlP4peNuf762MeZbYBXWEhkqCGlCUsoGItIbGI7n1VVPdz0uq7qIAs+VhEYB3xpj7JpE8yVgtIh0sOn1VTk0ISllj1uBvcCPHrZVy4SEtYRKCvbOqv4VcBS42cYYVBl0+QlVLYhIA+AR4Hys1Ut3A5OB/zPG7CtRtwXwHFYLBeAXrOW3fwG2GGMGBTjWCKyWwvfGmFwPVaprQhoNHMA6zrYwxmSJyGxgDHC7XXEoz7SFpEKeiNQF5gG3AD9jJZefXL/PEZF4t7r1gdlY6yFNwFpW+wjWSbJ2FYV8BhAHLCpj++lApjFmcxXFU1VGAz+WkYSr0nygsYi0szkOVYK2kFR1cC/QBvirMea1wkIRWQ684tr+L1fxfUBT4ApjzCeustdF5BngniqK91TX48aSG1zJMxUbWxGBICLtAQEetDsWThz3DsAfdgaiitOEpKqD0UAG8FaJ8jeBh1zbCxPSeUAa8GmJus9SdQkpyfW438O2roCD6tddNwrIwWq5+pWINMZaXbkdsAeYZIxZWs5TCrtwG/o7FnVyNCGp6qAlsMQYk+deaIzJE5E/OXFNprDuImNMQYm6e0TkgHuZiFwM3IG19PleY0yLEtsjsK5FXYnV/f0lVistp4J4C0eYeRr6fIbrscyEJCL9AU9DwqOAcGNMeIn6r2F1X/YxxswvsW0WMBAYaYyZ4lZ+MfA58IMx5lxXWVvgGaAvEIPrOp0x5m9lxepmNDDdGJPlRV2vichFwBDgXeC/WEnmMhEZA/yzjNF8hcddl8sOMpqQlCpbJlaXXyNgvIft/wQGA52A41iDKJ7BSmLlyXA91vOwrcIBDcaY2VjXoIqISBNgiSte9/JY4DKs1tj1WNdPSvoDuI7iSe56Sndn/YA1Su0KrJFqrbGSU7lEpCnQDbihorq+EJGOQAtjzF/dircC/xaRXlgj6V738NTC457hYZuykQ5qUNXBJkBcLZYirt/burYX2gKkikhYiboNgQT3MmPMNGPMZ1gnOU+uB540xuw0xmQADwNXi0h4GfULrXY9epox4HQgC/izgn0UEZForEQxxxjzZInNY4ECrIEeF4tIHKVNBIaISJJrf82xWoXfuL1GA6xrW28YY7KMMQXGmPXGmAlehDgKqzUy2dv35KUL8XwfF8aYBUCDkp8Jl1TX42oP25SNNCGp6uAbrOsy15cov8FV/rVb2XdAMnBpibo+zQogIglAM2C5W/EyIB5oUcHTfwcOAb1K7LMW1oX/5T7eOPoGVhfa1R62XQ98hpV0coFLPNQ5jHWMrnL9fh3wP+BYYQVjzF5gHfCeiFwiIq19iG80VrL0d4vkaOFxEpHeIrJXRNwHTSzF+kJSUi9gtzHG+DkedZK0y05VB89gtQReFZHTsU74XbFOrMa1vdDTWF1Y74tID6xuqf5AH6wbVb1NBIVDyQ+4lR0osc0jY0y+iHwFjBKRaGNM4Ym/MxAOxIjIPzw8NcsYU7JL7g7gXKC7MeZoiW1tsd7bPcaYYyLyGdYxecfDvt8F3hGRF7ES2znARSXqDMJK3P8EThWRbcA/jDETy3qvIlIPGIA10tFXQ0UkxkP5XmPMGyXKOgP1Kd6FeIgS/xeuFmJ/4L1KxKMCTFtIKuQZYw5inYjeBEYCL7se3wD6GWMOu9XdC/QDvgeuxUpQtbGuBTmAbC9ftnCfdd3KEkpsK8/rrvrnupUVXj/qBvzbw7+x7jsQkcGu+McaY7Z4eI3rgT+MMQtdv08AenmaNscYMw/r/T8MpBtjVnmos8cYc68x5jSs6zCvAf+r4H6ec7G++H5dTp2ynAU85uHfXa7tsW5138Fqif3FrawzsL7EPi8CamF9VlSQ0RaSCinGmFl4GJ3m6g661fWvon1sxrr+UMR1w2x9YJuXcRwQke1Y11oKu366YiWjLV48f5GIFN7E+6Wr7FXgVW9e3zXbxESs1s8sD9sjsbrg6opIeonN1wGeRsa9i9WavMWL+A8Bz4rI/ZR/P89oYEUZCbOsfc/C8wjEkraISB9jzDzXCMtvCje4bpZuYYwpObT+TuBrY4xePwpCmpBUjSMiscaYki2hwi6yaW71woFI1z+Hq/vI6dbF9g5wv2sqmlys1sUEY0y+l6H8HVghImcaY6b6EH8trJPv5JJdeG7OAxKxkqT7SfkK4D4R+Ycx5niJ57yFdU1snofXTMS6T+sTrAEXYVhde7WwrtWUZT7wdrlvqPI+Bl4SkdruM6aLSEusllSxpCsio4COwLgAxaNOkiYkVRP9KCJbsQYhhAFDsbqW5lF84s8rgffdfs/GGnHXwvX7k0ADYI1rP19gzQThFWPMGir3N3gRVndUWxHxdHI9Fau77lNjzFr3DSLyBvAA1si3Ytd+XK2e6WW85nGgMdZIuUZYAx7WAOeX1/oxxjxT1raTZYxxishdwG0icj3WaMIwrBuf7yw5h6Ex5huse7VUkHI4nXpvmKpZROTvWN1ZLbCuQ+zAGjb9iPv1JqVU1dKEpJRSKijoKDullFJBQROSUkqpoKAJSSmlVFDQhKSUUiooaEJSSikVFDQhKaWUCgqakJRSSgUFTUhKKaWCwv8DfwO2Q+o/xrYAAAAASUVORK5CYII=\n", + "text/plain": [ + "<Figure size 432x288 with 1 Axes>" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "# plot luminosity distribution\n", "ldist = population.grid_results['luminosity distribution']\n", @@ -491,10 +582,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "id": "5956f746-e3b9-4912-b75f-8eb0af66d3f6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ValueError", + "evalue": "Failed to rename grid variable M_1 to lnM_1.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Input \u001b[0;32mIn [27]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Rename the old variable (M_1) because we want it to be called lnM_1 now\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mpopulation\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrename_grid_variable\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mM_1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mlnM_1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/.pyenv/versions/3.9.9/envs/dev_binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/utils/population_extensions/gridcode.py:965\u001b[0m, in \u001b[0;36mgridcode.rename_grid_variable\u001b[0;34m(self, oldname, newname)\u001b[0m\n\u001b[1;32m 963\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 964\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFailed to rename grid variable \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m to \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(oldname, newname)\n\u001b[0;32m--> 965\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(msg)\n", + "\u001b[0;31mValueError\u001b[0m: Failed to rename grid variable M_1 to lnM_1." + ] + } + ], "source": [ "# Rename the old variable (M_1) because we want it to be called lnM_1 now\n", "population.rename_grid_variable(\"M_1\",\"lnM_1\")" @@ -520,8 +624,8 @@ "# because M * dprob/dM = dprob/dlnM\n", "population.update_grid_variable(\n", " name=\"lnM_1\",\n", - " samplerfunc=\"const(math.log({min}), math.log({max}), {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " samplerfunc=\"self.const_linear(math.log({min}), math.log({max}), {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnM_1\",\n", " parameter_name=\"M_1\",\n", " precode=\"M_1=math.exp(lnM_1)\",\n", @@ -615,7 +719,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -629,7 +733,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/doctrees/nbsphinx/examples/notebook_population.ipynb b/docs/build/doctrees/nbsphinx/examples/notebook_population.ipynb index 760b1480e9f9bdcc508ced177f8f0d806cfb53eb..ebc19cff04f8dd9e8e2fe6694fa9b0346425afe9 100644 --- a/docs/build/doctrees/nbsphinx/examples/notebook_population.ipynb +++ b/docs/build/doctrees/nbsphinx/examples/notebook_population.ipynb @@ -25,7 +25,7 @@ "import os\n", "\n", "from binarycpython.utils.custom_logging_functions import temp_dir\n", - "from binarycpython.utils.grid import Population\n", + "from binarycpython import Population\n", "\n", "TMP_DIR = temp_dir(\"notebooks\", \"notebook_population\")\n", "\n", @@ -58,13 +58,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: M_1=10 to BSE_options\n", - "adding: orbital_period=45000000080 to BSE_options\n", - "adding: max_evolution_time=15000 to BSE_options\n", - "adding: eccentricity=0.02 to BSE_options\n", "adding: num_cores=2 to grid_options\n", - "adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_population to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", @@ -139,13 +135,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "Writing settings to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json\n" + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n" ] }, { "data": { "text/plain": [ - "'/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json'" + "'/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz'" ] }, "execution_count": 3, @@ -185,9 +185,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on method add_grid_variable in module binarycpython.utils.grid:\n", + "Help on method add_grid_variable in module binarycpython.utils.population_extensions.gridcode:\n", "\n", - "add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int], gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None) -> None method of binarycpython.utils.grid.Population instance\n", + "add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int] = -1, gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None, index: Optional[int] = None, dry_parallel: Optional[bool] = False) -> 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", @@ -198,17 +198,15 @@ " beware that if you insert some destructive piece of code, it will be executed anyway.\n", " Use at own risk.\n", " \n", - " Tasks:\n", - " - TODO: Fix this complex function.\n", - " \n", " Args:\n", " name:\n", " name of parameter used in the grid Python code.\n", " This is evaluated as a parameter and you can use it throughout\n", " the rest of the function\n", " \n", - " Examples:\n", - " name = 'lnm1'\n", + " Examples::\n", + " \n", + " name = 'lnM_1'\n", " \n", " parameter_name:\n", " name of the parameter in binary_c\n", @@ -223,47 +221,66 @@ " longname:\n", " Long name of parameter\n", " \n", - " Examples:\n", + " Examples::\n", + " \n", " longname = 'Primary mass'\n", + " \n", " range:\n", " Range of values to take. Does not get used really, the samplerfunc is used to\n", " get the values from\n", " \n", - " Examples:\n", + " Examples::\n", + " \n", " range = [math.log(m_min), math.log(m_max)]\n", + " \n", " samplerfunc:\n", " Function returning a list or numpy array of samples spaced appropriately.\n", " You can either use a real function, or a string representation of a function call.\n", " \n", - " Examples:\n", - " samplerfunc = \"const(math.log(m_min), math.log(m_max), {})\".format(resolution['M_1'])\n", + " Examples::\n", + " \n", + " samplerfunc = \"self.const_linear(math.log(m_min), math.log(m_max), {})\".format(resolution['M_1'])\n", " \n", " 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", + " sampling function (i.e. a value for lnM_1 is chosen already)\n", + " \n", + " Examples::\n", + " \n", + " precode = 'M_1=math.exp(lnM_1);'\n", " \n", - " Examples:\n", - " precode = 'M_1=math.exp(lnm1);'\n", " postcode:\n", " Code executed after the probability is calculated.\n", + " \n", " probdist:\n", " Function determining the probability that gets assigned to the sampled parameter\n", " \n", - " Examples:\n", - " probdist = 'Kroupa2001(M_1)*M_1'\n", + " Examples::\n", + " \n", + " probdist = 'self.Kroupa2001(M_1)*M_1'\n", + " \n", " dphasevol:\n", " part of the parameter space that the total probability is calculated with. Put to -1\n", " if you want to ignore any dphasevol calculations and set the value to 1\n", - " Examples:\n", - " dphasevol = 'dlnm1'\n", + " \n", + " Examples::\n", + " \n", + " dphasevol = 'dlnM_1'\n", + " \n", " condition:\n", " condition that has to be met in order for the grid generation to continue\n", - " Examples:\n", - " condition = 'self.grid_options['binary']==1'\n", + " \n", + " Examples::\n", + " \n", + " condition = \"self.grid_options['binary']==1\"\n", + " \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 'centred'\n", - " (steps starting at lower edge + 0.5 * stepsize).\n", + " (steps starting at ``lower edge + 0.5 * stepsize``).\n", + " \n", + " dry_parallel:\n", + " If True, try to parallelize this variable in dry runs.\n", " \n", " topcode:\n", " Code added at the very top of the block.\n", @@ -313,35 +330,7 @@ "execution_count": 6, "id": "47979841-2c26-4b26-8945-603d013dc93a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Added grid variable: {\n", - " \"name\": \"lnm1\",\n", - " \"parameter_name\": \"M_1\",\n", - " \"longname\": \"Primary mass\",\n", - " \"valuerange\": [\n", - " 2,\n", - " 150\n", - " ],\n", - " \"samplerfunc\": \"const(math.log(2), math.log(150), 20)\",\n", - " \"precode\": \"M_1=math.exp(lnm1)\",\n", - " \"postcode\": null,\n", - " \"probdist\": \"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", - " \"dphasevol\": \"dlnm1\",\n", - " \"condition\": \"\",\n", - " \"gridtype\": \"centred\",\n", - " \"branchpoint\": 0,\n", - " \"branchcode\": null,\n", - " \"topcode\": null,\n", - " \"bottomcode\": null,\n", - " \"grid_variable_number\": 0\n", - "}\n" - ] - } - ], + "outputs": [], "source": [ "# Add grid variables\n", "resolution = {\"M_1\": 20}\n", @@ -351,9 +340,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -364,8 +353,8 @@ "# name=\"q\",\n", "# longname=\"Mass ratio\",\n", "# valuerange=[\"0.1/M_1\", 1],\n", - "# samplerfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n", - "# probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", + "# samplerfunc=\"self.const_linear(0.1/M_1, 1, {})\".format(resolution['q']),\n", + "# probdist=\"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", "# dphasevol=\"dq\",\n", "# precode=\"M_2 = q * M_1\",\n", "# parameter_name=\"M_2\",\n", @@ -377,12 +366,12 @@ "# name=\"log10per\", # in days\n", "# longname=\"log10(Orbital_Period)\",\n", "# valuerange=[0.15, 5.5],\n", - "# samplerfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", + "# samplerfunc=\"self.const_linear(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", "# precode=\"\"\"orbital_period = 10** log10per\n", "# sep = calc_sep_from_period(M_1, M_2, orbital_period)\n", "# sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n", "# sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n", - "# probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", + "# probdist=\"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", "# parameter_name=\"orbital_period\",\n", "# dphasevol=\"dlog10per\",\n", "# )\n" @@ -434,7 +423,7 @@ ], "source": [ "# Create custom logging statement: in this case we will log when the star turns into a compact object, and then terminate the evolution.\n", - "custom_logging_statement = \"\"\"\n", + "custom_logging_code = \"\"\"\n", "if(stardata->star[0].stellar_type >= 13) \n", "{\n", " if (stardata->model.time < stardata->model.max_evolution_time)\n", @@ -454,7 +443,7 @@ "\"\"\"\n", "\n", "example_pop.set(\n", - " C_logging_code=custom_logging_statement\n", + " C_logging_code=custom_logging_code\n", ")" ] }, @@ -476,7 +465,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function parse_function at 0x1528ac7290d0> to grid_options\n" + "adding: parse_function=<function parse_function at 0x7f2b6ca163a0> to grid_options\n" ] } ], @@ -552,38 +541,41 @@ "output_type": "stream", "text": [ "adding: verbosity=0 to grid_options\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "**************************************\n", - "* Total starcount for this run is 20 *\n", - "* Total probability is 0.0444029 *\n", - "**************************************\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 19 *\n", + "* Total probability is 0.0443872 *\n", + "**********************************\n", "\n", - "Generating grid code\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.450828476487e+00 1.81563 134.653 5.27143e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 3.598268106227e+01 1.30592 8.75988 0.00193614 13\n", + "EXAMPLE_COMPACT_OBJECT 2.436983545111e+01 1.35842 10.9948 0.00144093 13\n", + "EXAMPLE_COMPACT_OBJECT 1.690157944401e+01 1.43124 13.7998 0.00107238 13\n", + "EXAMPLE_COMPACT_OBJECT 1.242397939068e+01 1.52416 17.3205 0.000798096 13\n", + "EXAMPLE_COMPACT_OBJECT 9.756794139032e+00 1.66914 21.7394 0.000593966 13\n", + "EXAMPLE_COMPACT_OBJECT 8.401414766976e+00 1.73729 27.2857 0.000442046 13\n", + "EXAMPLE_COMPACT_OBJECT 7.536373523810e+00 1.80677 34.247 0.000328983 13\n", + "EXAMPLE_COMPACT_OBJECT 7.393982410080e+00 1.82164 42.9844 0.000244839 13\n", + "EXAMPLE_COMPACT_OBJECT 7.396470605248e+00 1.82129 53.9508 0.000182216 13\n", + "Do join of subprocesses ...\n", + "EXAMPLE_COMPACT_OBJECT 7.399005684057e+00 1.82041 67.7151 0.00013561 13\n", + "EXAMPLE_COMPACT_OBJECT 7.443375325717e+00 1.81645 84.9909 0.000100925 13\n", + "EXAMPLE_COMPACT_OBJECT 7.451195752942e+00 1.81559 106.674 7.51114e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 7.452661646076e+00 1.81543 133.89 5.59e-05 13\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-50fb66cc659c46c8bbc29fe0c8651c2f finished! *\n", - "* The total probability is 0.0444029. *\n", - "* It took a total of 3.30s to run 20 systems on 2 cores *\n", - "* = 6.60s of CPU time. *\n", - "* Maximum memory use 433.070 MB *\n", + "* Population-ce756bb317f64099a459bf8b55a746ac finished! *\n", + "* The total probability is 0.0443872. *\n", + "* It took a total of 0.73s to run 19 systems on 2 cores *\n", + "* = 1.46s of CPU time. *\n", + "* Maximum memory use 293.406 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n" + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" ] } ], @@ -614,7 +606,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'population_name': '50fb66cc659c46c8bbc29fe0c8651c2f', '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': 1635760967.3245144, 'end_timestamp': 1635760970.6249793, 'total_mass_run': 684.2544031669784, 'total_probability_weighted_mass_run': 0.28134439269236855, 'zero_prob_stars_skipped': 0}\n" + "{'population_id': 'ce756bb317f64099a459bf8b55a746ac', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.044387171445641534, 'total_count': 19, 'start_timestamp': 1646563001.7193637, 'end_timestamp': 1646563002.4480088, 'time_elapsed': 0.7286450862884521, 'total_mass_run': 649.905447944397, 'total_probability_weighted_mass_run': 0.28133908148630704, 'zero_prob_stars_skipped': 0}\n" ] } ], @@ -642,9 +634,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on method write_binary_c_calls_to_file in module binarycpython.utils.grid:\n", + "Help on method write_binary_c_calls_to_file in module binarycpython.utils.population_extensions.dataIO:\n", "\n", - "write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False) -> None method of binarycpython.utils.grid.Population instance\n", + "write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False, encoding='utf-8') -> None method of binarycpython.utils.grid.Population instance\n", " Function that loops over the grid code and writes the generated parameters to a file.\n", " In the form of a command line call\n", " \n", @@ -655,10 +647,6 @@ " \n", " On default this will write to the datadir, if it exists\n", " \n", - " Tasks:\n", - " - TODO: test this function\n", - " - TODO: make sure the binary_c_python .. output file has a unique name\n", - " \n", " Args:\n", " output_dir: (optional, default = None) directory where to write the file to. If custom_options['data_dir'] is present, then that one will be used first, and then the output_dir\n", " output_filename: (optional, default = None) filename of the output. If not set it will be called \"binary_c_calls.txt\"\n", @@ -685,19 +673,19 @@ "output_type": "stream", "text": [ "Generating grid code\n", - "Generating grid code\n", - "Saving grid code to grid_options\n", - "Writing grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py [dry_run = False]\n", - "Symlinked grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid-latest2 \n", - "Loading grid code function from /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py\n", + "Save grid code to grid_options\n", + "Write grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py [dry_run = False]\n", + "Symlinked grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid-latest2 \n", + "Load grid code function from /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py\n", "Grid code loaded\n", - "Writing binary_c calls to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "/tmp/binary_c_python-izzard/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.2158744056768156 probability 0.00823663875514986\n", - "binary_c M_1 3.430936289925951 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681537 probability 0.0062211552141636295\n", - "binary_c M_1 4.2576084265970895 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.2158744056768156 probability 0.004698855121516281\n" + "Writing binary_c calls to /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "binary_c M_1 2.2406484012210224 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.011394572976608001\n", + "binary_c M_1 2.812296769855663 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191117 probability 0.008480166685456411\n", + "binary_c M_1 3.5297876799548944 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.006311182276049824\n", + "binary_c M_1 4.430329401616038 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.004696962123378559\n", + "(abridged)\n" ] } ], @@ -707,7 +695,8 @@ "print(calls_filename)\n", "\n", "with open(calls_filename, 'r') as f:\n", - " print('\\n'.join(f.read().splitlines()[:4]))" + " print('\\n'.join(f.read().splitlines()[:4]))\n", + "print(\"(abridged)\")" ] }, { @@ -715,7 +704,15 @@ "id": "60359eb1-4d0c-4d2d-8265-ec5171b944a2", "metadata": {}, "source": [ - "## Full examples of population scripts\n", + "## Full examples of population scripts" + ] + }, + { + "cell_type": "markdown", + "id": "1ee279d6-e120-4aef-9e57-845e534f5c6a", + "metadata": {}, + "source": [ + "### Single star population\n", "Below is a full setup for a population of single stars" ] }, @@ -729,43 +726,51 @@ "name": "stdout", "output_type": "stream", "text": [ - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "**************************************\n", - "* Total starcount for this run is 20 *\n", - "* Total probability is 0.0444029 *\n", - "**************************************\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 19 *\n", + "* Total probability is 0.0443872 *\n", + "**********************************\n", "\n", - "Generating grid code\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-05e51ba114934b37bab48f1db40b7333 finished! *\n", - "* The total probability is 0.0444029. *\n", - "* It took a total of 3.46s to run 20 systems on 2 cores *\n", - "* = 6.93s of CPU time. *\n", - "* Maximum memory use 437.047 MB *\n", + "* Population-0fa4c2b8707741a5ab41d209ef95a3a4 finished! *\n", + "* The total probability is 0.0443872. *\n", + "* It took a total of 0.61s to run 19 systems on 2 cores *\n", + "* = 1.23s of CPU time. *\n", + "* Maximum memory use 299.531 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n", "\n", "\n", "time mass zams_mass probability radius stellar_type\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.450828476487e+00 1.81563 134.653 5.27143e-05 1.72498e-05 13\n", + "3.598268106227e+01 1.30592 8.75988 0.00193614 1.72498e-05 13\n", + "2.436983545111e+01 1.35842 10.9948 0.00144093 1.72498e-05 13\n", + "1.690157944401e+01 1.43124 13.7998 0.00107238 1.72498e-05 13\n", + "1.242397939068e+01 1.52416 17.3205 0.000798096 1.72498e-05 13\n", + "9.756794139032e+00 1.66914 21.7394 0.000593966 1.72498e-05 13\n", + "8.401414766976e+00 1.73729 27.2857 0.000442046 1.72498e-05 13\n", + "7.536373523810e+00 1.80677 34.247 0.000328983 1.72498e-05 13\n", + "7.393982410080e+00 1.82164 42.9844 0.000244839 1.72498e-05 13\n", + "7.396470605248e+00 1.82129 53.9508 0.000182216 1.72498e-05 13\n", + "7.399005684057e+00 1.82041 67.7151 0.00013561 1.72498e-05 13\n", + "7.451195752942e+00 1.81559 106.674 7.51114e-05 1.72498e-05 13\n", + "7.443375325717e+00 1.81645 84.9909 0.000100925 1.72498e-05 13\n", + "7.452661646076e+00 1.81543 133.89 5.59e-05 1.72498e-05 13\n", "\n" ] } @@ -877,9 +882,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\",\n", @@ -908,7 +913,8 @@ "id": "c2ab0979-6575-481d-9c1c-ca98517b2437", "metadata": {}, "source": [ - "We can also set up a population that samples biinary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded top be more useful" + "### Binary star population\n", + "We can also set up a population that samples binary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded to be more useful. Also note that we run very little systems in the following example, as its just intended to show how the code works." ] }, { @@ -921,45 +927,42 @@ "name": "stdout", "output_type": "stream", "text": [ - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 27 stars with a total probability of 0.0248684\n", - "**************************************\n", - "* Total starcount for this run is 27 *\n", - "* Total probability is 0.0248684 *\n", - "**************************************\n", + "Grid has handled 8 stars with a total probability of 0.0211592\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 8 *\n", + "* Total probability is 0.0211592 *\n", + "**********************************\n", "\n", - "Generating grid code\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-8bc1eafea1c34b05894c1618639d8c37 finished! *\n", - "* The total probability is 0.0248684. *\n", - "* It took a total of 16.10s to run 27 systems on 2 cores *\n", - "* = 32.20s of CPU time. *\n", - "* Maximum memory use 437.695 MB *\n", + "* Population-0eb5c0c9abd34607a6ee060b26a7e32f finished! *\n", + "* The total probability is 0.0211592. *\n", + "* It took a total of 0.84s to run 8 systems on 2 cores *\n", + "* = 1.68s of CPU time. *\n", + "* Maximum memory use 300.125 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\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", - "1.219029061236e+01 1.60007 17.3205 0 2.97008 13 5 15 15 0.02 0.000498487\n", - "1.935920339886e+01 1.29448 17.3205 0 8.71025 13 13 15 2 0.02 0.000498487\n", - "2.123794969278e+01 1.30902 17.3205 1.58518 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.548740826516e+01 1.52415 17.3205 1.45407 14.4504 13 13 13 5 0.02 0.000220016\n", - "1.779197348711e+01 1.3228 17.3205 1.71196 14.4504 13 13 13 8 0.02 0.000287968\n", - "1.367065497322e+01 1.66003 73.0434 1.79487 12.2572 13 13 13 8 0.02 7.67586e-05\n", - "1.772169325355e+01 1.81957 73.0434 1.46573 12.2572 13 13 13 5 0.02 4.43422e-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", - "9.823059079115e+00 2.43711 73.0434 1.81689 60.8862 14 14 13 8 0.02 7.67586e-05\n", - "7.394722435913e+00 1.79092 73.0434 1.79092 60.8862 13 8 13 8 0.02 4.43422e-05\n", - "7.396288708628e+00 1.8216 73.0434 1.8216 60.8862 13 8 13 8 0.02 3.38788e-05\n", + "1.378266748188e+01 1.66293 50.9713 1.78767 12.8178 13 13 13 8 0.02 0.000339963\n", + "1.817608462595e+01 1.82104 50.9713 1.41436 12.8178 13 13 13 5 0.02 0.000193036\n", + "7.422997711686e+00 1.82479 50.9713 1.82171 38.2535 13 13 13 8 0.02 0.000193036\n", + "1.205711924468e+01 1.73765 50.9713 0 38.2535 13 13 15 8 0.02 0.000339963\n", "\n" ] } @@ -1089,9 +1092,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -1102,8 +1105,8 @@ " name=\"q\",\n", " longname=\"Mass ratio\",\n", " valuerange=[\"0.1/M_1\", 1],\n", - " samplerfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n", - " probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", + " samplerfunc=\"self.const_linear(0.1/M_1, 1, {})\".format(resolution['q']),\n", + " probdist=\"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", " dphasevol=\"dq\",\n", " precode=\"M_2 = q * M_1\",\n", " parameter_name=\"M_2\",\n", @@ -1115,12 +1118,12 @@ " name=\"log10per\", # in days\n", " longname=\"log10(Orbital_Period)\",\n", " valuerange=[0.15, 5.5],\n", - " samplerfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", + " samplerfunc=\"self.const_linear(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", " precode=\"\"\"orbital_period = 10** log10per\n", "sep = calc_sep_from_period(M_1, M_2, orbital_period)\n", "sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n", "sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n", - " probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", + " probdist=\"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", " parameter_name=\"orbital_period\",\n", " dphasevol=\"dlog10per\",\n", ")\n", @@ -1145,7 +1148,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1159,7 +1162,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/doctrees/nbsphinx/examples/old/basic_example.ipynb b/docs/build/doctrees/nbsphinx/examples/old/basic_example.ipynb index 9078cfcb5fdcd35336ee3675accb3f810c21e5fe..7146b97671caad9e82ce7454511dcad2aa416a78 100644 --- a/docs/build/doctrees/nbsphinx/examples/old/basic_example.ipynb +++ b/docs/build/doctrees/nbsphinx/examples/old/basic_example.ipynb @@ -1,5 +1,14 @@ { "cells": [ + { + "cell_type": "markdown", + "id": "c09b9f85-5250-4fd2-8142-bb8097d138b5", + "metadata": {}, + "source": [ + "# Basic example\n", + "Running a single system" + ] + }, { "cell_type": "code", "execution_count": 1, @@ -106,7 +115,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -120,7 +129,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/doctrees/nbsphinx/examples/old/workshop_example_notebook.ipynb b/docs/build/doctrees/nbsphinx/examples/old/workshop_example_notebook.ipynb index 4eca5879779a9fec40521c733bda59768c8c4140..78d0860ad1dfc12104b4bb639055957d527c01e7 100644 --- a/docs/build/doctrees/nbsphinx/examples/old/workshop_example_notebook.ipynb +++ b/docs/build/doctrees/nbsphinx/examples/old/workshop_example_notebook.ipynb @@ -619,7 +619,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -633,7 +633,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/doctrees/nbsphinx/examples_notebook_luminosity_function_single_18_1.png b/docs/build/doctrees/nbsphinx/examples_notebook_luminosity_function_single_18_1.png new file mode 100644 index 0000000000000000000000000000000000000000..010c0d71f33a94c881df5bc7102d35b9fc4bee39 Binary files /dev/null and b/docs/build/doctrees/nbsphinx/examples_notebook_luminosity_function_single_18_1.png differ diff --git a/docs/build/doctrees/nbsphinx/examples_notebook_luminosity_function_single_23_1.png b/docs/build/doctrees/nbsphinx/examples_notebook_luminosity_function_single_23_1.png new file mode 100644 index 0000000000000000000000000000000000000000..389ac14b102032a1bf1c0dfa6612d009812ab605 Binary files /dev/null and b/docs/build/doctrees/nbsphinx/examples_notebook_luminosity_function_single_23_1.png differ diff --git a/docs/build/doctrees/nbsphinx/examples_old_basic_example_1_1.png b/docs/build/doctrees/nbsphinx/examples_old_basic_example_3_1.png similarity index 100% rename from docs/build/doctrees/nbsphinx/examples_old_basic_example_1_1.png rename to docs/build/doctrees/nbsphinx/examples_old_basic_example_3_1.png diff --git a/docs/build/doctrees/plot_functions.doctree b/docs/build/doctrees/plot_functions.doctree index 7bf0c1d91f63631f1f587a1c848cd62c4e68f16d..68351189ef9ee17ecd95dc472c001830385547ad 100644 Binary files a/docs/build/doctrees/plot_functions.doctree and b/docs/build/doctrees/plot_functions.doctree differ diff --git a/docs/build/doctrees/population_extensions/HPC.doctree b/docs/build/doctrees/population_extensions/HPC.doctree new file mode 100644 index 0000000000000000000000000000000000000000..662189361ecb47afa8b678a5202e2e1cb9328135 Binary files /dev/null and b/docs/build/doctrees/population_extensions/HPC.doctree differ diff --git a/docs/build/doctrees/population_extensions/Moe_di_Stefano_2017.doctree b/docs/build/doctrees/population_extensions/Moe_di_Stefano_2017.doctree new file mode 100644 index 0000000000000000000000000000000000000000..b406f6530e480ed894f63d9af843ce94f4183dcc Binary files /dev/null and b/docs/build/doctrees/population_extensions/Moe_di_Stefano_2017.doctree differ diff --git a/docs/build/doctrees/population_extensions/analytics.doctree b/docs/build/doctrees/population_extensions/analytics.doctree new file mode 100644 index 0000000000000000000000000000000000000000..59d6a4b5660cfb341db86ac41494b2f6ab0e2c4d Binary files /dev/null and b/docs/build/doctrees/population_extensions/analytics.doctree differ diff --git a/docs/build/doctrees/population_extensions/cache.doctree b/docs/build/doctrees/population_extensions/cache.doctree new file mode 100644 index 0000000000000000000000000000000000000000..a5eb9230bb82b975876cff3cbc1c1684dcb40ea5 Binary files /dev/null and b/docs/build/doctrees/population_extensions/cache.doctree differ diff --git a/docs/build/doctrees/population_extensions/condor.doctree b/docs/build/doctrees/population_extensions/condor.doctree new file mode 100644 index 0000000000000000000000000000000000000000..3c3dddfd1166bc199b57ffe5f9d3834f112c4209 Binary files /dev/null and b/docs/build/doctrees/population_extensions/condor.doctree differ diff --git a/docs/build/doctrees/population_extensions/dataIO.doctree b/docs/build/doctrees/population_extensions/dataIO.doctree new file mode 100644 index 0000000000000000000000000000000000000000..c776fd9b30dfb215f7106a87320117d91289c84e Binary files /dev/null and b/docs/build/doctrees/population_extensions/dataIO.doctree differ diff --git a/docs/build/doctrees/population_extensions/distribution_functions.doctree b/docs/build/doctrees/population_extensions/distribution_functions.doctree new file mode 100644 index 0000000000000000000000000000000000000000..c8e4bb25e4d04e30242dbe49623cf18da9a28875 Binary files /dev/null and b/docs/build/doctrees/population_extensions/distribution_functions.doctree differ diff --git a/docs/build/doctrees/population_extensions/grid_logging.doctree b/docs/build/doctrees/population_extensions/grid_logging.doctree new file mode 100644 index 0000000000000000000000000000000000000000..eb97dc3d10abca256a0bf03fd26b2c13269a6d92 Binary files /dev/null and b/docs/build/doctrees/population_extensions/grid_logging.doctree differ diff --git a/docs/build/doctrees/population_extensions/grid_options_defaults.doctree b/docs/build/doctrees/population_extensions/grid_options_defaults.doctree new file mode 100644 index 0000000000000000000000000000000000000000..da9be57414d652e3cffc0271b4fe7965675df218 Binary files /dev/null and b/docs/build/doctrees/population_extensions/grid_options_defaults.doctree differ diff --git a/docs/build/doctrees/population_extensions/gridcode.doctree b/docs/build/doctrees/population_extensions/gridcode.doctree new file mode 100644 index 0000000000000000000000000000000000000000..01bc7a289ce9263561bc2210e12a816f2565fb6a Binary files /dev/null and b/docs/build/doctrees/population_extensions/gridcode.doctree differ diff --git a/docs/build/doctrees/population_extensions/metadata.doctree b/docs/build/doctrees/population_extensions/metadata.doctree new file mode 100644 index 0000000000000000000000000000000000000000..1914636ab3dfbc5293f11af4eb496584febb0b1d Binary files /dev/null and b/docs/build/doctrees/population_extensions/metadata.doctree differ diff --git a/docs/build/doctrees/population_extensions/slurm.doctree b/docs/build/doctrees/population_extensions/slurm.doctree new file mode 100644 index 0000000000000000000000000000000000000000..3abb523900ae3b4d5464d05dea12fcd08a92b18f Binary files /dev/null and b/docs/build/doctrees/population_extensions/slurm.doctree differ diff --git a/docs/build/doctrees/population_extensions/spacing_functions.doctree b/docs/build/doctrees/population_extensions/spacing_functions.doctree new file mode 100644 index 0000000000000000000000000000000000000000..b95195b5cd428e6ed50041896a1b7f63cdd5187d Binary files /dev/null and b/docs/build/doctrees/population_extensions/spacing_functions.doctree differ diff --git a/docs/build/doctrees/population_extensions/version_info.doctree b/docs/build/doctrees/population_extensions/version_info.doctree new file mode 100644 index 0000000000000000000000000000000000000000..098cdd4b35debae8a7f36730d7029891a1e9ec81 Binary files /dev/null and b/docs/build/doctrees/population_extensions/version_info.doctree differ diff --git a/docs/build/doctrees/readme_link.doctree b/docs/build/doctrees/readme_link.doctree index 74e700e0edbfb2a05b4a68aa5ebbbaf244f31e75..c333475f313a366edbbb93fee68226ec2af9742e 100644 Binary files a/docs/build/doctrees/readme_link.doctree and b/docs/build/doctrees/readme_link.doctree differ diff --git a/docs/build/doctrees/run_system_wrapper.doctree b/docs/build/doctrees/run_system_wrapper.doctree index 5bd2f8a1e2a7ded6c127e05c51632405144f066d..c6f337e91119c17046ed68ea32542864ed2e2d17 100644 Binary files a/docs/build/doctrees/run_system_wrapper.doctree and b/docs/build/doctrees/run_system_wrapper.doctree differ diff --git a/docs/build/doctrees/spacing_functions.doctree b/docs/build/doctrees/spacing_functions.doctree deleted file mode 100644 index 0144377c069c2298fa8a383c9b78e9c248bbd606..0000000000000000000000000000000000000000 Binary files a/docs/build/doctrees/spacing_functions.doctree and /dev/null differ diff --git a/docs/build/doctrees/stellar_types.doctree b/docs/build/doctrees/stellar_types.doctree index 6a55f0ef4b6403ed5769de31b69987b1bb048a81..b2fea7138035c3d95911c21565188b4f2affefb4 100644 Binary files a/docs/build/doctrees/stellar_types.doctree and b/docs/build/doctrees/stellar_types.doctree differ diff --git a/docs/build/doctrees/useful_funcs.doctree b/docs/build/doctrees/useful_funcs.doctree index b8276fbde9276bf7f6e3db418b90b4b60e28f6e1..64a536977ac6d2b5fa4f8ba6e644147ad7e4eda9 100644 Binary files a/docs/build/doctrees/useful_funcs.doctree and b/docs/build/doctrees/useful_funcs.doctree differ diff --git a/docs/build/html/.buildinfo b/docs/build/html/.buildinfo index 858b45b13c13972d71e57763c4614684be375ac4..fbb0a5c1a006ce81d6bc25448504b8c9e3f9987b 100644 --- a/docs/build/html/.buildinfo +++ b/docs/build/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: a4f8e3a1f92628ed08655c4ea1d03fa6 +config: 152c93a9edbb6c06996a04d7f36b0eec tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/build/html/_images/examples_notebook_luminosity_function_single_18_1.png b/docs/build/html/_images/examples_notebook_luminosity_function_single_18_1.png new file mode 100644 index 0000000000000000000000000000000000000000..010c0d71f33a94c881df5bc7102d35b9fc4bee39 Binary files /dev/null and b/docs/build/html/_images/examples_notebook_luminosity_function_single_18_1.png differ diff --git a/docs/build/html/_images/examples_notebook_luminosity_function_single_23_1.png b/docs/build/html/_images/examples_notebook_luminosity_function_single_23_1.png new file mode 100644 index 0000000000000000000000000000000000000000..389ac14b102032a1bf1c0dfa6612d009812ab605 Binary files /dev/null and b/docs/build/html/_images/examples_notebook_luminosity_function_single_23_1.png differ diff --git a/docs/build/html/_images/examples_old_basic_example_1_1.png b/docs/build/html/_images/examples_old_basic_example_3_1.png similarity index 100% rename from docs/build/html/_images/examples_old_basic_example_1_1.png rename to docs/build/html/_images/examples_old_basic_example_3_1.png diff --git a/docs/build/html/_images/test_coverage.svg b/docs/build/html/_images/test_coverage.svg index dfb99a19bbb554f31bc566f509dce7df5d8bb40d..a4262d340358b7051e60330569727e5a2d1695f9 100644 --- a/docs/build/html/_images/test_coverage.svg +++ b/docs/build/html/_images/test_coverage.svg @@ -15,7 +15,7 @@ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text> <text x="31.5" y="14">coverage</text> - <text x="80" y="15" fill="#010101" fill-opacity=".3">67%</text> - <text x="80" y="14">67%</text> + <text x="80" y="15" fill="#010101" fill-opacity=".3">69%</text> + <text x="80" y="14">69%</text> </g> </svg> diff --git a/docs/build/html/_modules/binarycpython/utils/custom_logging_functions.html b/docs/build/html/_modules/binarycpython/utils/custom_logging_functions.html index 0c0977d4997514df8d0f6ec76336bbfe80a58174..1a1b520dd84ae217b985bc39b68f215b29cf5dda 100644 --- a/docs/build/html/_modules/binarycpython/utils/custom_logging_functions.html +++ b/docs/build/html/_modules/binarycpython/utils/custom_logging_functions.html @@ -1,68 +1,33 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>binarycpython.utils.custom_logging_functions — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - - - <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script> <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> <script src="../../../_static/jquery.js"></script> <script src="../../../_static/underscore.js"></script> + <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../../../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="../../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <script src="../../../_static/js/theme.js"></script> <link rel="index" title="Index" href="../../../genindex.html" /> <link rel="search" title="Search" href="../../../search.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../../../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -70,17 +35,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> @@ -92,66 +47,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../../../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../../../index.html">Docs</a> »</li> - + <li><a href="../../../index.html" class="icon icon-home"></a> »</li> <li><a href="../../index.html">Module code</a> »</li> - <li>binarycpython.utils.custom_logging_functions</li> - - <li class="wy-breadcrumbs-aside"> - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <h1>Source code for binarycpython.utils.custom_logging_functions</h1><div class="highlight"><pre> <span></span><span class="sd">"""</span> <span class="sd">Module containing functions for the custom logging functionality.</span> @@ -159,13 +78,15 @@ <span class="sd">"""</span> <span class="kn">import</span> <span class="nn">os</span> +<span class="kn">import</span> <span class="nn">uuid</span> +<span class="kn">import</span> <span class="nn">ctypes</span> +<span class="kn">import</span> <span class="nn">socket</span> <span class="kn">import</span> <span class="nn">textwrap</span> <span class="kn">import</span> <span class="nn">subprocess</span> -<span class="kn">import</span> <span class="nn">socket</span> -<span class="kn">import</span> <span class="nn">ctypes</span> -<span class="kn">import</span> <span class="nn">uuid</span> -<span class="kn">from</span> <span class="nn">typing</span> <span class="k">import</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Tuple</span><span class="p">,</span> <span class="n">Optional</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">temp_dir</span><span class="p">,</span> <span class="n">remove_file</span><span class="p">,</span> <span class="n">verbose_print</span> + +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Tuple</span><span class="p">,</span> <span class="n">Optional</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">temp_dir</span><span class="p">,</span> <span class="n">remove_file</span><span class="p">,</span> <span class="n">verbose_print</span> <div class="viewcode-block" id="autogen_C_logging_code"><a class="viewcode-back" href="../../../custom_logging_functions.html#binarycpython.utils.custom_logging_functions.autogen_C_logging_code">[docs]</a><span class="k">def</span> <span class="nf">autogen_C_logging_code</span><span class="p">(</span><span class="n">logging_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">verbosity</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-></span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> @@ -344,14 +265,14 @@ <div class="viewcode-block" id="from_binary_c_config"><a class="viewcode-back" href="../../../custom_logging_functions.html#binarycpython.utils.custom_logging_functions.from_binary_c_config">[docs]</a><span class="k">def</span> <span class="nf">from_binary_c_config</span><span class="p">(</span><span class="n">config_file</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">flag</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> <span class="sd">"""</span> -<span class="sd"> Function to run the binaryc_config command with flags</span> +<span class="sd"> Function to run the ``binaryc_config`` command with flags</span> <span class="sd"> Args:</span> -<span class="sd"> config_file: binary_c-config filepath TODO: change the name of this</span> -<span class="sd"> flag: flag used in the binary_c-config call.</span> +<span class="sd"> config_file: ``binary_c-config`` filepath. TODO: change the name of this</span> +<span class="sd"> flag: flag used in the ``binary_c-config`` call.</span> <span class="sd"> Returns:</span> -<span class="sd"> returns the result of <binary_c-config> <flag></span> +<span class="sd"> returns the result of ``<binary_c-config> <flag>``</span> <span class="sd"> """</span> <span class="n">res</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_output</span><span class="p">(</span> @@ -362,7 +283,6 @@ <span class="c1"># convert and chop off newline</span> <span class="n">res</span> <span class="o">=</span> <span class="n">res</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span><span class="o">.</span><span class="n">rstrip</span><span class="p">()</span> - <span class="c1"># print(res)</span> <span class="k">return</span> <span class="n">res</span></div> @@ -397,7 +317,7 @@ <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">NameError</span><span class="p">(</span><span class="s2">"Envvar BINARY_C doesnt exist"</span><span class="p">)</span> - <span class="c1"># TODO: make more options for the compiling</span> + <span class="c1">#</span> <span class="n">cc</span> <span class="o">=</span> <span class="n">from_binary_c_config</span><span class="p">(</span><span class="n">BINARY_C_CONFIG</span><span class="p">,</span> <span class="s2">"cc"</span><span class="p">)</span> <span class="c1"># Check for binary_c</span> @@ -406,7 +326,7 @@ <span class="nb">print</span><span class="p">(</span><span class="s2">"We require binary_c executable; have you built binary_c?"</span><span class="p">)</span> <span class="k">raise</span> <span class="ne">NameError</span><span class="p">(</span><span class="s2">"BINARY_C executable doesnt exist"</span><span class="p">)</span> - <span class="c1"># TODO: debug</span> + <span class="c1">#</span> <span class="n">libbinary_c</span> <span class="o">=</span> <span class="s2">"-lbinary_c"</span> <span class="n">binclibs</span> <span class="o">=</span> <span class="n">from_binary_c_config</span><span class="p">(</span><span class="n">BINARY_C_CONFIG</span><span class="p">,</span> <span class="s2">"libs"</span><span class="p">)</span> <span class="n">libdirs</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2"> -L</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> @@ -476,7 +396,6 @@ <span class="sd">"""</span> <span class="sd"> Function to write the custom logging code to a file and then compile it.</span> -<span class="sd"> TODO: nicely put in the -fPIC</span> <span class="sd"> TODO: consider returning a status</span> <span class="sd"> Args:</span> @@ -619,48 +538,36 @@ </pre></div> </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/dicts.html b/docs/build/html/_modules/binarycpython/utils/dicts.html new file mode 100644 index 0000000000000000000000000000000000000000..2eab7d38e337fdcfb34848fee6a4684a383e56c5 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/dicts.html @@ -0,0 +1,984 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.dicts — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> + <script src="../../../_static/jquery.js"></script> + <script src="../../../_static/underscore.js"></script> + <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../genindex.html" /> + <link rel="search" title="Search" href="../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../index.html">Module code</a> »</li> + <li>binarycpython.utils.dicts</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.dicts</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">Module containing functions that binary_c-python uses to modify dictionaries.</span> +<span class="sd">"""</span> + +<span class="kn">import</span> <span class="nn">collections</span> +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span> + +<span class="kn">import</span> <span class="nn">astropy.units</span> <span class="k">as</span> <span class="nn">u</span> +<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> + +<span class="c1"># Define all numerical types</span> + +<span class="n">ALLOWED_NUMERICAL_TYPES</span> <span class="o">=</span> <span class="p">(</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">complex</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">number</span><span class="p">)</span> +<span class="n">UNION_ALLOWED_NUMERICAL_TYPES</span> <span class="o">=</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">complex</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">number</span><span class="p">]</span> + + +<div class="viewcode-block" id="keys_to_floats"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.keys_to_floats">[docs]</a><span class="k">def</span> <span class="nf">keys_to_floats</span><span class="p">(</span><span class="n">input_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to convert all the keys of the dictionary to float to float</span> + +<span class="sd"> we need to convert keys to floats:</span> +<span class="sd"> this is ~ a factor 10 faster than David's ``recursive_change_key_to_float`` routine, probably because this version only does the float conversion, nothing else.</span> + +<span class="sd"> Args:</span> +<span class="sd"> input_dict: dict of which we want to turn all the keys to float types if possible</span> + +<span class="sd"> Returns:</span> +<span class="sd"> new_dict: dict of which the keys have been turned to float types where possible</span> +<span class="sd"> """</span> + + <span class="c1"># this adopts the type correctly *and* is fast</span> + <span class="n">new_dict</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">input_dict</span><span class="p">)()</span> + + <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">input_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> + <span class="c1"># convert key to a float, if we can</span> + <span class="c1"># otherwise leave as is</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">newkey</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + <span class="n">newkey</span> <span class="o">=</span> <span class="n">k</span> + + <span class="c1"># act on value(s)</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> + <span class="c1"># list data</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">newkey</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span> + <span class="n">keys_to_floats</span><span class="p">(</span><span class="n">item</span><span class="p">)</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">abc</span><span class="o">.</span><span class="n">Mapping</span><span class="p">)</span> + <span class="k">else</span> <span class="n">item</span> + <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">v</span> + <span class="p">]</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">abc</span><span class="o">.</span><span class="n">Mapping</span><span class="p">):</span> + <span class="c1"># dict, ordereddict, etc. data</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">newkey</span><span class="p">]</span> <span class="o">=</span> <span class="n">keys_to_floats</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># assume all other data are scalars</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">newkey</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span> + + <span class="k">return</span> <span class="n">new_dict</span></div> + + +<div class="viewcode-block" id="recursive_change_key_to_float"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.recursive_change_key_to_float">[docs]</a><span class="k">def</span> <span class="nf">recursive_change_key_to_float</span><span class="p">(</span><span class="n">input_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to recursively change the key to float</span> + +<span class="sd"> This only works if the dict contains just sub-dicts or numbers/strings.</span> + +<span class="sd"> Does not work with lists as values</span> + +<span class="sd"> Args:</span> +<span class="sd"> input_dict: dict of which we want to turn all the keys to float types if possible</span> + +<span class="sd"> Returns:</span> +<span class="sd"> new_dict: dict of which the keys have been turned to float types where possible</span> + +<span class="sd"> If input_dict is None or empty, returns an empty dict</span> +<span class="sd"> """</span> + + <span class="n">new_dict</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">()</span> + + <span class="c1"># if the input dict is None or empty, return an empty dict</span> + <span class="k">if</span> <span class="n">input_dict</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">input_dict</span><span class="p">:</span> + <span class="k">pass</span> + + <span class="k">else</span><span class="p">:</span> + <span class="c1"># dict has keys, loop over them</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">input_dict</span><span class="p">:</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">)):</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">num_key</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">num_key</span><span class="p">]</span> <span class="o">=</span> <span class="n">recursive_change_key_to_float</span><span class="p">(</span><span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">recursive_change_key_to_float</span><span class="p">(</span><span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">num_key</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">num_key</span><span class="p">]</span> <span class="o">=</span> <span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">return</span> <span class="n">new_dict</span></div> + + +<div class="viewcode-block" id="recursive_change_key_to_string"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.recursive_change_key_to_string">[docs]</a><span class="k">def</span> <span class="nf">recursive_change_key_to_string</span><span class="p">(</span><span class="n">input_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">custom_format</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{:g}</span><span class="s2">"</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to recursively change the key back to a string but this time in a format that we decide. We'll try to turn a string key into a float key before formatting the key</span> + +<span class="sd"> Args:</span> +<span class="sd"> input_dict: dict of which we want to turn all the keys to string types (with a custom format)</span> +<span class="sd"> custom_format: custom format used when turning the key to strings</span> + +<span class="sd"> Returns:</span> +<span class="sd"> new_dict: dict of which the keys have been turned to string types where possible</span> +<span class="sd"> """</span> + + <span class="n">new_dict</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">()</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">input_dict</span><span class="p">:</span> + <span class="c1"># Try to turn into a float</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">string_key</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + <span class="n">string_key</span> <span class="o">=</span> <span class="n">key</span> + + <span class="c1"># Turn into string with new format</span> + <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">string_key</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> + <span class="n">string_key</span> <span class="o">=</span> <span class="n">custom_format</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">string_key</span><span class="p">)</span> + + <span class="c1"># If dictionary type, call function again</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">)):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">string_key</span><span class="p">]</span> <span class="o">=</span> <span class="n">recursive_change_key_to_string</span><span class="p">(</span> + <span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">custom_format</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">string_key</span><span class="p">]</span> <span class="o">=</span> <span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">return</span> <span class="n">new_dict</span></div> + + +<span class="k">def</span> <span class="nf">_nested_set</span><span class="p">(</span><span class="n">dic</span><span class="p">,</span> <span class="n">keys</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Code to set a value of a nested dict based on a list of keys. We take into account the fact that the vallue in the dict might not be set at all by the setdefault call and the reverse looping of the keys</span> + +<span class="sd"> https://stackoverflow.com/questions/13687924/setting-a-value-in-a-nested-python-dictionary-given-a-list-of-indices-and-value</span> + +<span class="sd"> TODO: describe better</span> +<span class="sd"> """</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span> + <span class="n">dic</span> <span class="o">=</span> <span class="n">dic</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="p">{})</span> + <span class="n">dic</span><span class="p">[</span><span class="n">keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">value</span> + + +<span class="k">def</span> <span class="nf">_nested_get</span><span class="p">(</span><span class="n">dic</span><span class="p">,</span> <span class="n">keys</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Code to get a value of a nested dict based on a list of keys. We take into account the fact that the vallue in the dict might not be set at all by the setdefault call and the reverse looping of the keys</span> + +<span class="sd"> TODO: unused. Remove?</span> +<span class="sd"> """</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span> + <span class="n">dic</span> <span class="o">=</span> <span class="n">dic</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="p">{})</span> + <span class="k">return</span> <span class="n">dic</span><span class="p">[</span><span class="n">keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> + + +<span class="k">def</span> <span class="nf">_recursive_normalize_floats</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">input_dict</span><span class="p">,</span> <span class="n">factor</span><span class="p">,</span> <span class="n">parent</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ignore</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to walk through the dictionary, multiplying only float values by a factor</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">parent</span><span class="p">:</span> + <span class="n">parent</span> <span class="o">=</span> <span class="n">input_dict</span> + + <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">input_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> + <span class="k">if</span> <span class="n">ignore</span> <span class="ow">and</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">ignore</span><span class="p">:</span> + <span class="k">continue</span> + + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="nb">float</span><span class="p">):</span> + <span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> + <span class="c1"># must be a float, multiply by the factor</span> + <span class="n">_nested_set</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">v</span> <span class="o">*</span> <span class="n">factor</span><span class="p">)</span> + <span class="n">path</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">)):</span> + <span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> + <span class="c1"># do nothing to strings or ints</span> + <span class="n">path</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> + <span class="k">elif</span> <span class="n">v</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> + <span class="n">path</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> + + <span class="c1"># dicts</span> + <span class="c1"># note: isinstance isn't enough, we need to check the Mapping</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">abc</span><span class="o">.</span><span class="n">Mapping</span><span class="p">):</span> + <span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> + <span class="c1"># nested dict</span> + <span class="n">_recursive_normalize_floats</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">factor</span><span class="p">,</span> <span class="n">parent</span><span class="o">=</span><span class="n">parent</span><span class="p">)</span> + <span class="n">path</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"###Type </span><span class="si">{}</span><span class="s2"> not recognized: </span><span class="si">{}</span><span class="s2">.</span><span class="si">{}</span><span class="s2">=</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">),</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">),</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> + <span class="p">)</span> + <span class="p">)</span> + + +<div class="viewcode-block" id="multiply_float_values"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.multiply_float_values">[docs]</a><span class="k">def</span> <span class="nf">multiply_float_values</span><span class="p">(</span><span class="n">input_dict</span><span class="p">,</span> <span class="n">factor</span><span class="p">,</span> <span class="n">ignore</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> A function to recursively multiply values of a (nested) dictionary that are floats by a constant. Nested dictionaries call this function recursively.</span> + +<span class="sd"> Args:</span> +<span class="sd"> input_dict: the dictionary</span> +<span class="sd"> factor: the constant that multiplies float values</span> +<span class="sd"> """</span> + + <span class="n">path</span> <span class="o">=</span> <span class="p">[]</span> + <span class="n">_recursive_normalize_floats</span><span class="p">(</span> + <span class="n">path</span><span class="p">,</span> <span class="n">input_dict</span><span class="p">,</span> <span class="n">factor</span><span class="p">,</span> <span class="n">parent</span><span class="o">=</span><span class="n">input_dict</span><span class="p">,</span> <span class="n">ignore</span><span class="o">=</span><span class="n">ignore</span> + <span class="p">)</span></div> + + +<div class="viewcode-block" id="subtract_dicts"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.subtract_dicts">[docs]</a><span class="k">def</span> <span class="nf">subtract_dicts</span><span class="p">(</span><span class="n">dict_1</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">dict_2</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to subtract two dictionaries, i.e. ``dict_1 - dict_2``</span> + +<span class="sd"> Only allows values to be either a dict or a numerical type</span> + +<span class="sd"> For the overlapping keys (key name present in both dicts):</span> +<span class="sd"> When the keys are of the same type: If the types are of numerical type we subtract the value at dict 2 from dict 1. If the types are both dictionaries: call this function with the subdicts</span> + +<span class="sd"> When the keys are not of the same type: If the keys are all of numerical types we do the subtraction. If they are not numerical we raise an error.</span> + +<span class="sd"> For the unique keys:</span> +<span class="sd"> If the key is from dict 1: adds the value to the new dict (be it numerical value or dict)</span> + +<span class="sd"> If the key is from dict 2: Adds the negative of its value in case of numerical type. If the type is a dict, the result of ``subtract_dicts({}, dict_2[key])`` will be set</span> + +<span class="sd"> If the result is 0, the key will be removed from the resulting dict.</span> + +<span class="sd"> If that results in an empty dict, the dict will be removed too.</span> + +<span class="sd"> Args:</span> +<span class="sd"> dict_1: first dictionary</span> +<span class="sd"> dict_2: second dictionary</span> + +<span class="sd"> Returns:</span> +<span class="sd"> Subtracted dictionary, i.e. ``dict_1 - dict_2``</span> +<span class="sd"> """</span> + + <span class="c1"># Set up new dict</span> + <span class="n">new_dict</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="c1">#</span> + <span class="n">keys_1</span> <span class="o">=</span> <span class="n">dict_1</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + <span class="n">keys_2</span> <span class="o">=</span> <span class="n">dict_2</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + + <span class="c1"># Find overlapping keys of both dicts</span> + <span class="n">overlapping_keys</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">keys_1</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">keys_2</span><span class="p">))</span> + + <span class="c1"># Find the keys that are unique</span> + <span class="n">unique_to_dict_1</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">keys_1</span><span class="p">)</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">keys_2</span><span class="p">))</span> + <span class="n">unique_to_dict_2</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">keys_2</span><span class="p">)</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">keys_1</span><span class="p">))</span> + + <span class="c1"># Add the unique keys to the new dict</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">unique_to_dict_1</span><span class="p">:</span> + <span class="c1"># If these items are numerical types</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">ALLOWED_NUMERICAL_TYPES</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="k">if</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="k">del</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">dict</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Error: using unsupported type for key </span><span class="si">{}</span><span class="s2">: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Add the unique keys to the new dict</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">unique_to_dict_2</span><span class="p">:</span> + <span class="c1"># If these items are numerical type, we should add the negative of the value</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">ALLOWED_NUMERICAL_TYPES</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="k">if</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="k">del</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># Else we should place the negative of that dictionary in the new place</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">dict</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">subtract_dicts</span><span class="p">({},</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Error: using unsupported type for key </span><span class="si">{}</span><span class="s2">: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Go over the common keys:</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">overlapping_keys</span><span class="p">:</span> + + <span class="c1"># See whether the types are actually the same</span> + <span class="k">if</span> <span class="ow">not</span> <span class="nb">type</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> <span class="ow">is</span> <span class="nb">type</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]):</span> + <span class="c1"># Exceptions:</span> + <span class="k">if</span> <span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> <span class="ow">in</span> <span class="n">ALLOWED_NUMERICAL_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span> + <span class="nb">type</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> <span class="ow">in</span> <span class="n">ALLOWED_NUMERICAL_TYPES</span> + <span class="p">):</span> + <span class="c1"># We can safely subtract the values since they are all numeric</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">-</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="k">if</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="k">del</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Error key: </span><span class="si">{key}</span><span class="s2"> value: </span><span class="si">{value1}</span><span class="s2"> type: </span><span class="si">{type}</span><span class="s2"> and key: </span><span class="si">{key}</span><span class="s2"> value: </span><span class="si">{value2}</span><span class="s2"> type: </span><span class="si">{type2}</span><span class="s2"> are not of the same type and cannot be merged"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> + <span class="n">value1</span><span class="o">=</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> + <span class="nb">type</span><span class="o">=</span><span class="nb">type</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]),</span> + <span class="n">value2</span><span class="o">=</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> + <span class="n">type2</span><span class="o">=</span><span class="nb">type</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]),</span> + <span class="p">)</span> + + <span class="nb">print</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># This is where the keys are the same</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># If these items are numeric types</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">ALLOWED_NUMERICAL_TYPES</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">-</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># Remove entry if the value is 0</span> + <span class="k">if</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="k">del</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">dict</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">subtract_dicts</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + + <span class="c1"># Remove entry if it results in an empty dict</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]:</span> + <span class="k">del</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Error: using unsupported type for key </span><span class="si">{}</span><span class="s2">: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1">#</span> + <span class="k">return</span> <span class="n">new_dict</span></div> + + +<div class="viewcode-block" id="AutoVivificationDict"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.AutoVivificationDict">[docs]</a><span class="k">class</span> <span class="nc">AutoVivificationDict</span><span class="p">(</span><span class="nb">dict</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Implementation of perl's autovivification feature, by overriding the</span> +<span class="sd"> get item and the __iadd__ operator (https://docs.python.org/3/reference/datamodel.html?highlight=iadd#object.__iadd__)</span> + +<span class="sd"> This allows to set values within a subdict that might not exist yet:</span> + +<span class="sd"> Example:</span> +<span class="sd"> newdict = {}</span> +<span class="sd"> newdict['example']['mass'] += 10</span> +<span class="sd"> print(newdict)</span> +<span class="sd"> >>> {'example': {'mass': 10}}</span> +<span class="sd"> """</span> + +<div class="viewcode-block" id="AutoVivificationDict.__getitem__"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.AutoVivificationDict.__getitem__">[docs]</a> <span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Getitem function for the autovivication dict</span> +<span class="sd"> """</span> + + <span class="k">try</span><span class="p">:</span> + <span class="k">return</span> <span class="nb">dict</span><span class="o">.</span><span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span> + <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="p">[</span><span class="n">item</span><span class="p">]</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)()</span> + <span class="k">return</span> <span class="n">value</span></div> + +<div class="viewcode-block" id="AutoVivificationDict.__iadd__"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.AutoVivificationDict.__iadd__">[docs]</a> <span class="k">def</span> <span class="fm">__iadd__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> iadd function (handling the +=) for the autovivication dict.</span> +<span class="sd"> """</span> + + <span class="c1"># if a value does not exist, assume it is 0.0</span> + <span class="k">try</span><span class="p">:</span> + <span class="bp">self</span> <span class="o">+=</span> <span class="n">other</span> + <span class="k">except</span><span class="p">:</span> + <span class="bp">self</span> <span class="o">=</span> <span class="n">other</span> + <span class="k">return</span> <span class="bp">self</span></div></div> + + +<div class="viewcode-block" id="inspect_dict"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.inspect_dict">[docs]</a><span class="k">def</span> <span class="nf">inspect_dict</span><span class="p">(</span> + <span class="n">input_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="n">print_structure</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +<span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to (recursively) inspect a (nested) dictionary.</span> +<span class="sd"> The object that is returned is a dictionary containing the key of the input_dict, but as value</span> +<span class="sd"> it will return the type of what the value would be in the input_dict</span> + +<span class="sd"> In this way we inspect the structure of these dictionaries, rather than the exact contents.</span> + +<span class="sd"> Args:</span> +<span class="sd"> input_dict: dictionary you want to inspect</span> +<span class="sd"> print_structure: (optional, default = True)</span> +<span class="sd"> indent: (optional, default = 0) indent of the first output</span> + +<span class="sd"> Returns:</span> +<span class="sd"> Dictionary that has the same structure as the input_dict, but as values it has the</span> +<span class="sd"> type(input_dict[key]) (except if the value is a dict)</span> +<span class="sd"> """</span> + + <span class="n">structure_dict</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">()</span> + + <span class="c1">#</span> + <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">input_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> + <span class="n">structure_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">print_structure</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="se">\t</span><span class="s2">"</span> <span class="o">*</span> <span class="n">indent</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">value</span><span class="p">))</span> + + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> + <span class="n">structure_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">inspect_dict</span><span class="p">(</span> + <span class="n">value</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="n">indent</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">print_structure</span><span class="o">=</span><span class="n">print_structure</span> + <span class="p">)</span> + + <span class="k">return</span> <span class="n">structure_dict</span></div> + + +<div class="viewcode-block" id="count_keys_recursive"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.count_keys_recursive">[docs]</a><span class="k">def</span> <span class="nf">count_keys_recursive</span><span class="p">(</span><span class="n">input_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to recursively count the total number of keys in a dictionary.</span> + +<span class="sd"> Args:</span> +<span class="sd"> input_dict: dictionary that we want to know the total amount of keys from.</span> + +<span class="sd"> Returns:</span> +<span class="sd"> local_count: total amount of keys within the input_dict.</span> +<span class="sd"> """</span> + + <span class="n">local_count</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">input_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> + <span class="n">local_count</span> <span class="o">+=</span> <span class="mi">1</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">)):</span> + <span class="n">local_count</span> <span class="o">+=</span> <span class="n">count_keys_recursive</span><span class="p">(</span><span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + + <span class="k">return</span> <span class="n">local_count</span></div> + + +<div class="viewcode-block" id="merge_dicts"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.merge_dicts">[docs]</a><span class="k">def</span> <span class="nf">merge_dicts</span><span class="p">(</span><span class="n">dict_1</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">dict_2</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to merge two dictionaries in a custom way.</span> + +<span class="sd"> Behaviour:</span> + +<span class="sd"> When dict keys are only present in one of either:</span> +<span class="sd"> - we just add the content to the new dict</span> + +<span class="sd"> When dict keys are present in both, we decide based on the value types how to combine them:</span> +<span class="sd"> - dictionaries will be merged by calling recursively calling this function again</span> +<span class="sd"> - numbers will be added</span> +<span class="sd"> - (opt) lists will be appended</span> +<span class="sd"> - booleans are merged with logical OR</span> +<span class="sd"> - identical strings are just set to the string</span> +<span class="sd"> - non-identical strings are concatenated</span> +<span class="sd"> - NoneTypes are set to None</span> +<span class="sd"> - In the case that the instances do not match: for now I will raise an error</span> + +<span class="sd"> Args:</span> +<span class="sd"> dict_1: first dictionary</span> +<span class="sd"> dict_2: second dictionary</span> + +<span class="sd"> Returns:</span> +<span class="sd"> Merged dictionary</span> + +<span class="sd"> """</span> + + <span class="c1"># Set up new dict</span> + <span class="n">new_dict</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">()</span> + + <span class="c1">#</span> + <span class="n">keys_1</span> <span class="o">=</span> <span class="n">dict_1</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + <span class="n">keys_2</span> <span class="o">=</span> <span class="n">dict_2</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + + <span class="c1"># Find overlapping keys of both dicts</span> + <span class="n">overlapping_keys</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">keys_1</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">keys_2</span><span class="p">))</span> + + <span class="c1"># Find the keys that are unique</span> + <span class="n">unique_to_dict_1</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">keys_1</span><span class="p">)</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">keys_2</span><span class="p">))</span> + <span class="n">unique_to_dict_2</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">keys_2</span><span class="p">)</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">keys_1</span><span class="p">))</span> + + <span class="c1"># Add the unique keys to the new dict</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">unique_to_dict_1</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">unique_to_dict_2</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># Go over the common keys:</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">overlapping_keys</span><span class="p">:</span> + + <span class="c1"># If they keys are not the same, it depends on their type whether we still deal with them at all, or just raise an error</span> + <span class="k">if</span> <span class="ow">not</span> <span class="nb">type</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> <span class="ow">is</span> <span class="nb">type</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]):</span> + <span class="c1"># Exceptions: numbers can be added</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">ALLOWED_NUMERICAL_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span> + <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">ALLOWED_NUMERICAL_TYPES</span> + <span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">+</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># Exceptions: versions of dicts can be merged</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span> + <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">AutoVivificationDict</span><span class="p">))</span> + <span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span> + <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">AutoVivificationDict</span><span class="p">))</span> + <span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">merge_dicts</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + + <span class="c1"># string-int clash : convert both to ints and save</span> + <span class="k">elif</span> <span class="p">(</span> + <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">str</span><span class="p">)</span> + <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">int</span><span class="p">)</span> + <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">int</span><span class="p">)</span> + <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">str</span><span class="p">)</span> + <span class="p">):</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> <span class="o">+</span> <span class="nb">int</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + <span class="k">except</span> <span class="ne">ValueError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">: Failed to convert string (either '</span><span class="si">{}</span><span class="s2">' or '</span><span class="si">{}</span><span class="s2">') to an int"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="p">,</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span> + + <span class="c1"># string-float clash : convert both to floats and save</span> + <span class="k">elif</span> <span class="p">(</span> + <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">str</span><span class="p">)</span> + <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">float</span><span class="p">)</span> + <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">float</span><span class="p">)</span> + <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">str</span><span class="p">)</span> + <span class="p">):</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> <span class="o">+</span> <span class="nb">float</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + <span class="k">except</span> <span class="ne">ValueError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">: Failed to convert string (either '</span><span class="si">{}</span><span class="s2">' or '</span><span class="si">{}</span><span class="s2">') to an float"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="p">,</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span> + + <span class="c1"># If the above cases have not dealt with it, then we should raise an error</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"merge_dicts error: key: </span><span class="si">{key}</span><span class="s2"> value: </span><span class="si">{value1}</span><span class="s2"> type: </span><span class="si">{type1}</span><span class="s2"> and key: </span><span class="si">{key}</span><span class="s2"> value: </span><span class="si">{value2}</span><span class="s2"> type: </span><span class="si">{type2}</span><span class="s2"> are not of the same type and cannot be merged"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> + <span class="n">value1</span><span class="o">=</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> + <span class="n">type1</span><span class="o">=</span><span class="nb">type</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]),</span> + <span class="n">value2</span><span class="o">=</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> + <span class="n">type2</span><span class="o">=</span><span class="nb">type</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]),</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Here the keys are the same type</span> + <span class="c1"># Here we check for the cases that we want to explicitly catch. Ints will be added,</span> + <span class="c1"># floats will be added, lists will be appended (though that might change) and dicts will be</span> + <span class="c1"># dealt with by calling this function again.</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># ints</span> + <span class="c1"># Booleans (has to be the type Bool, not just a 0 or 1)</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">bool</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">bool</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="ow">or</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">int</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">int</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">+</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># floats</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">float</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">float</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">+</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># lists</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">list</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">list</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">+</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># Astropy quantities (using a dummy type representing the numpy array)</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">type</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">])</span> <span class="o">*</span> <span class="n">u</span><span class="o">.</span><span class="n">m</span><span class="p">))</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span> + <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">type</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">])</span> <span class="o">*</span> <span class="n">u</span><span class="o">.</span><span class="n">m</span><span class="p">)</span> + <span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">+</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># dicts</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">dict</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">dict</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">merge_dicts</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + + <span class="c1"># strings</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">str</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">str</span><span class="p">):</span> + <span class="k">if</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">==</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]:</span> + <span class="c1"># same strings</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># different strings: just concatenate them</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">+</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># None types</span> + <span class="k">elif</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Object types </span><span class="si">{}</span><span class="s2">: </span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2">), </span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2">) not supported."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="p">,</span> + <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> + <span class="nb">type</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]),</span> + <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> + <span class="nb">type</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]),</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1">#</span> + <span class="k">return</span> <span class="n">new_dict</span></div> + + +<div class="viewcode-block" id="update_dicts"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.update_dicts">[docs]</a><span class="k">def</span> <span class="nf">update_dicts</span><span class="p">(</span><span class="n">dict_1</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">dict_2</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to update dict_1 with values of dict_2 in a recursive way.</span> + +<span class="sd"> Behaviour:</span> +<span class="sd"> When dict keys are only present in one of either: we just add the content to the new dict</span> + +<span class="sd"> When dict keys are present in both, we decide based on the value types how to combine them: value of dict2 will be taken</span> + +<span class="sd"> Args:</span> +<span class="sd"> dict_1: first dictionary</span> +<span class="sd"> dict_2: second dictionary</span> + +<span class="sd"> Returns:</span> +<span class="sd"> New dictionary with Updated values</span> + +<span class="sd"> """</span> + + <span class="c1"># Set up new dict of the same type as dict_1</span> + <span class="n">new_dict</span> <span class="o">=</span> <span class="n">dict_1</span><span class="o">.</span><span class="vm">__class__</span><span class="p">()</span> + + <span class="c1"># Get keys</span> + <span class="n">keys_1</span> <span class="o">=</span> <span class="n">dict_1</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + <span class="n">keys_2</span> <span class="o">=</span> <span class="n">dict_2</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + + <span class="c1"># Find overlapping keys of both dicts</span> + <span class="n">overlapping_keys</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">keys_1</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">keys_2</span><span class="p">))</span> + + <span class="c1"># Find the keys that are unique</span> + <span class="n">unique_to_dict_1</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">keys_1</span><span class="p">)</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">keys_2</span><span class="p">))</span> + <span class="n">unique_to_dict_2</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">keys_2</span><span class="p">)</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">keys_1</span><span class="p">))</span> + + <span class="c1"># Add the unique keys to the new dict</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">unique_to_dict_1</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">unique_to_dict_2</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># Go over the common keys:</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">overlapping_keys</span><span class="p">:</span> + + <span class="c1"># See whether the types are actually the same</span> + <span class="k">if</span> <span class="ow">not</span> <span class="nb">type</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> <span class="ow">is</span> <span class="nb">type</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]):</span> + <span class="c1"># Exceptions:</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">ALLOWED_NUMERICAL_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span> + <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">ALLOWED_NUMERICAL_TYPES</span> + <span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Error key: </span><span class="si">{key}</span><span class="s2"> value: </span><span class="si">{value1}</span><span class="s2"> type: </span><span class="si">{type1}</span><span class="s2"> and key: </span><span class="si">{key}</span><span class="s2"> value: </span><span class="si">{value2}</span><span class="s2"> type: </span><span class="si">{type2}</span><span class="s2"> are not of the same type and cannot be merged"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> + <span class="n">value1</span><span class="o">=</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> + <span class="n">type1</span><span class="o">=</span><span class="nb">type</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">]),</span> + <span class="n">value2</span><span class="o">=</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> + <span class="n">type2</span><span class="o">=</span><span class="nb">type</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]),</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span> + + <span class="c1"># Here we check for the cases that we want to explicitly catch. Ints will be added,</span> + <span class="c1"># floats will be added, lists will be appended (though that might change) and dicts will be</span> + <span class="c1"># dealt with by calling this function again.</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># dicts</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">dict</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="nb">dict</span><span class="p">):</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">update_dicts</span><span class="p">(</span><span class="n">dict_1</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">dict_2</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="c1">#</span> + <span class="k">return</span> <span class="n">new_dict</span></div> + + +<div class="viewcode-block" id="multiply_values_dict"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.multiply_values_dict">[docs]</a><span class="k">def</span> <span class="nf">multiply_values_dict</span><span class="p">(</span><span class="n">input_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">factor</span><span class="p">:</span> <span class="n">UNION_ALLOWED_NUMERICAL_TYPES</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that goes over dictionary recursively and multiplies the value if possible by a factor</span> + +<span class="sd"> If the key equals "general_info", the multiplication gets skipped.</span> + +<span class="sd"> This function changes the values in-place, so the original dict is modified</span> + +<span class="sd"> Args:</span> +<span class="sd"> input_dict: dictionary of which we want to multiply the values by <factor></span> +<span class="sd"> factor: factor that we want to multiply the values with</span> + +<span class="sd"> Returns:</span> +<span class="sd"> multiplied_dict: dict containing the multiplied keys. This is the same object as we passed as input.</span> +<span class="sd"> """</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">input_dict</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span> <span class="o">==</span> <span class="s2">"general_info"</span><span class="p">:</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">)):</span> + <span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">multiply_values_dict</span><span class="p">(</span><span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">factor</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="p">(</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">)):</span> + <span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">*</span> <span class="n">factor</span> + + <span class="k">return</span> <span class="n">input_dict</span></div> + + +<div class="viewcode-block" id="custom_sort_dict"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.custom_sort_dict">[docs]</a><span class="k">def</span> <span class="nf">custom_sort_dict</span><span class="p">(</span><span class="n">input_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Returns a dictionary that is ordered, but can handle numbers better than normal OrderedDict</span> + +<span class="sd"> When the keys of the current dictionary are of mixed type, we first find all the unique types.</span> +<span class="sd"> Sort that list of type names. Then find the values that fit that type.</span> +<span class="sd"> Sort those and append them to the sorted keys list.</span> +<span class="sd"> This is done until all the keys are sorted.</span> + +<span class="sd"> All objects other than dictionary types are directly return as they are</span> + +<span class="sd"> Args:</span> +<span class="sd"> input_dict: object which will be sorted (and returned as a new object) if its a dictionary, otherwise it will be returned without change.</span> +<span class="sd"> """</span> + + <span class="c1"># If the new input is a dictionary, then try to sort it</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">input_dict</span><span class="p">,</span> <span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">)):</span> + <span class="n">new_dict</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">()</span> + + <span class="n">keys</span> <span class="o">=</span> <span class="n">input_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + + <span class="c1"># Check if types are the same</span> + <span class="n">all_types_keys</span> <span class="o">=</span> <span class="p">[]</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="nb">type</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="ow">in</span> <span class="n">all_types_keys</span><span class="p">:</span> + <span class="n">all_types_keys</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> + + <span class="c1"># If there are multiple types, then we loop over them and do a piece wise sort</span> + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">all_types_keys</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Different types in the same dictionary key set"</span> + <span class="nb">print</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Create a string repr of the type name to sort them afterwards</span> + <span class="n">str_types</span> <span class="o">=</span> <span class="p">{</span><span class="nb">repr</span><span class="p">(</span><span class="n">el</span><span class="p">):</span> <span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">all_types_keys</span><span class="p">}</span> + + <span class="c1"># Set up sorted keys list</span> + <span class="n">sorted_keys</span> <span class="o">=</span> <span class="p">[]</span> + + <span class="k">for</span> <span class="n">key_str_type</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">str_types</span><span class="o">.</span><span class="n">keys</span><span class="p">()):</span> + <span class="n">cur_type</span> <span class="o">=</span> <span class="n">str_types</span><span class="p">[</span><span class="n">key_str_type</span><span class="p">]</span> + + <span class="n">cur_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">cur_type</span><span class="p">)]</span> + <span class="n">cur_sorted_list</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">cur_list</span><span class="p">)</span> + + <span class="n">sorted_keys</span> <span class="o">=</span> <span class="n">sorted_keys</span> <span class="o">+</span> <span class="n">cur_sorted_list</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">sorted_keys</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">sorted_keys</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">custom_sort_dict</span><span class="p">(</span><span class="n">input_dict</span><span class="p">[</span><span class="n">key</span><span class="p">])</span> + + <span class="k">return</span> <span class="n">new_dict</span> + + <span class="k">return</span> <span class="n">input_dict</span></div> + + +<div class="viewcode-block" id="filter_dict"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.filter_dict">[docs]</a><span class="k">def</span> <span class="nf">filter_dict</span><span class="p">(</span><span class="n">arg_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">filter_list</span><span class="p">:</span> <span class="nb">list</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to filter out keys that are contains in filter_list</span> + +<span class="sd"> Args:</span> +<span class="sd"> arg_dict: dictionary containing the argument + default key pairs of binary_c</span> +<span class="sd"> filter_list: lists of keys to be filtered out</span> +<span class="sd"> Returns:</span> +<span class="sd"> filtered dictionary</span> +<span class="sd"> """</span> + + <span class="n">new_dict</span> <span class="o">=</span> <span class="n">arg_dict</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">filter_list</span><span class="p">:</span> + <span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">new_dict</span><span class="p">:</span> + <span class="k">del</span> <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">return</span> <span class="n">new_dict</span></div> + + +<div class="viewcode-block" id="filter_dict_through_values"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.filter_dict_through_values">[docs]</a><span class="k">def</span> <span class="nf">filter_dict_through_values</span><span class="p">(</span><span class="n">arg_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">filter_list</span><span class="p">:</span> <span class="nb">list</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to filter out keys that contain values included in filter_list</span> + +<span class="sd"> Args:</span> +<span class="sd"> arg_dict: dictionary containing the argument + default key pairs of binary_c</span> +<span class="sd"> filter_list: lists of values to be filtered out</span> +<span class="sd"> Returns:</span> +<span class="sd"> filtered dictionary</span> +<span class="sd"> """</span> + + <span class="n">new_dict</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">arg_dict</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">arg_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="ow">in</span> <span class="n">filter_list</span><span class="p">:</span> + <span class="n">new_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">arg_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="k">return</span> <span class="n">new_dict</span></div> + + +<div class="viewcode-block" id="prepare_dict"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.prepare_dict">[docs]</a><span class="k">def</span> <span class="nf">prepare_dict</span><span class="p">(</span><span class="n">global_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">list_of_sub_keys</span><span class="p">:</span> <span class="nb">list</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function that makes sure that the global dict is prepared to have a value set there.</span> +<span class="sd"> This dictionary will store values and factors for the distribution functions,</span> +<span class="sd"> so that they don't have to be calculated each time.</span> + +<span class="sd"> Args:</span> +<span class="sd"> global_dict: globally accessible dictionary where factors are stored in</span> +<span class="sd"> list_of_sub_keys: List of keys that must become be(come) present in the global_dict</span> +<span class="sd"> """</span> + + <span class="n">internal_dict_value</span> <span class="o">=</span> <span class="n">global_dict</span> + + <span class="c1"># This loop almost mimics a recursive loop into the dictionary.</span> + <span class="c1"># It checks whether the first key of the list is present, if not; set it with an empty dict.</span> + <span class="c1"># Then it overrides itself to be that (new) item, and goes on to do that again, until the list</span> + <span class="c1"># exhausted</span> + <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">list_of_sub_keys</span><span class="p">:</span> + <span class="c1"># If the sub key doesnt exist then make an empty dict</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">internal_dict_value</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">internal_dict_value</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + <span class="n">internal_dict_value</span> <span class="o">=</span> <span class="n">internal_dict_value</span><span class="p">[</span><span class="n">k</span><span class="p">]</span></div> + + +<div class="viewcode-block" id="set_opts"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.set_opts">[docs]</a><span class="k">def</span> <span class="nf">set_opts</span><span class="p">(</span><span class="n">opts</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">newopts</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to take a default dict and override it with newer values.</span> + +<span class="sd"> # TODO: consider changing this to just a dict.update</span> + +<span class="sd"> Args:</span> +<span class="sd"> opts: dictionary with default values</span> +<span class="sd"> newopts: dictionary with new values</span> + +<span class="sd"> Returns:</span> +<span class="sd"> returns an updated dictionary</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">newopts</span><span class="p">:</span> + <span class="k">for</span> <span class="n">opt</span> <span class="ow">in</span> <span class="n">newopts</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> + <span class="k">if</span> <span class="n">opt</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> + <span class="n">opts</span><span class="p">[</span><span class="n">opt</span><span class="p">]</span> <span class="o">=</span> <span class="n">newopts</span><span class="p">[</span><span class="n">opt</span><span class="p">]</span> + + <span class="k">return</span> <span class="n">opts</span></div> + + +<div class="viewcode-block" id="normalize_dict"><a class="viewcode-back" href="../../../dicts.html#binarycpython.utils.dicts.normalize_dict">[docs]</a><span class="k">def</span> <span class="nf">normalize_dict</span><span class="p">(</span><span class="n">result_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to normalise a dictionary by summing all the values and dividing each term by the total. Designed for dictionary containing only positive values.</span> + +<span class="sd"> Args:</span> +<span class="sd"> result_dict: dictionary where values should be positive number objects</span> + +<span class="sd"> Returns:</span> +<span class="sd"> normalized_dict: dictionary where the values are normalised to sum to 1</span> +<span class="sd"> """</span> + + <span class="n">normalized_dict</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="n">sum_result</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">result_dict</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">result_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> + <span class="n">normalized_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">result_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">/</span> <span class="n">sum_result</span> + + <span class="k">return</span> <span class="n">normalized_dict</span></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/distribution_functions.html b/docs/build/html/_modules/binarycpython/utils/distribution_functions.html deleted file mode 100644 index b8ca67092c93ce67d45d7c0c70b9139b334b10c4..0000000000000000000000000000000000000000 --- a/docs/build/html/_modules/binarycpython/utils/distribution_functions.html +++ /dev/null @@ -1,2628 +0,0 @@ - - -<!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> -<head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>binarycpython.utils.distribution_functions — binary_c-python documentation</title> - - - - - - - - - <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script> - <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> - <script src="../../../_static/jquery.js"></script> - <script src="../../../_static/underscore.js"></script> - <script src="../../../_static/doctools.js"></script> - <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="../../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="index" title="Index" href="../../../genindex.html" /> - <link rel="search" title="Search" href="../../../search.html" /> -</head> - -<body class="wy-body-for-nav"> - - - <div class="wy-grid-for-nav"> - - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> - <div class="wy-side-scroll"> - <div class="wy-side-nav-search" > - - - - <a href="../../../index.html" class="icon icon-home"> binary_c-python - - - - </a> - - - - - - - -<div role="search"> - <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> - <input type="text" name="q" placeholder="Search docs" /> - <input type="hidden" name="check_keywords" value="yes" /> - <input type="hidden" name="area" value="default" /> - </form> -</div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - - <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> -<ul> -<li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../modules.html">Binarycpython code</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../example_notebooks.html">Example notebooks</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../binary_c_parameters.html">Binary_c parameters</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../grid_options_descriptions.html">Population grid code options</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> -</ul> - - - - </div> - </div> - </nav> - - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - - <i data-toggle="wy-nav-top" class="fa fa-bars"></i> - <a href="../../../index.html">binary_c-python</a> - - </nav> - - - <div class="wy-nav-content"> - - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - - <ul class="wy-breadcrumbs"> - - <li><a href="../../../index.html">Docs</a> »</li> - - <li><a href="../../index.html">Module code</a> »</li> - - <li>binarycpython.utils.distribution_functions</li> - - - <li class="wy-breadcrumbs-aside"> - - </li> - - </ul> - - - <hr/> -</div> - <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> - <div itemprop="articleBody"> - - <h1>Source code for binarycpython.utils.distribution_functions</h1><div class="highlight"><pre> -<span></span><span class="sd">"""</span> -<span class="sd">Module containing the predefined distribution functions</span> - -<span class="sd">The user can use any of these distribution functions to</span> -<span class="sd">generate probability distributions for sampling populations</span> - -<span class="sd">There are distributions for the following parameters:</span> -<span class="sd"> - mass</span> -<span class="sd"> - period</span> -<span class="sd"> - mass ratio</span> -<span class="sd"> - binary fraction</span> - -<span class="sd">Tasks:</span> -<span class="sd"> - TODO: make some things globally present? rob does this in his module..i guess it saves</span> -<span class="sd"> calculations but not sure if I'm gonna do that now</span> -<span class="sd"> - TODO: add eccentricity distribution: thermal</span> -<span class="sd"> - TODO: Add SFH distributions depending on redshift</span> -<span class="sd"> - TODO: Add metallicity distributions depending on redshift</span> -<span class="sd"> - TODO: Add initial rotational velocity distributions</span> -<span class="sd"> - TODO: make an n-part power law that's general enough to fix the three part and the 4 part</span> -<span class="sd">"""</span> - -<span class="kn">import</span> <span class="nn">functools</span> -<span class="kn">import</span> <span class="nn">math</span> -<span class="kn">import</span> <span class="nn">json</span> - -<span class="kn">import</span> <span class="nn">traceback</span> -<span class="kn">import</span> <span class="nn">sys</span> - -<span class="kn">from</span> <span class="nn">typing</span> <span class="k">import</span> <span class="n">Union</span> - -<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> - -<span class="kn">from</span> <span class="nn">binarycpython.utils.useful_funcs</span> <span class="k">import</span> <span class="n">calc_period_from_sep</span><span class="p">,</span> <span class="n">calc_sep_from_period</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">verbose_print</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.grid_options_defaults</span> <span class="k">import</span> <span class="p">(</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span><span class="p">,</span> -<span class="p">)</span> - -<span class="c1">###</span> -<span class="c1"># File containing probability distributions</span> -<span class="c1"># Mostly copied from the Perl modules</span> -<span class="n">LOG_LN_CONVERTER</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="mf">10.0</span><span class="p">)</span> -<span class="n">distribution_constants</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># To store the constants in</span> - - -<div class="viewcode-block" id="prepare_dict"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.prepare_dict">[docs]</a><span class="k">def</span> <span class="nf">prepare_dict</span><span class="p">(</span><span class="n">global_dict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">list_of_sub_keys</span><span class="p">:</span> <span class="nb">list</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Function that makes sure that the global dict is prepared to have a value set there.</span> -<span class="sd"> This dictionary will store values and factors for the distribution functions,</span> -<span class="sd"> so that they don't have to be calculated each time.</span> - -<span class="sd"> Args:</span> -<span class="sd"> global_dict: globally accessible dictionary where factors are stored in</span> -<span class="sd"> list_of_sub_keys: List of keys that must become be(come) present in the global_dict</span> -<span class="sd"> """</span> - - <span class="n">internal_dict_value</span> <span class="o">=</span> <span class="n">global_dict</span> - - <span class="c1"># This loop almost mimics a recursive loop into the dictionary.</span> - <span class="c1"># It checks whether the first key of the list is present, if not; set it with an empty dict.</span> - <span class="c1"># Then it overrides itself to be that (new) item, and goes on to do that again, until the list</span> - <span class="c1"># exhausted</span> - <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">list_of_sub_keys</span><span class="p">:</span> - <span class="c1"># If the sub key doesnt exist then make an empty dict</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">internal_dict_value</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">internal_dict_value</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> - <span class="n">internal_dict_value</span> <span class="o">=</span> <span class="n">internal_dict_value</span><span class="p">[</span><span class="n">k</span><span class="p">]</span></div> - - -<div class="viewcode-block" id="set_opts"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.set_opts">[docs]</a><span class="k">def</span> <span class="nf">set_opts</span><span class="p">(</span><span class="n">opts</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">newopts</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Function to take a default dict and override it with newer values.</span> - -<span class="sd"> # TODO: consider changing this to just a dict.update</span> - -<span class="sd"> Args:</span> -<span class="sd"> opts: dictionary with default values</span> -<span class="sd"> newopts: dictionary with new values</span> - -<span class="sd"> Returns:</span> -<span class="sd"> returns an updated dictionary</span> -<span class="sd"> """</span> - - <span class="k">if</span> <span class="n">newopts</span><span class="p">:</span> - <span class="k">for</span> <span class="n">opt</span> <span class="ow">in</span> <span class="n">newopts</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> - <span class="k">if</span> <span class="n">opt</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> - <span class="n">opts</span><span class="p">[</span><span class="n">opt</span><span class="p">]</span> <span class="o">=</span> <span class="n">newopts</span><span class="p">[</span><span class="n">opt</span><span class="p">]</span> - - <span class="k">return</span> <span class="n">opts</span></div> - - -<div class="viewcode-block" id="flat"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.flat">[docs]</a><span class="k">def</span> <span class="nf">flat</span><span class="p">()</span> <span class="o">-></span> <span class="nb">float</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Dummy distribution function that returns 1</span> - -<span class="sd"> Returns:</span> -<span class="sd"> a flat uniform distribution: 1</span> -<span class="sd"> """</span> - - <span class="k">return</span> <span class="mf">1.0</span></div> - - -<div class="viewcode-block" id="number"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.number">[docs]</a><span class="k">def</span> <span class="nf">number</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Dummy distribution function that returns the input</span> - -<span class="sd"> Args:</span> -<span class="sd"> value: the value that will be returned by this function.</span> - -<span class="sd"> Returns:</span> -<span class="sd"> the value that was provided</span> -<span class="sd"> """</span> - - <span class="k">return</span> <span class="n">value</span></div> - - -<div class="viewcode-block" id="const"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.const">[docs]</a><span class="k">def</span> <span class="nf">const</span><span class="p">(</span> - <span class="n">min_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">max_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">val</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="kc">None</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> a constant distribution function between min=min_bound and max=max_bound.</span> - -<span class="sd"> Args:</span> -<span class="sd"> min_bound: lower bound of the range</span> -<span class="sd"> max_bound: upper bound of the range</span> - -<span class="sd"> Returns:</span> -<span class="sd"> returns the value of 1/(max_bound-min_bound). If val is provided, it will check whether min_bound < val <= max_bound. if not: returns 0</span> -<span class="sd"> """</span> - - <span class="k">if</span> <span class="n">val</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">min_bound</span> <span class="o"><</span> <span class="n">val</span> <span class="o"><=</span> <span class="n">max_bound</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"out of bounds"</span><span class="p">)</span> - <span class="n">prob</span> <span class="o">=</span> <span class="mi">0</span> - <span class="k">return</span> <span class="n">prob</span> - <span class="n">prob</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="n">max_bound</span> <span class="o">-</span> <span class="n">min_bound</span><span class="p">)</span> - <span class="k">return</span> <span class="n">prob</span></div> - - -<div class="viewcode-block" id="powerlaw_constant"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.powerlaw_constant">[docs]</a><span class="nd">@functools</span><span class="o">.</span><span class="n">lru_cache</span><span class="p">(</span><span class="n">maxsize</span><span class="o">=</span><span class="mi">16</span><span class="p">)</span> -<span class="k">def</span> <span class="nf">powerlaw_constant</span><span class="p">(</span> - <span class="n">min_val</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">max_val</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">k</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Function that returns the constant to normalise a power law</span> - -<span class="sd"> TODO: what if k is -1?</span> - -<span class="sd"> Args:</span> -<span class="sd"> min_val: lower bound of the range</span> -<span class="sd"> max_val: upper bound of the range</span> -<span class="sd"> k: power law slope</span> - -<span class="sd"> Returns:</span> -<span class="sd"> constant to normalise the given power law between the min_val and max_val range</span> -<span class="sd"> """</span> - - <span class="n">k1</span> <span class="o">=</span> <span class="n">k</span> <span class="o">+</span> <span class="mf">1.0</span> - <span class="c1"># print(</span> - <span class="c1"># "Powerlaw consts from {} to {}, k={} where k1={}".format(</span> - <span class="c1"># min_val, max_val, k, k1</span> - <span class="c1"># )</span> - <span class="c1"># )</span> - - <span class="n">powerlaw_const</span> <span class="o">=</span> <span class="n">k1</span> <span class="o">/</span> <span class="p">(</span><span class="n">max_val</span> <span class="o">**</span> <span class="n">k1</span> <span class="o">-</span> <span class="n">min_val</span> <span class="o">**</span> <span class="n">k1</span><span class="p">)</span> - <span class="k">return</span> <span class="n">powerlaw_const</span></div> - - -<div class="viewcode-block" id="powerlaw"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.powerlaw">[docs]</a><span class="k">def</span> <span class="nf">powerlaw</span><span class="p">(</span> - <span class="n">min_val</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">max_val</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">k</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">x</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Single power law with index k at x from min to max</span> - -<span class="sd"> Args:</span> -<span class="sd"> min_val: lower bound of the power law</span> -<span class="sd"> max_val: upper bound of the power law</span> -<span class="sd"> k: slope of the power law</span> -<span class="sd"> x: position at which we want to evaluate</span> - -<span class="sd"> Returns:</span> -<span class="sd"> `probability` at the given position(x)</span> -<span class="sd"> """</span> - - <span class="c1"># Handle faulty value</span> - <span class="k">if</span> <span class="n">k</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"wrong value for k"</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="k">if</span> <span class="p">(</span><span class="n">x</span> <span class="o"><</span> <span class="n">min_val</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">x</span> <span class="o">></span> <span class="n">max_val</span><span class="p">):</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"input value is out of bounds!"</span><span class="p">)</span> - <span class="k">return</span> <span class="mi">0</span> - - <span class="n">powerlaw_const</span> <span class="o">=</span> <span class="n">powerlaw_constant</span><span class="p">(</span><span class="n">min_val</span><span class="p">,</span> <span class="n">max_val</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> - - <span class="c1"># power law</span> - <span class="n">prob</span> <span class="o">=</span> <span class="n">powerlaw_const</span> <span class="o">*</span> <span class="p">(</span><span class="n">x</span> <span class="o">**</span> <span class="n">k</span><span class="p">)</span> - <span class="c1"># print(</span> - <span class="c1"># "Power law from {} to {}: const = {}, y = {}".format(</span> - <span class="c1"># min_val, max_val, const, y</span> - <span class="c1"># )</span> - <span class="c1"># )</span> - <span class="k">return</span> <span class="n">prob</span></div> - - -<div class="viewcode-block" id="calculate_constants_three_part_powerlaw"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.calculate_constants_three_part_powerlaw">[docs]</a><span class="nd">@functools</span><span class="o">.</span><span class="n">lru_cache</span><span class="p">(</span><span class="n">maxsize</span><span class="o">=</span><span class="mi">16</span><span class="p">)</span> -<span class="k">def</span> <span class="nf">calculate_constants_three_part_powerlaw</span><span class="p">(</span> - <span class="n">m0</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">m1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">m2</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">m_max</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">p1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">p2</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">p3</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Function to calculate the constants for a three-part power law</span> - -<span class="sd"> TODO: use the power law_constant function to calculate all these values</span> - -<span class="sd"> Args:</span> -<span class="sd"> m0: lower bound mass</span> -<span class="sd"> m1: second boundary, between the first slope and the second slope</span> -<span class="sd"> m2: third boundary, between the second slope and the third slope</span> -<span class="sd"> m_max: upper bound mass</span> -<span class="sd"> p1: first slope</span> -<span class="sd"> p2: second slope</span> -<span class="sd"> p3: third slope</span> - -<span class="sd"> Returns:</span> -<span class="sd"> array of normalisation constants</span> -<span class="sd"> """</span> - - <span class="c1"># print("Initialising constants for the three-part powerlaw: m0={} m1={} m2={}\</span> - <span class="c1"># m_max={} p1={} p2={} p3={}\n".format(m0, m1, m2, m_max, p1, p2, p3))</span> - - <span class="n">array_constants_three_part_powerlaw</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span> - - <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> - <span class="p">((</span><span class="n">m1</span> <span class="o">**</span> <span class="n">p2</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">m1</span> <span class="o">**</span> <span class="p">(</span><span class="o">-</span><span class="n">p1</span><span class="p">)))</span> - <span class="o">*</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p1</span><span class="p">))</span> - <span class="o">*</span> <span class="p">(</span><span class="n">m1</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p1</span><span class="p">)</span> <span class="o">-</span> <span class="n">m0</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p1</span><span class="p">))</span> - <span class="p">)</span> - <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+=</span> <span class="p">(</span> - <span class="p">(</span><span class="n">m2</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p2</span><span class="p">)</span> <span class="o">-</span> <span class="n">m1</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p2</span><span class="p">))</span> - <span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p2</span><span class="p">))</span> - <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+=</span> <span class="p">(</span> - <span class="p">((</span><span class="n">m2</span> <span class="o">**</span> <span class="n">p2</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">m2</span> <span class="o">**</span> <span class="p">(</span><span class="o">-</span><span class="n">p3</span><span class="p">)))</span> - <span class="o">*</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p3</span><span class="p">))</span> - <span class="o">*</span> <span class="p">(</span><span class="n">m_max</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p3</span><span class="p">)</span> <span class="o">-</span> <span class="n">m2</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p3</span><span class="p">))</span> - <span class="p">)</span> - <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span> - <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1e-50</span> - <span class="p">)</span> - - <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span> - <span class="p">(</span><span class="n">m1</span> <span class="o">**</span> <span class="n">p2</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">m1</span> <span class="o">**</span> <span class="p">(</span><span class="o">-</span><span class="n">p1</span><span class="p">))</span> - <span class="p">)</span> - <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span> - <span class="p">(</span><span class="n">m2</span> <span class="o">**</span> <span class="n">p2</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">m2</span> <span class="o">**</span> <span class="p">(</span><span class="o">-</span><span class="n">p3</span><span class="p">))</span> - <span class="p">)</span> - - <span class="k">return</span> <span class="n">array_constants_three_part_powerlaw</span></div> - <span class="c1"># $$array[1]=(($m1**$p2)*($m1**(-$p1)))*</span> - <span class="c1"># (1.0/(1.0+$p1))*</span> - <span class="c1"># ($m1**(1.0+$p1)-$m0**(1.0+$p1))+</span> - <span class="c1"># (($m2**(1.0+$p2)-$m1**(1.0+$p2)))*</span> - <span class="c1"># (1.0/(1.0+$p2))+</span> - <span class="c1"># (($m2**$p2)*($m2**(-$p3)))*</span> - <span class="c1"># (1.0/(1.0+$p3))*</span> - <span class="c1"># ($mmax**(1.0+$p3)-$m2**(1.0+$p3));</span> - <span class="c1"># $$array[1]=1.0/($$array[1]+1e-50);</span> - <span class="c1"># $$array[0]=$$array[1]*$m1**$p2*$m1**(-$p1);</span> - <span class="c1"># $$array[2]=$$array[1]*$m2**$p2*$m2**(-$p3);</span> - <span class="c1"># #print "ARRAY SET @_ => @$array\n";</span> - <span class="c1"># $threepart_powerlaw_consts{"@_"}=[@$array];</span> - - -<div class="viewcode-block" id="three_part_powerlaw"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.three_part_powerlaw">[docs]</a><span class="k">def</span> <span class="nf">three_part_powerlaw</span><span class="p">(</span> - <span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">m0</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">m1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">m2</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">m_max</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">p1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">p2</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">p3</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Generalised three-part power law, usually used for mass distributions</span> - -<span class="sd"> Args:</span> -<span class="sd"> m: mass at which we want to evaluate the distribution.</span> -<span class="sd"> m0: lower bound mass</span> -<span class="sd"> m1: second boundary, between the first slope and the second slope</span> -<span class="sd"> m2: third boundary, between the second slope and the third slope</span> -<span class="sd"> m_max: upper bound mass</span> -<span class="sd"> p1: first slope</span> -<span class="sd"> p2: second slope</span> -<span class="sd"> p3: third slope</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' at given mass m</span> -<span class="sd"> """</span> - - <span class="c1"># TODO: add check on whether the values exist</span> - - <span class="n">three_part_powerlaw_constants</span> <span class="o">=</span> <span class="n">calculate_constants_three_part_powerlaw</span><span class="p">(</span> - <span class="n">m0</span><span class="p">,</span> <span class="n">m1</span><span class="p">,</span> <span class="n">m2</span><span class="p">,</span> <span class="n">m_max</span><span class="p">,</span> <span class="n">p1</span><span class="p">,</span> <span class="n">p2</span><span class="p">,</span> <span class="n">p3</span> - <span class="p">)</span> - - <span class="c1">#</span> - <span class="k">if</span> <span class="n">m</span> <span class="o"><</span> <span class="n">m0</span><span class="p">:</span> - <span class="n">prob</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># Below lower bound TODO: make this clear.</span> - <span class="k">elif</span> <span class="n">m0</span> <span class="o"><</span> <span class="n">m</span> <span class="o"><=</span> <span class="n">m1</span><span class="p">:</span> - <span class="n">prob</span> <span class="o">=</span> <span class="n">three_part_powerlaw_constants</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="n">p1</span><span class="p">)</span> <span class="c1"># Between M0 and M1</span> - <span class="k">elif</span> <span class="n">m1</span> <span class="o"><</span> <span class="n">m</span> <span class="o"><=</span> <span class="n">m2</span><span class="p">:</span> - <span class="n">prob</span> <span class="o">=</span> <span class="n">three_part_powerlaw_constants</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="n">p2</span><span class="p">)</span> <span class="c1"># Between M1 and M2</span> - <span class="k">elif</span> <span class="n">m2</span> <span class="o"><</span> <span class="n">m</span> <span class="o"><=</span> <span class="n">m_max</span><span class="p">:</span> - <span class="n">prob</span> <span class="o">=</span> <span class="n">three_part_powerlaw_constants</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="n">p3</span><span class="p">)</span> <span class="c1"># Between M2 and M_MAX</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">prob</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># Above M_MAX</span> - - <span class="k">return</span> <span class="n">prob</span></div> - - -<div class="viewcode-block" id="gaussian_normalizing_const"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.gaussian_normalizing_const">[docs]</a><span class="nd">@functools</span><span class="o">.</span><span class="n">lru_cache</span><span class="p">(</span><span class="n">maxsize</span><span class="o">=</span><span class="mi">16</span><span class="p">)</span> -<span class="k">def</span> <span class="nf">gaussian_normalizing_const</span><span class="p">(</span> - <span class="n">mean</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">sigma</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">gmin</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">gmax</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Function to calculate the normalisation constant for the Gaussian</span> - -<span class="sd"> Args:</span> -<span class="sd"> mean: mean of the Gaussian</span> -<span class="sd"> sigma: standard deviation of the Gaussian</span> -<span class="sd"> gmin: lower bound of the range to calculate the probabilities in</span> -<span class="sd"> gmax: upper bound of the range to calculate the probabilities in</span> - -<span class="sd"> Returns:</span> -<span class="sd"> normalisation constant for the Gaussian distribution(mean, sigma) between gmin and gmax</span> -<span class="sd"> """</span> - - <span class="c1"># First time; calculate multiplier for given mean and sigma</span> - <span class="n">ptot</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">resolution</span> <span class="o">=</span> <span class="mi">1000</span> - <span class="n">d</span> <span class="o">=</span> <span class="p">(</span><span class="n">gmax</span> <span class="o">-</span> <span class="n">gmin</span><span class="p">)</span> <span class="o">/</span> <span class="n">resolution</span> - - <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">resolution</span><span class="p">):</span> - <span class="n">y</span> <span class="o">=</span> <span class="n">gmin</span> <span class="o">+</span> <span class="n">i</span> <span class="o">*</span> <span class="n">d</span> - <span class="n">ptot</span> <span class="o">+=</span> <span class="n">d</span> <span class="o">*</span> <span class="n">gaussian_func</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">mean</span><span class="p">,</span> <span class="n">sigma</span><span class="p">)</span> - - <span class="c1"># TODO: Set value in global</span> - <span class="k">return</span> <span class="n">ptot</span></div> - - -<div class="viewcode-block" id="gaussian_func"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.gaussian_func">[docs]</a><span class="k">def</span> <span class="nf">gaussian_func</span><span class="p">(</span> - <span class="n">x</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">mean</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">sigma</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Function to evaluate a Gaussian at a given point, but this time without any boundaries.</span> - -<span class="sd"> Args:</span> -<span class="sd"> x: location at which to evaluate the distribution</span> -<span class="sd"> mean: mean of the Gaussian</span> -<span class="sd"> sigma: standard deviation of the Gaussian</span> - -<span class="sd"> Returns:</span> -<span class="sd"> value of the Gaussian at x</span> -<span class="sd"> """</span> - <span class="n">gaussian_prefactor</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="mf">2.0</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">pi</span><span class="p">)</span> - - <span class="n">r</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="n">sigma</span><span class="p">)</span> - <span class="n">y</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">mean</span><span class="p">)</span> <span class="o">*</span> <span class="n">r</span> - <span class="k">return</span> <span class="n">gaussian_prefactor</span> <span class="o">*</span> <span class="n">r</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span> <span class="o">*</span> <span class="n">y</span> <span class="o">**</span> <span class="mi">2</span><span class="p">)</span></div> - - -<div class="viewcode-block" id="gaussian"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.gaussian">[docs]</a><span class="k">def</span> <span class="nf">gaussian</span><span class="p">(</span> - <span class="n">x</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">mean</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">sigma</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">gmin</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">gmax</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Gaussian distribution function. used for e.g. Duquennoy + Mayor 1991</span> - -<span class="sd"> Args:</span> -<span class="sd"> x: location at which to evaluate the distribution</span> -<span class="sd"> mean: mean of the Gaussian</span> -<span class="sd"> sigma: standard deviation of the Gaussian</span> -<span class="sd"> gmin: lower bound of the range to calculate the probabilities in</span> -<span class="sd"> gmax: upper bound of the range to calculate the probabilities in</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' of the Gaussian distribution between the boundaries, evaluated at x</span> -<span class="sd"> """</span> - - <span class="c1"># # location (X value), mean and sigma, min and max range</span> - <span class="c1"># my ($x,$mean,$sigma,$gmin,$gmax) = @_;</span> - - <span class="k">if</span> <span class="p">(</span><span class="n">x</span> <span class="o"><</span> <span class="n">gmin</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">x</span> <span class="o">></span> <span class="n">gmax</span><span class="p">):</span> - <span class="n">prob</span> <span class="o">=</span> <span class="mi">0</span> - <span class="k">else</span><span class="p">:</span> - <span class="c1"># normalise over given range</span> - <span class="c1"># TODO: add loading into global var</span> - <span class="n">normalisation</span> <span class="o">=</span> <span class="n">gaussian_normalizing_const</span><span class="p">(</span><span class="n">mean</span><span class="p">,</span> <span class="n">sigma</span><span class="p">,</span> <span class="n">gmin</span><span class="p">,</span> <span class="n">gmax</span><span class="p">)</span> - <span class="n">prob</span> <span class="o">=</span> <span class="n">gaussian_func</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">mean</span><span class="p">,</span> <span class="n">sigma</span><span class="p">)</span> <span class="o">/</span> <span class="n">normalisation</span> - - <span class="k">return</span> <span class="n">prob</span></div> - - -<span class="c1">#####</span> -<span class="c1"># Mass distributions</span> -<span class="c1">#####</span> - - -<div class="viewcode-block" id="Kroupa2001"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.Kroupa2001">[docs]</a><span class="k">def</span> <span class="nf">Kroupa2001</span><span class="p">(</span><span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">newopts</span><span class="p">:</span> <span class="nb">dict</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Probability distribution function for Kroupa 2001 IMF, where the default values to the</span> -<span class="sd"> three_part_powerlaw are: default = {"m0": 0.1, "m1": 0.5, "m2": 1, "mmax": 100, "p1": -1.3, "p2": -2.3,"p3": -2.3}</span> - -<span class="sd"> Args:</span> -<span class="sd"> m: mass to evaluate the distribution at</span> -<span class="sd"> newopts: optional dict to override the default values.</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' of distribution function evaluated at m</span> -<span class="sd"> """</span> - - <span class="c1"># Default parameters and override them</span> - <span class="n">default</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"m0"</span><span class="p">:</span> <span class="mf">0.1</span><span class="p">,</span> - <span class="s2">"m1"</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">,</span> - <span class="s2">"m2"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> - <span class="s2">"mmax"</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span> - <span class="s2">"p1"</span><span class="p">:</span> <span class="o">-</span><span class="mf">1.3</span><span class="p">,</span> - <span class="s2">"p2"</span><span class="p">:</span> <span class="o">-</span><span class="mf">2.3</span><span class="p">,</span> - <span class="s2">"p3"</span><span class="p">:</span> <span class="o">-</span><span class="mf">2.3</span><span class="p">,</span> - <span class="p">}</span> - - <span class="n">value_dict</span> <span class="o">=</span> <span class="n">default</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> - - <span class="k">if</span> <span class="n">newopts</span><span class="p">:</span> - <span class="n">value_dict</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">newopts</span><span class="p">)</span> - - <span class="k">return</span> <span class="n">three_part_powerlaw</span><span class="p">(</span> - <span class="n">m</span><span class="p">,</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m0"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m1"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m2"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"mmax"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p1"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p2"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p3"</span><span class="p">],</span> - <span class="p">)</span></div> - - -<div class="viewcode-block" id="ktg93"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.ktg93">[docs]</a><span class="k">def</span> <span class="nf">ktg93</span><span class="p">(</span><span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">newopts</span><span class="p">:</span> <span class="nb">dict</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Probability distribution function for KTG93 IMF, where the default values to the three_part_powerlaw are: default = {"m0": 0.1, "m1": 0.5, "m2": 1, "mmax": 80, "p1": -1.3, "p2": -2.2,"p3": -2.7}</span> - -<span class="sd"> Args:</span> -<span class="sd"> m: mass to evaluate the distribution at</span> -<span class="sd"> newopts: optional dict to override the default values.</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' of distribution function evaluated at m</span> -<span class="sd"> """</span> - <span class="c1"># TODO: ask rob what this means</span> - - <span class="c1"># if($m eq 'uncertainties')</span> - <span class="c1"># {</span> - <span class="c1"># # return (pointer to) the uncertainties hash</span> - <span class="c1"># return {</span> - <span class="c1"># m0=>{default=>0.1,</span> - <span class="c1"># fixed=>1},</span> - <span class="c1"># m1=>{default=>0.5,</span> - <span class="c1"># fixed=>1},</span> - <span class="c1"># m2=>{default=>1.0,</span> - <span class="c1"># fixed=>1},</span> - <span class="c1"># mmax=>{default=>80.0,</span> - <span class="c1"># fixed=>1},</span> - <span class="c1"># p1=>{default=>-1.3,</span> - <span class="c1"># low=>-1.3,</span> - <span class="c1"># high=>-1.3},</span> - <span class="c1"># p2=>{default=>-2.2,</span> - <span class="c1"># low=>-2.2,</span> - <span class="c1"># high=>-2.2},</span> - <span class="c1"># p3=>{default=>-2.7,</span> - <span class="c1"># low=>-2.7,</span> - <span class="c1"># high=>-2.7}</span> - <span class="c1"># };</span> - <span class="c1"># }</span> - - <span class="c1"># set options</span> - <span class="c1"># opts = set_opts({'m0':0.1, 'm1':0.5, 'm2':1.0, 'mmax':80, 'p1':-1.3, 'p2':-2.2, 'p3':-2.7},</span> - <span class="c1"># newopts)</span> - - <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"m0"</span><span class="p">:</span> <span class="mf">0.1</span><span class="p">,</span> - <span class="s2">"m1"</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">,</span> - <span class="s2">"m2"</span><span class="p">:</span> <span class="mf">1.0</span><span class="p">,</span> - <span class="s2">"mmax"</span><span class="p">:</span> <span class="mi">80</span><span class="p">,</span> - <span class="s2">"p1"</span><span class="p">:</span> <span class="o">-</span><span class="mf">1.3</span><span class="p">,</span> - <span class="s2">"p2"</span><span class="p">:</span> <span class="o">-</span><span class="mf">2.2</span><span class="p">,</span> - <span class="s2">"p3"</span><span class="p">:</span> <span class="o">-</span><span class="mf">2.7</span><span class="p">,</span> - <span class="p">}</span> - <span class="n">value_dict</span> <span class="o">=</span> <span class="n">defaults</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> - - <span class="k">if</span> <span class="n">newopts</span><span class="p">:</span> - <span class="n">value_dict</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">newopts</span><span class="p">)</span> - - <span class="k">return</span> <span class="n">three_part_powerlaw</span><span class="p">(</span> - <span class="n">m</span><span class="p">,</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m0"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m1"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m2"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"mmax"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p1"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p2"</span><span class="p">],</span> - <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p3"</span><span class="p">],</span> - <span class="p">)</span></div> - - -<span class="c1"># sub ktg93_lnspace</span> -<span class="c1"># {</span> -<span class="c1"># # wrapper for KTG93 on a ln(m) grid</span> -<span class="c1"># my $m=$_[0];</span> -<span class="c1"># return ktg93(@_) * $m;</span> -<span class="c1"># }</span> - - -<div class="viewcode-block" id="imf_tinsley1980"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.imf_tinsley1980">[docs]</a><span class="k">def</span> <span class="nf">imf_tinsley1980</span><span class="p">(</span><span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Probability distribution function for Tinsley 1980 IMF (defined up until 80Msol): three_part_powerlaw(m, 0.1, 2.0, 10.0, 80.0, -2.0, -2.3, -3.3)</span> - -<span class="sd"> Args:</span> -<span class="sd"> m: mass to evaluate the distribution at</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' of distribution function evaluated at m</span> -<span class="sd"> """</span> - - <span class="k">return</span> <span class="n">three_part_powerlaw</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">,</span> <span class="mf">10.0</span><span class="p">,</span> <span class="mf">80.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.3</span><span class="p">,</span> <span class="o">-</span><span class="mf">3.3</span><span class="p">)</span></div> - - -<div class="viewcode-block" id="imf_scalo1986"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.imf_scalo1986">[docs]</a><span class="k">def</span> <span class="nf">imf_scalo1986</span><span class="p">(</span><span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Probability distribution function for Scalo 1986 IMF (defined up until 80Msol): three_part_powerlaw(m, 0.1, 1.0, 2.0, 80.0, -2.35, -2.35, -2.70)</span> - -<span class="sd"> Args:</span> -<span class="sd"> m: mass to evaluate the distribution at</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' of distribution function evaluated at m</span> -<span class="sd"> """</span> - <span class="k">return</span> <span class="n">three_part_powerlaw</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">,</span> <span class="mf">80.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.35</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.35</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.70</span><span class="p">)</span></div> - - -<div class="viewcode-block" id="imf_scalo1998"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.imf_scalo1998">[docs]</a><span class="k">def</span> <span class="nf">imf_scalo1998</span><span class="p">(</span><span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> From Scalo 1998</span> - -<span class="sd"> Probability distribution function for Scalo 1998 IMF (defined up until 80Msol): three_part_powerlaw(m, 0.1, 1.0, 10.0, 80.0, -1.2, -2.7, -2.3)</span> - -<span class="sd"> Args:</span> -<span class="sd"> m: mass to evaluate the distribution at</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' of distribution function evaluated at m</span> -<span class="sd"> """</span> - - <span class="k">return</span> <span class="n">three_part_powerlaw</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">10.0</span><span class="p">,</span> <span class="mf">80.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.2</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.7</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.3</span><span class="p">)</span></div> - - -<div class="viewcode-block" id="imf_chabrier2003"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.imf_chabrier2003">[docs]</a><span class="k">def</span> <span class="nf">imf_chabrier2003</span><span class="p">(</span><span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Probability distribution function for IMF of Chabrier 2003 PASP 115:763-795</span> - -<span class="sd"> Args:</span> -<span class="sd"> m: mass to evaluate the distribution at</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' of distribution function evaluated at m</span> -<span class="sd"> """</span> - - <span class="n">chabrier_logmc</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="mf">0.079</span><span class="p">)</span> - <span class="n">chabrier_sigma2</span> <span class="o">=</span> <span class="mf">0.69</span> <span class="o">*</span> <span class="mf">0.69</span> - <span class="n">chabrier_a1</span> <span class="o">=</span> <span class="mf">0.158</span> - <span class="n">chabrier_a2</span> <span class="o">=</span> <span class="mf">4.43e-2</span> - <span class="n">chabrier_x</span> <span class="o">=</span> <span class="o">-</span><span class="mf">1.3</span> - <span class="k">if</span> <span class="n">m</span> <span class="o"><=</span> <span class="mi">0</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"below bounds"</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - <span class="k">if</span> <span class="mi">0</span> <span class="o"><</span> <span class="n">m</span> <span class="o"><</span> <span class="mf">1.0</span><span class="p">:</span> - <span class="n">A</span> <span class="o">=</span> <span class="mf">0.158</span> - <span class="n">dm</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> <span class="o">-</span> <span class="n">chabrier_logmc</span> - <span class="n">prob</span> <span class="o">=</span> <span class="n">chabrier_a1</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="p">(</span><span class="n">dm</span> <span class="o">**</span> <span class="mi">2</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mf">2.0</span> <span class="o">*</span> <span class="n">chabrier_sigma2</span><span class="p">))</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">prob</span> <span class="o">=</span> <span class="n">chabrier_a2</span> <span class="o">*</span> <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="n">chabrier_x</span><span class="p">)</span> - <span class="n">prob</span> <span class="o">=</span> <span class="n">prob</span> <span class="o">/</span> <span class="p">(</span><span class="mf">0.1202462</span> <span class="o">*</span> <span class="n">m</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="mi">10</span><span class="p">))</span> - <span class="k">return</span> <span class="n">prob</span></div> - - -<span class="c1">########################################################################</span> -<span class="c1"># Binary fractions</span> -<span class="c1">########################################################################</span> - - -<div class="viewcode-block" id="Arenou2010_binary_fraction"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.Arenou2010_binary_fraction">[docs]</a><span class="k">def</span> <span class="nf">Arenou2010_binary_fraction</span><span class="p">(</span><span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Arenou 2010 function for the binary fraction as f(M1)</span> - -<span class="sd"> GAIA-C2-SP-OPM-FA-054</span> -<span class="sd"> www.rssd.esa.int/doc_fetch.php?id=2969346</span> - -<span class="sd"> Args:</span> -<span class="sd"> m: mass to evaluate the distribution at</span> - -<span class="sd"> Returns:</span> -<span class="sd"> binary fraction at m</span> -<span class="sd"> """</span> - - <span class="k">return</span> <span class="mf">0.8388</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">tanh</span><span class="p">(</span><span class="mf">0.688</span> <span class="o">*</span> <span class="n">m</span> <span class="o">+</span> <span class="mf">0.079</span><span class="p">)</span></div> - - -<span class="c1"># print(Arenou2010_binary_fraction(0.4))</span> - - -<div class="viewcode-block" id="raghavan2010_binary_fraction"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.raghavan2010_binary_fraction">[docs]</a><span class="k">def</span> <span class="nf">raghavan2010_binary_fraction</span><span class="p">(</span><span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Fit to the Raghavan 2010 binary fraction as a function of</span> -<span class="sd"> spectral type (Fig 12). Valid for local stars (Z=Zsolar).</span> - -<span class="sd"> The spectral type is converted mass by use of the ZAMS</span> -<span class="sd"> effective temperatures from binary_c/BSE (at Z=0.02)</span> -<span class="sd"> and the new "long_spectral_type" function of binary_c</span> -<span class="sd"> (based on Jaschek+Jaschek's Teff-spectral type table).</span> - -<span class="sd"> Rob then fitted the result</span> - -<span class="sd"> Args:</span> -<span class="sd"> m: mass to evaluate the distribution at</span> - -<span class="sd"> Returns:</span> -<span class="sd"> binary fraction at m</span> -<span class="sd"> """</span> - - <span class="k">return</span> <span class="nb">min</span><span class="p">(</span> - <span class="mf">1.0</span><span class="p">,</span> - <span class="nb">max</span><span class="p">(</span> - <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="mf">0.1</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mf">5.12310e-01</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="o">-</span><span class="mf">1.02070e-01</span><span class="p">),</span> - <span class="p">(</span><span class="mf">1.10450e00</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="p">(</span><span class="mf">4.93670e-01</span><span class="p">))</span> <span class="o">+</span> <span class="p">(</span><span class="o">-</span><span class="mf">6.95630e-01</span><span class="p">),</span> - <span class="p">),</span> - <span class="p">)</span></div> - - -<span class="c1"># print(raghavan2010_binary_fraction(2))</span> - -<span class="c1">########################################################################</span> -<span class="c1"># Period distributions</span> -<span class="c1">########################################################################</span> - - -<div class="viewcode-block" id="duquennoy1991"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.duquennoy1991">[docs]</a><span class="k">def</span> <span class="nf">duquennoy1991</span><span class="p">(</span><span class="n">logper</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Period distribution from Duquennoy + Mayor 1991. Evaluated the function gaussian(logper, 4.8, 2.3, -2, 12)</span> - -<span class="sd"> Args:</span> -<span class="sd"> logper: logarithm of period to evaluate the distribution at</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' at gaussian(logper, 4.8, 2.3, -2, 12)</span> -<span class="sd"> """</span> - <span class="k">return</span> <span class="n">gaussian</span><span class="p">(</span><span class="n">logper</span><span class="p">,</span> <span class="mf">4.8</span><span class="p">,</span> <span class="mf">2.3</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span></div> - - -<div class="viewcode-block" id="sana12"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.sana12">[docs]</a><span class="k">def</span> <span class="nf">sana12</span><span class="p">(</span> - <span class="n">M1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">M2</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">a</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">P</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">amin</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">amax</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">x0</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">x1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">p</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> distribution of initial orbital periods as found by Sana et al. (2012)</span> -<span class="sd"> which is a flat distribution in ln(a) and ln(P) respectively for stars</span> -<span class="sd"> * less massive than 15Msun (no O-stars)</span> -<span class="sd"> * mass ratio q=M2/M1<0.1</span> -<span class="sd"> * log(P)<0.15=x0 and log(P)>3.5=x1</span> -<span class="sd"> and is be given by dp/dlogP ~ (logP)^p for all other binary configurations (default p=-0.55)</span> - -<span class="sd"> arguments are M1, M2, a, Period P, amin, amax, x0=log P0, x1=log P1, p</span> - -<span class="sd"> example args: 10, 5, sep(M1, M2, P), sep, ?, -2, 12, -0.55</span> - -<span class="sd"> # TODO: Fix this function!</span> - -<span class="sd"> Args:</span> -<span class="sd"> M1: Mass of primary</span> -<span class="sd"> M2: Mass of secondary</span> -<span class="sd"> a: separation of binary</span> -<span class="sd"> P: period of binary</span> -<span class="sd"> amin: minimum separation of the distribution (lower bound of the range)</span> -<span class="sd"> amax: maximum separation of the distribution (upper bound of the range)</span> -<span class="sd"> x0: log of minimum period of the distribution (lower bound of the range)</span> -<span class="sd"> x1: log of maximum period of the distribution (upper bound of the range)</span> -<span class="sd"> p: slope of the distribution</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' of orbital period P given the other parameters</span> -<span class="sd"> """</span> - - <span class="n">res</span> <span class="o">=</span> <span class="mi">0</span> - <span class="k">if</span> <span class="p">(</span><span class="n">M1</span> <span class="o"><</span> <span class="mf">15.0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">M2</span> <span class="o">/</span> <span class="n">M1</span> <span class="o"><</span> <span class="mf">0.1</span><span class="p">):</span> - <span class="n">res</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">amax</span><span class="p">)</span> <span class="o">-</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">amin</span><span class="p">))</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">p1</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">+</span> <span class="n">p</span> - - <span class="c1"># For more details see the LyX document of binary_c for this distribution</span> - <span class="c1"># where the variables and normalisations are given</span> - <span class="c1"># we use the notation x=log(P), xmin=log(Pmin), x0=log(P0), ... to determine the</span> - <span class="n">x</span> <span class="o">=</span> <span class="n">LOG_LN_CONVERTER</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">P</span><span class="p">)</span> - <span class="n">xmin</span> <span class="o">=</span> <span class="n">LOG_LN_CONVERTER</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">calc_period_from_sep</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="n">M2</span><span class="p">,</span> <span class="n">amin</span><span class="p">))</span> - <span class="n">xmax</span> <span class="o">=</span> <span class="n">LOG_LN_CONVERTER</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">calc_period_from_sep</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="n">M2</span><span class="p">,</span> <span class="n">amax</span><span class="p">))</span> - - <span class="c1"># print("M1 M2 amin amax P x xmin xmax")</span> - <span class="c1"># print(M1, M2, amin, amax, P, x, xmin, xmax)</span> - <span class="c1"># my $x0 = 0.15;</span> - <span class="c1"># my $x1 = 3.5;</span> - - <span class="n">A1</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span> - <span class="n">x0</span> <span class="o">**</span> <span class="n">p</span> <span class="o">*</span> <span class="p">(</span><span class="n">x0</span> <span class="o">-</span> <span class="n">xmin</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="n">x1</span> <span class="o">**</span> <span class="n">p1</span> <span class="o">-</span> <span class="n">x0</span> <span class="o">**</span> <span class="n">p1</span><span class="p">)</span> <span class="o">/</span> <span class="n">p1</span> <span class="o">+</span> <span class="n">x1</span> <span class="o">**</span> <span class="n">p</span> <span class="o">*</span> <span class="p">(</span><span class="n">xmax</span> <span class="o">-</span> <span class="n">x1</span><span class="p">)</span> - <span class="p">)</span> - <span class="n">A0</span> <span class="o">=</span> <span class="n">A1</span> <span class="o">*</span> <span class="n">x0</span> <span class="o">**</span> <span class="n">p</span> - <span class="n">A2</span> <span class="o">=</span> <span class="n">A1</span> <span class="o">*</span> <span class="n">x1</span> <span class="o">**</span> <span class="n">p</span> - - <span class="k">if</span> <span class="n">x</span> <span class="o"><</span> <span class="n">x0</span><span class="p">:</span> - <span class="n">res</span> <span class="o">=</span> <span class="mf">3.0</span> <span class="o">/</span> <span class="mf">2.0</span> <span class="o">*</span> <span class="n">LOG_LN_CONVERTER</span> <span class="o">*</span> <span class="n">A0</span> - <span class="k">elif</span> <span class="n">x</span> <span class="o">></span> <span class="n">x1</span><span class="p">:</span> - <span class="n">res</span> <span class="o">=</span> <span class="mf">3.0</span> <span class="o">/</span> <span class="mf">2.0</span> <span class="o">*</span> <span class="n">LOG_LN_CONVERTER</span> <span class="o">*</span> <span class="n">A2</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">res</span> <span class="o">=</span> <span class="mf">3.0</span> <span class="o">/</span> <span class="mf">2.0</span> <span class="o">*</span> <span class="n">LOG_LN_CONVERTER</span> <span class="o">*</span> <span class="n">A1</span> <span class="o">*</span> <span class="n">x</span> <span class="o">**</span> <span class="n">p</span> - - <span class="k">return</span> <span class="n">res</span></div> - - -<span class="c1"># print(sana12(10, 2, 10, 100, 1, 1000, math.log(10), math.log(1000), 6))</span> - - -<div class="viewcode-block" id="interpolate_in_mass_izzard2012"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.interpolate_in_mass_izzard2012">[docs]</a><span class="k">def</span> <span class="nf">interpolate_in_mass_izzard2012</span><span class="p">(</span> - <span class="n">M</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">high</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">low</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Function to interpolate in mass</span> - -<span class="sd"> TODO: fix this function.</span> -<span class="sd"> TODO: describe the args</span> -<span class="sd"> high: at M=16.3</span> -<span class="sd"> low: at 1.15</span> - -<span class="sd"> Args:</span> -<span class="sd"> M: mass</span> -<span class="sd"> high:</span> -<span class="sd"> low:</span> - -<span class="sd"> Returns:</span> - -<span class="sd"> """</span> - - <span class="n">log_interpolation</span> <span class="o">=</span> <span class="kc">False</span> - - <span class="k">if</span> <span class="n">log_interpolation</span><span class="p">:</span> - <span class="k">return</span> <span class="p">(</span><span class="n">high</span> <span class="o">-</span> <span class="n">low</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="mf">16.3</span><span class="p">)</span> <span class="o">-</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="mf">1.15</span><span class="p">))</span> <span class="o">*</span> <span class="p">(</span> - <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">M</span><span class="p">)</span> <span class="o">-</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="mf">1.15</span><span class="p">)</span> - <span class="p">)</span> <span class="o">+</span> <span class="n">low</span> - <span class="k">else</span><span class="p">:</span> - <span class="k">return</span> <span class="p">(</span><span class="n">high</span> <span class="o">-</span> <span class="n">low</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mf">16.3</span> <span class="o">-</span> <span class="mf">1.15</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">M</span> <span class="o">-</span> <span class="mf">1.15</span><span class="p">)</span> <span class="o">+</span> <span class="n">low</span></div> - - -<div class="viewcode-block" id="Izzard2012_period_distribution"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.Izzard2012_period_distribution">[docs]</a><span class="k">def</span> <span class="nf">Izzard2012_period_distribution</span><span class="p">(</span> - <span class="n">P</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">M1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">log10Pmin</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mf">1.0</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> period distribution which interpolates between</span> -<span class="sd"> Duquennoy and Mayor 1991 at low mass (G/K spectral type <~1.15Msun)</span> -<span class="sd"> and Sana et al 2012 at high mass (O spectral type >~16.3Msun)</span> - -<span class="sd"> This gives dN/dlogP, i.e. DM/Raghavan's Gaussian in log10P at low mass</span> -<span class="sd"> and Sana's power law (as a function of logP) at high mass</span> - -<span class="sd"> TODO: fix this function</span> - -<span class="sd"> Args:</span> -<span class="sd"> P: period</span> -<span class="sd"> M1: Primary star mass</span> -<span class="sd"> log10Pmin: minimum period in base log10 (optional)</span> - -<span class="sd"> Returns:</span> -<span class="sd"> 'probability' of interpolated distribution function at P and M1</span> - -<span class="sd"> """</span> - - <span class="c1"># Check if there is input and force it to be at least 1</span> - <span class="n">log10Pmin</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">log10Pmin</span><span class="p">)</span> - - <span class="c1"># save mass input and limit mass used (M1 from now on) to fitted range</span> - <span class="n">Mwas</span> <span class="o">=</span> <span class="n">M1</span> - <span class="n">M1</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mf">1.15</span><span class="p">,</span> <span class="nb">min</span><span class="p">(</span><span class="mf">16.3</span><span class="p">,</span> <span class="n">M1</span><span class="p">))</span> - <span class="c1"># print("Izzard2012 called for M={} (truncated to {}), P={}\n".format(Mwas, M1, P))</span> - - <span class="c1"># Calculate the normalisations</span> - <span class="c1"># need to normalise the distribution for this mass</span> - <span class="c1"># (and perhaps secondary mass)</span> - <span class="n">prepare_dict</span><span class="p">(</span><span class="n">distribution_constants</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Izzard2012"</span><span class="p">,</span> <span class="n">M1</span><span class="p">])</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"Izzard2012"</span><span class="p">][</span><span class="n">M1</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">log10Pmin</span><span class="p">):</span> - <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"Izzard2012"</span><span class="p">][</span><span class="n">M1</span><span class="p">][</span> - <span class="n">log10Pmin</span> - <span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> <span class="c1"># To prevent this loop from going recursive</span> - <span class="n">N</span> <span class="o">=</span> <span class="mf">200.0</span> <span class="c1"># Resolution for normalisation. I hope 1000 is enough</span> - <span class="n">dlP</span> <span class="o">=</span> <span class="p">(</span><span class="mf">10.0</span> <span class="o">-</span> <span class="n">log10Pmin</span><span class="p">)</span> <span class="o">/</span> <span class="n">N</span> - <span class="n">C</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># normalisation constant.</span> - <span class="c1"># print("LOOP",log10Pmin)</span> - <span class="k">for</span> <span class="n">lP</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">log10Pmin</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">dlP</span><span class="p">):</span> - <span class="n">C</span> <span class="o">+=</span> <span class="n">dlP</span> <span class="o">*</span> <span class="n">Izzard2012_period_distribution</span><span class="p">(</span><span class="mi">10</span> <span class="o">**</span> <span class="n">lP</span><span class="p">,</span> <span class="n">M1</span><span class="p">,</span> <span class="n">log10Pmin</span><span class="p">)</span> - - <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"Izzard2012"</span><span class="p">][</span><span class="n">M1</span><span class="p">][</span><span class="n">log10Pmin</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">C</span> - <span class="c1"># print(</span> - <span class="c1"># "Normalisation constant for Izzard2012 M={} (log10Pmin={}) is\</span> - <span class="c1"># {}\n".format(</span> - <span class="c1"># M1, log10Pmin, distribution_constants["Izzard2012"][M1][log10Pmin]</span> - <span class="c1"># )</span> - <span class="c1"># )</span> - - <span class="n">lP</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">P</span><span class="p">)</span> - <span class="c1"># log period</span> - - <span class="c1"># # fits</span> - <span class="n">mu</span> <span class="o">=</span> <span class="n">interpolate_in_mass_izzard2012</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="o">-</span><span class="mf">17.8</span><span class="p">,</span> <span class="mf">5.03</span><span class="p">)</span> - <span class="n">sigma</span> <span class="o">=</span> <span class="n">interpolate_in_mass_izzard2012</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="mf">9.18</span><span class="p">,</span> <span class="mf">2.28</span><span class="p">)</span> - <span class="n">K</span> <span class="o">=</span> <span class="n">interpolate_in_mass_izzard2012</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="mf">6.93e-2</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> - <span class="n">nu</span> <span class="o">=</span> <span class="n">interpolate_in_mass_izzard2012</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="mf">0.3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> - <span class="n">g</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="mf">1e-30</span> <span class="o">**</span> <span class="p">(</span><span class="n">lP</span> <span class="o">-</span> <span class="n">nu</span><span class="p">))</span> - - <span class="n">lPmu</span> <span class="o">=</span> <span class="n">lP</span> <span class="o">-</span> <span class="n">mu</span> - <span class="c1"># print(</span> - <span class="c1"># "M={} ({}) P={} : mu={} sigma={} K={} nu={} norm=%g\n".format(</span> - <span class="c1"># Mwas, M1, P, mu, sigma, K, nu</span> - <span class="c1"># )</span> - <span class="c1"># )</span> - - <span class="c1"># print "FUNC $distdata{Izzard2012}{$M}{$log10Pmin} * (exp(- (x-$mu)**2/(2.0*$sigma*$sigma) ) + $K/MAX(0.1,$lP)) * $g;\n";</span> - - <span class="k">if</span> <span class="p">(</span><span class="n">lP</span> <span class="o"><</span> <span class="n">log10Pmin</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">lP</span> <span class="o">></span> <span class="mf">10.0</span><span class="p">):</span> - <span class="k">return</span> <span class="mi">0</span> - - <span class="k">else</span><span class="p">:</span> - <span class="k">return</span> <span class="p">(</span> - <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"Izzard2012"</span><span class="p">][</span><span class="n">M1</span><span class="p">][</span><span class="n">log10Pmin</span><span class="p">]</span> - <span class="o">*</span> <span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">lPmu</span> <span class="o">*</span> <span class="n">lPmu</span> <span class="o">/</span> <span class="p">(</span><span class="mf">2.0</span> <span class="o">*</span> <span class="n">sigma</span> <span class="o">*</span> <span class="n">sigma</span><span class="p">))</span> <span class="o">+</span> <span class="n">K</span> <span class="o">/</span> <span class="nb">max</span><span class="p">(</span><span class="mf">0.1</span><span class="p">,</span> <span class="n">lP</span><span class="p">))</span> - <span class="o">*</span> <span class="n">g</span> - <span class="p">)</span></div> - - -<span class="c1">########################################################################</span> -<span class="c1"># Mass ratio distributions</span> -<span class="c1">########################################################################</span> - - -<div class="viewcode-block" id="flatsections"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.flatsections">[docs]</a><span class="k">def</span> <span class="nf">flatsections</span><span class="p">(</span><span class="n">x</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="n">opts</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Function to generate flat distributions, possibly in multiple sections</span> - -<span class="sd"> Args:</span> -<span class="sd"> x: mass ratio value</span> -<span class="sd"> opts: list containing the flat sections. Which are themselves dictionaries, with keys "max": upper bound, "min": lower bound and "height": value</span> - -<span class="sd"> Returns:</span> -<span class="sd"> probability of that mass ratio.</span> -<span class="sd"> """</span> - - <span class="n">c</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">y</span> <span class="o">=</span> <span class="mi">0</span> - - <span class="k">for</span> <span class="n">opt</span> <span class="ow">in</span> <span class="n">opts</span><span class="p">:</span> - <span class="n">dc</span> <span class="o">=</span> <span class="p">(</span><span class="n">opt</span><span class="p">[</span><span class="s2">"max"</span><span class="p">]</span> <span class="o">-</span> <span class="n">opt</span><span class="p">[</span><span class="s2">"min"</span><span class="p">])</span> <span class="o">*</span> <span class="n">opt</span><span class="p">[</span><span class="s2">"height"</span><span class="p">]</span> - <span class="c1"># print("added flatsection ({}-{})*{} = {}\n".format(</span> - <span class="c1"># opt['max'], opt['min'], opt['height'], dc))</span> - <span class="n">c</span> <span class="o">+=</span> <span class="n">dc</span> - <span class="k">if</span> <span class="n">opt</span><span class="p">[</span><span class="s2">"min"</span><span class="p">]</span> <span class="o"><=</span> <span class="n">x</span> <span class="o"><=</span> <span class="n">opt</span><span class="p">[</span><span class="s2">"max"</span><span class="p">]:</span> - <span class="n">y</span> <span class="o">=</span> <span class="n">opt</span><span class="p">[</span><span class="s2">"height"</span><span class="p">]</span> - <span class="c1"># print("Use this\n")</span> - - <span class="n">c</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">c</span> - <span class="n">y</span> <span class="o">=</span> <span class="n">y</span> <span class="o">*</span> <span class="n">c</span> - - <span class="c1"># print("flatsections gives C={}: y={}\n",c,y)</span> - <span class="k">return</span> <span class="n">y</span></div> - - -<span class="c1"># print(flatsections(1, [{'min': 0, 'max': 2, 'height': 3}]))</span> - -<span class="c1">########################################################################</span> -<span class="c1"># Eccentricity distributions</span> -<span class="c1">########################################################################</span> - -<span class="c1">########################################################################</span> -<span class="c1"># Star formation histories</span> -<span class="c1">########################################################################</span> - - -<div class="viewcode-block" id="cosmic_SFH_madau_dickinson2014"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.cosmic_SFH_madau_dickinson2014">[docs]</a><span class="k">def</span> <span class="nf">cosmic_SFH_madau_dickinson2014</span><span class="p">(</span><span class="n">z</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Cosmic star formation history distribution from Madau & Dickonson 2014 (https://arxiv.org/pdf/1403.0007.pdf)</span> - -<span class="sd"> Args:</span> -<span class="sd"> z: redshift</span> - -<span class="sd"> Returns:</span> -<span class="sd"> Cosmic star formation rate in Solar mass year^-1 mega parsec^-3</span> -<span class="sd"> """</span> - - <span class="n">CSFH</span> <span class="o">=</span> <span class="mf">0.015</span> <span class="o">*</span> <span class="p">((</span><span class="mi">1</span> <span class="o">+</span> <span class="n">z</span><span class="p">)</span> <span class="o">**</span> <span class="mf">2.7</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="p">(((</span><span class="mi">1</span> <span class="o">+</span> <span class="n">z</span><span class="p">)</span> <span class="o">/</span> <span class="mf">2.9</span><span class="p">)</span> <span class="o">**</span> <span class="mf">5.6</span><span class="p">))</span> - - <span class="k">return</span> <span class="n">CSFH</span></div> - - -<span class="c1">########################################################################</span> -<span class="c1"># Metallicity distributions</span> -<span class="c1">########################################################################</span> - - -<span class="c1">########################################################################</span> -<span class="c1"># Moe & DiStefano 2017 functions</span> -<span class="c1">#</span> -<span class="c1"># The code below are functions that are used to set up and interpolate</span> -<span class="c1"># on the Moe & DiStefano 2017 data. The interpolators take the last</span> -<span class="c1"># known value if we try to interpolate outside of the tables.</span> -<span class="c1"># There are still some open tasks and improvements that can be made:</span> -<span class="c1">#</span> -<span class="c1"># TODO: Solve the memory issues that are present.</span> -<span class="c1"># Are the interpolators not cleaned?</span> -<span class="c1"># TODO: Parallelize the setting up of the interpolators</span> -<span class="c1"># TODO: Generalise the code such that we can input other/newer tables</span> - -<span class="c1">########################################################################</span> - -<span class="kn">import</span> <span class="nn">py_rinterpolate</span> - -<span class="c1"># Global dictionary to store values in</span> -<span class="n">Moecache</span> <span class="o">=</span> <span class="p">{}</span> - - -<div class="viewcode-block" id="poisson"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.poisson">[docs]</a><span class="k">def</span> <span class="nf">poisson</span><span class="p">(</span><span class="n">lambda_val</span><span class="p">,</span> <span class="n">n</span><span class="p">,</span> <span class="n">nmax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function that calculates the Poisson value and normalises</span> -<span class="sd"> TODO: improve the description</span> -<span class="sd"> """</span> - - <span class="n">cachekey</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lambda_val</span><span class="p">,</span> <span class="n">n</span><span class="p">,</span> <span class="n">nmax</span><span class="p">)</span> - - <span class="k">if</span> <span class="n">distribution_constants</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"poisson_cache"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="k">if</span> <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"poisson_cache"</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cachekey</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">p_val</span> <span class="o">=</span> <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"poisson_cache"</span><span class="p">][</span><span class="n">cachekey</span><span class="p">]</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: found cached value for poisson(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">): </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">lambda_val</span><span class="p">,</span> <span class="n">n</span><span class="p">,</span> <span class="n">nmax</span><span class="p">,</span> <span class="n">p_val</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">return</span> <span class="n">p_val</span> - - <span class="c1"># Poisson distribution : note, n can be zero</span> - <span class="c1">#</span> - <span class="c1"># nmax is the truncation : if set, we normalise</span> - <span class="c1"># correctly.</span> - <span class="n">p_val</span> <span class="o">=</span> <span class="n">_poisson</span><span class="p">(</span><span class="n">lambda_val</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span> - - <span class="k">if</span> <span class="n">nmax</span><span class="p">:</span> - <span class="n">I_poisson</span> <span class="o">=</span> <span class="mi">0</span> - <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nmax</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span> - <span class="n">I_poisson</span> <span class="o">+=</span> <span class="n">_poisson</span><span class="p">(</span><span class="n">lambda_val</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> - <span class="n">p_val</span> <span class="o">=</span> <span class="n">p_val</span> <span class="o">/</span> <span class="n">I_poisson</span> - - <span class="c1"># Add to cache</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">distribution_constants</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"poisson_cache"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"poisson_cache"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> - <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"poisson_cache"</span><span class="p">][</span><span class="n">cachekey</span><span class="p">]</span> <span class="o">=</span> <span class="n">p_val</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Poisson(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">): </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">lambda_val</span><span class="p">,</span> <span class="n">n</span><span class="p">,</span> <span class="n">nmax</span><span class="p">,</span> <span class="n">p_val</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">return</span> <span class="n">p_val</span></div> - - -<span class="k">def</span> <span class="nf">_poisson</span><span class="p">(</span><span class="n">lambda_val</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to return the Poisson value</span> -<span class="sd"> """</span> - - <span class="k">return</span> <span class="p">(</span><span class="n">lambda_val</span> <span class="o">**</span> <span class="n">n</span><span class="p">)</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">lambda_val</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">factorial</span><span class="p">(</span><span class="n">n</span><span class="p">))</span> - - -<div class="viewcode-block" id="get_max_multiplicity"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.get_max_multiplicity">[docs]</a><span class="k">def</span> <span class="nf">get_max_multiplicity</span><span class="p">(</span><span class="n">multiplicity_array</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to get the maximum multiplicity</span> -<span class="sd"> """</span> - - <span class="n">max_multiplicity</span> <span class="o">=</span> <span class="mi">0</span> - <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span> - <span class="k">if</span> <span class="n">multiplicity_array</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> - <span class="n">max_multiplicity</span> <span class="o">=</span> <span class="n">n</span> <span class="o">+</span> <span class="mi">1</span> - <span class="k">return</span> <span class="n">max_multiplicity</span></div> - - -<div class="viewcode-block" id="merge_multiplicities"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.merge_multiplicities">[docs]</a><span class="k">def</span> <span class="nf">merge_multiplicities</span><span class="p">(</span><span class="n">result_array</span><span class="p">,</span> <span class="n">max_multiplicity</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to fold the multiplicities higher than the max_multiplicity onto the max_multiplicity</span> - -<span class="sd"> if max_multiplicity == 1:</span> -<span class="sd"> All the multiplicities are folded onto multiplicity == 1. This will always total to 1</span> -<span class="sd"> if max_multiplicity == 2:</span> -<span class="sd"> The multiplicity fractions of the triple and quadruples are folded onto that of the binary multiplicity fraction</span> -<span class="sd"> if max_multiplicity == 3:</span> -<span class="sd"> The multiplicity fractions of the quadruples are folded onto that of the triples</span> -<span class="sd"> """</span> - - <span class="k">if</span> <span class="ow">not</span> <span class="n">max_multiplicity</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">5</span><span class="p">):</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: merge_multiplicities: max_multiplicity has to be between 1 and 4. It is </span><span class="si">{}</span><span class="s2"> now"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">max_multiplicity</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="n">msg</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="mi">0</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="c1"># Fold multiplicities:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: merge_multiplicities: Merging multiplicities with initial array </span><span class="si">{}</span><span class="s2"> and max multiplicity </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">result_array</span><span class="p">,</span> <span class="n">max_multiplicity</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">max_multiplicity</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">result_array</span><span class="p">))[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span> - <span class="n">result_array</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">+=</span> <span class="n">result_array</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> - <span class="n">result_array</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: merge_multiplicities: Merging multiplicities to new array </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">result_array</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">return</span> <span class="n">result_array</span></div> - - -<div class="viewcode-block" id="normalize_dict"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.normalize_dict">[docs]</a><span class="k">def</span> <span class="nf">normalize_dict</span><span class="p">(</span><span class="n">result_dict</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to normalise a dictionary</span> -<span class="sd"> """</span> - - <span class="n">sum_result</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">([</span><span class="n">result_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">result_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span> - <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">result_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> - <span class="n">result_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">result_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">/</span> <span class="n">sum_result</span> - <span class="k">return</span> <span class="n">result_dict</span></div> - - -<div class="viewcode-block" id="Moe_di_Stefano_2017_multiplicity_fractions"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.Moe_di_Stefano_2017_multiplicity_fractions">[docs]</a><span class="k">def</span> <span class="nf">Moe_di_Stefano_2017_multiplicity_fractions</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function that creates a list of probability fractions and</span> -<span class="sd"> normalises and merges them according to the users choice.</span> - -<span class="sd"> TODO: make an extrapolation functionality in this. log10(1.6e1)</span> -<span class="sd"> is low, we can probably go a bit further</span> - -<span class="sd"> The default result that is returned when sampling the mass outside</span> -<span class="sd"> of the mass range is now the last known value</span> - -<span class="sd"> Returns a list of multiplicity fractions for a given input of mass</span> -<span class="sd"> """</span> - - <span class="c1"># Use the global Moecache</span> - <span class="k">global</span> <span class="n">Moecache</span> - - <span class="n">multiplicity_modulator_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"multiplicity_modulator"</span><span class="p">]</span> - <span class="p">)</span> <span class="c1"># Modulator array</span> - - <span class="c1"># Check for length</span> - <span class="k">if</span> <span class="ow">not</span> <span class="nb">len</span><span class="p">(</span><span class="n">multiplicity_modulator_array</span><span class="p">)</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Multiplicity modulator has to have 4 elements. Now it is </span><span class="si">{}</span><span class="s2">, len: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">multiplicity_modulator_array</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">multiplicity_modulator_array</span><span class="p">)</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="n">msg</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="mi">0</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="c1"># Set up some arrays</span> - <span class="n">full_fractions_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="c1"># Meant to contain the real fractions</span> - <span class="n">weighted_fractions_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span> - <span class="mi">4</span> - <span class="p">)</span> <span class="c1"># Meant to contain the fractions multiplied by the multiplicity modulator</span> - - <span class="c1"># Get max multiplicity</span> - <span class="n">max_multiplicity</span> <span class="o">=</span> <span class="n">get_max_multiplicity</span><span class="p">(</span><span class="n">multiplicity_modulator_array</span><span class="p">)</span> - - <span class="c1"># ... it's better to interpolate the multiplicity and then</span> - <span class="c1"># use a Poisson distribution to calculate the fractions</span> - <span class="c1"># (this is more accurate)</span> - - <span class="c1"># Set up the multiplicity interpolator</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_multiplicity"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_multiplicity"</span><span class="p">]</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> - <span class="n">table</span><span class="o">=</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"multiplicity_table"</span><span class="p">],</span> <span class="c1"># Contains the table of data</span> - <span class="n">nparams</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># logM1</span> - <span class="n">ndata</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="c1"># The number of datapoints (the parameters that we want to interpolate)</span> - <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> <span class="o">-</span> <span class="p">(</span><span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> - <span class="p">)</span> - - <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"multiplicity_model"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"Poisson"</span><span class="p">:</span> - <span class="n">multiplicity</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_multiplicity"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">])]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - - <span class="c1"># Fill the multiplicity array</span> - <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span> - <span class="n">full_fractions_array</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="n">poisson</span><span class="p">(</span><span class="n">multiplicity</span><span class="p">,</span> <span class="n">n</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="n">verbosity</span><span class="p">)</span> - - <span class="c1"># Normalize it so it fills to one when taking all the multiplicities:</span> - <span class="n">full_fractions_array</span> <span class="o">=</span> <span class="n">full_fractions_array</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">full_fractions_array</span><span class="p">)</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: using model </span><span class="si">{}</span><span class="s2">: full_fractions_array: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="s2">"Poisson"</span><span class="p">,</span> <span class="n">full_fractions_array</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">elif</span> <span class="n">options</span><span class="p">[</span><span class="s2">"multiplicity_model"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"data"</span><span class="p">:</span> - <span class="c1"># use the fractions calculated from Moe's data directly</span> - <span class="c1">#</span> - <span class="c1"># note that in this case, there are no quadruples: these</span> - <span class="c1"># are combined with triples</span> - - <span class="c1"># Fill with the raw values</span> - <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span> - <span class="n">full_fractions_array</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span> - <span class="s2">"rinterpolator_multiplicity"</span> - <span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">])])[</span><span class="n">n</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> - - <span class="c1"># Set last value</span> - <span class="n">full_fractions_array</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span> <span class="c1"># no quadruples</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: using model </span><span class="si">{}</span><span class="s2">: full_fractions_array: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="s2">"data"</span><span class="p">,</span> <span class="n">full_fractions_array</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Normalisation:</span> - <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"normalize_multiplicities"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"raw"</span><span class="p">:</span> - <span class="c1"># Don't multiply by the multiplicity_array, but do give a fractions array</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Not normalising (using raw results): results: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">full_fractions_array</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="n">result</span> <span class="o">=</span> <span class="n">full_fractions_array</span> - - <span class="k">elif</span> <span class="n">options</span><span class="p">[</span><span class="s2">"normalize_multiplicities"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"norm"</span><span class="p">:</span> - <span class="c1"># Multiply the full_multiplicity_fraction array by the multiplicity_multiplier_array, creating a weighted fractions array</span> - <span class="n">weighted_fractions_array</span> <span class="o">=</span> <span class="n">full_fractions_array</span> <span class="o">*</span> <span class="n">multiplicity_modulator_array</span> - - <span class="c1"># Normalise this so it is in total 1:</span> - <span class="n">result</span> <span class="o">=</span> <span class="n">weighted_fractions_array</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">weighted_fractions_array</span><span class="p">)</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with </span><span class="si">{}</span><span class="s2">. result: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="s2">"norm"</span><span class="p">,</span> <span class="n">result</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">elif</span> <span class="n">options</span><span class="p">[</span><span class="s2">"normalize_multiplicities"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"merge"</span><span class="p">:</span> - <span class="c1"># We first take the full multiplicity array</span> - <span class="c1"># (i.e. not multiplied by multiplier) and do the merging</span> - <span class="n">result</span> <span class="o">=</span> <span class="n">merge_multiplicities</span><span class="p">(</span> - <span class="n">full_fractions_array</span><span class="p">,</span> <span class="n">max_multiplicity</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> - <span class="p">)</span> - - <span class="c1"># Then normalise to be sure</span> - <span class="n">result</span> <span class="o">=</span> <span class="n">result</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with </span><span class="si">{}</span><span class="s2">, max_multiplicity=</span><span class="si">{}</span><span class="s2"> result=</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="s2">"merge"</span><span class="p">,</span> <span class="n">max_multiplicity</span><span class="p">,</span> <span class="n">result</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="nb">str</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># return array reference</span> - <span class="k">return</span> <span class="n">result</span></div> - - -<div class="viewcode-block" id="build_q_table"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.build_q_table">[docs]</a><span class="k">def</span> <span class="nf">build_q_table</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> - <span class="c1">############################################################</span> - <span class="c1">#</span> - <span class="c1"># Build an interpolation table for q, given a mass and</span> - <span class="c1"># orbital period.</span> - <span class="c1">#</span> - <span class="c1"># $m and $p are labels which determine which system(s)</span> - <span class="c1"># to look up from Moe's data:</span> - <span class="c1">#</span> - <span class="c1"># $m can be M1, M2, M3, M4, or if set M1+M2 etc.</span> - <span class="c1"># $p can be P, P2, P3</span> - <span class="c1">#</span> - <span class="c1"># The actual values are in $opts:</span> - <span class="c1">#</span> - <span class="c1"># mass is in $opts->{$m}</span> - <span class="c1"># period is $opts->{$p}</span> - <span class="c1">#</span> - <span class="c1"># Since the information from the table for Moe and di Stefano 2017 is independent of any choice we make,</span> - <span class="c1"># we need to take into account that for example our choice of minimum mass leads to</span> - <span class="c1"># a minimum q_min that is not the same as in the table</span> - <span class="c1"># We should ignore those parts of the table and renormalise.</span> - <span class="c1"># If we are below the lowest value of qmin in the table we need to extrapolate the data</span> - <span class="c1">#</span> - <span class="c1"># Anyway, the goal of this function is to provide some extrapolated values for q when we should sample outside of the boundaries</span> - <span class="c1">############################################################</span> - - <span class="c1"># We can check if we have a cached value for this already:</span> - <span class="c1"># TODO: fix this cache check.</span> - <span class="n">incache</span> <span class="o">=</span> <span class="kc">False</span> - <span class="k">if</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="k">if</span> <span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span> <span class="ow">and</span> <span class="p">(</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="p">):</span> - <span class="k">if</span> <span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">][</span><span class="n">m</span><span class="p">]</span> <span class="o">==</span> <span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">])</span> <span class="ow">and</span> <span class="p">(</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">][</span><span class="n">p</span><span class="p">]</span> <span class="o">==</span> <span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> - <span class="p">):</span> - <span class="n">incache</span> <span class="o">=</span> <span class="kc">True</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Found cached values for m=</span><span class="si">{}</span><span class="s2"> p=</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Cached values for different m=</span><span class="si">{}</span><span class="s2"> p=</span><span class="si">{}</span><span class="s2">. Freeing current table and making new table"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1">#</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">incache</span><span class="p">:</span> - <span class="c1"># trim and/or expand the table to the range $qmin to $qmax.</span> - - <span class="c1"># qmin is set by the minimum stellar mass : below this</span> - <span class="c1"># the companions are planets</span> - <span class="c1"># qmin = options["ranges"]["M"][</span> - <span class="c1"># 0</span> - <span class="c1"># ] # TODO: this lower range must not be lower than Mmin.</span> - - <span class="n">qmin</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"Mmin"</span><span class="p">]</span> <span class="o">/</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table qmin: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">qmin</span><span class="p">,</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># qmax = maximum_mass_ratio_for_RLOF(options[m], options[p])</span> - <span class="c1"># TODO: change this to the above</span> - <span class="n">qmax</span> <span class="o">=</span> <span class="mi">1</span> - - <span class="c1"># qdata contains the table that we modify: we get</span> - <span class="c1"># the original data by interpolating Moe's table</span> - <span class="n">qdata</span> <span class="o">=</span> <span class="p">{}</span> - <span class="n">can_renormalize</span> <span class="o">=</span> <span class="mi">1</span> - - <span class="n">qeps</span> <span class="o">=</span> <span class="mf">1e-8</span> <span class="c1"># small number but such that qeps+1 != 1</span> - <span class="k">if</span> <span class="n">qeps</span> <span class="o">+</span> <span class="mi">1</span> <span class="o">==</span> <span class="mf">1.0</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: qeps (= </span><span class="si">{}</span><span class="s2">) +1 == 1. Make qeps larger"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">qeps</span><span class="p">,</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">if</span> <span class="n">qmin</span> <span class="o">>=</span> <span class="n">qmax</span><span class="p">:</span> - <span class="c1"># there may be NO binaries in this part of the parameter space:</span> - <span class="c1"># in which case, set up a table with lots of zero in it</span> - - <span class="n">qdata</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">:</span> <span class="mi">0</span><span class="p">}</span> - <span class="n">can_renormalize</span> <span class="o">=</span> <span class="mi">0</span> - - <span class="k">else</span><span class="p">:</span> - <span class="c1"># qmin and qmax mean we'll get something non-zero</span> - <span class="n">can_renormalize</span> <span class="o">=</span> <span class="mi">1</span> - - <span class="c1"># require extrapolation sets whether we need to extrapolate</span> - <span class="c1"># at the low and high ends</span> - <span class="n">require_extrapolation</span> <span class="o">=</span> <span class="p">{}</span> - - <span class="k">if</span> <span class="n">qmin</span> <span class="o">>=</span> <span class="mf">0.15</span><span class="p">:</span> - <span class="c1"># qmin is inside Moe's table : this is easy,</span> - <span class="c1"># we just keep points from qmin at the low</span> - <span class="c1"># end to qmax at the high end.</span> - <span class="n">require_extrapolation</span><span class="p">[</span><span class="s2">"low"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">require_extrapolation</span><span class="p">[</span> - <span class="s2">"high"</span> - <span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> <span class="c1"># TODO: shouldn't the extrapolation need to happen if qmax > 0.95</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">qmin</span><span class="p">]</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]),</span> <span class="n">qmin</span><span class="p">]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - - <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">0.15</span><span class="p">,</span> <span class="mf">0.950001</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">):</span> - <span class="k">if</span> <span class="p">(</span><span class="n">q</span> <span class="o">>=</span> <span class="n">qmin</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">q</span> <span class="o"><=</span> <span class="n">qmax</span><span class="p">):</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]),</span> <span class="n">q</span><span class="p">]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">require_extrapolation</span><span class="p">[</span><span class="s2">"low"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> - <span class="n">require_extrapolation</span><span class="p">[</span><span class="s2">"high"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> - <span class="k">if</span> <span class="n">qmax</span> <span class="o"><</span> <span class="mf">0.15</span><span class="p">:</span> - <span class="c1"># qmax < 0.15 which is off the edge</span> - <span class="c1"># of the table. In this case, choose</span> - <span class="c1"># two points at q=0.15 and 0.16 and interpolate</span> - <span class="c1"># at these in case we want to extrapolate.</span> - <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="p">[</span><span class="mf">0.15</span><span class="p">,</span> <span class="mf">0.16</span><span class="p">]:</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]),</span> <span class="n">q</span><span class="p">]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - <span class="k">else</span><span class="p">:</span> - <span class="c1"># qmin < 0.15 and qmax > 0.15, so we</span> - <span class="c1"># have to generate Moe's table for</span> - <span class="c1"># q = 0.15 (i.e. 0.1 to 0.2) to 0.95 (0.9 to 1)</span> - <span class="c1"># as a function of M1 and orbital period,</span> - <span class="c1"># to obtain the q distribution data.</span> - - <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">0.15</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">([</span><span class="mf">0.950001</span><span class="p">,</span> <span class="n">qmax</span> <span class="o">+</span> <span class="mf">0.0001</span><span class="p">]),</span> <span class="mf">0.1</span><span class="p">):</span> - <span class="n">val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]),</span> <span class="n">q</span><span class="p">]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span> - - <span class="c1"># just below qmin, if qmin>qeps, we want nothing</span> - <span class="k">if</span> <span class="n">qmin</span> <span class="o">-</span> <span class="mf">0.15</span> <span class="o">></span> <span class="n">qeps</span><span class="p">:</span> - <span class="n">q</span> <span class="o">=</span> <span class="n">qmin</span> <span class="o">-</span> <span class="n">qeps</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">require_extrapolation</span><span class="p">[</span><span class="s2">"low"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - - <span class="c1"># just above qmax, if qmax<1, we want nothing</span> - <span class="k">if</span> <span class="n">qmax</span> <span class="o"><</span> <span class="mf">0.95</span><span class="p">:</span> - <span class="n">q</span> <span class="o">=</span> <span class="n">qmax</span> <span class="o">+</span> <span class="n">qeps</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">require_extrapolation</span><span class="p">[</span><span class="s2">"high"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - - <span class="c1"># sorted list of qs</span> - <span class="n">qs</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">qdata</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> - - <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">qs</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"No qs found error"</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">qs</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="c1"># only one q value : pretend there are two</span> - <span class="c1"># with a flat distribution up to 1.0.</span> - <span class="k">if</span> <span class="n">qs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mf">1.0</span><span class="p">:</span> - <span class="n">qs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">-</span> <span class="mf">1e-6</span> - <span class="n">qs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="mi">1</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="mi">1</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">qs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">qs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> - - <span class="c1"># We actually should do the extrapolation now.</span> - <span class="k">else</span><span class="p">:</span> - <span class="c1"># Loop over both the lower end and the upper end</span> - <span class="k">for</span> <span class="n">pre</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"low"</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">]:</span> - <span class="k">if</span> <span class="n">require_extrapolation</span><span class="p">[</span><span class="n">pre</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> - <span class="k">continue</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">sign</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> <span class="k">if</span> <span class="n">pre</span> <span class="o">==</span> <span class="s2">"low"</span> <span class="k">else</span> <span class="mi">1</span> - <span class="n">end_index</span> <span class="o">=</span> <span class="mi">0</span> <span class="k">if</span> <span class="n">pre</span> <span class="o">==</span> <span class="s2">"low"</span> <span class="k">else</span> <span class="nb">len</span><span class="p">(</span><span class="n">qs</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span> - <span class="n">indices</span> <span class="o">=</span> <span class="p">(</span> - <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="n">pre</span> <span class="o">==</span> <span class="s2">"low"</span> <span class="k">else</span> <span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="n">qs</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">qs</span><span class="p">)</span> <span class="o">-</span> <span class="mi">2</span><span class="p">]</span> - <span class="p">)</span> <span class="c1"># Based on whether we do the high or low end we need to use two different indices</span> - <span class="n">method</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> - <span class="s2">"q_</span><span class="si">{}</span><span class="s2">_extrapolation_method"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">pre</span><span class="p">),</span> <span class="kc">None</span> - <span class="p">)</span> - <span class="n">qlimit</span> <span class="o">=</span> <span class="n">qmin</span> <span class="k">if</span> <span class="n">pre</span> <span class="o">==</span> <span class="s2">"low"</span> <span class="k">else</span> <span class="n">qmax</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Extrapolating: Q: </span><span class="si">{}</span><span class="s2"> method: </span><span class="si">{}</span><span class="s2">, indices: </span><span class="si">{}</span><span class="s2"> End index: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">pre</span><span class="p">,</span> <span class="n">method</span><span class="p">,</span> <span class="n">indices</span><span class="p">,</span> <span class="n">end_index</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># truncate the distribution</span> - <span class="n">qdata</span><span class="p">[</span><span class="nb">max</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="nb">min</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">qlimit</span> <span class="o">+</span> <span class="n">sign</span> <span class="o">*</span> <span class="n">qeps</span><span class="p">))]</span> <span class="o">=</span> <span class="mi">0</span> - - <span class="k">if</span> <span class="n">method</span> <span class="o">==</span> <span class="kc">None</span><span class="p">:</span> - <span class="c1"># no extrapolation : just interpolate between 0.10 and 0.95</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: using no extrapolations"</span><span class="o">.</span><span class="n">format</span><span class="p">(),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">continue</span> - <span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">"flat"</span><span class="p">:</span> - <span class="c1"># use the end value and extrapolate it</span> - <span class="c1"># with zero slope</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">qlimit</span><span class="p">]</span> <span class="o">=</span> <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">end_index</span><span class="p">]]</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: using constant extrapolation"</span><span class="o">.</span><span class="n">format</span><span class="p">(),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">"linear"</span><span class="p">:</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">qlimit</span><span class="p">]</span> <span class="o">=</span> <span class="n">linear_extrapolation_q</span><span class="p">(</span> - <span class="n">qs</span><span class="o">=</span><span class="n">qs</span><span class="p">,</span> - <span class="n">indices</span><span class="o">=</span><span class="n">indices</span><span class="p">,</span> - <span class="n">qlimit</span><span class="o">=</span><span class="n">qlimit</span><span class="p">,</span> - <span class="n">qdata</span><span class="o">=</span><span class="n">qdata</span><span class="p">,</span> - <span class="n">end_index</span><span class="o">=</span><span class="n">end_index</span><span class="p">,</span> - <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span><span class="p">,</span> - <span class="p">)</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: using linear extrapolation"</span><span class="o">.</span><span class="n">format</span><span class="p">(),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">if</span> <span class="n">pre</span> <span class="o">==</span> <span class="s2">"low"</span><span class="p">:</span> - <span class="n">below_qlimit</span> <span class="o">=</span> <span class="n">qlimit</span> <span class="o">-</span> <span class="n">qeps</span> - <span class="k">if</span> <span class="n">below_qlimit</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">below_qlimit</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">qdata</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: using linear extrapolation and setting the points below the lower q bound (</span><span class="si">{}</span><span class="s2">) to 0 "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">qlimit</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">"plaw2"</span><span class="p">:</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">qlimit</span><span class="p">]</span> <span class="o">=</span> <span class="n">powerlaw_extrapolation_q</span><span class="p">(</span> - <span class="n">qs</span><span class="o">=</span><span class="n">qs</span><span class="p">,</span> <span class="n">indices</span><span class="o">=</span><span class="n">indices</span><span class="p">,</span> <span class="n">qdata</span><span class="o">=</span><span class="n">qdata</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> - <span class="p">)</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: using powerlaw extrapolation"</span><span class="o">.</span><span class="n">format</span><span class="p">(),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">"nolowq"</span><span class="p">:</span> - <span class="n">newq</span> <span class="o">=</span> <span class="mf">0.05</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">newq</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: setting lowq to 0"</span><span class="o">.</span><span class="n">format</span><span class="p">(),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">"poly"</span><span class="p">:</span> - <span class="c1"># TODO: consider implementing the poly method (see Perl version)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> - <span class="s2">"Moe and di Stefano 2017: build_q_table: Method 'poly' not implemented"</span> - <span class="p">)</span> - - <span class="k">else</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Error no other methods available. The chosen method (</span><span class="si">{}</span><span class="s2">) does not exist!"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">method</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="n">msg</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="c1"># regenerate qs in new table. This is now the updated list of qs where we have some extrapolated numbers</span> - <span class="n">tmp_table</span> <span class="o">=</span> <span class="p">[]</span> - <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">qdata</span><span class="o">.</span><span class="n">keys</span><span class="p">()):</span> - <span class="n">tmp_table</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">q</span><span class="p">,</span> <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]])</span> - - <span class="c1"># Make an interpolation table to contain our modified data</span> - <span class="n">q_interpolator</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> - <span class="n">table</span><span class="o">=</span><span class="n">tmp_table</span><span class="p">,</span> - <span class="n">nparams</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="n">ndata</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># Contains the table of data # q #</span> - <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> <span class="o">-</span> <span class="p">(</span><span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Created a new Q table"</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">if</span> <span class="n">can_renormalize</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Renormalising table"</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># now we integrate and renormalise (if the table is not all zero)</span> - <span class="n">I</span> <span class="o">=</span> <span class="n">get_integration_constant_q</span><span class="p">(</span> - <span class="n">q_interpolator</span><span class="p">,</span> <span class="n">tmp_table</span><span class="p">,</span> <span class="n">qdata</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> - <span class="p">)</span> - - <span class="k">if</span> <span class="n">I</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> - <span class="c1"># normalise to 1.0 by dividing the data by 1.0/$I</span> - <span class="n">q_interpolator</span><span class="o">.</span><span class="n">multiply_table_column</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">I</span><span class="p">)</span> - - <span class="c1"># test this</span> - <span class="n">new_I</span> <span class="o">=</span> <span class="n">get_integration_constant_q</span><span class="p">(</span> - <span class="n">q_interpolator</span><span class="p">,</span> <span class="n">tmp_table</span><span class="p">,</span> <span class="n">qdata</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> - <span class="p">)</span> - - <span class="c1"># fail if error in integral > 1e-6 (should be ~ machine precision)</span> - <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="mf">1.0</span> <span class="o">-</span> <span class="n">new_I</span><span class="p">)</span> <span class="o">></span> <span class="mf">1e-6</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Error: > 1e-6 in q probability integral: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">I</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># set this new table in the cache</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">p</span><span class="p">)]</span> <span class="o">=</span> <span class="n">q_interpolator</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: stored q_interpolater as </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Store the values for which this table was set up in the dict</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">][</span><span class="n">m</span><span class="p">]</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">]</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">][</span><span class="n">p</span><span class="p">]</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]</span></div> - - -<div class="viewcode-block" id="powerlaw_extrapolation_q"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.powerlaw_extrapolation_q">[docs]</a><span class="k">def</span> <span class="nf">powerlaw_extrapolation_q</span><span class="p">(</span><span class="n">qdata</span><span class="p">,</span> <span class="n">qs</span><span class="p">,</span> <span class="n">indices</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to do the power law extrapolation at the lower end of the q range</span> -<span class="sd"> """</span> - <span class="n">newq</span> <span class="o">=</span> <span class="mf">0.05</span> - - <span class="c1"># use a power-law extrapolation down to q=0.05, if possible</span> - <span class="k">if</span> <span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]]</span> <span class="o">==</span> <span class="mf">0.0</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">]]]</span> <span class="o">==</span> <span class="mf">0.0</span><span class="p">):</span> - <span class="c1"># not possible</span> - <span class="k">return</span> <span class="mi">0</span> - - <span class="k">else</span><span class="p">:</span> - <span class="n">slope</span> <span class="o">=</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">]]])</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]]))</span> <span class="o">/</span> <span class="p">(</span> - <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">]])</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]])</span> - <span class="p">)</span> - <span class="n">intercept</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]])</span> <span class="o">-</span> <span class="n">slope</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]])</span> - - <span class="k">return</span> <span class="n">slope</span> <span class="o">*</span> <span class="n">newq</span> <span class="o">+</span> <span class="n">intercept</span></div> - - -<div class="viewcode-block" id="linear_extrapolation_q"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.linear_extrapolation_q">[docs]</a><span class="k">def</span> <span class="nf">linear_extrapolation_q</span><span class="p">(</span><span class="n">qs</span><span class="p">,</span> <span class="n">indices</span><span class="p">,</span> <span class="n">qlimit</span><span class="p">,</span> <span class="n">qdata</span><span class="p">,</span> <span class="n">end_index</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to do the linear extrapolation for q.</span> -<span class="sd"> """</span> - - <span class="c1"># linear extrapolation</span> - <span class="n">dq</span> <span class="o">=</span> <span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">-</span> <span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> - - <span class="k">if</span> <span class="n">dq</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: linear dq=0"</span><span class="o">.</span><span class="n">format</span><span class="p">(),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># No change</span> - <span class="k">return</span> <span class="n">qs</span><span class="p">[</span><span class="n">end_index</span><span class="p">]</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">slope</span> <span class="o">=</span> <span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">]]]</span> <span class="o">-</span> <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]])</span> <span class="o">/</span> <span class="n">dq</span> - - <span class="n">intercept</span> <span class="o">=</span> <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]]</span> <span class="o">-</span> <span class="n">slope</span> <span class="o">*</span> <span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> - <span class="n">qdata</span><span class="p">[</span><span class="n">qlimit</span><span class="p">]</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">slope</span> <span class="o">*</span> <span class="n">qlimit</span> <span class="o">+</span> <span class="n">intercept</span><span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: linear Slope: </span><span class="si">{}</span><span class="s2"> intercept: </span><span class="si">{}</span><span class="s2"> dn/dq(</span><span class="si">{}</span><span class="s2">) = </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">slope</span><span class="p">,</span> <span class="n">intercept</span><span class="p">,</span> <span class="n">qlimit</span><span class="p">,</span> <span class="n">qdata</span><span class="p">[</span><span class="n">qlimit</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">return</span> <span class="nb">max</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">slope</span> <span class="o">*</span> <span class="n">qlimit</span> <span class="o">+</span> <span class="n">intercept</span><span class="p">)</span></div> - - -<div class="viewcode-block" id="get_integration_constant_q"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.get_integration_constant_q">[docs]</a><span class="k">def</span> <span class="nf">get_integration_constant_q</span><span class="p">(</span><span class="n">q_interpolator</span><span class="p">,</span> <span class="n">tmp_table</span><span class="p">,</span> <span class="n">qdata</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to integrate the q interpolator and return the integration constant</span> -<span class="sd"> """</span> - - <span class="n">dq</span> <span class="o">=</span> <span class="mf">1e-3</span> <span class="c1"># resolution of the integration/renormalisation</span> - <span class="n">I</span> <span class="o">=</span> <span class="mi">0</span> - - <span class="c1"># integrate: note that the value of the integral is</span> - <span class="c1"># meaningless to within a factor (which depends on $dq)</span> - <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span> <span class="o">+</span> <span class="mf">2e-6</span><span class="p">,</span> <span class="n">dq</span><span class="p">):</span> - <span class="n">x</span> <span class="o">=</span> <span class="n">q_interpolator</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">q</span><span class="p">])</span> - <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Q interpolator table interpolation failed.</span><span class="se">\n\t\t</span><span class="s2">tmp_table = </span><span class="si">{}</span><span class="se">\n\t\t</span><span class="s2">q_data = </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="nb">str</span><span class="p">(</span><span class="n">tmp_table</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">qdata</span><span class="p">)</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="n">msg</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">I</span> <span class="o">+=</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">dq</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "\tMoe and di Stefano 2017: build_q_table: dn/dq ({}) = {} I -> = {}".format(q, x[0], I),</span> - <span class="c1"># verbosity,</span> - <span class="c1"># _MOE2017_VERBOSITY_LEVEL,</span> - <span class="c1"># )</span> - <span class="k">return</span> <span class="n">I</span></div> - - -<div class="viewcode-block" id="fill_data"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.fill_data">[docs]</a><span class="k">def</span> <span class="nf">fill_data</span><span class="p">(</span><span class="n">sample_values</span><span class="p">,</span> <span class="n">data_dict</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function that returns the normalised array of values for given logmass and logperiod</span> -<span class="sd"> used for the e and q values</span> - -<span class="sd"> TODO: make sure we do the correct thing with the dstep</span> -<span class="sd"> """</span> - - <span class="n">data</span> <span class="o">=</span> <span class="p">{}</span> - <span class="n">I</span> <span class="o">=</span> <span class="mi">0</span> - - <span class="n">dstep</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">sample_values</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">-</span> <span class="nb">float</span><span class="p">(</span><span class="n">sample_values</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> - - <span class="c1"># Read out the data</span> - <span class="k">for</span> <span class="n">sample_value</span> <span class="ow">in</span> <span class="n">sample_values</span><span class="p">:</span> - <span class="n">val</span> <span class="o">=</span> <span class="n">data_dict</span><span class="p">[</span><span class="n">sample_value</span><span class="p">]</span> - <span class="n">data</span><span class="p">[</span><span class="n">sample_value</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span> - <span class="n">I</span> <span class="o">+=</span> <span class="n">val</span> - - <span class="c1"># Normalise the data</span> - <span class="k">for</span> <span class="n">sample_value</span> <span class="ow">in</span> <span class="n">sample_values</span><span class="p">:</span> - <span class="n">data</span><span class="p">[</span><span class="n">sample_value</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">sample_value</span><span class="p">]</span> <span class="o">/</span> <span class="n">I</span> - - <span class="k">return</span> <span class="n">data</span></div> - - -<div class="viewcode-block" id="calc_e_integral"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.calc_e_integral">[docs]</a><span class="k">def</span> <span class="nf">calc_e_integral</span><span class="p">(</span> - <span class="n">options</span><span class="p">,</span> - <span class="n">integrals_string</span><span class="p">,</span> - <span class="n">interpolator_name</span><span class="p">,</span> - <span class="n">mass_string</span><span class="p">,</span> - <span class="n">period_string</span><span class="p">,</span> - <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> -<span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to calculate the P integral</span> - -<span class="sd"> We need to renormalise this because min_per > 0, and not all periods should be included</span> -<span class="sd"> """</span> - - <span class="k">global</span> <span class="n">Moecache</span> - <span class="n">min_ecc</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">max_ecc</span> <span class="o">=</span> <span class="mf">0.9999</span> - - <span class="n">mass_period_string</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">_</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="n">period_string</span><span class="p">])</span> - - <span class="c1"># Check if the dict exists</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">integrals_string</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> - - <span class="c1"># Check for cached value. If it doesn't exist: calculate</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">mass_period_string</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">I</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">decc</span> <span class="o">=</span> <span class="mf">1e-3</span> - - <span class="k">for</span> <span class="n">ecc</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">min_ecc</span><span class="p">,</span> <span class="n">max_ecc</span><span class="p">,</span> <span class="n">decc</span><span class="p">):</span> - <span class="c1"># Loop over all the values in the table, between the min and max P</span> - <span class="n">dp_decc</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="n">interpolator_name</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">period_string</span><span class="p">]),</span> <span class="n">ecc</span><span class="p">]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - - <span class="n">I</span> <span class="o">+=</span> <span class="n">dp_decc</span> <span class="o">*</span> <span class="n">decc</span> - - <span class="c1"># Set the integral value in the dict</span> - <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">][</span><span class="n">mass_period_string</span><span class="p">]</span> <span class="o">=</span> <span class="n">I</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: calc_ecc_integral: min_ecc: </span><span class="si">{}</span><span class="s2"> max ecc: </span><span class="si">{}</span><span class="s2"> integrals_string: </span><span class="si">{}</span><span class="s2"> interpolator_name: </span><span class="si">{}</span><span class="s2"> mass_string: </span><span class="si">{}</span><span class="s2"> period_string: </span><span class="si">{}</span><span class="s2"> mass: </span><span class="si">{}</span><span class="s2"> period: </span><span class="si">{}</span><span class="s2"> I: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">min_ecc</span><span class="p">,</span> - <span class="n">max_ecc</span><span class="p">,</span> - <span class="n">integrals_string</span><span class="p">,</span> - <span class="n">interpolator_name</span><span class="p">,</span> - <span class="n">mass_string</span><span class="p">,</span> - <span class="n">period_string</span><span class="p">,</span> - <span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="n">period_string</span><span class="p">],</span> - <span class="n">I</span><span class="p">,</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: calc_ecc_integral: Found cached value for min_ecc: </span><span class="si">{}</span><span class="s2"> max ecc: </span><span class="si">{}</span><span class="s2"> integrals_string: </span><span class="si">{}</span><span class="s2"> interpolator_name: </span><span class="si">{}</span><span class="s2"> mass_string: </span><span class="si">{}</span><span class="s2"> period_string: </span><span class="si">{}</span><span class="s2"> mass: </span><span class="si">{}</span><span class="s2"> period: </span><span class="si">{}</span><span class="s2"> I: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">min_ecc</span><span class="p">,</span> - <span class="n">max_ecc</span><span class="p">,</span> - <span class="n">integrals_string</span><span class="p">,</span> - <span class="n">interpolator_name</span><span class="p">,</span> - <span class="n">mass_string</span><span class="p">,</span> - <span class="n">period_string</span><span class="p">,</span> - <span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="n">period_string</span><span class="p">],</span> - <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">][</span><span class="n">mass_period_string</span><span class="p">],</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span></div> - - -<div class="viewcode-block" id="calc_P_integral"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.calc_P_integral">[docs]</a><span class="k">def</span> <span class="nf">calc_P_integral</span><span class="p">(</span> - <span class="n">options</span><span class="p">,</span> - <span class="n">min_logP</span><span class="p">,</span> - <span class="n">max_logP</span><span class="p">,</span> - <span class="n">integrals_string</span><span class="p">,</span> - <span class="n">interpolator_name</span><span class="p">,</span> - <span class="n">mass_string</span><span class="p">,</span> - <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> -<span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to calculate the P integral</span> - -<span class="sd"> We need to renormalise this because min_per > 0, and not all periods should be included</span> -<span class="sd"> """</span> - - <span class="k">global</span> <span class="n">Moecache</span> - - <span class="c1"># Check if the dict exists</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">integrals_string</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> - - <span class="c1"># Check for cached value. If it doesn't exist: calculate</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">I</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">dlogP</span> <span class="o">=</span> <span class="mf">1e-3</span> - - <span class="k">for</span> <span class="n">logP</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">min_logP</span><span class="p">,</span> <span class="n">max_logP</span><span class="p">,</span> <span class="n">dlogP</span><span class="p">):</span> - <span class="c1"># Loop over all the values in the table, between the min and max P</span> - <span class="n">dp_dlogP</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="n">interpolator_name</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">]),</span> <span class="n">logP</span><span class="p">]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - - <span class="n">I</span> <span class="o">+=</span> <span class="n">dp_dlogP</span> <span class="o">*</span> <span class="n">dlogP</span> - - <span class="c1"># Set the integral value in the dict</span> - <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">][</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">]]</span> <span class="o">=</span> <span class="n">I</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: calc_P_integral: min_logP: </span><span class="si">{}</span><span class="s2"> integrals_string: </span><span class="si">{}</span><span class="s2"> interpolator_name: </span><span class="si">{}</span><span class="s2"> mass_string: </span><span class="si">{}</span><span class="s2"> mass: </span><span class="si">{}</span><span class="s2"> I: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">min_logP</span><span class="p">,</span> - <span class="n">integrals_string</span><span class="p">,</span> - <span class="n">interpolator_name</span><span class="p">,</span> - <span class="n">mass_string</span><span class="p">,</span> - <span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> - <span class="n">I</span><span class="p">,</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: calc_P_integral: Found cached value for min_logP: </span><span class="si">{}</span><span class="s2"> integrals_string: </span><span class="si">{}</span><span class="s2"> interpolator_name: </span><span class="si">{}</span><span class="s2"> mass_string: </span><span class="si">{}</span><span class="s2"> mass: </span><span class="si">{}</span><span class="s2"> I: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">min_logP</span><span class="p">,</span> - <span class="n">integrals_string</span><span class="p">,</span> - <span class="n">interpolator_name</span><span class="p">,</span> - <span class="n">mass_string</span><span class="p">,</span> - <span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> - <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">][</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">]],</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span></div> - - -<div class="viewcode-block" id="calc_total_probdens"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.calc_total_probdens">[docs]</a><span class="k">def</span> <span class="nf">calc_total_probdens</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to calculate the total probability density</span> -<span class="sd"> """</span> - - <span class="n">total_probdens</span> <span class="o">=</span> <span class="mi">1</span> - <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">prob_dict</span><span class="p">:</span> - <span class="n">total_probdens</span> <span class="o">*=</span> <span class="n">prob_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"total_probdens"</span><span class="p">]</span> <span class="o">=</span> <span class="n">total_probdens</span> - - <span class="k">return</span> <span class="n">prob_dict</span></div> - - -<div class="viewcode-block" id="Moe_di_Stefano_2017_pdf"><a class="viewcode-back" href="../../../distribution_functions.html#binarycpython.utils.distribution_functions.Moe_di_Stefano_2017_pdf">[docs]</a><span class="k">def</span> <span class="nf">Moe_di_Stefano_2017_pdf</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Moe & diStefano function to calculate the probability density.</span> - -<span class="sd"> takes a dictionary as input (in options) with options:</span> - -<span class="sd"> M1, M2, M3, M4 => masses (Msun) [M1 required, rest optional]</span> -<span class="sd"> P, P2, P3 => periods (days) [number: none=binary, 2=triple, 3=quadruple]</span> -<span class="sd"> ecc, ecc2, ecc3 => eccentricities [numbering as for P above]</span> - -<span class="sd"> mmin => minimum allowed stellar mass (default 0.07)</span> -<span class="sd"> mmax => maximum allowed stellar mass (default 80.0)</span> -<span class="sd"> """</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf with options:</span><span class="se">\n\t\t</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">options</span><span class="p">)),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="n">prob_dict</span> <span class="o">=</span> <span class="p">(</span> - <span class="p">{}</span> - <span class="p">)</span> <span class="c1"># Dictionary containing all the pdf values for the different parameters</span> - - <span class="c1"># Get the multiplicity from the options, and if its not there, calculate it based on the</span> - <span class="c1"># TODO: the function below makes no sense. We NEED to pass the multiplicity in the</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"multiplicity"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Did not find a multiplicity value in the options dictionary"</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="n">msg</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - <span class="c1"># multiplicity = 1</span> - <span class="c1"># for n in range(2, 5):</span> - <span class="c1"># multiplicity += 1 if options.get("M{}".format(n), None) else 0</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">multiplicity</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">]</span> - - <span class="c1"># Immediately return 0 if the multiplicity modulator is 0</span> - <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"multiplicity_modulator"</span><span class="p">][</span><span class="n">multiplicity</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: returning 0 because of the multiplicity modulator being 0"</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">return</span> <span class="mi">0</span> - - <span class="c1">############################################################</span> - <span class="c1"># multiplicity fraction</span> - <span class="c1"># Calculate the probability, or rather, fraction, of stars that belong to this mass</span> - - <span class="n">multiplicity_probability</span> <span class="o">=</span> <span class="n">Moe_di_Stefano_2017_multiplicity_fractions</span><span class="p">(</span> - <span class="n">options</span><span class="p">,</span> <span class="n">verbosity</span> - <span class="p">)[</span><span class="n">multiplicity</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">]</span> <span class="o">=</span> <span class="n">multiplicity_probability</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended multiplicity (mass1 = </span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob dict (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">],</span> <span class="n">prob_dict</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1">############################################################</span> - <span class="c1"># always require an IMF for the primary star</span> - <span class="c1">#</span> - <span class="c1"># NB multiply by M1 to convert dN/dM to dN/dlnM</span> - <span class="c1"># (dlnM = dM/M, so 1/dlnM = M/dM)</span> - - <span class="c1"># TODO: Create an n-part-powerlaw method that can have breakpoints and slopes. I'm using a three-part power law now.</span> - <span class="c1"># TODO: is this actually the correct way? putting the M1 in there? Do we sample in log space?</span> - <span class="n">M1_probability</span> <span class="o">=</span> <span class="n">Kroupa2001</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">])</span> <span class="o">*</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="o">=</span> <span class="n">M1_probability</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended Mass (m=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob dict (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">prob_dict</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># if M1_probability == 0: # If the probability is 0 then we don't have to calculate more</span> - <span class="c1"># calc_total_probdens(prob_dict)</span> - <span class="c1"># return prob_dict</span> - - <span class="sd">"""</span> -<span class="sd"> From here we go through the multiplicities.</span> -<span class="sd"> """</span> - <span class="k">if</span> <span class="n">multiplicity</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> - <span class="c1"># If the multiplicity is higher than 1, we will need to construct the following tables:</span> - <span class="c1"># - period distribution table</span> - <span class="c1"># - q distribution table</span> - <span class="c1"># - eccentricity distribution table</span> - - <span class="c1"># Set up the interpolator for the periods</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_log10P"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_log10P"</span><span class="p">]</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> - <span class="n">table</span><span class="o">=</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">],</span> <span class="c1"># Contains the table of data</span> - <span class="n">nparams</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="c1"># log10M, log10P</span> - <span class="n">ndata</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="c1"># binary, triple</span> - <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> <span class="o">-</span> <span class="p">(</span><span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Created new period interpolator: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_log10P"</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Make a table storing Moe's data for q distributions</span> - <span class="k">if</span> <span class="p">(</span> - <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="ow">or</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_3"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="ow">or</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_4"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="p">):</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> - <span class="n">table</span><span class="o">=</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"q_distributions"</span><span class="p">],</span> <span class="c1"># Contains the table of data</span> - <span class="n">nparams</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="c1"># log10M, log10P, q</span> - <span class="n">ndata</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="c1">#</span> - <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> <span class="o">-</span> <span class="p">(</span><span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Created new q interpolator: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Make a table storing Moe's data for q distributions, but only if the ecc is actually sampled</span> - <span class="k">if</span> <span class="s2">"ecc"</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="o">==</span> <span class="kc">None</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_e"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_e"</span><span class="p">]</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> - <span class="n">table</span><span class="o">=</span><span class="n">Moecache</span><span class="p">[</span> - <span class="s2">"ecc_distributions"</span> - <span class="p">],</span> <span class="c1"># Contains the table of data</span> - <span class="n">nparams</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="c1"># log10M, log10P, e</span> - <span class="n">ndata</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="c1">#</span> - <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> - <span class="o">-</span> <span class="p">(</span><span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Created new e interpolator: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_e"</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1">###############</span> - <span class="c1"># Calculation for period of the binary</span> - - <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="c1"># Separation of the inner binary</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"sep"</span><span class="p">]</span> <span class="o">=</span> <span class="n">calc_sep_from_period</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]</span> - <span class="p">)</span> - <span class="c1"># TODO: add check for min_logP with instant RLOF?</span> - <span class="c1"># TODO: Actually use the value above.</span> - <span class="c1"># Total mass inner binary:</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="o">+</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> - - <span class="c1"># Calculate P integral or use cached value</span> - - <span class="c1"># get the periods from the Moecahe</span> - <span class="n">min_logP</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"logperiods"</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span> - <span class="n">max_logP</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"logperiods"</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> - - <span class="n">calc_P_integral</span><span class="p">(</span> - <span class="n">options</span><span class="p">,</span> - <span class="n">min_logP</span><span class="p">,</span> - <span class="n">max_logP</span><span class="p">,</span> - <span class="s2">"P_integrals"</span><span class="p">,</span> - <span class="s2">"rinterpolator_log10P"</span><span class="p">,</span> - <span class="s2">"M_1"</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Set probabilty for P1</span> - <span class="n">p_val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_log10P"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">])]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">p_val</span> <span class="o">=</span> <span class="n">p_val</span> <span class="o">/</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"P_integrals"</span><span class="p">][</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]]</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]</span> <span class="o">=</span> <span class="n">p_val</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended period (m=</span><span class="si">{}</span><span class="s2">, P=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> <span class="n">prob_dict</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># if prob_dict['P'] == 0: # If the probability is 0 then we don't have to calculate more</span> - <span class="c1"># calc_total_probdens(prob_dict)</span> - <span class="c1"># return prob_dict</span> - - <span class="c1">############################################################</span> - <span class="c1"># mass ratio (0 < q = M2/M1 < qmax)</span> - <span class="c1">#</span> - <span class="c1"># we need to construct the q table for the given M1</span> - <span class="c1"># subject to qmin = Mmin/M1</span> - - <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="c1"># Build the table for q</span> - <span class="n">primary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> - <span class="n">secondary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> - <span class="n">m_label</span> <span class="o">=</span> <span class="s2">"M_1"</span> - <span class="n">p_label</span> <span class="o">=</span> <span class="s2">"P"</span> - - <span class="c1"># Construct the q table</span> - <span class="n">build_q_table</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span><span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Created q_table (</span><span class="si">{}</span><span class="s2">) for m=</span><span class="si">{}</span><span class="s2"> p=</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">Moecache</span><span class="p">[</span> - <span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">)</span> - <span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="n">m_label</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="n">p_label</span><span class="p">],</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Add probability for the mass ratio</span> - <span class="n">q_prob</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span> - <span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">)</span> - <span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">secondary_mass</span> <span class="o">/</span> <span class="n">primary_mass</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q"</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_prob</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: appended mass ratio (M=</span><span class="si">{}</span><span class="s2"> P=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">) "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> <span class="o">/</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q"</span><span class="p">],</span> - <span class="n">prob_dict</span><span class="p">,</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># if prob_dict['q'] == 0: # If the probability is 0 then we don't have to calculate more</span> - <span class="c1"># calc_total_probdens(prob_dict)</span> - <span class="c1"># return prob_dict</span> - - <span class="c1">############################################################</span> - <span class="c1"># Eccentricity</span> - <span class="c1"># TODO: ask rob if the eccentricity requires an extrapolation as well.</span> - - <span class="c1"># Only do this if the eccentricity is sampled</span> - <span class="k">if</span> <span class="s2">"ecc"</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="o">==</span> <span class="kc">None</span><span class="p">:</span> - <span class="c1"># Calculate ecc integral or use cached value</span> - <span class="n">calc_e_integral</span><span class="p">(</span> - <span class="n">options</span><span class="p">,</span> <span class="s2">"ecc_integrals"</span><span class="p">,</span> <span class="s2">"rinterpolator_e"</span><span class="p">,</span> <span class="s2">"M_1"</span><span class="p">,</span> <span class="s2">"P"</span><span class="p">,</span> <span class="n">verbosity</span> - <span class="p">)</span> - <span class="n">mass_period_string</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">_</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">])</span> - - <span class="c1"># Set probability for ecc</span> - <span class="n">ecc_val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_e"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]),</span> <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">ecc_val</span> <span class="o">=</span> <span class="n">ecc_val</span> <span class="o">/</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"ecc_integrals"</span><span class="p">][</span><span class="n">mass_period_string</span><span class="p">]</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="o">=</span> <span class="n">ecc_val</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended eccentricity (m=</span><span class="si">{}</span><span class="s2">, P=</span><span class="si">{}</span><span class="s2">, ecc=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">],</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">],</span> - <span class="n">prob_dict</span><span class="p">,</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># if prob_dict['ecc'] == 0: # If the probability is 0 then we don't have to calculate more</span> - <span class="c1"># calc_total_probdens(prob_dict)</span> - <span class="c1"># return prob_dict</span> - - <span class="c1"># Calculations for when multiplicity is bigger than 3</span> - <span class="c1"># BEWARE: binary_c does not evolve these systems actually and the code below should be revised for when binary_c actually evolves triples.</span> - <span class="c1"># For that reason, I would not advise to use things with multiplicity > 3</span> - <span class="k">if</span> <span class="n">multiplicity</span> <span class="o">>=</span> <span class="mi">3</span><span class="p">:</span> - - <span class="c1">############################################################</span> - <span class="c1"># orbital period 2 =</span> - <span class="c1"># orbital period of star 3 (multiplicity==3) or</span> - <span class="c1"># the star3+star4 binary (multiplicity==4)</span> - <span class="c1">#</span> - <span class="c1"># we assume the same period distribution for star 3</span> - <span class="c1"># (or stars 3 and 4) but with a separation that is >10*a*(1+e)</span> - <span class="c1"># where 10*a*(1+e) is the maximum apastron separation of</span> - <span class="c1"># stars 1 and 2</span> - - <span class="c1"># TODO: Is this a correct assumption?</span> - <span class="n">max_sep</span> <span class="o">=</span> <span class="mf">10.0</span> <span class="o">*</span> <span class="n">options</span><span class="p">[</span><span class="s2">"sep"</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">])</span> - <span class="n">min_P2</span> <span class="o">=</span> <span class="n">calc_period_from_sep</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"mmin"</span><span class="p">],</span> <span class="n">max_sep</span><span class="p">)</span> - <span class="n">min_logP2</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">min_P2</span><span class="p">)</span> - <span class="c1"># max_logP2 = 10.0</span> - <span class="c1"># min_logP = Moecache['logperiods'][0]</span> - <span class="n">max_logP2</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"logperiods"</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> - - <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]</span> <span class="o"><</span> <span class="n">min_P2</span><span class="p">:</span> - <span class="c1"># period is too short : system is not hierarchical</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: period2 is too short: </span><span class="si">{}</span><span class="s2"> < </span><span class="si">{}</span><span class="s2">, system is not hierarchical. Added 0 to probability list"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"P1"</span><span class="p">],</span> <span class="n">min_P2</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># if prob_dict['P2'] == 0: # If the probability is 0 then we don't have to calculate more</span> - <span class="c1"># calc_total_probdens(prob_dict)</span> - <span class="c1"># return prob_dict</span> - - <span class="k">else</span><span class="p">:</span> - <span class="c1"># period is long enough that the system is hierarchical</span> - <span class="c1"># hence the separation between the outer star</span> - <span class="c1"># and inner binary</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"sep2"</span><span class="p">]</span> <span class="o">=</span> <span class="n">calc_sep_from_period</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]</span> - <span class="p">)</span> - - <span class="c1"># Check for cached value of P integral or calculate</span> - <span class="n">calc_P_integral</span><span class="p">(</span> - <span class="n">options</span><span class="p">,</span> - <span class="n">min_logP2</span><span class="p">,</span> - <span class="n">max_logP2</span><span class="p">,</span> - <span class="s2">"P2_integrals"</span><span class="p">,</span> - <span class="s2">"rinterpolator_log10P"</span><span class="p">,</span> - <span class="s2">"M_1+M_2"</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Add the probability</span> - <span class="n">p_val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_log10P"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">])]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">p_val</span> <span class="o">=</span> <span class="n">p_val</span> <span class="o">/</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"P2_integrals"</span><span class="p">][</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]]</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]</span> <span class="o">=</span> <span class="n">p_val</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended period2 (m1=</span><span class="si">{}</span><span class="s2"> m2=</span><span class="si">{}</span><span class="s2">, P2=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">],</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">],</span> - <span class="n">prob_dict</span><span class="p">,</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># if prob_dict['P2'] == 0: # If the probability is 0 then we don't have to calculate more</span> - <span class="c1"># calc_total_probdens(prob_dict)</span> - <span class="c1"># return prob_dict</span> - - <span class="c1">############################################################</span> - <span class="c1"># mass ratio 2 = q2 = M3 / (M1+M2)</span> - <span class="c1">#</span> - <span class="c1"># we need to construct the q table for the given M1</span> - <span class="c1"># subject to qmin = Mmin/(M1+M2)</span> - - <span class="c1"># Set the variables for the masses and their names</span> - <span class="n">primary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]</span> - <span class="n">secondary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">]</span> - <span class="n">m_label</span> <span class="o">=</span> <span class="s2">"M_1+M_2"</span> - <span class="n">p_label</span> <span class="o">=</span> <span class="s2">"P2"</span> - - <span class="c1"># Build q table</span> - <span class="n">build_q_table</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span><span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Called build_q_table"</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Add the probability</span> - <span class="n">q2_val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span> - <span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">)</span> - <span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">secondary_mass</span> <span class="o">/</span> <span class="n">primary_mass</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q2"</span><span class="p">]</span> <span class="o">=</span> <span class="n">q2_val</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: appended mass ratio (M_1+M_2=</span><span class="si">{}</span><span class="s2"> M_3=</span><span class="si">{}</span><span class="s2"> P=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">) "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> - <span class="n">secondary_mass</span> <span class="o">/</span> <span class="n">primary_mass</span><span class="p">,</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q2"</span><span class="p">],</span> - <span class="n">prob_dict</span><span class="p">,</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># if prob_dict['q2'] == 0: # If the probability is 0 then we don't have to calculate more</span> - <span class="c1"># calc_total_probdens(prob_dict)</span> - <span class="c1"># return prob_dict</span> - - <span class="c1"># TODO: Implement ecc2 calculation</span> - <span class="k">if</span> <span class="n">multiplicity</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span> - <span class="c1"># quadruple system.</span> - <span class="c1"># TODO: Ask Rob about the structure of the quadruple. Is this only double binary quadruples?</span> - - <span class="c1">############################################################</span> - <span class="c1"># orbital period 3</span> - <span class="c1">#</span> - <span class="c1"># we assume the same period distribution for star 4</span> - <span class="c1"># as for any other stars but Pmax must be such that</span> - <span class="c1"># sep3 < sep2 * 0.2</span> - - <span class="c1"># TODO: fix this here</span> - <span class="n">max_sep3</span> <span class="o">=</span> <span class="mf">0.2</span> <span class="o">*</span> <span class="n">options</span><span class="p">[</span><span class="s2">"sep2"</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">options</span><span class="p">[</span><span class="s2">"ecc2"</span><span class="p">])</span> - <span class="n">max_per3</span> <span class="o">=</span> <span class="n">calc_period_from_sep</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"mmin"</span><span class="p">],</span> <span class="n">max_sep3</span> - <span class="p">)</span> - - <span class="c1"># Calculate P integral or use the cached value</span> - <span class="c1"># TODO: Make sure we use the correct period idea here.</span> - <span class="n">calc_P_integral</span><span class="p">(</span> - <span class="n">options</span><span class="p">,</span> - <span class="n">min_logP2</span><span class="p">,</span> - <span class="n">max_logP2</span><span class="p">,</span> - <span class="s2">"P2_integrals"</span><span class="p">,</span> - <span class="s2">"rinterpolator_log10P"</span><span class="p">,</span> - <span class="s2">"M_1+M_2"</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Set probability</span> - <span class="n">p_val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_log10P"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> - <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">])]</span> - <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">p_val</span> <span class="o">=</span> <span class="n">p_val</span> <span class="o">/</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"P2_integrals"</span><span class="p">][</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]]</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P3"</span><span class="p">]</span> <span class="o">=</span> <span class="n">p_val</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended period2 (M=4) (M_1=</span><span class="si">{}</span><span class="s2"> M_2=</span><span class="si">{}</span><span class="s2">, P2=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">],</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P3"</span><span class="p">],</span> - <span class="n">prob_dict</span><span class="p">,</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># if prob_dict['P3'] == 0: # If the probability is 0 then we don't have to calculate more</span> - <span class="c1"># calc_total_probdens(prob_dict)</span> - <span class="c1"># return prob_dict</span> - - <span class="c1">############################################################</span> - <span class="c1"># mass ratio 2</span> - <span class="c1">#</span> - <span class="c1"># we need to construct the q table for the given M1</span> - <span class="c1"># subject to qmin = Mmin/(M1+M2)</span> - <span class="c1"># Make a table storing Moe's data for q distributions</span> - - <span class="c1"># Build the table for q2</span> - <span class="n">primary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]</span> - <span class="n">secondary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">]</span> - <span class="n">m_label</span> <span class="o">=</span> <span class="s2">"M_1+M_2"</span> - <span class="n">p_label</span> <span class="o">=</span> <span class="s2">"P2"</span> - - <span class="c1"># Calculate new q table</span> - <span class="n">build_q_table</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span><span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Created q_table "</span><span class="o">.</span><span class="n">format</span><span class="p">(),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Add the probability</span> - <span class="n">q3_prob</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span> - <span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">)</span> - <span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">secondary_mass</span> <span class="o">/</span> <span class="n">primary_mass</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q3"</span><span class="p">]</span> <span class="o">=</span> <span class="n">q3_prob</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: appended mass ratio (M_1+M_2=</span><span class="si">{}</span><span class="s2"> M_3=</span><span class="si">{}</span><span class="s2"> P=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">) "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> - <span class="n">secondary_mass</span> <span class="o">/</span> <span class="n">primary_mass</span><span class="p">,</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q3"</span><span class="p">],</span> - <span class="n">prob_dict</span><span class="p">,</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># if prob_dict['q3'] == 0: # If the probability is 0 then we don't have to calculate more</span> - <span class="c1"># calc_total_probdens(prob_dict)</span> - <span class="c1"># return prob_dict</span> - - <span class="c1"># TODO ecc 3</span> - - <span class="c1"># check for input of multiplicity</span> - <span class="k">elif</span> <span class="n">multiplicity</span> <span class="ow">not</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">5</span><span class="p">):</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Unknown multiplicity </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">multiplicity</span><span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="n">msg</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="c1"># Calculate total probdens:</span> - <span class="n">prob_dict</span> <span class="o">=</span> <span class="n">calc_total_probdens</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">)</span> - - <span class="c1"># Some info</span> - <span class="k">if</span> <span class="n">multiplicity</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: M_1=</span><span class="si">{}</span><span class="s2"> q=N/A log10P=N/A (</span><span class="si">{}</span><span class="s2">): </span><span class="si">{}</span><span class="s2"> -> </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> - <span class="nb">len</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> - <span class="nb">str</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"total_probdens"</span><span class="p">],</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">elif</span> <span class="n">multiplicity</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: M_1=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2"> log10P=</span><span class="si">{}</span><span class="s2"> ecc=</span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2">): </span><span class="si">{}</span><span class="s2"> -> </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> <span class="o">/</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> - <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]),</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> - <span class="nb">len</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> - <span class="nb">str</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"total_probdens"</span><span class="p">],</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">elif</span> <span class="n">multiplicity</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: M_1=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2"> log10P=</span><span class="si">{}</span><span class="s2"> ecc=</span><span class="si">{}</span><span class="s2"> M_3=</span><span class="si">{}</span><span class="s2"> log10P2=</span><span class="si">{}</span><span class="s2"> ecc2=</span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2">): </span><span class="si">{}</span><span class="s2"> -> </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> <span class="o">/</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> - <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]),</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">],</span> - <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]),</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"ecc2"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> - <span class="nb">len</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> - <span class="nb">str</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"total_probdens"</span><span class="p">],</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">elif</span> <span class="n">multiplicity</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Moe_di_Stefano_2017_pdf: M_1=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2"> log10P=</span><span class="si">{}</span><span class="s2"> ecc=</span><span class="si">{}</span><span class="s2"> M_3=</span><span class="si">{}</span><span class="s2"> log10P2=</span><span class="si">{}</span><span class="s2"> ecc2=</span><span class="si">{}</span><span class="s2"> M_4=</span><span class="si">{}</span><span class="s2"> log10P3=</span><span class="si">{}</span><span class="s2"> ecc3=</span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2">) : </span><span class="si">{}</span><span class="s2"> -> </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> <span class="o">/</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> - <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]),</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">],</span> - <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]),</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"ecc2"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"M_4"</span><span class="p">],</span> - <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P3"</span><span class="p">]),</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"ecc3"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc3"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> - <span class="nb">len</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> - <span class="nb">str</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> - <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"total_probdens"</span><span class="p">],</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">return</span> <span class="n">prob_dict</span></div> -</pre></div> - - </div> - - </div> - <footer> - - - <hr/> - - <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> - </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. -<br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. -<br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. - - - -</footer> - - </div> - </div> - - </section> - - </div> - - - - <script type="text/javascript"> - jQuery(function () { - SphinxRtdTheme.Navigation.enable(true); - }); - </script> - - - - - - -</body> -</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/ensemble.html b/docs/build/html/_modules/binarycpython/utils/ensemble.html new file mode 100644 index 0000000000000000000000000000000000000000..aa9a9d83d452f20732959628da330c2c5fae6f02 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/ensemble.html @@ -0,0 +1,498 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.ensemble — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> + <script src="../../../_static/jquery.js"></script> + <script src="../../../_static/underscore.js"></script> + <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../genindex.html" /> + <link rel="search" title="Search" href="../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../index.html">Module code</a> »</li> + <li>binarycpython.utils.ensemble</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.ensemble</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">Module containing functions to interact with binary_c's</span> +<span class="sd">population ensemble using the binarycpython package</span> + +<span class="sd">"""</span> + +<span class="kn">import</span> <span class="nn">sys</span> +<span class="kn">import</span> <span class="nn">bz2</span> +<span class="kn">import</span> <span class="nn">time</span> +<span class="kn">import</span> <span class="nn">json</span> +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Any</span> +<span class="kn">import</span> <span class="nn">gc</span> +<span class="kn">import</span> <span class="nn">gzip</span> +<span class="kn">import</span> <span class="nn">inspect</span> + +<span class="kn">from</span> <span class="nn">halo</span> <span class="kn">import</span> <span class="n">Halo</span> +<span class="kn">import</span> <span class="nn">msgpack</span> +<span class="kn">import</span> <span class="nn">py_rinterpolate</span> + +<span class="kn">import</span> <span class="nn">simplejson</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.dicts</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">keys_to_floats</span><span class="p">,</span> + <span class="n">recursive_change_key_to_float</span><span class="p">,</span> + <span class="n">custom_sort_dict</span><span class="p">,</span> + <span class="n">recursive_change_key_to_string</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">verbose_print</span> + + +<div class="viewcode-block" id="ensemble_setting"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.ensemble_setting">[docs]</a><span class="k">def</span> <span class="nf">ensemble_setting</span><span class="p">(</span><span class="n">ensemble</span><span class="p">,</span> <span class="n">parameter_name</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to get the setting of parameter_name in the given ensemble, or return the default value.</span> +<span class="sd"> """</span> + <span class="n">value</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">try</span><span class="p">:</span> + <span class="n">value</span> <span class="o">=</span> <span class="n">ensemble</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"settings"</span><span class="p">][</span><span class="s2">"population_settings"</span><span class="p">][</span><span class="s2">"bse_options"</span><span class="p">][</span> + <span class="n">parameter_name</span> + <span class="p">]</span> + <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span> + <span class="n">value</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">value</span> <span class="o">=</span> <span class="n">ensemble</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"settings"</span><span class="p">][</span><span class="s2">"population_settings"</span><span class="p">][</span> + <span class="s2">"grid_options"</span> + <span class="p">][</span><span class="n">parameter_name</span><span class="p">]</span> + <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span> + <span class="n">value</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">value</span> <span class="o">=</span> <span class="n">ensemble</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"settings"</span><span class="p">][</span><span class="s2">"population_settings"</span><span class="p">][</span> + <span class="s2">"custom_options"</span> + <span class="p">][</span><span class="n">parameter_name</span><span class="p">]</span> + <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span> + <span class="n">value</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="c1"># not found, try the default</span> + <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">value</span> <span class="o">=</span> <span class="n">ensemble</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"settings"</span><span class="p">][</span><span class="s2">"binary_c_defaults"</span><span class="p">][</span> + <span class="n">parameter_name</span> + <span class="p">]</span> + <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span> + <span class="n">value</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">return</span> <span class="n">value</span></div> + + +<div class="viewcode-block" id="open_ensemble"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.open_ensemble">[docs]</a><span class="k">def</span> <span class="nf">open_ensemble</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to open an ensemble at filename for reading and decompression if required.</span> +<span class="sd"> """</span> + + <span class="n">compression</span> <span class="o">=</span> <span class="n">ensemble_compression</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> + <span class="k">if</span> <span class="n">ensemble_file_type</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"msgpack"</span><span class="p">:</span> + <span class="n">flags</span> <span class="o">=</span> <span class="s2">"rb"</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">flags</span> <span class="o">=</span> <span class="s2">"rt"</span> + <span class="k">if</span> <span class="n">compression</span> <span class="o">==</span> <span class="s2">"bzip2"</span><span class="p">:</span> + <span class="n">file_object</span> <span class="o">=</span> <span class="n">bz2</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">flags</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">)</span> + <span class="k">elif</span> <span class="n">compression</span> <span class="o">==</span> <span class="s2">"gzip"</span><span class="p">:</span> + <span class="n">file_object</span> <span class="o">=</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">flags</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">file_object</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">flags</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">)</span> + <span class="k">return</span> <span class="n">file_object</span></div> + + +<div class="viewcode-block" id="ensemble_compression"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.ensemble_compression">[docs]</a><span class="k">def</span> <span class="nf">ensemble_compression</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Return the compression type of the ensemble file, based on its filename extension.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">filename</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".bz2"</span><span class="p">):</span> + <span class="k">return</span> <span class="s2">"bzip2"</span> + <span class="k">if</span> <span class="n">filename</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".gz"</span><span class="p">):</span> + <span class="k">return</span> <span class="s2">"gzip"</span> + <span class="k">return</span> <span class="kc">None</span></div> + + +<div class="viewcode-block" id="ensemble_file_type"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.ensemble_file_type">[docs]</a><span class="k">def</span> <span class="nf">ensemble_file_type</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Returns the file type of an ensemble file.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="s2">".json"</span> <span class="ow">in</span> <span class="n">filename</span><span class="p">:</span> + <span class="n">filetype</span> <span class="o">=</span> <span class="s2">"JSON"</span> + <span class="k">elif</span> <span class="s2">".msgpack"</span> <span class="ow">in</span> <span class="n">filename</span><span class="p">:</span> + <span class="n">filetype</span> <span class="o">=</span> <span class="s2">"msgpack"</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">filetype</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">return</span> <span class="n">filetype</span></div> + + +<div class="viewcode-block" id="load_ensemble"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.load_ensemble">[docs]</a><span class="k">def</span> <span class="nf">load_ensemble</span><span class="p">(</span> + <span class="n">filename</span><span class="p">,</span> <span class="n">convert_float_keys</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">select_keys</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">timing</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">flush</span><span class="o">=</span><span class="kc">False</span> +<span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to load an ensemeble file, even if it is compressed,</span> +<span class="sd"> and return its contents to as a Python dictionary.</span> + +<span class="sd"> Args:</span> +<span class="sd"> convert_float_keys : if True, converts strings to floats.</span> +<span class="sd"> select_keys : a list of keys to be selected from the ensemble.</span> +<span class="sd"> """</span> + + <span class="c1"># open the file</span> + + <span class="c1"># load with some info to the terminal</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Loading JSON..."</span><span class="p">,</span> <span class="n">flush</span><span class="o">=</span><span class="n">flush</span><span class="p">)</span> + + <span class="c1"># open the ensemble and get the file type</span> + <span class="n">file_object</span> <span class="o">=</span> <span class="n">open_ensemble</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> + <span class="n">filetype</span> <span class="o">=</span> <span class="n">ensemble_file_type</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">filetype</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">file_object</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Unknown filetype : your ensemble should be saved either as JSON or msgpack data."</span><span class="p">,</span> + <span class="n">flush</span><span class="o">=</span><span class="n">flush</span><span class="p">,</span> + <span class="p">)</span> + <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span> + + <span class="k">with</span> <span class="n">Halo</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">"Loading"</span><span class="p">,</span> <span class="n">interval</span><span class="o">=</span><span class="mi">250</span><span class="p">,</span> <span class="n">spinner</span><span class="o">=</span><span class="s2">"moon"</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s2">"yellow"</span><span class="p">):</span> + <span class="n">tstart</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> + <span class="n">_loaded</span> <span class="o">=</span> <span class="kc">False</span> + + <span class="k">def</span> <span class="nf">_hook</span><span class="p">(</span><span class="n">obj</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Hook to load ensemble</span> +<span class="sd"> """</span> + + <span class="k">nonlocal</span> <span class="n">_loaded</span> + <span class="k">if</span> <span class="n">_loaded</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span> + <span class="n">_loaded</span> <span class="o">=</span> <span class="kc">True</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">Loaded </span><span class="si">{}</span><span class="s2"> data, now putting in a dictionary"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">filetype</span><span class="p">),</span> + <span class="n">flush</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">return</span> <span class="n">obj</span> + + <span class="k">if</span> <span class="n">filetype</span> <span class="o">==</span> <span class="s2">"JSON"</span><span class="p">:</span> + <span class="c1"># orjson promises to be fast, but it doesn't seem to be</span> + <span class="c1"># and fails on "Infinity"... oops</span> + <span class="c1"># data = orjson.loads(file_object.read())</span> + + <span class="c1"># simplejson is faster than standard json and "just works"</span> + <span class="c1"># on the big Moe set in 37s</span> + <span class="n">data</span> <span class="o">=</span> <span class="n">simplejson</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">file_object</span><span class="p">,</span> <span class="n">object_hook</span><span class="o">=</span><span class="n">_hook</span><span class="p">)</span> + <span class="n">file_object</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + + <span class="c1"># standard json module</span> + <span class="c1"># on the big Moe set takes 42s</span> + <span class="c1"># data = json.load(file_object,</span> + <span class="c1"># object_hook=_hook)</span> + <span class="k">elif</span> <span class="n">filetype</span> <span class="o">==</span> <span class="s2">"msgpack"</span><span class="p">:</span> + <span class="n">data</span> <span class="o">=</span> <span class="n">msgpack</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">file_object</span><span class="p">,</span> <span class="n">object_hook</span><span class="o">=</span><span class="n">_hook</span><span class="p">)</span> + <span class="n">file_object</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + + <span class="k">if</span> <span class="n">timing</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n\n</span><span class="s2">Took </span><span class="si">{}</span><span class="s2"> s to load the data</span><span class="se">\n\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">-</span> <span class="n">tstart</span><span class="p">),</span> + <span class="n">flush</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># strip non-selected keys, if a list is given in select_keys</span> + <span class="k">if</span> <span class="n">select_keys</span><span class="p">:</span> + <span class="n">keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">"ensemble"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">select_keys</span><span class="p">:</span> + <span class="k">del</span> <span class="n">data</span><span class="p">[</span><span class="s2">"ensemble"</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> + + <span class="c1"># perhaps convert floats?</span> + <span class="n">tstart</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> + <span class="k">if</span> <span class="n">convert_float_keys</span><span class="p">:</span> + <span class="c1"># timings are for 100 iterations on the big Moe data set</span> + <span class="c1"># data = format_ensemble_results(data) # 213s</span> + <span class="c1"># data = recursive_change_key_to_float(data) # 61s</span> + <span class="n">data</span> <span class="o">=</span> <span class="n">keys_to_floats</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="c1"># 6.94s</span> + + <span class="k">if</span> <span class="n">timing</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n\n</span><span class="s2">Took </span><span class="si">{}</span><span class="s2"> s to convert floats</span><span class="se">\n\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">-</span> <span class="n">tstart</span><span class="p">),</span> + <span class="n">flush</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># return data</span> + <span class="k">return</span> <span class="n">data</span></div> + + +<span class="c1">#####</span> +<div class="viewcode-block" id="extract_ensemble_json_from_string"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.extract_ensemble_json_from_string">[docs]</a><span class="k">def</span> <span class="nf">extract_ensemble_json_from_string</span><span class="p">(</span><span class="n">binary_c_output</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to extract the ensemble_json information from a raw binary_c output string</span> + +<span class="sd"> Args:</span> +<span class="sd"> binary_c_output: raw binary_c output string</span> + +<span class="sd"> Returns:</span> +<span class="sd"> JSON dictionary with the parsed ENSEMBLE_JSON data</span> +<span class="sd"> """</span> + + <span class="n">json_dict</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">try</span><span class="p">:</span> + <span class="c1"># If there is no output just return an empty dict:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">binary_c_output</span><span class="p">:</span> + <span class="n">json_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">return</span> <span class="n">json_dict</span> + + <span class="n">ensemble_jsons_strings</span> <span class="o">=</span> <span class="p">[</span> + <span class="n">line</span> + <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">binary_c_output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span> + <span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"ENSEMBLE_JSON"</span><span class="p">)</span> + <span class="p">]</span> + + <span class="n">json_dict</span> <span class="o">=</span> <span class="n">handle_ensemble_string_to_json</span><span class="p">(</span> + <span class="n">ensemble_jsons_strings</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="nb">len</span><span class="p">(</span><span class="s2">"ENSEMBLE_JSON "</span><span class="p">)</span> <span class="p">:]</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">ensemble_jsons_strings</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Warning: There is more than one line starting with ENSEMBLE_JSON. Taking the first, but you should check this out."</span><span class="p">,</span> + <span class="mi">1</span><span class="p">,</span> + <span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Error: Couldn't extract the ensemble information from the output string"</span><span class="p">,</span> + <span class="mi">0</span><span class="p">,</span> + <span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">return</span> <span class="n">json_dict</span></div> + + +<div class="viewcode-block" id="handle_ensemble_string_to_json"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.handle_ensemble_string_to_json">[docs]</a><span class="k">def</span> <span class="nf">handle_ensemble_string_to_json</span><span class="p">(</span><span class="n">raw_output</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that deals with the raw output of the ensemble and</span> +<span class="sd"> creates a working JSON dictionary out of it.</span> + +<span class="sd"> Having this wrapper makes it easy to</span> + +<span class="sd"> Args:</span> +<span class="sd"> raw_output: raw output of the ensemble dump by binary_c</span> + +<span class="sd"> Returns:</span> +<span class="sd"> json.loads(raw_output, cls=BinarycDecoder)</span> + +<span class="sd"> """</span> + <span class="k">return</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">raw_output</span><span class="p">,</span> <span class="bp">cls</span><span class="o">=</span><span class="n">BinarycDecoder</span><span class="p">)</span></div> + + +<div class="viewcode-block" id="binaryc_json_serializer"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.binaryc_json_serializer">[docs]</a><span class="k">def</span> <span class="nf">binaryc_json_serializer</span><span class="p">(</span><span class="n">obj</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Any</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Custom serialiser for binary_c to use when functions are present in the dictionary</span> +<span class="sd"> that we want to export.</span> + +<span class="sd"> Function objects will be turned into str representations of themselves</span> + +<span class="sd"> Args:</span> +<span class="sd"> obj: The object that might not be serialisable</span> + +<span class="sd"> Returns:</span> +<span class="sd"> Either string representation of object if the object is a function, or the object itself</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">inspect</span><span class="o">.</span><span class="n">isfunction</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">):</span> + <span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">string_version</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> + <span class="k">return</span> <span class="n">string_version</span> + <span class="k">except</span><span class="p">:</span> + <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span> + <span class="s2">"Unserializable object </span><span class="si">{}</span><span class="s2"> of type </span><span class="si">{}</span><span class="s2">. Attempted to convert to string but that failed."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">obj</span><span class="p">))</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="BinarycDecoder"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.BinarycDecoder">[docs]</a><span class="k">class</span> <span class="nc">BinarycDecoder</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">JSONDecoder</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Custom decoder to transform the numbers that are strings to actual floats</span> +<span class="sd"> """</span> + +<div class="viewcode-block" id="BinarycDecoder.decode"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.BinarycDecoder.decode">[docs]</a> <span class="k">def</span> <span class="nf">decode</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">s</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Entry point function for decoding</span> +<span class="sd"> """</span> + + <span class="n">result</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span> + <span class="n">s</span> + <span class="p">)</span> <span class="c1"># result = super(Decoder, self).decode(s) for Python 2.x</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_decode</span><span class="p">(</span><span class="n">result</span><span class="p">)</span></div> + + <span class="k">def</span> <span class="nf">_decode</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">o</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Depending on the type of object is will determine whether to loop over the elements,</span> +<span class="sd"> or try to change the type of the object from string to float</span> + +<span class="sd"> The try except might be a somewhat rough solution but it catches all cases.</span> +<span class="sd"> """</span> + + <span class="c1"># Check if we can turn it into a float</span> + <span class="c1"># if isinstance(o, str) or isinstance(o, unicode):</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">o</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> + <span class="k">try</span><span class="p">:</span> + <span class="k">return</span> <span class="nb">float</span><span class="p">(</span><span class="n">o</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + <span class="k">return</span> <span class="n">o</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">o</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> + <span class="k">return</span> <span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_decode</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">o</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> + <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">o</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> + <span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_decode</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">o</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">return</span> <span class="n">o</span></div> + + +<div class="viewcode-block" id="BinarycEncoder"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.BinarycEncoder">[docs]</a><span class="k">class</span> <span class="nc">BinarycEncoder</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">JSONEncoder</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Encoding class function to attempt to convert things to strings.</span> +<span class="sd"> """</span> + +<div class="viewcode-block" id="BinarycEncoder.default"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.BinarycEncoder.default">[docs]</a> <span class="k">def</span> <span class="nf">default</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">o</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Converting function. Well, could be more precise. look at the JSON module</span> +<span class="sd"> """</span> + + <span class="k">try</span><span class="p">:</span> + <span class="n">str_repr</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">o</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span> + <span class="k">pass</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">return</span> <span class="n">str_repr</span> + + <span class="c1"># Let the base class default method raise the TypeError</span> + <span class="k">return</span> <span class="n">json</span><span class="o">.</span><span class="n">JSONEncoder</span><span class="o">.</span><span class="n">default</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">o</span><span class="p">)</span></div></div> + + +<div class="viewcode-block" id="format_ensemble_results"><a class="viewcode-back" href="../../../ensemble.html#binarycpython.utils.ensemble.format_ensemble_results">[docs]</a><span class="k">def</span> <span class="nf">format_ensemble_results</span><span class="p">(</span><span class="n">ensemble_dictionary</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to handle all the steps of formatting the ensemble output again.</span> + +<span class="sd"> Input:</span> +<span class="sd"> ensemble_dictionary: dictionary containing all the ensemble results</span> +<span class="sd"> """</span> + + <span class="n">original_ensemble_results</span> <span class="o">=</span> <span class="n">ensemble_dictionary</span> + + <span class="n">float_format_ensemble_results</span> <span class="o">=</span> <span class="n">recursive_change_key_to_float</span><span class="p">(</span> + <span class="n">original_ensemble_results</span> + <span class="p">)</span> + <span class="k">del</span> <span class="n">original_ensemble_results</span> + <span class="n">gc</span><span class="o">.</span><span class="n">collect</span><span class="p">()</span> + + <span class="c1"># Then sort the dictionary</span> + <span class="n">sorted_ensemble_results</span> <span class="o">=</span> <span class="n">custom_sort_dict</span><span class="p">(</span><span class="n">float_format_ensemble_results</span><span class="p">)</span> + <span class="k">del</span> <span class="n">float_format_ensemble_results</span> + <span class="n">gc</span><span class="o">.</span><span class="n">collect</span><span class="p">()</span> + + <span class="c1"># Then Change the keys back to a string but with a %g format.</span> + <span class="n">reformatted_ensemble_results</span> <span class="o">=</span> <span class="n">recursive_change_key_to_string</span><span class="p">(</span> + <span class="n">sorted_ensemble_results</span> + <span class="p">)</span> + <span class="k">del</span> <span class="n">sorted_ensemble_results</span> + <span class="n">gc</span><span class="o">.</span><span class="n">collect</span><span class="p">()</span> + + <span class="c1"># Put back in the dictionary</span> + <span class="k">return</span> <span class="n">reformatted_ensemble_results</span></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/functions.html b/docs/build/html/_modules/binarycpython/utils/functions.html index 746c546e22a83631d90a67fce6803e01970025de..e11289f1e5d36cf0b583da7e1824e2dff638c841 100644 --- a/docs/build/html/_modules/binarycpython/utils/functions.html +++ b/docs/build/html/_modules/binarycpython/utils/functions.html @@ -1,68 +1,33 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>binarycpython.utils.functions — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - - - <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script> <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> <script src="../../../_static/jquery.js"></script> <script src="../../../_static/underscore.js"></script> + <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../../../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="../../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <script src="../../../_static/js/theme.js"></script> <link rel="index" title="Index" href="../../../genindex.html" /> <link rel="search" title="Search" href="../../../search.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../../../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -70,17 +35,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> @@ -92,66 +47,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../../../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../../../index.html">Docs</a> »</li> - + <li><a href="../../../index.html" class="icon icon-home"></a> »</li> <li><a href="../../index.html">Module code</a> »</li> - <li>binarycpython.utils.functions</li> - - <li class="wy-breadcrumbs-aside"> - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <h1>Source code for binarycpython.utils.functions</h1><div class="highlight"><pre> <span></span><span class="sd">"""</span> <span class="sd">Module containing most of the utility functions for the binarycpython package</span> @@ -163,52 +82,64 @@ <span class="sd"> - TODO: change all prints to verbose_prints</span> <span class="sd">"""</span> - -<span class="kn">import</span> <span class="nn">bz2</span> -<span class="kn">import</span> <span class="nn">collections</span> -<span class="kn">from</span> <span class="nn">colorama</span> <span class="k">import</span> <span class="n">Fore</span><span class="p">,</span> <span class="n">Back</span><span class="p">,</span> <span class="n">Style</span> -<span class="kn">import</span> <span class="nn">copy</span> -<span class="kn">import</span> <span class="nn">datetime</span> <span class="k">as</span> <span class="nn">dt</span> -<span class="kn">import</span> <span class="nn">gc</span> -<span class="kn">import</span> <span class="nn">gzip</span> -<span class="kn">from</span> <span class="nn">halo</span> <span class="k">import</span> <span class="n">Halo</span> -<span class="kn">import</span> <span class="nn">h5py</span> -<span class="kn">import</span> <span class="nn">humanize</span> -<span class="kn">import</span> <span class="nn">inspect</span> -<span class="kn">from</span> <span class="nn">io</span> <span class="k">import</span> <span class="n">StringIO</span> -<span class="kn">import</span> <span class="nn">json</span> -<span class="kn">import</span> <span class="nn">msgpack</span> -<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> <span class="kn">import</span> <span class="nn">os</span> -<span class="kn">import</span> <span class="nn">psutil</span> -<span class="kn">import</span> <span class="nn">py_rinterpolate</span> -<span class="kn">import</span> <span class="nn">re</span> -<span class="kn">import</span> <span class="nn">resource</span> <span class="kn">import</span> <span class="nn">sys</span> -<span class="kn">import</span> <span class="nn">subprocess</span> -<span class="kn">import</span> <span class="nn">tempfile</span> <span class="kn">import</span> <span class="nn">time</span> +<span class="kn">import</span> <span class="nn">json</span> +<span class="kn">import</span> <span class="nn">datetime</span> +<span class="kn">import</span> <span class="nn">collections</span> +<span class="kn">import</span> <span class="nn">resource</span> +<span class="kn">import</span> <span class="nn">tempfile</span> +<span class="kn">import</span> <span class="nn">subprocess</span> <span class="kn">import</span> <span class="nn">types</span> -<span class="kn">from</span> <span class="nn">typing</span> <span class="k">import</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Any</span> - -<span class="kn">import</span> <span class="nn">simplejson</span> -<span class="c1"># import orjson</span> +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span> +<span class="kn">from</span> <span class="nn">io</span> <span class="kn">import</span> <span class="n">StringIO</span> -<span class="kn">import</span> <span class="nn">astropy.units</span> <span class="k">as</span> <span class="nn">u</span> -<span class="kn">import</span> <span class="nn">binarycpython.utils.moe_di_stefano_2017_data</span> <span class="k">as</span> <span class="nn">moe_di_stefano_2017_data</span> - -<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="k">import</span> <span class="n">_binary_c_bindings</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.dicts</span> <span class="k">import</span> <span class="n">filter_dict</span><span class="p">,</span> <span class="n">filter_dict_through_values</span> +<span class="kn">import</span> <span class="nn">h5py</span> +<span class="kn">import</span> <span class="nn">humanize</span> +<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> +<span class="kn">import</span> <span class="nn">psutil</span> +<span class="kn">from</span> <span class="nn">colorama</span> <span class="kn">import</span> <span class="n">Fore</span><span class="p">,</span> <span class="n">Back</span><span class="p">,</span> <span class="n">Style</span> +<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">_binary_c_bindings</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.dicts</span> <span class="kn">import</span> <span class="n">filter_dict_through_values</span> <span class="c1">########################################################</span> <span class="c1"># Unsorted</span> <span class="c1">########################################################</span> +<div class="viewcode-block" id="now"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.now">[docs]</a><span class="k">def</span> <span class="nf">now</span><span class="p">(</span><span class="n">now_object</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">custom_format</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> convenience function to return a string of the current time, using the format ``%m/%d/%Y %H:%M:%S``</span> + +<span class="sd"> Args:</span> +<span class="sd"> style : if "nospace" then return the date/time with the format ``%Y%m%d_%H%M%S``, else use format ``%m/%d/%Y %H:%M:%S``</span> + +<span class="sd"> custom_format: if set, uses this as a format rather than whatever is set by default or in the style variable</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">now_object</span><span class="p">:</span> + <span class="n">now_object</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">custom_format</span><span class="p">:</span> + <span class="k">if</span> <span class="n">style</span> <span class="o">==</span> <span class="s2">"nospace"</span><span class="p">:</span> + <span class="c1"># special case</span> + <span class="n">date_format</span> <span class="o">=</span> <span class="s2">"%Y%m</span><span class="si">%d</span><span class="s2">_%H%M%S"</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># our default</span> + <span class="n">date_format</span> <span class="o">=</span> <span class="s2">"%m/</span><span class="si">%d</span><span class="s2">/%Y %H:%M:%S"</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">date_format</span> <span class="o">=</span> <span class="n">custom_format</span> + + <span class="k">return</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="n">now_object</span><span class="p">,</span> <span class="n">date_format</span><span class="p">)</span></div> + + <div class="viewcode-block" id="format_number"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.format_number">[docs]</a><span class="k">def</span> <span class="nf">format_number</span><span class="p">(</span><span class="n">number</span><span class="p">):</span> - <span class="c1"># compact number formatter</span> + <span class="sd">"""</span> +<span class="sd"> Function to take a number, express format it in scientific notation, and remove the trailing 0 if the exponent is 0</span> +<span class="sd"> """</span> <span class="n">string</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{number:.2g}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">number</span><span class="o">=</span><span class="n">number</span><span class="p">)</span> <span class="n">string</span> <span class="o">=</span> <span class="n">string</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"e+0"</span><span class="p">,</span> <span class="s2">"e+"</span><span class="p">)</span> @@ -222,12 +153,7 @@ <span class="sd"> Function to check whether the script is running from a shell</span> <span class="sd"> """</span> - <span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">stdin</span> <span class="ow">and</span> <span class="n">sys</span><span class="o">.</span><span class="n">stdin</span><span class="o">.</span><span class="n">isatty</span><span class="p">():</span> - <span class="n">in_shell</span> <span class="o">=</span> <span class="kc">True</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">in_shell</span> <span class="o">=</span> <span class="kc">False</span> - - <span class="k">return</span> <span class="n">in_shell</span></div> + <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdin</span> <span class="ow">and</span> <span class="n">sys</span><span class="o">.</span><span class="n">stdin</span><span class="o">.</span><span class="n">isatty</span><span class="p">())</span></div> <div class="viewcode-block" id="timedelta"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.timedelta">[docs]</a><span class="k">def</span> <span class="nf">timedelta</span><span class="p">(</span><span class="n">delta</span><span class="p">):</span> @@ -237,7 +163,7 @@ <span class="sd"> """</span> <span class="c1"># currently use the humanize module to do this</span> <span class="n">t</span> <span class="o">=</span> <span class="n">humanize</span><span class="o">.</span><span class="n">time</span><span class="o">.</span><span class="n">precisedelta</span><span class="p">(</span> - <span class="n">dt</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">seconds</span><span class="o">=</span><span class="n">delta</span><span class="p">),</span> + <span class="n">datetime</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">seconds</span><span class="o">=</span><span class="n">delta</span><span class="p">),</span> <span class="nb">format</span><span class="o">=</span><span class="s2">"</span><span class="si">%0.2f</span><span class="s2">"</span><span class="p">,</span> <span class="n">minimum_unit</span><span class="o">=</span><span class="s2">"milliseconds"</span><span class="p">,</span> <span class="n">suppress</span><span class="o">=</span><span class="p">[</span><span class="s2">"milliseconds"</span><span class="p">],</span> @@ -255,6 +181,10 @@ <div class="viewcode-block" id="get_ANSI_colours"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.get_ANSI_colours">[docs]</a><span class="k">def</span> <span class="nf">get_ANSI_colours</span><span class="p">():</span> + <span class="sd">"""</span> +<span class="sd"> Function that returns a dictionary with text-colors in ANSI formatting</span> +<span class="sd"> """</span> + <span class="c1"># ANSI colours dictionary</span> <span class="n">foreground_colours</span> <span class="o">=</span> <span class="p">{</span> <span class="s2">"red"</span><span class="p">:</span> <span class="n">Fore</span><span class="o">.</span><span class="n">RED</span><span class="p">,</span> @@ -265,6 +195,7 @@ <span class="s2">"magenta"</span><span class="p">:</span> <span class="n">Fore</span><span class="o">.</span><span class="n">MAGENTA</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">:</span> <span class="n">Fore</span><span class="o">.</span><span class="n">WHITE</span><span class="p">,</span> <span class="s2">"black"</span><span class="p">:</span> <span class="n">Fore</span><span class="o">.</span><span class="n">BLACK</span><span class="p">,</span> + <span class="s2">"bold"</span><span class="p">:</span> <span class="n">Style</span><span class="o">.</span><span class="n">BRIGHT</span><span class="p">,</span> <span class="p">}</span> <span class="n">background_colours</span> <span class="o">=</span> <span class="p">{</span> @@ -281,18 +212,19 @@ <span class="n">default_style</span> <span class="o">=</span> <span class="n">Style</span><span class="o">.</span><span class="n">BRIGHT</span> <span class="n">colours</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">foreground_colours</span><span class="p">:</span> - <span class="n">colours</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="o">=</span> <span class="n">default_style</span> <span class="o">+</span> <span class="n">foreground_colours</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> - <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">background_colours</span><span class="p">:</span> - <span class="n">colours</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="s2">" on "</span> <span class="o">+</span> <span class="n">d</span><span class="p">]</span> <span class="o">=</span> <span class="n">foreground_colours</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="o">+</span> <span class="n">background_colours</span><span class="p">[</span><span class="n">d</span><span class="p">]</span> + <span class="k">for</span> <span class="n">c</span><span class="p">,</span> <span class="n">foreground_colour</span> <span class="ow">in</span> <span class="n">foreground_colours</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> + <span class="n">colours</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="o">=</span> <span class="n">default_style</span> <span class="o">+</span> <span class="n">foreground_colour</span> + <span class="k">for</span> <span class="n">d</span><span class="p">,</span> <span class="n">background_colour</span> <span class="ow">in</span> <span class="n">background_colours</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> + <span class="n">colours</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="s2">" on "</span> <span class="o">+</span> <span class="n">d</span><span class="p">]</span> <span class="o">=</span> <span class="n">foreground_colour</span> <span class="o">+</span> <span class="n">background_colour</span> <span class="n">colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">]</span> <span class="o">=</span> <span class="n">Style</span><span class="o">.</span><span class="n">RESET_ALL</span> - <span class="k">return</span> <span class="n">colours</span></div> <div class="viewcode-block" id="mem_use"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.mem_use">[docs]</a><span class="k">def</span> <span class="nf">mem_use</span><span class="p">():</span> <span class="sd">"""</span> -<span class="sd"> Return current process memory use in MB. (Takes no arguments) Note: this is per-thread only.</span> +<span class="sd"> Return current process memory use in MB. (Takes no arguments)</span> + +<span class="sd"> Note: this is per-thread only.</span> <span class="sd"> """</span> <span class="k">return</span> <span class="n">resource</span><span class="o">.</span><span class="n">getrusage</span><span class="p">(</span><span class="n">resource</span><span class="o">.</span><span class="n">RUSAGE_SELF</span><span class="p">)</span><span class="o">.</span><span class="n">ru_maxrss</span> <span class="o">/</span> <span class="mf">1024.0</span></div> @@ -300,11 +232,19 @@ <div class="viewcode-block" id="trem"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.trem">[docs]</a><span class="k">def</span> <span class="nf">trem</span><span class="p">(</span><span class="n">dt</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">dn</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span> <span class="sd">"""</span> -<span class="sd"> Estimate time remaining (seconds) given a differential time and count (i.e. progress = $count/$n). $dt is the time since the last call, $count is the current progress count, $dn is the number run since the last call, and $n is the total number required.</span> +<span class="sd"> Estimate time remaining (seconds) given a differential time and count (i.e. ``progress = count/n``).</span> + +<span class="sd"> Args:</span> +<span class="sd"> dt: is the time since the last call.</span> +<span class="sd"> count: is the current progress count.</span> +<span class="sd"> dn: is the number run since the last call.</span> +<span class="sd"> n: is the total number required.</span> <span class="sd"> """</span> + <span class="n">tpr</span> <span class="o">=</span> <span class="n">dt</span> <span class="o">/</span> <span class="nb">max</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">dn</span><span class="p">)</span> <span class="n">etasecs</span> <span class="o">=</span> <span class="n">tpr</span> <span class="o">*</span> <span class="p">(</span><span class="n">n</span> <span class="o">-</span> <span class="n">count</span><span class="p">)</span> <span class="p">(</span><span class="n">eta</span><span class="p">,</span> <span class="n">units</span><span class="p">)</span> <span class="o">=</span> <span class="n">conv_time_units</span><span class="p">(</span><span class="n">etasecs</span><span class="p">)</span> + <span class="k">return</span> <span class="p">(</span><span class="n">eta</span><span class="p">,</span> <span class="n">units</span><span class="p">,</span> <span class="n">tpr</span><span class="p">,</span> <span class="n">etasecs</span><span class="p">)</span></div> @@ -325,9 +265,16 @@ <div class="viewcode-block" id="bin_data"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.bin_data">[docs]</a><span class="k">def</span> <span class="nf">bin_data</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">binwidth</span><span class="p">):</span> <span class="sd">"""</span> -<span class="sd"> Function that bins the data</span> +<span class="sd"> Function that bins the data using the absolute value of binwidth using the following formula::</span> + +<span class="sd"> ((0.5 if value > 0.0 else -0.5) + int(value / abs(binwidth))) * abs(binwidth)</span> -<span class="sd"> Uses the absolute value of binwidth</span> +<span class="sd"> Args:</span> +<span class="sd"> value: value that we want to bin</span> +<span class="sd"> binwidth: width of the binning</span> + +<span class="sd"> Returns:</span> +<span class="sd"> binned value</span> <span class="sd"> """</span> <span class="k">return</span> <span class="p">((</span><span class="mf">0.5</span> <span class="k">if</span> <span class="n">value</span> <span class="o">></span> <span class="mf">0.0</span> <span class="k">else</span> <span class="o">-</span><span class="mf">0.5</span><span class="p">)</span> <span class="o">+</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span> <span class="o">/</span> <span class="nb">abs</span><span class="p">(</span><span class="n">binwidth</span><span class="p">)))</span> <span class="o">*</span> <span class="nb">abs</span><span class="p">(</span><span class="n">binwidth</span><span class="p">)</span></div> @@ -359,6 +306,7 @@ <span class="n">obj_id</span> <span class="o">=</span> <span class="nb">id</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> <span class="k">if</span> <span class="n">obj_id</span> <span class="ow">in</span> <span class="n">seen</span><span class="p">:</span> <span class="k">return</span> <span class="mi">0</span> + <span class="c1"># Important mark as seen *before* entering recursion to gracefully handle</span> <span class="c1"># self-referential objects</span> <span class="n">seen</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">obj_id</span><span class="p">)</span> @@ -372,69 +320,51 @@ <span class="k">return</span> <span class="n">size</span></div> -<div class="viewcode-block" id="get_moe_di_stefano_dataset"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.get_moe_di_stefano_dataset">[docs]</a><span class="k">def</span> <span class="nf">get_moe_di_stefano_dataset</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> +<div class="viewcode-block" id="imports"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.imports">[docs]</a><span class="k">def</span> <span class="nf">imports</span><span class="p">():</span> <span class="sd">"""</span> -<span class="sd"> Function to get the default Moe and di Stefano dataset or accept a user input.</span> - -<span class="sd"> Returns a dict containing the (JSON) data.</span> +<span class="sd"> Generator that generates the names of all the modules that are loaded in the globals</span> <span class="sd"> """</span> - <span class="n">json_data</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="nb">globals</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">val</span><span class="p">,</span> <span class="n">types</span><span class="o">.</span><span class="n">ModuleType</span><span class="p">):</span> + <span class="k">yield</span> <span class="n">val</span><span class="o">.</span><span class="vm">__name__</span></div> - <span class="k">if</span> <span class="s2">"JSON"</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> - <span class="c1"># use the JSON data passed in</span> - <span class="n">json_data</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"JSON"</span><span class="p">]</span> - <span class="k">elif</span> <span class="s2">"file"</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> - <span class="c1"># use the file passed in, if provided</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"file"</span><span class="p">]):</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"The provided 'file' Moe and de Stefano JSON file does not seem to exist at </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">options</span><span class="p">[</span><span class="s2">"file"</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> +<div class="viewcode-block" id="isfloat"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.isfloat">[docs]</a><span class="k">def</span> <span class="nf">isfloat</span><span class="p">(</span><span class="n">x</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">]):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return `True` if the "number" x, which could be a string, is an float, otherwise return `False`.</span> - <span class="k">raise</span> <span class="ne">ValueError</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="p">[</span><span class="s2">"file"</span><span class="p">]</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".json"</span><span class="p">):</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Provided filename is not a json file"</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> +<span class="sd"> Args:</span> +<span class="sd"> x: string float or int that we will attempt to convert to an `float` value.</span> +<span class="sd"> """</span> - <span class="k">else</span><span class="p">:</span> - <span class="c1"># Read input data and Clean up the data if there are white spaces around the keys</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"file"</span><span class="p">],</span> <span class="s2">"r"</span><span class="p">)</span> <span class="k">as</span> <span class="n">data_filehandle</span><span class="p">:</span> - <span class="n">datafile_data</span> <span class="o">=</span> <span class="n">data_filehandle</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> - <span class="n">datafile_data</span> <span class="o">=</span> <span class="n">datafile_data</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">'" '</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">)</span> - <span class="n">datafile_data</span> <span class="o">=</span> <span class="n">datafile_data</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">' "'</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">)</span> - <span class="n">datafile_data</span> <span class="o">=</span> <span class="n">datafile_data</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">' "'</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">)</span> - <span class="n">json_data</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">datafile_data</span><span class="p">)</span> - - <span class="k">if</span> <span class="ow">not</span> <span class="n">json_data</span><span class="p">:</span> - <span class="c1"># no JSON data or filename given, use the default 2017 dataset</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Using the default Moe and de Stefano 2017 datafile"</span><span class="p">,</span> - <span class="n">verbosity</span><span class="p">,</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - <span class="n">json_data</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">moe_di_stefano_2017_data</span><span class="o">.</span><span class="n">moe_di_stefano_2017_data</span><span class="p">)</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">_</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> + <span class="k">return</span> <span class="kc">True</span> + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + <span class="k">return</span> <span class="kc">False</span></div> - <span class="k">return</span> <span class="n">json_data</span></div> +<div class="viewcode-block" id="isint"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.isint">[docs]</a><span class="k">def</span> <span class="nf">isint</span><span class="p">(</span><span class="n">x</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">]):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return `True` if the "number" x, which could be a string, is an int, otherwise return `False`.</span> -<div class="viewcode-block" id="imports"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.imports">[docs]</a><span class="k">def</span> <span class="nf">imports</span><span class="p">():</span> - <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="nb">globals</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> - <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">val</span><span class="p">,</span> <span class="n">types</span><span class="o">.</span><span class="n">ModuleType</span><span class="p">):</span> - <span class="k">yield</span> <span class="n">val</span><span class="o">.</span><span class="vm">__name__</span></div> +<span class="sd"> Args:</span> +<span class="sd"> x: string float or int that we will attempt to convert to an `int` value.</span> +<span class="sd"> """</span> + + <span class="k">try</span><span class="p">:</span> + <span class="n">_</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> + <span class="k">return</span> <span class="kc">True</span> + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + <span class="k">return</span> <span class="kc">False</span></div> <div class="viewcode-block" id="convfloat"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.convfloat">[docs]</a><span class="k">def</span> <span class="nf">convfloat</span><span class="p">(</span><span class="n">x</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Convert scalar x to a float if we can, in which case return the float, otherwise just return x without changing it. Usually, x is a string, but could be anything that float() can handle without failure.</span> <span class="sd"> """</span> + <span class="k">try</span><span class="p">:</span> <span class="n">y</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">return</span> <span class="n">y</span> @@ -445,11 +375,13 @@ <div class="viewcode-block" id="datalinedict"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.datalinedict">[docs]</a><span class="k">def</span> <span class="nf">datalinedict</span><span class="p">(</span><span class="n">line</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">parameters</span><span class="p">:</span> <span class="nb">list</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Convert a line of data to a more convenient dictionary.</span> + <span class="sd"> Arguments:</span> <span class="sd"> line = a line of data as a string</span> <span class="sd"> parameters = a list of the parameter names</span> -<span class="sd"> Note: if the parameter is a floating point number, it will be converted to Python's float type.</span> +<span class="sd"> Note:</span> +<span class="sd"> If the parameter is a floating point number, it will be converted to Python's float type.</span> <span class="sd"> """</span> <span class="k">return</span> <span class="p">{</span><span class="n">param</span><span class="p">:</span> <span class="n">convfloat</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">param</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">parameters</span><span class="p">,</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">())}</span></div> @@ -458,6 +390,10 @@ <div class="viewcode-block" id="pad_output_distribution"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.pad_output_distribution">[docs]</a><span class="k">def</span> <span class="nf">pad_output_distribution</span><span class="p">(</span><span class="n">dist</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">binwidth</span><span class="p">:</span> <span class="nb">float</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Given a distribution, dist (a dictionary), which should be binned every binwidth (float), fill the distribution with zeros when there is no data. Note: this changes the data in place.</span> + +<span class="sd"> Args:</span> +<span class="sd"> dist: dictionary containing the distribution data.</span> +<span class="sd"> binwidth: binwidth that is used to fill the distribution with 0 in places where there is no value/key.</span> <span class="sd"> """</span> <span class="c1"># sorted list of the keys</span> @@ -476,19 +412,19 @@ <span class="k">return</span> <span class="n">dist</span></div> -<div class="viewcode-block" id="catchtime"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.catchtime">[docs]</a><span class="k">class</span> <span class="nc">catchtime</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> +<div class="viewcode-block" id="catchtime"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.catchtime">[docs]</a><span class="k">class</span> <span class="nc">catchtime</span><span class="p">:</span> <span class="sd">"""</span> <span class="sd"> Context manager to calculate time spent</span> <span class="sd"> """</span> -<div class="viewcode-block" id="catchtime.__enter__"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.catchtime.__enter__">[docs]</a> <span class="k">def</span> <span class="nf">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +<div class="viewcode-block" id="catchtime.__enter__"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.catchtime.__enter__">[docs]</a> <span class="k">def</span> <span class="fm">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""On entry we start the clock"""</span> - <span class="bp">self</span><span class="o">.</span><span class="n">t</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">clock</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">t</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">process_time</span><span class="p">()</span> <span class="k">return</span> <span class="bp">self</span></div> -<div class="viewcode-block" id="catchtime.__exit__"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.catchtime.__exit__">[docs]</a> <span class="k">def</span> <span class="nf">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">type</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">traceback</span><span class="p">):</span> +<div class="viewcode-block" id="catchtime.__exit__"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.catchtime.__exit__">[docs]</a> <span class="k">def</span> <span class="fm">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_val</span><span class="p">,</span> <span class="n">exc_tb</span><span class="p">):</span> <span class="sd">"""On exit we stop the clock and measure the time spent"""</span> - <span class="bp">self</span><span class="o">.</span><span class="n">t</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">clock</span><span class="p">()</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">t</span> + <span class="bp">self</span><span class="o">.</span><span class="n">t</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">process_time</span><span class="p">()</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">t</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"Took </span><span class="si">{}</span><span class="s2">s"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">))</span></div></div> @@ -506,14 +442,14 @@ <span class="sd"> Context manager to capture output and store it</span> <span class="sd"> """</span> -<div class="viewcode-block" id="Capturing.__enter__"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.Capturing.__enter__">[docs]</a> <span class="k">def</span> <span class="nf">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +<div class="viewcode-block" id="Capturing.__enter__"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.Capturing.__enter__">[docs]</a> <span class="k">def</span> <span class="fm">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""On entry we capture the stdout output"""</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stdout</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span> <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stringio</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">()</span> <span class="k">return</span> <span class="bp">self</span></div> -<div class="viewcode-block" id="Capturing.__exit__"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.Capturing.__exit__">[docs]</a> <span class="k">def</span> <span class="nf">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> +<div class="viewcode-block" id="Capturing.__exit__"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.Capturing.__exit__">[docs]</a> <span class="k">def</span> <span class="fm">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> <span class="sd">"""On exit we release the capture again"""</span> <span class="bp">self</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stringio</span><span class="o">.</span><span class="n">getvalue</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">())</span> @@ -525,11 +461,11 @@ <span class="sd">"""</span> <span class="sd"> Function to interface with the binary_c config file</span> -<span class="sd"> input:</span> -<span class="sd"> - argument: argument for the binary_c config</span> +<span class="sd"> Args:</span> +<span class="sd"> argument: argument for the binary_c config</span> <span class="sd"> Returns:</span> -<span class="sd"> - raw output of binary_c-config</span> +<span class="sd"> raw output of binary_c-config</span> <span class="sd"> """</span> <span class="n">BINARY_C_DIR</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">"BINARY_C"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> @@ -554,21 +490,25 @@ <span class="c1">########################################################</span> -<div class="viewcode-block" id="verbose_print"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.verbose_print">[docs]</a><span class="k">def</span> <span class="nf">verbose_print</span><span class="p">(</span><span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">verbosity</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">minimal_verbosity</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +<div class="viewcode-block" id="verbose_print"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.verbose_print">[docs]</a><span class="k">def</span> <span class="nf">verbose_print</span><span class="p">(</span> + <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">verbosity</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">minimal_verbosity</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">newline</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> +<span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="sd">"""</span> <span class="sd"> Function that decides whether to print a message based on the current verbosity</span> -<span class="sd"> and its minimum verbosity</span> - -<span class="sd"> if verbosity is equal or higher than the minimum, then we print</span> +<span class="sd"> and its minimum verbosity. If verbosity is equal or higher than the minimum, then we print.</span> <span class="sd"> Args:</span> -<span class="sd"> message: message to print</span> -<span class="sd"> verbosity: current verbosity level</span> -<span class="sd"> minimal_verbosity: threshold verbosity above which to print</span> +<span class="sd"> message: message to print.</span> +<span class="sd"> verbosity: current verbosity level.</span> +<span class="sd"> minimal_verbosity: threshold verbosity above which to print.</span> +<span class="sd"> newline: newline character (or set of characters), defaults to ``\\n`` but ``\\x0d`` (carriage return) might be useful.</span> <span class="sd"> """</span> <span class="k">if</span> <span class="n">verbosity</span> <span class="o">>=</span> <span class="n">minimal_verbosity</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> + <span class="k">if</span> <span class="n">newline</span> <span class="o">==</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">newline</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">end</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span></div> @@ -606,17 +546,21 @@ <div class="viewcode-block" id="get_username"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.get_username">[docs]</a><span class="k">def</span> <span class="nf">get_username</span><span class="p">():</span> + <span class="sd">"""</span> +<span class="sd"> Function to get the username of the user that spawned the current process</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="n">psutil</span><span class="o">.</span><span class="n">Process</span><span class="p">()</span><span class="o">.</span><span class="n">username</span><span class="p">()</span></div> -<div class="viewcode-block" id="temp_dir"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.temp_dir">[docs]</a><span class="k">def</span> <span class="nf">temp_dir</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +<div class="viewcode-block" id="temp_dir"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.temp_dir">[docs]</a><span class="k">def</span> <span class="nf">temp_dir</span><span class="p">(</span><span class="o">*</span><span class="n">child_dirs</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> <span class="sd">"""</span> -<span class="sd"> Function to create directory within the TMP directory of the file system</span> +<span class="sd"> Function to create directory within the TMP directory of the file system, starting with `/<TMP>/binary_c_python-<username>`</span> <span class="sd"> Makes use of os.makedirs exist_ok which requires python 3.2+</span> <span class="sd"> Args:</span> -<span class="sd"> function arguments: str input where each next input will be a child of the previous full_path. e.g. temp_dir('tests', 'grid') will become '/tmp/binary_c_python/tests/grid'</span> +<span class="sd"> *child_dirs: str input where each next input will be a child of the previous full_path. e.g. ``temp_dir('tests', 'grid')`` will become ``'/tmp/binary_c_python-<username>/tests/grid'``</span> <span class="sd"> Returns:</span> <span class="sd"> the path of a sub directory called binary_c_python in the TMP of the file system</span> @@ -627,8 +571,8 @@ <span class="n">path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">tmp_dir</span><span class="p">,</span> <span class="s2">"binary_c_python-</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">username</span><span class="p">))</span> <span class="c1"># loop over the other paths if there are any:</span> - <span class="k">if</span> <span class="n">args</span><span class="p">:</span> - <span class="k">for</span> <span class="n">extra_dir</span> <span class="ow">in</span> <span class="n">args</span><span class="p">:</span> + <span class="k">if</span> <span class="n">child_dirs</span><span class="p">:</span> + <span class="k">for</span> <span class="n">extra_dir</span> <span class="ow">in</span> <span class="n">child_dirs</span><span class="p">:</span> <span class="n">path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">extra_dir</span><span class="p">)</span> <span class="c1">#</span> @@ -661,21 +605,23 @@ <span class="n">content_data_dir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">data_dir</span><span class="p">)</span> <span class="c1"># Settings</span> - <span class="k">if</span> <span class="nb">any</span><span class="p">([</span><span class="n">file</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">"_settings.json"</span><span class="p">)</span> <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">content_data_dir</span><span class="p">]):</span> + <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="n">file</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">"_settings.json"</span><span class="p">)</span> <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">content_data_dir</span><span class="p">):</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"Adding settings to HDF5 file"</span><span class="p">)</span> <span class="n">settings_file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> <span class="n">data_dir</span><span class="p">,</span> <span class="p">[</span><span class="n">file</span> <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">content_data_dir</span> <span class="k">if</span> <span class="n">file</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">"_settings.json"</span><span class="p">)][</span><span class="mi">0</span><span class="p">],</span> <span class="p">)</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">settings_file</span><span class="p">,</span> <span class="s2">"r"</span><span class="p">)</span> <span class="k">as</span> <span class="n">settings_file</span><span class="p">:</span> + <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">settings_file</span><span class="p">,</span> <span class="s2">"r"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">settings_file</span><span class="p">:</span> <span class="n">settings_json</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">settings_file</span><span class="p">)</span> <span class="c1"># Create settings group</span> <span class="n">settings_grp</span> <span class="o">=</span> <span class="n">hdf5_file</span><span class="o">.</span><span class="n">create_group</span><span class="p">(</span><span class="s2">"settings"</span><span class="p">)</span> <span class="c1"># Write version_string to settings_group</span> - <span class="n">settings_grp</span><span class="o">.</span><span class="n">create_dataset</span><span class="p">(</span><span class="s2">"used_settings"</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">settings_json</span><span class="p">))</span> + <span class="n">settings_grp</span><span class="o">.</span><span class="n">create_dataset</span><span class="p">(</span> + <span class="s2">"used_settings"</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">settings_json</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> + <span class="p">)</span> <span class="c1"># Get data files</span> <span class="n">data_files</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">content_data_dir</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".dat"</span><span class="p">)]</span> @@ -706,325 +652,6 @@ <span class="n">hdf5_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div> -<span class="c1">########################################################</span> -<span class="c1"># version_info functions</span> -<span class="c1">########################################################</span> - - -<div class="viewcode-block" id="return_binary_c_version_info"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.return_binary_c_version_info">[docs]</a><span class="k">def</span> <span class="nf">return_binary_c_version_info</span><span class="p">(</span><span class="n">parsed</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">dict</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Function that returns the version information of binary_c. This function calls the function</span> -<span class="sd"> _binary_c_bindings.return_version_info()</span> - -<span class="sd"> Args:</span> -<span class="sd"> parsed: Boolean flag whether to parse the version_info output of binary_c. default = False</span> - -<span class="sd"> Returns:</span> -<span class="sd"> Either the raw string of binary_c or a parsed version of this in the form of a nested</span> -<span class="sd"> dictionary</span> -<span class="sd"> """</span> - - <span class="n">found_prev</span> <span class="o">=</span> <span class="kc">False</span> - <span class="k">if</span> <span class="s2">"BINARY_C_MACRO_HEADER"</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">:</span> - <span class="c1"># the env var is already present. lets save that and put that back later</span> - <span class="n">found_prev</span> <span class="o">=</span> <span class="kc">True</span> - <span class="n">prev_value</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C_MACRO_HEADER"</span><span class="p">]</span> - - <span class="c1">#</span> - <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C_MACRO_HEADER"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"macroxyz"</span> - - <span class="c1"># Get version_info</span> - <span class="n">version_info</span> <span class="o">=</span> <span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">return_version_info</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> - - <span class="c1"># parse if wanted</span> - <span class="k">if</span> <span class="n">parsed</span><span class="p">:</span> - <span class="n">version_info</span> <span class="o">=</span> <span class="n">parse_binary_c_version_info</span><span class="p">(</span><span class="n">version_info</span><span class="p">)</span> - - <span class="c1"># delete value</span> - <span class="k">del</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C_MACRO_HEADER"</span><span class="p">]</span> - - <span class="c1"># put stuff back if we found a previous one</span> - <span class="k">if</span> <span class="n">found_prev</span><span class="p">:</span> - <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C_MACRO_HEADER"</span><span class="p">]</span> <span class="o">=</span> <span class="n">prev_value</span> - - <span class="k">return</span> <span class="n">version_info</span></div> - - -<div class="viewcode-block" id="parse_binary_c_version_info"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.parse_binary_c_version_info">[docs]</a><span class="k">def</span> <span class="nf">parse_binary_c_version_info</span><span class="p">(</span><span class="n">version_info_string</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Function that parses the binary_c version info. Long function with a lot of branches</span> - -<span class="sd"> TODO: fix this function. stuff is missing: isotopes, macros, nucleosynthesis_sources</span> - -<span class="sd"> Args:</span> -<span class="sd"> version_info_string: raw output of version_info call to binary_c</span> - -<span class="sd"> Returns:</span> -<span class="sd"> Parsed version of the version info, which is a dictionary containing the keys: 'isotopes' for isotope info, 'argpairs' for argument pair info (TODO: explain), 'ensembles' for ensemble settings/info, 'macros' for macros, 'elements' for atomic element info, 'DTlimit' for (TODO: explain), 'nucleosynthesis_sources' for nucleosynthesis sources, and 'miscellaneous' for all those that were not caught by the previous groups. 'git_branch', 'git_build', 'revision' and 'email' are also keys, but its clear what those contain.</span> -<span class="sd"> """</span> - - <span class="n">version_info_dict</span> <span class="o">=</span> <span class="p">{}</span> - - <span class="c1"># Clean data and put in correct shape</span> - <span class="n">splitted</span> <span class="o">=</span> <span class="n">version_info_string</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">splitted</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">el</span> <span class="o">==</span> <span class="s2">""</span><span class="p">}</span> - - <span class="c1">##########################</span> - <span class="c1"># Network:</span> - <span class="c1"># Split off all the networks and parse the info.</span> - - <span class="n">networks</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Network "</span><span class="p">)}</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="n">networks</span> - - <span class="n">networks_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">networks</span><span class="p">:</span> - <span class="n">network_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Network "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"=="</span><span class="p">)</span> - - <span class="n">network_number</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> - <span class="n">network_dict</span><span class="p">[</span><span class="s2">"network_number"</span><span class="p">]</span> <span class="o">=</span> <span class="n">network_number</span> - - <span class="n">network_info_split</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> - - <span class="n">shortname</span> <span class="o">=</span> <span class="n">network_info_split</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> - <span class="n">network_dict</span><span class="p">[</span><span class="s2">"shortname"</span><span class="p">]</span> <span class="o">=</span> <span class="n">shortname</span> - - <span class="k">if</span> <span class="ow">not</span> <span class="n">network_info_split</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">":"</span><span class="p">):</span> - <span class="n">network_split_info_extra</span> <span class="o">=</span> <span class="n">network_info_split</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)</span> - - <span class="n">longname</span> <span class="o">=</span> <span class="n">network_split_info_extra</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> - <span class="n">network_dict</span><span class="p">[</span><span class="s2">"longname"</span><span class="p">]</span> <span class="o">=</span> <span class="n">longname</span> - - <span class="n">implementation</span> <span class="o">=</span> <span class="p">(</span> - <span class="n">network_split_info_extra</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"implemented in"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> - <span class="p">)</span> - <span class="k">if</span> <span class="n">implementation</span><span class="p">:</span> - <span class="n">network_dict</span><span class="p">[</span><span class="s2">"implemented_in"</span><span class="p">]</span> <span class="o">=</span> <span class="n">implementation</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> - - <span class="n">networks_dict</span><span class="p">[</span><span class="n">network_number</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">network_dict</span><span class="p">)</span> - <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"networks"</span><span class="p">]</span> <span class="o">=</span> <span class="n">networks_dict</span> <span class="k">if</span> <span class="n">networks_dict</span> <span class="k">else</span> <span class="kc">None</span> - - <span class="c1">##########################</span> - <span class="c1"># Isotopes:</span> - <span class="c1"># Split off</span> - <span class="n">isotopes</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Isotope "</span><span class="p">)}</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="n">isotopes</span> - - <span class="n">isotope_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">isotopes</span><span class="p">:</span> - <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Isotope "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> - - <span class="n">isotope_info</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> - <span class="n">name</span> <span class="o">=</span> <span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> - - <span class="c1"># Get details</span> - <span class="n">mass_g</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span> - <span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"("</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">][:</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> - <span class="p">)</span> - <span class="n">mass_amu</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span> - <span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"("</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> - <span class="p">)</span> - <span class="n">mass_mev</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span> - <span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)[</span><span class="o">-</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">")"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> - <span class="p">)</span> - <span class="n">A</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">")"</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span> - <span class="n">Z</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> - - <span class="c1">#</span> - <span class="n">isotope_dict</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])]</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"name"</span><span class="p">:</span> <span class="n">name</span><span class="p">,</span> - <span class="s2">"Z"</span><span class="p">:</span> <span class="n">Z</span><span class="p">,</span> - <span class="s2">"A"</span><span class="p">:</span> <span class="n">A</span><span class="p">,</span> - <span class="s2">"mass_mev"</span><span class="p">:</span> <span class="n">mass_mev</span><span class="p">,</span> - <span class="s2">"mass_g"</span><span class="p">:</span> <span class="n">mass_g</span><span class="p">,</span> - <span class="s2">"mass_amu"</span><span class="p">:</span> <span class="n">mass_amu</span><span class="p">,</span> - <span class="p">}</span> - <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"isotopes"</span><span class="p">]</span> <span class="o">=</span> <span class="n">isotope_dict</span> <span class="k">if</span> <span class="n">isotope_dict</span> <span class="k">else</span> <span class="kc">None</span> - - <span class="c1">##########################</span> - <span class="c1"># Arg pairs:</span> - <span class="c1"># Split off</span> - <span class="n">argpairs</span> <span class="o">=</span> <span class="nb">set</span><span class="p">([</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"ArgPair"</span><span class="p">)])</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="n">argpairs</span> - - <span class="n">argpair_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">argpairs</span><span class="p">):</span> - <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"ArgPair "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)</span> - - <span class="k">if</span> <span class="ow">not</span> <span class="n">argpair_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">argpair_dict</span><span class="p">[</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span><span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">2</span><span class="p">]}</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">argpair_dict</span><span class="p">[</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]][</span><span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> - - <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"argpairs"</span><span class="p">]</span> <span class="o">=</span> <span class="n">argpair_dict</span> <span class="k">if</span> <span class="n">argpair_dict</span> <span class="k">else</span> <span class="kc">None</span> - - <span class="c1">##########################</span> - <span class="c1"># ensembles:</span> - <span class="c1"># Split off</span> - <span class="n">ensembles</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Ensemble"</span><span class="p">)}</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="n">ensembles</span> - - <span class="n">ensemble_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="n">ensemble_filter_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">ensembles</span><span class="p">:</span> - <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Ensemble "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> - - <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">split_info</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"filter"</span><span class="p">):</span> - <span class="n">ensemble_dict</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])]</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">filter_no</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"filter "</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span> - <span class="n">ensemble_filter_dict</span><span class="p">[</span><span class="n">filter_no</span><span class="p">]</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> - - <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"ensembles"</span><span class="p">]</span> <span class="o">=</span> <span class="n">ensemble_dict</span> <span class="k">if</span> <span class="n">ensemble_dict</span> <span class="k">else</span> <span class="kc">None</span> - <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"ensemble_filters"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> - <span class="n">ensemble_filter_dict</span> <span class="k">if</span> <span class="n">ensemble_filter_dict</span> <span class="k">else</span> <span class="kc">None</span> - <span class="p">)</span> - - <span class="c1">##########################</span> - <span class="c1"># macros:</span> - <span class="c1"># Split off</span> - <span class="n">macros</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"macroxyz"</span><span class="p">)}</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="n">macros</span> - - <span class="n">param_type_dict</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"STRING"</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> - <span class="s2">"FLOAT"</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> - <span class="s2">"MACRO"</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> - <span class="s2">"INT"</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> - <span class="s2">"LONG_INT"</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> - <span class="s2">"UINT"</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> - <span class="p">}</span> - - <span class="n">macros_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">macros</span><span class="p">:</span> - <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"macroxyz "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" : "</span><span class="p">)</span> - <span class="n">param_type</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> - - <span class="n">new_split</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> - <span class="n">param_name</span> <span class="o">=</span> <span class="n">new_split</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">param_value</span> <span class="o">=</span> <span class="s2">" is "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">new_split</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span> - - <span class="c1"># Sometimes the macros have extra information behind it. Needs an update in outputting by binary_c</span> - <span class="k">try</span><span class="p">:</span> - <span class="n">macros_dict</span><span class="p">[</span><span class="n">param_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">param_type_dict</span><span class="p">[</span><span class="n">param_type</span><span class="p">](</span><span class="n">param_value</span><span class="p">)</span> - <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> - <span class="n">macros_dict</span><span class="p">[</span><span class="n">param_name</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">param_value</span><span class="p">)</span> - <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"macros"</span><span class="p">]</span> <span class="o">=</span> <span class="n">macros_dict</span> <span class="k">if</span> <span class="n">macros_dict</span> <span class="k">else</span> <span class="kc">None</span> - - <span class="c1">##########################</span> - <span class="c1"># Elements:</span> - <span class="c1"># Split off:</span> - <span class="n">elements</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Element"</span><span class="p">)}</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="n">elements</span> - - <span class="c1"># Fill dict:</span> - <span class="n">elements_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">elements</span><span class="p">:</span> - <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Element "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" : "</span><span class="p">)</span> - <span class="n">name_info</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> - - <span class="c1"># get isotope info</span> - <span class="n">isotopes</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"0"</span><span class="p">:</span> - <span class="n">isotope_string</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" = "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> - <span class="n">isotopes</span> <span class="o">=</span> <span class="p">{</span> - <span class="nb">int</span><span class="p">(</span><span class="n">split_isotope</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="mi">0</span><span class="p">]):</span> <span class="n">split_isotope</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span> - <span class="k">for</span> <span class="n">split_isotope</span> <span class="ow">in</span> <span class="n">isotope_string</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)</span> - <span class="p">}</span> - - <span class="n">elements_dict</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">name_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])]</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"name"</span><span class="p">:</span> <span class="n">name_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> - <span class="s2">"atomic_number"</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="n">name_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> - <span class="s2">"amt_isotopes"</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">isotopes</span><span class="p">),</span> - <span class="s2">"isotopes"</span><span class="p">:</span> <span class="n">isotopes</span><span class="p">,</span> - <span class="p">}</span> - <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"elements"</span><span class="p">]</span> <span class="o">=</span> <span class="n">elements_dict</span> <span class="k">if</span> <span class="n">elements_dict</span> <span class="k">else</span> <span class="kc">None</span> - - <span class="c1">##########################</span> - <span class="c1"># dt_limits:</span> - <span class="c1"># split off</span> - <span class="n">dt_limits</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"DTlimit"</span><span class="p">)}</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="n">dt_limits</span> - - <span class="c1"># Fill dict</span> - <span class="n">dt_limits_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">dt_limits</span><span class="p">:</span> - <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"DTlimit "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" : "</span><span class="p">)</span> - <span class="n">dt_limits_dict</span><span class="p">[</span><span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()]</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"index"</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> - <span class="s2">"value"</span><span class="p">:</span> <span class="nb">float</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]),</span> - <span class="p">}</span> - - <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"dt_limits"</span><span class="p">]</span> <span class="o">=</span> <span class="n">dt_limits_dict</span> <span class="k">if</span> <span class="n">dt_limits_dict</span> <span class="k">else</span> <span class="kc">None</span> - - <span class="c1">##########################</span> - <span class="c1"># Nucleosynthesis sources:</span> - <span class="c1"># Split off</span> - <span class="n">nucsyn_sources</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Nucleosynthesis"</span><span class="p">)}</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="n">nucsyn_sources</span> - - <span class="c1"># Fill dict</span> - <span class="n">nucsyn_sources_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">nucsyn_sources</span><span class="p">:</span> - <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Nucleosynthesis source"</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> - <span class="n">nucsyn_sources_dict</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])]</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> - - <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"nucleosynthesis_sources"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> - <span class="n">nucsyn_sources_dict</span> <span class="k">if</span> <span class="n">nucsyn_sources_dict</span> <span class="k">else</span> <span class="kc">None</span> - <span class="p">)</span> - - <span class="c1">##########################</span> - <span class="c1"># miscellaneous:</span> - <span class="c1"># All those that I didn't catch with the above filters. Could try to get some more out though.</span> - <span class="c1"># TODO: filter a bit more.</span> - - <span class="n">misc_dict</span> <span class="o">=</span> <span class="p">{}</span> - - <span class="c1"># Filter out git revision</span> - <span class="n">git_revision</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"git revision"</span><span class="p">)]</span> - <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"git_revision"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> - <span class="n">git_revision</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"git revision "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">'"'</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> - <span class="p">)</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">git_revision</span><span class="p">)</span> - - <span class="c1"># filter out git url</span> - <span class="n">git_url</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"git URL"</span><span class="p">)]</span> - <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"git_url"</span><span class="p">]</span> <span class="o">=</span> <span class="n">git_url</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"git URL "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">'"'</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">git_url</span><span class="p">)</span> - - <span class="c1"># filter out version</span> - <span class="n">version</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Version"</span><span class="p">)]</span> - <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"version"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">version</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Version "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">version</span><span class="p">)</span> - - <span class="n">git_branch</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"git branch"</span><span class="p">)]</span> - <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"git_branch"</span><span class="p">]</span> <span class="o">=</span> <span class="n">git_branch</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"git branch "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">'"'</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">git_branch</span><span class="p">)</span> - - <span class="n">build</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Build"</span><span class="p">)]</span> - <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"build"</span><span class="p">]</span> <span class="o">=</span> <span class="n">build</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Build: "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">'"'</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">build</span><span class="p">)</span> - - <span class="n">email</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Email"</span><span class="p">)]</span> - <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"email"</span><span class="p">]</span> <span class="o">=</span> <span class="n">email</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Email "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">email</span><span class="p">)</span> - - <span class="n">other_items</span> <span class="o">=</span> <span class="nb">set</span><span class="p">([</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="s2">" is "</span> <span class="ow">in</span> <span class="n">el</span><span class="p">])</span> - <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="n">other_items</span> - - <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">other_items</span><span class="p">:</span> - <span class="n">split</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> - <span class="n">key</span> <span class="o">=</span> <span class="n">split</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> - <span class="n">val</span> <span class="o">=</span> <span class="s2">" is "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">split</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> - <span class="n">misc_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span> - - <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"uncaught"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">cleaned</span><span class="p">)</span> - - <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"miscellaneous"</span><span class="p">]</span> <span class="o">=</span> <span class="n">misc_dict</span> <span class="k">if</span> <span class="n">misc_dict</span> <span class="k">else</span> <span class="kc">None</span> - <span class="k">return</span> <span class="n">version_info_dict</span></div> - - <span class="c1">########################################################</span> <span class="c1"># binary_c output functions</span> <span class="c1">########################################################</span> @@ -1233,7 +860,7 @@ <span class="sd"> Will check whether it is a valid parameter.</span> -<span class="sd"> Binary_c will output things in the following order;</span> +<span class="sd"> Binary_c will output things in the following order:</span> <span class="sd"> - Did you mean?</span> <span class="sd"> - binary_c help for variable</span> <span class="sd"> - default</span> @@ -1241,9 +868,6 @@ <span class="sd"> This function reads out that structure and catches the different components of this output</span> -<span class="sd"> Tasks:</span> -<span class="sd"> - TODO: consider not returning None, but return empty dict</span> - <span class="sd"> Args:</span> <span class="sd"> param_name: name of the parameter that you want info from. Will get checked whether its a</span> <span class="sd"> valid parameter name</span> @@ -1252,8 +876,8 @@ <span class="sd"> parameter isn't valid</span> <span class="sd"> Returns:</span> -<span class="sd"> Dictionary containing the help info. This dictionary contains 'parameter_name',</span> -<span class="sd"> 'parameter_value_input_type', 'description', optionally 'macros'</span> +<span class="sd"> Dictionary containing the help info. This dictionary contains `parameter_name`,</span> +<span class="sd"> `parameter_value_input_type`, `description`, optionally `macros`</span> <span class="sd"> """</span> <span class="n">available_arg_keys</span> <span class="o">=</span> <span class="n">get_arg_keys</span><span class="p">()</span> @@ -1321,20 +945,20 @@ <span class="n">help_info_dict</span><span class="p">[</span><span class="s2">"macros"</span><span class="p">]</span> <span class="o">=</span> <span class="n">macros</span> <span class="k">if</span> <span class="n">print_help</span><span class="p">:</span> - <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">help_info_dict</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">:</span><span class="se">\n\t</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">help_info_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]))</span> + <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">help_info_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">:</span><span class="se">\n\t</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">))</span> <span class="k">return</span> <span class="n">help_info_dict</span> - <span class="k">else</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">fail_silently</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{}</span><span class="s2"> is not a valid parameter name. Please choose from the </span><span class="se">\</span> -<span class="s2"> following parameters:</span><span class="se">\n\t</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">param_name</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">available_arg_keys</span><span class="p">)</span> - <span class="p">)</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">fail_silently</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{}</span><span class="s2"> is not a valid parameter name. Please choose from the </span><span class="se">\</span> +<span class="s2"> following parameters:</span><span class="se">\n\t</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">param_name</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">available_arg_keys</span><span class="p">)</span> <span class="p">)</span> - <span class="k">return</span> <span class="kc">None</span></div> + <span class="p">)</span> + + <span class="k">return</span> <span class="p">{}</span></div> <div class="viewcode-block" id="get_help_all"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.get_help_all">[docs]</a><span class="k">def</span> <span class="nf">get_help_all</span><span class="p">(</span><span class="n">print_help</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> @@ -1363,11 +987,11 @@ <span class="n">help_all_dict</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># Select the section name and the contents of that section. Note, not all sections have content!</span> - <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">section_nums</span><span class="p">)):</span> + <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">section_num</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">section_nums</span><span class="p">):</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">section_nums</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span> - <span class="n">params</span> <span class="o">=</span> <span class="n">cleaned</span><span class="p">[</span><span class="n">section_nums</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span> <span class="p">:</span> <span class="n">section_nums</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]]</span> + <span class="n">params</span> <span class="o">=</span> <span class="n">cleaned</span><span class="p">[</span><span class="n">section_num</span> <span class="o">+</span> <span class="mi">1</span> <span class="p">:</span> <span class="n">section_nums</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]]</span> <span class="k">else</span><span class="p">:</span> - <span class="n">params</span> <span class="o">=</span> <span class="n">cleaned</span><span class="p">[</span><span class="n">section_nums</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span> <span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">cleaned</span><span class="p">)]</span> + <span class="n">params</span> <span class="o">=</span> <span class="n">cleaned</span><span class="p">[</span><span class="n">section_num</span> <span class="o">+</span> <span class="mi">1</span> <span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">cleaned</span><span class="p">)]</span> <span class="n">section_name</span> <span class="o">=</span> <span class="p">(</span> <span class="n">cleaned</span><span class="p">[</span><span class="n">section_nums</span><span class="p">[</span><span class="n">i</span><span class="p">]]</span> <span class="o">.</span><span class="n">lstrip</span><span class="p">(</span><span class="s2">"#####"</span><span class="p">)</span> @@ -1465,21 +1089,14 @@ <span class="c1"># Get help_all information</span> <span class="n">help_all_dict</span> <span class="o">=</span> <span class="n">get_help_all</span><span class="p">(</span><span class="n">print_help</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> - <span class="k">for</span> <span class="n">section_name</span> <span class="ow">in</span> <span class="n">help_all_dict</span><span class="p">:</span> - <span class="n">section</span> <span class="o">=</span> <span class="n">help_all_dict</span><span class="p">[</span><span class="n">section_name</span><span class="p">]</span> - - <span class="c1"># print(section_name)</span> - <span class="c1"># for parameter_name in section["parameters"].keys():</span> - <span class="c1"># print("\t", parameter_name)</span> + <span class="c1">#</span> <span class="n">help_all_super_dict</span> <span class="o">=</span> <span class="n">help_all_dict</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="c1"># Loop over all sections and stuff</span> - <span class="k">for</span> <span class="n">section_name</span> <span class="ow">in</span> <span class="n">help_all_dict</span><span class="p">:</span> + <span class="k">for</span> <span class="n">section_name</span><span class="p">,</span> <span class="n">section</span> <span class="ow">in</span> <span class="n">help_all_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> <span class="c1"># Skipping the section i/o because that one shouldn't be available to python anyway</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">section_name</span> <span class="o">==</span> <span class="s2">"i/o"</span><span class="p">:</span> - <span class="n">section</span> <span class="o">=</span> <span class="n">help_all_dict</span><span class="p">[</span><span class="n">section_name</span><span class="p">]</span> - <span class="k">for</span> <span class="n">parameter_name</span> <span class="ow">in</span> <span class="n">section</span><span class="p">[</span><span class="s2">"parameters"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> <span class="n">parameter</span> <span class="o">=</span> <span class="n">section</span><span class="p">[</span><span class="s2">"parameters"</span><span class="p">][</span><span class="n">parameter_name</span><span class="p">]</span> @@ -1494,7 +1111,7 @@ <span class="c1"># check whether the descriptions of help_all and detailed help are the same</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">fail_silently</span><span class="p">:</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">parameter</span><span class="p">[</span><span class="s2">"description"</span><span class="p">]</span> <span class="o">==</span> <span class="n">detailed_help</span><span class="p">[</span><span class="s2">"description"</span><span class="p">]:</span> - <span class="nb">print</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">parameter</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">))</span> + <span class="nb">print</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">parameter</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> <span class="c1">## put values into help all super dict</span> <span class="c1"># input type</span> @@ -1506,13 +1123,13 @@ <span class="n">parameter</span><span class="p">[</span><span class="s2">"default"</span><span class="p">]</span> <span class="o">=</span> <span class="n">detailed_help</span><span class="p">[</span><span class="s2">"default"</span><span class="p">]</span> <span class="c1"># macros</span> - <span class="k">if</span> <span class="s2">"macros"</span> <span class="ow">in</span> <span class="n">detailed_help</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> + <span class="k">if</span> <span class="s2">"macros"</span> <span class="ow">in</span> <span class="n">detailed_help</span><span class="p">:</span> <span class="n">parameter</span><span class="p">[</span><span class="s2">"macros"</span><span class="p">]</span> <span class="o">=</span> <span class="n">detailed_help</span><span class="p">[</span><span class="s2">"macros"</span><span class="p">]</span> <span class="n">section</span><span class="p">[</span><span class="s2">"parameters"</span><span class="p">][</span><span class="n">parameter_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">parameter</span> <span class="k">if</span> <span class="n">print_help</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">help_all_super_dict</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">))</span> + <span class="nb">print</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">help_all_super_dict</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> <span class="k">return</span> <span class="n">help_all_super_dict</span></div> @@ -1524,8 +1141,11 @@ <span class="sd"> Returns:</span> <span class="sd"> string containing information about the build and the git branch</span> <span class="sd"> """</span> + <span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="kn">import</span> <span class="n">Population</span> - <span class="n">version_info</span> <span class="o">=</span> <span class="n">return_binary_c_version_info</span><span class="p">(</span><span class="n">parsed</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <span class="n">version_pop</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> + <span class="n">version_info</span> <span class="o">=</span> <span class="n">version_pop</span><span class="o">.</span><span class="n">return_binary_c_version_info</span><span class="p">(</span><span class="n">parsed</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <span class="c1"># version_info = return_binary_c_version_info(parsed=True)</span> <span class="n">git_revision</span> <span class="o">=</span> <span class="n">version_info</span><span class="p">[</span><span class="s2">"miscellaneous"</span><span class="p">][</span><span class="s2">"git_revision"</span><span class="p">]</span> <span class="n">git_branch</span> <span class="o">=</span> <span class="n">version_info</span><span class="p">[</span><span class="s2">"miscellaneous"</span><span class="p">][</span><span class="s2">"git_branch"</span><span class="p">]</span> @@ -1545,11 +1165,8 @@ <span class="sd">"""</span> <span class="sd"> Function that calls the get_help_super() to get the help text/descriptions for all the</span> <span class="sd"> parameters available in that build.</span> -<span class="sd"> Writes the results to a .rst file that can be included in the docs.</span> -<span class="sd"> Tasks:</span> -<span class="sd"> - TODO: add the specific version git branch, git build, git commit, and binary_c version to</span> -<span class="sd"> this document</span> +<span class="sd"> Writes the results to a .rst file that can be included in the docs.</span> <span class="sd"> Args:</span> <span class="sd"> output_file: name of the output .rst file containing the ReStructuredText formatted output</span> @@ -1562,10 +1179,13 @@ <span class="n">build_info</span> <span class="o">=</span> <span class="n">make_build_text</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">output_file</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".rst"</span><span class="p">):</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"Filename doesn't end with .rst, please provide a proper filename"</span><span class="p">)</span> - <span class="k">return</span> <span class="kc">None</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> + <span class="s2">"Filename (</span><span class="si">{}</span><span class="s2">) doesn't end with .rst, please provide a proper filename."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">output_file</span> + <span class="p">)</span> + <span class="p">)</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> + <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"Binary</span><span class="se">\\</span><span class="s2">_c parameters"</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s2">"="</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="s2">"Binary</span><span class="se">\\</span><span class="s2">_c parameters"</span><span class="p">)),</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> @@ -1580,13 +1200,19 @@ <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">arguments_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"Section: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">el</span><span class="p">),</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s2">"-"</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="s2">"Section: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">el</span><span class="p">))),</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> - <span class="c1"># print(arguments_dict[el]['parameters'].keys())</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">arguments_dict</span><span class="p">[</span><span class="n">el</span><span class="p">][</span><span class="s2">"parameters"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> <span class="n">argdict</span> <span class="o">=</span> <span class="n">arguments_dict</span><span class="p">[</span><span class="n">el</span><span class="p">][</span><span class="s2">"parameters"</span><span class="p">][</span><span class="n">arg</span><span class="p">]</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"| **Parameter**: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">argdict</span><span class="p">[</span><span class="s2">"param_name"</span><span class="p">]),</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"| **Description**: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">argdict</span><span class="p">[</span><span class="s2">"description"</span><span class="p">]),</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"| **Description**: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">argdict</span><span class="p">[</span><span class="s2">"description"</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span> + <span class="s2">"|Rout/Rin-1|"</span><span class="p">,</span> <span class="s2">"abs(Rout/Rin-1)"</span> + <span class="p">)</span> + <span class="p">),</span> + <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> + <span class="p">)</span> <span class="k">if</span> <span class="s2">"parameter_value_input_type"</span> <span class="ow">in</span> <span class="n">argdict</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span> <span class="s2">"| **Parameter input type**: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> @@ -1608,14 +1234,14 @@ <span class="c1">########################################################</span> -<div class="viewcode-block" id="load_logfile"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.load_logfile">[docs]</a><span class="k">def</span> <span class="nf">load_logfile</span><span class="p">(</span><span class="n">logfile</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +<div class="viewcode-block" id="load_logfile"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.load_logfile">[docs]</a><span class="k">def</span> <span class="nf">load_logfile</span><span class="p">(</span><span class="n">logfile</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="c1"># pragma: no cover</span> <span class="sd">"""</span> <span class="sd"> Experimental function that parses the generated log file of binary_c.</span> <span class="sd"> This function is not finished and shouldn't be used yet.</span> <span class="sd"> Tasks:</span> -<span class="sd"> - TODO:</span> +<span class="sd"> - TODO: fix this function</span> <span class="sd"> Args:</span> <span class="sd"> - logfile: filename of the log file you want to parse</span> @@ -1624,7 +1250,7 @@ <span class="sd"> """</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">logfile</span><span class="p">,</span> <span class="s2">"r"</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span> + <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">logfile</span><span class="p">,</span> <span class="s2">"r"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span> <span class="n">logfile_data</span> <span class="o">=</span> <span class="n">file</span><span class="o">.</span><span class="n">readlines</span><span class="p">()</span> <span class="n">time_list</span> <span class="o">=</span> <span class="p">[]</span> @@ -1657,51 +1283,51 @@ <span class="n">event_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">split_line</span><span class="p">[</span><span class="mi">9</span><span class="p">:]))</span> <span class="nb">print</span><span class="p">(</span><span class="n">event_list</span><span class="p">)</span></div> + +<div class="viewcode-block" id="quotewrap"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.quotewrap">[docs]</a><span class="k">def</span> <span class="nf">quotewrap</span><span class="p">(</span><span class="nb">list</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Given a list, wrap each item in double quotes and return the new list</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="p">[</span><span class="s1">'"'</span> <span class="o">+</span> <span class="n">_x</span> <span class="o">+</span> <span class="s1">'"'</span> <span class="k">for</span> <span class="n">_x</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">]</span></div> + +<div class="viewcode-block" id="command_string_from_list"><a class="viewcode-back" href="../../../functions.html#binarycpython.utils.functions.command_string_from_list">[docs]</a><span class="k">def</span> <span class="nf">command_string_from_list</span><span class="p">(</span><span class="nb">list</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Given a list, turn it into a quoted command string</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="s1">' '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">quotewrap</span><span class="p">(</span><span class="nb">list</span><span class="p">))</span></div> </pre></div> </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/grid.html b/docs/build/html/_modules/binarycpython/utils/grid.html index fdb5a7b421cfdb223eb4979459c1c4bc4331a7c7..24fc6c8c43072e0a323a7ac9899ee8e230380b17 100644 --- a/docs/build/html/_modules/binarycpython/utils/grid.html +++ b/docs/build/html/_modules/binarycpython/utils/grid.html @@ -1,68 +1,33 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>binarycpython.utils.grid — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - - - <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script> <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> <script src="../../../_static/jquery.js"></script> <script src="../../../_static/underscore.js"></script> + <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../../../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="../../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <script src="../../../_static/js/theme.js"></script> <link rel="index" title="Index" href="../../../genindex.html" /> <link rel="search" title="Search" href="../../../search.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../../../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -70,17 +35,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> @@ -92,72 +47,38 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../../../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../../../index.html">Docs</a> »</li> - + <li><a href="../../../index.html" class="icon icon-home"></a> »</li> <li><a href="../../index.html">Module code</a> »</li> - <li>binarycpython.utils.grid</li> - - <li class="wy-breadcrumbs-aside"> - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <h1>Source code for binarycpython.utils.grid</h1><div class="highlight"><pre> <span></span><span class="sd">"""</span> <span class="sd">Module containing the Population grid class object.</span> <span class="sd">Here all the functionality of a Population object is defined.</span> +<span class="sd">TODO: the save_snapshots and save_snapshot, are they actually distinct?</span> + <span class="sd">Tasks:</span> <span class="sd"> - TODO: add functionality to 'on-init' set arguments</span> <span class="sd"> - TODO: add functionality to return the initial_abundance_hash</span> @@ -170,129 +91,129 @@ <span class="sd"> - TODO: consider spreading the functions over more files.</span> <span class="sd"> - TODO: type the private functions</span> <span class="sd"> - TODO: fix the correct object types for the default values of the bse_options</span> -<span class="sd"> - TODO: uncomment and implement the HPC functionality</span> <span class="sd"> - TODO: think of a clean and nice way to unload and remove the custom_logging_info library from memory (and from disk)</span> <span class="sd"> - TODO: think of a nice way to remove the loaded grid_code/ generator from memory.</span> + +<span class="sd">TODO: Some of the methods that we have defined in the (mixin) class are designed to be used as a portal to information (return_binary_c_version_info for example.) THe current design is that they are all instance methods, but that is not always necessary. We can decorate them with @staticmethod, or @classmethod to make it easier to use them (https://realpython.com/instance-class-and-static-methods-demystified/)</span> <span class="sd">"""</span> -<span class="kn">import</span> <span class="nn">argparse</span> -<span class="kn">import</span> <span class="nn">bz2</span> -<span class="kn">import</span> <span class="nn">copy</span> -<span class="kn">import</span> <span class="nn">datetime</span> -<span class="kn">import</span> <span class="nn">json</span> -<span class="kn">import</span> <span class="nn">gc</span> -<span class="kn">import</span> <span class="nn">gzip</span> -<span class="kn">import</span> <span class="nn">importlib.util</span> -<span class="kn">import</span> <span class="nn">logging</span> -<span class="kn">import</span> <span class="nn">msgpack</span> -<span class="kn">import</span> <span class="nn">multiprocessing</span> <span class="kn">import</span> <span class="nn">os</span> -<span class="kn">import</span> <span class="nn">py_rinterpolate</span> -<span class="kn">import</span> <span class="nn">re</span> -<span class="kn">import</span> <span class="nn">resource</span> -<span class="kn">import</span> <span class="nn">setproctitle</span> -<span class="kn">import</span> <span class="nn">strip_ansi</span> +<span class="kn">import</span> <span class="nn">gc</span> <span class="kn">import</span> <span class="nn">sys</span> <span class="kn">import</span> <span class="nn">time</span> +<span class="kn">import</span> <span class="nn">copy</span> +<span class="kn">import</span> <span class="nn">json</span> <span class="kn">import</span> <span class="nn">uuid</span> +<span class="kn">import</span> <span class="nn">queue</span> +<span class="kn">import</span> <span class="nn">signal</span> +<span class="kn">import</span> <span class="nn">datetime</span> +<span class="kn">import</span> <span class="nn">functools</span> +<span class="kn">import</span> <span class="nn">traceback</span> +<span class="kn">import</span> <span class="nn">multiprocessing</span> -<span class="n">_count</span> <span class="o">=</span> <span class="mi">0</span> -<span class="kn">from</span> <span class="nn">typing</span> <span class="k">import</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Any</span> -<span class="kn">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="p">(</span> +<span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="p">(</span> <span class="n">OrderedDict</span><span class="p">,</span> <span class="p">)</span> -<span class="kn">from</span> <span class="nn">collections.abc</span> <span class="k">import</span> <span class="n">Iterable</span> <span class="c1"># drop `.abc` with Python 2.7 or lower</span> +<span class="kn">from</span> <span class="nn">collections.abc</span> <span class="kn">import</span> <span class="n">Iterable</span> <span class="c1"># drop `.abc` with Python 2.7 or lower</span> +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Any</span> +<span class="kn">import</span> <span class="nn">psutil</span> <span class="kn">import</span> <span class="nn">setproctitle</span> -<span class="kn">import</span> <span class="nn">py_rinterpolate</span> +<span class="kn">import</span> <span class="nn">str2bool</span> +<span class="kn">from</span> <span class="nn">colorama</span> <span class="kn">import</span> <span class="n">init</span> <span class="k">as</span> <span class="n">colorama_init</span> -<span class="kn">from</span> <span class="nn">colorama</span> <span class="k">import</span> <span class="n">init</span> <span class="k">as</span> <span class="n">colorama_init</span> - -<span class="n">colorama_init</span><span class="p">()</span> - -<span class="kn">from</span> <span class="nn">binarycpython.utils.grid_options_defaults</span> <span class="k">import</span> <span class="p">(</span> - <span class="n">grid_options_defaults_dict</span><span class="p">,</span> - <span class="n">moe_di_stefano_default_options</span><span class="p">,</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">,</span> -<span class="p">)</span> - -<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="k">import</span> <span class="p">(</span> - <span class="n">autogen_C_logging_code</span><span class="p">,</span> - <span class="n">binary_c_log_code</span><span class="p">,</span> - <span class="n">create_and_load_logging_function</span><span class="p">,</span> -<span class="p">)</span> - -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="p">(</span> - <span class="n">get_defaults</span><span class="p">,</span> - <span class="n">remove_file</span><span class="p">,</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">check_if_in_shell</span><span class="p">,</span> <span class="n">filter_arg_dict</span><span class="p">,</span> + <span class="n">get_ANSI_colours</span><span class="p">,</span> + <span class="n">get_defaults</span><span class="p">,</span> <span class="n">get_help_all</span><span class="p">,</span> - <span class="n">return_binary_c_version_info</span><span class="p">,</span> - <span class="n">verbose_print</span><span class="p">,</span> - <span class="n">get_moe_di_stefano_dataset</span><span class="p">,</span> - <span class="n">trem</span><span class="p">,</span> - <span class="n">conv_time_units</span><span class="p">,</span> <span class="n">mem_use</span><span class="p">,</span> - <span class="n">get_ANSI_colours</span><span class="p">,</span> - <span class="n">check_if_in_shell</span><span class="p">,</span> - <span class="n">format_number</span><span class="p">,</span> <span class="n">timedelta</span><span class="p">,</span> + <span class="n">now</span><span class="p">,</span> <span class="p">)</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.ensemble</span> <span class="k">import</span> <span class="p">(</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.ensemble</span> <span class="kn">import</span> <span class="p">(</span> <span class="n">binaryc_json_serializer</span><span class="p">,</span> - <span class="n">ensemble_compression</span><span class="p">,</span> - <span class="n">ensemble_file_type</span><span class="p">,</span> <span class="n">extract_ensemble_json_from_string</span><span class="p">,</span> <span class="n">format_ensemble_results</span><span class="p">,</span> <span class="p">)</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.dicts</span> <span class="k">import</span> <span class="p">(</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.dicts</span> <span class="kn">import</span> <span class="p">(</span> <span class="n">AutoVivificationDict</span><span class="p">,</span> - <span class="n">custom_sort_dict</span><span class="p">,</span> <span class="n">merge_dicts</span><span class="p">,</span> - <span class="n">multiply_values_dict</span><span class="p">,</span> - <span class="n">recursive_change_key_to_float</span><span class="p">,</span> - <span class="n">recursive_change_key_to_string</span><span class="p">,</span> - <span class="n">update_dicts</span><span class="p">,</span> + <span class="n">keys_to_floats</span><span class="p">,</span> <span class="p">)</span> -<span class="c1"># from binarycpython.utils.hpc_functions import (</span> -<span class="c1"># get_condor_version,</span> -<span class="c1"># get_slurm_version,</span> -<span class="c1"># create_directories_hpc,</span> -<span class="c1"># path_of_calling_script,</span> -<span class="c1"># get_python_details,</span> -<span class="c1"># )</span> - -<span class="kn">from</span> <span class="nn">binarycpython.utils.distribution_functions</span> <span class="k">import</span> <span class="p">(</span> - <span class="n">Moecache</span><span class="p">,</span> - <span class="n">LOG_LN_CONVERTER</span><span class="p">,</span> - <span class="n">fill_data</span><span class="p">,</span> - <span class="n">get_max_multiplicity</span><span class="p">,</span> - <span class="n">Arenou2010_binary_fraction</span><span class="p">,</span> - <span class="n">raghavan2010_binary_fraction</span><span class="p">,</span> - <span class="n">Moe_di_Stefano_2017_multiplicity_fractions</span><span class="p">,</span> - <span class="n">normalize_dict</span><span class="p">,</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.analytics</span> <span class="kn">import</span> <span class="n">analytics</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.cache</span> <span class="kn">import</span> <span class="n">cache</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.dataIO</span> <span class="kn">import</span> <span class="n">dataIO</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.distribution_functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">distribution_functions</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.grid_logging</span> <span class="kn">import</span> <span class="n">grid_logging</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.grid_options_defaults</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">grid_options_defaults</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.gridcode</span> <span class="kn">import</span> <span class="n">gridcode</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.HPC</span> <span class="kn">import</span> <span class="n">HPC</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.metadata</span> <span class="kn">import</span> <span class="n">metadata</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.Moe_di_Stefano_2017</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">Moe_di_Stefano_2017</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.spacing_functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">spacing_functions</span><span class="p">,</span> <span class="p">)</span> -<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="k">import</span> <span class="n">_binary_c_bindings</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.version_info</span> <span class="kn">import</span> <span class="n">version_info</span> -<span class="n">secs_per_day</span> <span class="o">=</span> <span class="mi">86400</span> <span class="c1"># probably needs to go somewhere more sensible</span> +<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">_binary_c_bindings</span> + +<span class="c1"># Initialise the colorama stuff</span> +<span class="n">colorama_init</span><span class="p">()</span> -<div class="viewcode-block" id="Population"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population">[docs]</a><span class="k">class</span> <span class="nc">Population</span><span class="p">:</span> +<div class="viewcode-block" id="Population"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population">[docs]</a><span class="k">class</span> <span class="nc">Population</span><span class="p">(</span> + <span class="n">analytics</span><span class="p">,</span> + <span class="n">cache</span><span class="p">,</span> + <span class="n">dataIO</span><span class="p">,</span> + <span class="n">distribution_functions</span><span class="p">,</span> + <span class="n">grid_logging</span><span class="p">,</span> + <span class="n">grid_options_defaults</span><span class="p">,</span> + <span class="n">gridcode</span><span class="p">,</span> + <span class="n">HPC</span><span class="p">,</span> + <span class="n">metadata</span><span class="p">,</span> + <span class="n">Moe_di_Stefano_2017</span><span class="p">,</span> + <span class="n">spacing_functions</span><span class="p">,</span> + <span class="n">version_info</span><span class="p">,</span> +<span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Population Object. Contains all the necessary functions to set up, run and process a</span> <span class="sd"> population of systems</span> <span class="sd"> """</span> - <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Initialisation function of the population class</span> <span class="sd"> """</span> - <span class="c1"># Different sections of options</span> + <span class="c1"># Initialise the parent classes</span> + <span class="n">analytics</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">cache</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">dataIO</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">distribution_functions</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">grid_logging</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">grid_options_defaults</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">gridcode</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">HPC</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">metadata</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">Moe_di_Stefano_2017</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">spacing_functions</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">version_info</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + + <span class="c1"># caches</span> + <span class="bp">self</span><span class="o">.</span><span class="n">caches</span> <span class="o">=</span> <span class="p">{}</span> + <span class="bp">self</span><span class="o">.</span><span class="n">cached_function_cache</span> <span class="o">=</span> <span class="p">{}</span> + <span class="bp">self</span><span class="o">.</span><span class="n">original_function_cache</span> <span class="o">=</span> <span class="p">{}</span> + <span class="c1"># Different sections of options</span> <span class="c1"># get binary_c defaults and create a cleaned up dict</span> <span class="c1"># Setting stuff will check against the defaults to see if the input is correct.</span> <span class="bp">self</span><span class="o">.</span><span class="n">defaults</span> <span class="o">=</span> <span class="n">get_defaults</span><span class="p">()</span> @@ -301,42 +222,55 @@ <span class="bp">self</span><span class="o">.</span><span class="n">special_params</span> <span class="o">=</span> <span class="p">[</span> <span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">defaults</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">)</span> <span class="p">]</span> + <span class="bp">self</span><span class="o">.</span><span class="n">preloaded_population</span> <span class="o">=</span> <span class="kc">None</span> + <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># make the input dictionary</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># bse_options is just empty.</span> <span class="c1"># Grid options</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">grid_options_defaults_dict</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_grid_options_defaults_dict</span><span class="p">())</span> <span class="c1"># Custom options</span> - <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span> <span class="o">=</span> <span class="p">{}</span> + <span class="c1"># TODO: is this really necessary here? The custom options should be empty on start i think</span> + <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"save_snapshot"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> + <span class="p">}</span> <span class="c1"># grid code generation</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent_depth</span> <span class="o">=</span> <span class="mi">0</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent_string</span> <span class="o">=</span> <span class="s2">" "</span> <span class="bp">self</span><span class="o">.</span><span class="n">code_string</span> <span class="o">=</span> <span class="s2">""</span> + <span class="c1"># cached value of minimum stellar mass</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_minimum_stellar_mass</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="c1"># logging levels</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_LOGGER_VERBOSITY_LEVEL</span> <span class="o">=</span> <span class="mi">1</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">=</span> <span class="mi">2</span> + <span class="c1"># Set the options that are passed at creation of the object</span> <span class="bp">self</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># Load Moe and di Stefano options</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span> - <span class="n">moe_di_stefano_default_options</span> + <span class="bp">self</span><span class="o">.</span><span class="n">get_Moe_di_Stefano_2017_default_options</span><span class="p">()</span> <span class="p">)</span> - <span class="c1"># Write MOE2017 options to a file. NOTE: not sure why i put this here anymore</span> + <span class="c1"># Write MOE2017 options to a file. NOTE: (david) not sure why i put this here anymore</span> <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span> <span class="p">)</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> <span class="s2">"moeopts.dat"</span><span class="p">,</span> <span class="p">),</span> <span class="s2">"w"</span><span class="p">,</span> <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> - <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">],</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">))</span> - <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="n">json</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">],</span> <span class="n">f</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span> + <span class="p">)</span> <span class="c1"># Argline dict</span> <span class="bp">self</span><span class="o">.</span><span class="n">argline_dict</span> <span class="o">=</span> <span class="p">{}</span> @@ -352,7 +286,7 @@ <span class="c1"># ANSI colours: use them if in a shell</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span> <span class="o">=</span> <span class="n">get_ANSI_colours</span><span class="p">()</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_shell</span> <span class="o">==</span> <span class="kc">False</span><span class="p">:</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_shell</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="o">=</span> <span class="s2">""</span> @@ -363,11 +297,61 @@ <span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># Create location to store results. Users should write to this dictionary.</span> - <span class="c1"># The AutoVivificationDict allows for perls method of accessing possibly non-existant subdicts</span> + <span class="c1"># The AutoVivificationDict allows for Perl-like addition of possibly</span> + <span class="c1"># non-existant subdicts.</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_results</span> <span class="o">=</span> <span class="n">AutoVivificationDict</span><span class="p">()</span> - <span class="c1"># Create location where ensemble results are written to</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span> <span class="o">=</span> <span class="p">{}</span> + <span class="c1"># Create grid ensemble data location</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_new_grid_ensemble_results</span><span class="p">()</span> + + <span class="c1"># add metadata</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_system_metadata</span><span class="p">()</span> + + <span class="c1"># set up function cache.</span> + <span class="c1"># NOTE: (david) I added this here to be able to test the distributions functions without actually running anything.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">setup_function_cache</span><span class="p">()</span> + +<div class="viewcode-block" id="Population.jobID"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.jobID">[docs]</a> <span class="k">def</span> <span class="nf">jobID</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the job ID number of this process as a string.</span> + +<span class="sd"> Normal processes return their process ID (PID)</span> +<span class="sd"> HPC processes return whatever HPC_jobID() gives.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job</span><span class="p">():</span> + <span class="n">jobID</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_jobID</span><span class="p">()</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">jobID</span><span class="p">:</span> + <span class="c1"># fallback: use process ID but with "HPC" prepended</span> + <span class="c1"># (this should never happen!)</span> + <span class="n">jobID</span> <span class="o">=</span> <span class="s2">"HPC</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">jobID</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">)</span> + <span class="k">return</span> <span class="n">jobID</span></div> + +<div class="viewcode-block" id="Population.exit"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.exit">[docs]</a> <span class="k">def</span> <span class="nf">exit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">code</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">message</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">flush</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">stacktrace</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Exit function: use this to exit from a Population object.</span> +<span class="sd"> Really it's just a wrapper for sys.exit() to return the correct exit code,</span> +<span class="sd"> but also to post a message (if message is True, default is True)</span> +<span class="sd"> and perhaps a stacktrace (if stacktrace is True, default is False).</span> +<span class="sd"> """</span> + <span class="c1"># if we've been killed, set exit code to 1</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"exit_code"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_killed"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"exit_code"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> + <span class="c1"># but override with code passed in</span> + <span class="k">if</span> <span class="n">code</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"exit_code"</span><span class="p">]</span> <span class="o">=</span> <span class="n">code</span> + <span class="k">if</span> <span class="n">message</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"exit from binary_c-python Population with code </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"exit_code"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">if</span> <span class="n">flush</span><span class="p">:</span> + <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span> + <span class="k">if</span> <span class="n">stacktrace</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"print_stack_on_exit"</span><span class="p">]:</span> + <span class="n">traceback</span><span class="o">.</span><span class="n">print_stack</span><span class="p">()</span> + <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"exit_code"</span><span class="p">])</span></div> <span class="c1">###################################################</span> <span class="c1"># Argument functions</span> @@ -408,24 +392,21 @@ <span class="c1"># Go over all the input</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span> <span class="c1"># Filter out keys for the bse_options</span> - <span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">defaults</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">defaults</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"adding: </span><span class="si">{}</span><span class="s2">=</span><span class="si">{}</span><span class="s2"> to BSE_options"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> + <span class="mi">2</span><span class="p">,</span> <span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="c1"># Extra check to check if the key fits one of parameter names that end with %d</span> + <span class="c1"># TODO: abstract this function</span> <span class="k">elif</span> <span class="nb">any</span><span class="p">(</span> - <span class="p">[</span> - <span class="kc">True</span> - <span class="k">if</span> <span class="p">(</span><span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">param</span><span class="p">[:</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">param</span><span class="p">[:</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="o"><</span> <span class="nb">len</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> - <span class="k">else</span> <span class="kc">False</span> - <span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">special_params</span> - <span class="p">]</span> + <span class="nb">bool</span><span class="p">(</span><span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">param</span><span class="p">[:</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">param</span><span class="p">[:</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="o"><</span> <span class="nb">len</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> + <span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">special_params</span> <span class="p">):</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"adding: </span><span class="si">{}</span><span class="s2">=</span><span class="si">{}</span><span class="s2"> to BSE_options by catching the </span><span class="si">%d</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="n">key</span><span class="p">,</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="p">),</span> @@ -436,7 +417,7 @@ <span class="c1"># Filter out keys for the grid_options</span> <span class="k">elif</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"adding: </span><span class="si">{}</span><span class="s2">=</span><span class="si">{}</span><span class="s2"> to grid_options"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">,</span> @@ -445,7 +426,7 @@ <span class="c1"># The of the keys go into a custom_options dict</span> <span class="k">else</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"<<<< Warning: Key does not match previously known parameter: </span><span class="se">\</span> <span class="s2"> adding: </span><span class="si">{}</span><span class="s2">=</span><span class="si">{}</span><span class="s2"> to custom_options >>>>"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="n">key</span><span class="p">,</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> @@ -475,7 +456,7 @@ <span class="n">cmdline_args</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="k">if</span> <span class="n">cmdline_args</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Found cmdline args. Parsing them now"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">,</span> @@ -489,47 +470,98 @@ <span class="n">cmdline_dict</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">for</span> <span class="n">cmdline_arg</span> <span class="ow">in</span> <span class="n">cmdline_args</span><span class="p">:</span> <span class="n">split</span> <span class="o">=</span> <span class="n">cmdline_arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)</span> - <span class="n">parameter</span> <span class="o">=</span> <span class="n">split</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">value</span> <span class="o">=</span> <span class="n">split</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> - <span class="n">old_value_found</span> <span class="o">=</span> <span class="kc">False</span> - - <span class="c1"># Find an old value</span> - <span class="k">if</span> <span class="n">parameter</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">:</span> - <span class="n">old_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">parameter</span><span class="p">]</span> - <span class="n">old_value_found</span> <span class="o">=</span> <span class="kc">True</span> - - <span class="k">elif</span> <span class="n">parameter</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">defaults</span><span class="p">:</span> - <span class="n">old_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">defaults</span><span class="p">[</span><span class="n">parameter</span><span class="p">]</span> - <span class="n">old_value_found</span> <span class="o">=</span> <span class="kc">True</span> - - <span class="k">elif</span> <span class="n">parameter</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">:</span> - <span class="n">old_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="n">parameter</span><span class="p">]</span> - <span class="n">old_value_found</span> <span class="o">=</span> <span class="kc">True</span> - - <span class="c1"># (attempt to) convert</span> - <span class="k">if</span> <span class="n">old_value_found</span><span class="p">:</span> - <span class="k">try</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Converting type of </span><span class="si">{}</span><span class="s2"> from </span><span class="si">{}</span><span class="s2"> to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">parameter</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">value</span><span class="p">),</span> <span class="nb">type</span><span class="p">(</span><span class="n">old_value</span><span class="p">)</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">2</span><span class="p">,</span> - <span class="p">)</span> - <span class="n">value</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">old_value</span><span class="p">)(</span><span class="n">value</span><span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span><span class="s2">"Success!"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">2</span><span class="p">)</span> - <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Tried to convert the given parameter </span><span class="si">{}</span><span class="s2">/value </span><span class="si">{}</span><span class="s2"> to its correct type </span><span class="si">{}</span><span class="s2"> (from old value </span><span class="si">{}</span><span class="s2">). But that wasn't possible."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">parameter</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">old_value</span><span class="p">),</span> <span class="n">old_value</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">0</span><span class="p">,</span> - <span class="p">)</span> + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">split</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> + <span class="n">parameter</span> <span class="o">=</span> <span class="n">split</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">value</span> <span class="o">=</span> <span class="n">split</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> + <span class="n">old_value_found</span> <span class="o">=</span> <span class="kc">False</span> + + <span class="c1"># Find an old value</span> + <span class="k">if</span> <span class="n">parameter</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">:</span> + <span class="n">old_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">parameter</span><span class="p">]</span> + <span class="n">old_value_found</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="k">elif</span> <span class="n">parameter</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">:</span> + <span class="n">old_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="n">parameter</span><span class="p">]</span> + <span class="n">old_value_found</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="k">elif</span> <span class="n">parameter</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">:</span> + <span class="n">old_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">[</span><span class="n">parameter</span><span class="p">]</span> + <span class="n">old_value_found</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="k">elif</span> <span class="n">parameter</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">defaults</span><span class="p">:</span> + <span class="c1"># this will revert to a string type, always</span> + <span class="n">old_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">defaults</span><span class="p">[</span><span class="n">parameter</span><span class="p">]</span> + <span class="n">old_value_found</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="c1"># (attempt to) convert type</span> + <span class="k">if</span> <span class="n">old_value_found</span><span class="p">:</span> + <span class="k">if</span> <span class="n">old_value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Converting type of </span><span class="si">{}</span><span class="s2"> from </span><span class="si">{}</span><span class="s2"> to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">parameter</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">value</span><span class="p">),</span> <span class="nb">type</span><span class="p">(</span><span class="n">old_value</span><span class="p">)</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">try</span><span class="p">:</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">old_value</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span> + <span class="n">value</span> <span class="o">=</span> <span class="n">str2bool</span><span class="o">.</span><span class="n">str2bool</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">value</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">old_value</span><span class="p">)(</span><span class="n">value</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Success!"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">2</span> + <span class="p">)</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Failed to convert </span><span class="si">{param}</span><span class="s2"> value with type </span><span class="si">{type}</span><span class="s2">: old_value is '</span><span class="si">{old}</span><span class="s2">', new value is '</span><span class="si">{new}</span><span class="s2">', </span><span class="si">{e}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">param</span><span class="o">=</span><span class="n">parameter</span><span class="p">,</span> + <span class="n">old</span><span class="o">=</span><span class="n">old_value</span><span class="p">,</span> + <span class="nb">type</span><span class="o">=</span><span class="nb">type</span><span class="p">(</span><span class="n">old_value</span><span class="p">),</span> + <span class="n">new</span><span class="o">=</span><span class="n">split</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> + <span class="n">e</span><span class="o">=</span><span class="n">e</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + + <span class="c1"># might be able to eval the parameter, e.g.</span> + <span class="c1"># an expression like "2-1" can eval to "1"</span> + <span class="c1"># which would be valid</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">evaled</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> + <span class="n">value</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">old_value</span><span class="p">)(</span><span class="n">evaled</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Success! (evaled)"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">2</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Tried to convert the given parameter </span><span class="si">{}</span><span class="s2">/value </span><span class="si">{}</span><span class="s2"> to its correct type </span><span class="si">{}</span><span class="s2"> (from old value </span><span class="si">{}</span><span class="s2">). But that wasn't possible."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">parameter</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">old_value</span><span class="p">),</span> <span class="n">old_value</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># Add to dict</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"setting </span><span class="si">{}</span><span class="s2"> = </span><span class="si">{}</span><span class="s2"> "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">parameter</span><span class="p">,</span> <span class="n">value</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> + <span class="n">cmdline_dict</span><span class="p">[</span><span class="n">parameter</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span> - <span class="c1"># Add to dict</span> - <span class="n">cmdline_dict</span><span class="p">[</span><span class="n">parameter</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Error: I do not know how to process"</span><span class="p">,</span> + <span class="n">cmdline_arg</span><span class="p">,</span> + <span class="s2">" : cmdline args should be in the format x=y, yours appears not to be."</span><span class="p">,</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># unpack the dictionary into the setting function that handles where the values are set</span> <span class="bp">self</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="o">**</span><span class="n">cmdline_dict</span><span class="p">)</span></div> @@ -547,246 +579,8 @@ <span class="k">for</span> <span class="n">param_name</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">parameter_dict</span><span class="p">):</span> <span class="n">argline</span> <span class="o">+=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param_name</span><span class="p">,</span> <span class="n">parameter_dict</span><span class="p">[</span><span class="n">param_name</span><span class="p">])</span> <span class="n">argline</span> <span class="o">=</span> <span class="n">argline</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> - <span class="k">return</span> <span class="n">argline</span> - - <span class="k">def</span> <span class="nf">_last_grid_variable</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function that returns the last grid variable</span> -<span class="sd"> (i.e. the one with the highest grid_variable_number)</span> -<span class="sd"> """</span> - - <span class="n">number</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">])</span> - <span class="k">for</span> <span class="n">grid_variable</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]:</span> - <span class="k">if</span> <span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">grid_variable</span><span class="p">][</span> - <span class="s2">"grid_variable_number"</span> - <span class="p">]</span> - <span class="o">==</span> <span class="n">number</span> <span class="o">-</span> <span class="mi">1</span> - <span class="p">):</span> - <span class="k">return</span> <span class="n">grid_variable</span> - -<div class="viewcode-block" id="Population.update_grid_variable"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.update_grid_variable">[docs]</a> <span class="k">def</span> <span class="nf">update_grid_variable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Function to update the values of a grid variable.</span> - -<span class="sd"> Args:</span> -<span class="sd"> name:</span> -<span class="sd"> name of the grid variable to be changed.</span> -<span class="sd"> **kwargs:</span> -<span class="sd"> key-value pairs to override the existing grid variable data. See add_grid_variable for these names.</span> -<span class="sd"> """</span> - - <span class="n">grid_variable</span> <span class="o">=</span> <span class="kc">None</span> - <span class="k">try</span><span class="p">:</span> - <span class="n">grid_variable</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">name</span><span class="p">]</span> - <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Unknown grid variable </span><span class="si">{}</span><span class="s2"> - please create it with the add_grid_variable() method."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">name</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Updated grid variable: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">)),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span></div> - -<div class="viewcode-block" id="Population.delete_grid_variable"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.delete_grid_variable">[docs]</a> <span class="k">def</span> <span class="nf">delete_grid_variable</span><span class="p">(</span> - <span class="bp">self</span><span class="p">,</span> - <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> - <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="k">try</span><span class="p">:</span> - <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">name</span><span class="p">]</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Deleted grid variable: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">except</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Failed to remove grid variable </span><span class="si">{}</span><span class="s2"> : please check it exists."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">name</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span></div> - -<div class="viewcode-block" id="Population.rename_grid_variable"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.rename_grid_variable">[docs]</a> <span class="k">def</span> <span class="nf">rename_grid_variable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">oldname</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">newname</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Function to rename a grid variable.</span> - -<span class="sd"> note: this does NOT alter the order</span> -<span class="sd"> of the self.grid_options["_grid_variables"] dictionary.</span> - -<span class="sd"> The order in which the grid variables are loaded into the grid is based on their</span> -<span class="sd"> `grid_variable_number` property</span> - -<span class="sd"> Args:</span> -<span class="sd"> oldname:</span> -<span class="sd"> old name of the grid variable</span> -<span class="sd"> newname:</span> -<span class="sd"> new name of the grid variable</span> -<span class="sd"> """</span> - - <span class="k">try</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">newname</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> - <span class="s2">"_grid_variables"</span> - <span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">oldname</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">newname</span><span class="p">][</span><span class="s2">"name"</span><span class="p">]</span> <span class="o">=</span> <span class="n">newname</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Rename grid variable: </span><span class="si">{}</span><span class="s2"> to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">oldname</span><span class="p">,</span> <span class="n">newname</span><span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">except</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Failed to rename grid variable </span><span class="si">{}</span><span class="s2"> to </span><span class="si">{}</span><span class="s2">."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">oldname</span><span class="p">,</span> <span class="n">newname</span><span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span></div> - -<div class="viewcode-block" id="Population.add_grid_variable"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.add_grid_variable">[docs]</a> <span class="k">def</span> <span class="nf">add_grid_variable</span><span class="p">(</span> - <span class="bp">self</span><span class="p">,</span> - <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> - <span class="n">longname</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> - <span class="n">valuerange</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">list</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> - <span class="n">samplerfunc</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> - <span class="n">probdist</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">],</span> - <span class="n">gridtype</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"centred"</span><span class="p">,</span> - <span class="n">branchpoint</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> - <span class="n">branchcode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> - <span class="n">precode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> - <span class="n">postcode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> - <span class="n">topcode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> - <span class="n">bottomcode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> - <span class="n">condition</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> - <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Function to add grid variables to the grid_options.</span> - -<span class="sd"> The execution of the grid generation will be through a nested for loop.</span> -<span class="sd"> Each of the grid variables will get create a deeper for loop.</span> - -<span class="sd"> The real function that generates the numbers will get written to a new file in the TMP_DIR,</span> -<span class="sd"> and then loaded imported and evaluated.</span> -<span class="sd"> beware that if you insert some destructive piece of code, it will be executed anyway.</span> -<span class="sd"> Use at own risk.</span> - -<span class="sd"> Tasks:</span> -<span class="sd"> - TODO: Fix this complex function.</span> - -<span class="sd"> Args:</span> -<span class="sd"> name:</span> -<span class="sd"> name of parameter used in the grid Python code.</span> -<span class="sd"> This is evaluated as a parameter and you can use it throughout</span> -<span class="sd"> the rest of the function</span> - -<span class="sd"> Examples:</span> -<span class="sd"> name = 'lnm1'</span> - -<span class="sd"> parameter_name:</span> -<span class="sd"> name of the parameter in binary_c</span> - -<span class="sd"> This name must correspond to a Python variable of the same name,</span> -<span class="sd"> which is automatic if parameter_name == name.</span> - -<span class="sd"> Note: if parameter_name != name, you must set a</span> -<span class="sd"> variable in "precode" or "postcode" to define a Python variable</span> -<span class="sd"> called parameter_name</span> - -<span class="sd"> longname:</span> -<span class="sd"> Long name of parameter</span> - -<span class="sd"> Examples:</span> -<span class="sd"> longname = 'Primary mass'</span> -<span class="sd"> range:</span> -<span class="sd"> Range of values to take. Does not get used really, the samplerfunc is used to</span> -<span class="sd"> get the values from</span> - -<span class="sd"> Examples:</span> -<span class="sd"> range = [math.log(m_min), math.log(m_max)]</span> -<span class="sd"> samplerfunc:</span> -<span class="sd"> Function returning a list or numpy array of samples spaced appropriately.</span> -<span class="sd"> You can either use a real function, or a string representation of a function call.</span> - -<span class="sd"> Examples:</span> -<span class="sd"> samplerfunc = "const(math.log(m_min), math.log(m_max), {})".format(resolution['M_1'])</span> - -<span class="sd"> precode:</span> -<span class="sd"> Extra room for some code. This code will be evaluated within the loop of the</span> -<span class="sd"> sampling function (i.e. a value for lnm1 is chosen already)</span> - -<span class="sd"> Examples:</span> -<span class="sd"> precode = 'M_1=math.exp(lnm1);'</span> -<span class="sd"> postcode:</span> -<span class="sd"> Code executed after the probability is calculated.</span> -<span class="sd"> probdist:</span> -<span class="sd"> Function determining the probability that gets assigned to the sampled parameter</span> - -<span class="sd"> Examples:</span> -<span class="sd"> probdist = 'Kroupa2001(M_1)*M_1'</span> -<span class="sd"> dphasevol:</span> -<span class="sd"> part of the parameter space that the total probability is calculated with. Put to -1</span> -<span class="sd"> if you want to ignore any dphasevol calculations and set the value to 1</span> -<span class="sd"> Examples:</span> -<span class="sd"> dphasevol = 'dlnm1'</span> -<span class="sd"> condition:</span> -<span class="sd"> condition that has to be met in order for the grid generation to continue</span> -<span class="sd"> Examples:</span> -<span class="sd"> condition = 'self.grid_options['binary']==1'</span> -<span class="sd"> gridtype:</span> -<span class="sd"> Method on how the value range is sampled. Can be either 'edge' (steps starting at</span> -<span class="sd"> the lower edge of the value range) or 'centred'</span> -<span class="sd"> (steps starting at lower edge + 0.5 * stepsize).</span> - -<span class="sd"> topcode:</span> -<span class="sd"> Code added at the very top of the block.</span> - -<span class="sd"> bottomcode:</span> -<span class="sd"> Code added at the very bottom of the block.</span> -<span class="sd"> """</span> - - <span class="c1"># Add grid_variable</span> - <span class="n">grid_variable</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"name"</span><span class="p">:</span> <span class="n">name</span><span class="p">,</span> - <span class="s2">"parameter_name"</span><span class="p">:</span> <span class="n">parameter_name</span><span class="p">,</span> - <span class="s2">"longname"</span><span class="p">:</span> <span class="n">longname</span><span class="p">,</span> - <span class="s2">"valuerange"</span><span class="p">:</span> <span class="n">valuerange</span><span class="p">,</span> - <span class="c1"># "resolution": 0,</span> - <span class="s2">"samplerfunc"</span><span class="p">:</span> <span class="n">samplerfunc</span><span class="p">,</span> - <span class="s2">"precode"</span><span class="p">:</span> <span class="n">precode</span><span class="p">,</span> - <span class="s2">"postcode"</span><span class="p">:</span> <span class="n">postcode</span><span class="p">,</span> - <span class="s2">"probdist"</span><span class="p">:</span> <span class="n">probdist</span><span class="p">,</span> - <span class="s2">"dphasevol"</span><span class="p">:</span> <span class="n">dphasevol</span><span class="p">,</span> - <span class="s2">"condition"</span><span class="p">:</span> <span class="n">condition</span><span class="p">,</span> - <span class="s2">"gridtype"</span><span class="p">:</span> <span class="n">gridtype</span><span class="p">,</span> - <span class="s2">"branchpoint"</span><span class="p">:</span> <span class="n">branchpoint</span><span class="p">,</span> - <span class="s2">"branchcode"</span><span class="p">:</span> <span class="n">branchcode</span><span class="p">,</span> - <span class="s2">"topcode"</span><span class="p">:</span> <span class="n">topcode</span><span class="p">,</span> - <span class="s2">"bottomcode"</span><span class="p">:</span> <span class="n">bottomcode</span><span class="p">,</span> - <span class="s2">"grid_variable_number"</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]),</span> - <span class="p">}</span> - - <span class="c1"># Check for gridtype input</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">gridtype</span> <span class="ow">in</span> <span class="p">[</span> - <span class="s2">"edge"</span><span class="p">,</span> - <span class="s2">"right"</span><span class="p">,</span> - <span class="s2">"right edge"</span><span class="p">,</span> - <span class="s2">"left"</span><span class="p">,</span> - <span class="s2">"left edge"</span><span class="p">,</span> - <span class="s2">"centred"</span><span class="p">,</span> - <span class="s2">"centre"</span><span class="p">,</span> - <span class="s2">"center"</span><span class="p">,</span> - <span class="p">]:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Unknown gridtype value. Please start another one"</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="c1"># Load it into the grid_options</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]]</span> <span class="o">=</span> <span class="n">grid_variable</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Added grid variable: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">)),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span></div> + <span class="k">return</span> <span class="n">argline</span> <span class="c1">###################################################</span> <span class="c1"># Return functions</span> @@ -809,15 +603,6 @@ <span class="k">return</span> <span class="n">options</span></div> -<div class="viewcode-block" id="Population.return_binary_c_version_info"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.return_binary_c_version_info">[docs]</a> <span class="k">def</span> <span class="nf">return_binary_c_version_info</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function that returns the version information of binary_c</span> -<span class="sd"> """</span> - - <span class="n">version_info</span> <span class="o">=</span> <span class="n">return_binary_c_version_info</span><span class="p">(</span><span class="n">parsed</span><span class="o">=</span><span class="n">parsed</span><span class="p">)</span> - - <span class="k">return</span> <span class="n">version_info</span></div> - <div class="viewcode-block" id="Population.return_binary_c_defaults"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.return_binary_c_defaults">[docs]</a> <span class="k">def</span> <span class="nf">return_binary_c_defaults</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Function that returns the defaults of the binary_c version that is used.</span> @@ -865,7 +650,7 @@ <span class="n">all_info</span><span class="p">[</span><span class="s2">"binary_c_defaults"</span><span class="p">]</span> <span class="o">=</span> <span class="n">binary_c_defaults</span> <span class="k">if</span> <span class="n">include_binary_c_version_info</span><span class="p">:</span> - <span class="n">binary_c_version_info</span> <span class="o">=</span> <span class="n">return_binary_c_version_info</span><span class="p">(</span><span class="n">parsed</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <span class="n">binary_c_version_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">return_binary_c_version_info</span><span class="p">(</span><span class="n">parsed</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="n">all_info</span><span class="p">[</span><span class="s2">"binary_c_version_info"</span><span class="p">]</span> <span class="o">=</span> <span class="n">binary_c_version_info</span> <span class="k">if</span> <span class="n">include_binary_c_help_all</span><span class="p">:</span> @@ -882,14 +667,13 @@ <span class="n">include_binary_c_defaults</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">include_binary_c_version_info</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">include_binary_c_help_all</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> + <span class="n">ensure_ascii</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> + <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">4</span><span class="p">,</span> <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]:</span> <span class="sd">"""</span> <span class="sd"> Function that exports the all_info to a JSON file</span> <span class="sd"> Tasks:</span> -<span class="sd"> - TODO: if any of the values in the dicts here is of a not-serialisable form, then we</span> -<span class="sd"> need to change that to a string or something so, use a recursive function that</span> -<span class="sd"> goes over the all_info dict and finds those that fit</span> <span class="sd"> - TODO: Fix to write things to the directory. which options do which etc</span> <span class="sd"> - TODO: there's flawed logic here. rewrite this part pls</span> <span class="sd"> - TODO: consider actually just removing the whole 'output to file' part and let the</span> @@ -909,6 +693,9 @@ <span class="sd"> <custom_options["base_filename"]>_settings.json. Otherwise a file called</span> <span class="sd"> simulation_<date+time>_settings.json will be created</span> <span class="sd"> outfile: if use_datadir is false, a custom filename will be used</span> +<span class="sd"> ensure_ascii: the ensure_ascii flag passed to json.dump and/or json.dumps</span> +<span class="sd"> (Default: False)</span> +<span class="sd"> indent: indentation passed to json.dump and/or json.dumps (default 4)</span> <span class="sd"> """</span> <span class="n">all_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">return_all_info</span><span class="p">(</span> @@ -924,17 +711,14 @@ <span class="k">if</span> <span class="n">use_datadir</span><span class="p">:</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"data_dir"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"base_filename"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">base_name</span> <span class="o">=</span> <span class="s2">"simulation_</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span> - <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">(),</span> <span class="s2">"%Y%m</span><span class="si">%d</span><span class="s2">_%H%M%S"</span> - <span class="p">)</span> - <span class="p">)</span> + <span class="n">base_name</span> <span class="o">=</span> <span class="s2">"simulation_</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">now</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s2">"nospace"</span><span class="p">))</span> <span class="k">else</span><span class="p">:</span> <span class="n">base_name</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="s2">"base_filename"</span><span class="p">])[</span> <span class="mi">0</span> <span class="p">]</span> - <span class="n">settings_name</span> <span class="o">=</span> <span class="n">base_name</span> <span class="o">+</span> <span class="s2">"_settings.json"</span> + <span class="c1"># save settings as gzipped JSON</span> + <span class="n">settings_name</span> <span class="o">=</span> <span class="n">base_name</span> <span class="o">+</span> <span class="s2">"_settings.json.gz"</span> <span class="c1"># Check directory, make if necessary</span> <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="s2">"data_dir"</span><span class="p">],</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> @@ -943,184 +727,96 @@ <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="s2">"data_dir"</span><span class="p">],</span> <span class="n">settings_name</span> <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Writing settings to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">settings_fullname</span><span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># if not outfile.endswith('json'):</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">settings_fullname</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span> - <span class="n">file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span> - <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span> - <span class="n">all_info_cleaned</span><span class="p">,</span> - <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> - <span class="n">default</span><span class="o">=</span><span class="n">binaryc_json_serializer</span><span class="p">,</span> - <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"ok"</span><span class="p">)</span> + + <span class="c1"># open locked settings file, then output if we get the lock</span> + <span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">lock</span><span class="p">)</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locked_open_for_write</span><span class="p">(</span><span class="n">settings_fullname</span><span class="p">,</span> <span class="n">vb</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"ok"</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">lock</span> <span class="ow">and</span> <span class="n">f</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Writing settings to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">settings_fullname</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> <span class="p">)</span> + <span class="n">json</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span> + <span class="n">all_info_cleaned</span><span class="p">,</span> + <span class="n">f</span><span class="p">,</span> + <span class="n">indent</span><span class="o">=</span><span class="n">indent</span><span class="p">,</span> + <span class="n">default</span><span class="o">=</span><span class="n">binaryc_json_serializer</span><span class="p">,</span> + <span class="n">ensure_ascii</span><span class="o">=</span><span class="n">ensure_ascii</span><span class="p">,</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"ok pre"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">locked_close</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">lock</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"ok ret"</span><span class="p">)</span> <span class="k">return</span> <span class="n">settings_fullname</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Exporting all info without passing a value for `outfile` requires custom_options['data_dir'] to be present. That is not the cause. Either set the `data_dir` or pass a value for `outfile` "</span> - <span class="k">raise</span> <span class="ne">ValueError</span> + + <span class="c1"># TODO: turn it around and have the exception be within the if statement</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Exporting all info without passing a value for `outfile` requires custom_options['data_dir'] to be present. That is not the cause. Either set the `data_dir` or pass a value for `outfile` "</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> <span class="k">else</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Writing settings to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">outfile</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">,</span> <span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">outfile</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">"json"</span><span class="p">):</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Error: outfile (</span><span class="si">{}</span><span class="s2">) must end with .json"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">outfile</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> <span class="p">)</span> <span class="k">raise</span> <span class="ne">ValueError</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span> - <span class="n">file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span> - <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span> - <span class="n">all_info_cleaned</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">binaryc_json_serializer</span> - <span class="p">)</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span> + <span class="n">json</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span> + <span class="n">all_info_cleaned</span><span class="p">,</span> + <span class="n">file</span><span class="p">,</span> + <span class="n">indent</span><span class="o">=</span><span class="n">indent</span><span class="p">,</span> + <span class="n">default</span><span class="o">=</span><span class="n">binaryc_json_serializer</span><span class="p">,</span> + <span class="n">ensure_ascii</span><span class="o">=</span><span class="n">ensure_ascii</span><span class="p">,</span> <span class="p">)</span> <span class="k">return</span> <span class="n">outfile</span></div> - <span class="k">def</span> <span class="nf">_boxed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="nb">list</span><span class="p">,</span> <span class="n">colour</span><span class="o">=</span><span class="s2">"yellow on black"</span><span class="p">,</span> <span class="n">boxchar</span><span class="o">=</span><span class="s2">"*"</span><span class="p">,</span> <span class="n">separator</span><span class="o">=</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to output a list of strings in a single box.</span> + <span class="c1">###################################################</span> + <span class="c1"># Evolution functions</span> + <span class="c1">###################################################</span> -<span class="sd"> Args:</span> -<span class="sd"> list = a list of strings to be output. If these contain the separator</span> -<span class="sd"> (see below) these strings are split by it.</span> -<span class="sd"> separator = strings are split on this, default "\n"</span> -<span class="sd"> colour = the colour to be used, usually this is 'yellow on black'</span> -<span class="sd"> as set in the ANSI_colours dict</span> -<span class="sd"> boxchar = the character used to make the box, '*' by default</span> - -<span class="sd"> Note: handles tabs (\t) badly, do not use them!</span> -<span class="sd"> """</span> - <span class="n">strlen</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">strings</span> <span class="o">=</span> <span class="p">[]</span> - <span class="n">lengths</span> <span class="o">=</span> <span class="p">[]</span> - - <span class="c1"># make a list of strings</span> - <span class="k">if</span> <span class="n">separator</span><span class="p">:</span> - <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">:</span> - <span class="n">strings</span> <span class="o">+=</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">sep</span><span class="o">=</span><span class="n">separator</span><span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">strings</span> <span class="o">=</span> <span class="nb">list</span> - - <span class="c1"># get lengths without ANSI codes</span> - <span class="k">for</span> <span class="n">string</span> <span class="ow">in</span> <span class="n">strings</span><span class="p">:</span> - <span class="n">lengths</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">strip_ansi</span><span class="o">.</span><span class="n">strip_ansi</span><span class="p">(</span><span class="n">string</span><span class="p">)))</span> - - <span class="c1"># hence the max length</span> - <span class="n">strlen</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">lengths</span><span class="p">)</span> - <span class="n">strlen</span> <span class="o">+=</span> <span class="n">strlen</span> <span class="o">%</span> <span class="mi">2</span> - <span class="n">header</span> <span class="o">=</span> <span class="n">boxchar</span> <span class="o">*</span> <span class="p">(</span><span class="mi">4</span> <span class="o">+</span> <span class="n">strlen</span><span class="p">)</span> - - <span class="c1"># start output</span> - <span class="n">out</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="n">colour</span><span class="p">]</span> <span class="o">+</span> <span class="n">header</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - - <span class="c1"># loop over strings to output, padding as required</span> - <span class="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="n">string</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">strings</span><span class="p">):</span> - <span class="k">if</span> <span class="n">lengths</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="n">string</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">string</span> - <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="nb">int</span><span class="p">((</span><span class="n">strlen</span> <span class="o">-</span> <span class="n">lengths</span><span class="p">[</span><span class="n">n</span><span class="p">])</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span> - <span class="n">out</span> <span class="o">=</span> <span class="n">out</span> <span class="o">+</span> <span class="n">boxchar</span> <span class="o">+</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">pad</span> <span class="o">+</span> <span class="n">string</span> <span class="o">+</span> <span class="n">pad</span> <span class="o">+</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">boxchar</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="c1"># close output and return</span> - <span class="n">out</span> <span class="o">=</span> <span class="n">out</span> <span class="o">+</span> <span class="n">header</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">]</span> - <span class="k">return</span> <span class="n">out</span> - - <span class="k">def</span> <span class="nf">_set_custom_logging</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="k">def</span> <span class="nf">_set_nprocesses</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> -<span class="sd"> Function/routine to set all the custom logging so that the function memory pointer</span> -<span class="sd"> is known to the grid.</span> - -<span class="sd"> When the memory adress is loaded and the library file is set we'll skip rebuilding the library</span> -<span class="sd"> """</span> - - <span class="c1"># Only if the values are the 'default' unset values</span> - <span class="k">if</span> <span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"custom_logging_func_memaddr"</span><span class="p">]</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span> - <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span> - <span class="p">):</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Creating and loading custom logging functionality"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># C_logging_code gets priority of C_autogen_code</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"C_logging_code"</span><span class="p">]:</span> - <span class="c1"># Generate entire shared lib code around logging lines</span> - <span class="n">custom_logging_code</span> <span class="o">=</span> <span class="n">binary_c_log_code</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"C_logging_code"</span><span class="p">],</span> - <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> - <span class="o">-</span> <span class="p">(</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> - <span class="p">)</span> +<span class="sd"> Function to set the number of processes used in multiprocessing.</span> - <span class="c1"># Load memory address</span> - <span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"custom_logging_func_memaddr"</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">],</span> - <span class="p">)</span> <span class="o">=</span> <span class="n">create_and_load_logging_function</span><span class="p">(</span> - <span class="n">custom_logging_code</span><span class="p">,</span> - <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> - <span class="o">-</span> <span class="p">(</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> - <span class="n">custom_tmp_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> - <span class="p">)</span> - - <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"C_auto_logging"</span><span class="p">]:</span> - <span class="c1"># Generate real logging code</span> - <span class="n">logging_line</span> <span class="o">=</span> <span class="n">autogen_C_logging_code</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"C_auto_logging"</span><span class="p">],</span> - <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> - <span class="o">-</span> <span class="p">(</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> - <span class="p">)</span> +<span class="sd"> If grid_options['num_cores'] <= 0, set automatically</span> - <span class="c1"># Generate entire shared lib code around logging lines</span> - <span class="n">custom_logging_code</span> <span class="o">=</span> <span class="n">binary_c_log_code</span><span class="p">(</span> - <span class="n">logging_line</span><span class="p">,</span> - <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> - <span class="o">-</span> <span class="p">(</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> - <span class="p">)</span> +<span class="sd"> If grid_options['num_cores'] is 0, we use as many as we have available</span> +<span class="sd"> """</span> + <span class="c1"># backwards compatibility</span> + <span class="k">if</span> <span class="s2">"amt_cores"</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"amt_cores"</span><span class="p">]</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"amt_cores"</span><span class="p">]</span> - <span class="c1"># Load memory address</span> - <span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"custom_logging_func_memaddr"</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">],</span> - <span class="p">)</span> <span class="o">=</span> <span class="n">create_and_load_logging_function</span><span class="p">(</span> - <span class="n">custom_logging_code</span><span class="p">,</span> - <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> - <span class="o">-</span> <span class="p">(</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> - <span class="n">custom_tmp_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> - <span class="p">)</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="c1"># use all logical cores available to us</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">psutil</span><span class="o">.</span><span class="n">cpu_count</span><span class="p">(</span><span class="n">logical</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">]</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span> + <span class="c1"># use all physical cores available to us</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">psutil</span><span class="o">.</span><span class="n">cpu_count</span><span class="p">(</span><span class="n">logical</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> <span class="k">else</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Custom logging library already loaded. Not setting them again."</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1">###################################################</span> - <span class="c1"># Ensemble functions</span> - <span class="c1">###################################################</span> - - <span class="c1"># Now they are stored in the _process_run_population thing.</span> - <span class="c1"># Needed less code since they all</span> + <span class="c1"># manually specify number of cores made available</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">]</span> - <span class="c1">###################################################</span> - <span class="c1"># Evolution functions</span> - <span class="c1">###################################################</span> - - <span class="k">def</span> <span class="nf">_pre_run_cleanup</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> + <span class="k">def</span> <span class="nf">_pre_run_setup</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="sd">"""</span> <span class="sd"> Function to clean up some stuff in the grid before a run (like results, ensemble results etc)</span> <span class="sd"> """</span> <span class="c1"># empty results</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"results"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_results</span> <span class="o">=</span> <span class="n">AutoVivificationDict</span><span class="p">()</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span> <span class="o">=</span> <span class="p">{}</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_new_grid_ensemble_results</span><span class="p">()</span> + + <span class="c1"># set number of processes/cores we want to use</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_set_nprocesses</span><span class="p">()</span> <span class="c1"># Reset the process ID (should not have a value initially, but can't hurt if it does)</span> <span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span> <span class="o">=</span> <span class="mi">0</span> @@ -1133,7 +829,6 @@ <span class="c1"># set previous logging time</span> <span class="n">_t</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> - <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_time"</span><span class="p">]</span> <span class="o">=</span> <span class="n">multiprocessing</span><span class="o">.</span><span class="n">Array</span><span class="p">(</span> <span class="s2">"d"</span><span class="p">,</span> <span class="p">[</span><span class="n">_t</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"n_logging_stats"</span><span class="p">]</span> <span class="p">)</span> @@ -1145,85 +840,167 @@ <span class="c1"># arrays to store memory and max memory use per-thread</span> <span class="n">mem</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">*</span> <span class="n">mem_use</span><span class="p">()</span> - <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"memory_use_per_thread"</span><span class="p">]</span> <span class="o">=</span> <span class="n">multiprocessing</span><span class="o">.</span><span class="n">Array</span><span class="p">(</span> - <span class="s2">"d"</span><span class="p">,</span> <span class="p">[</span><span class="n">mem</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">]</span> - <span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"max_memory_use_per_thread"</span><span class="p">]</span> <span class="o">=</span> <span class="n">multiprocessing</span><span class="o">.</span><span class="n">Array</span><span class="p">(</span> - <span class="s2">"d"</span><span class="p">,</span> <span class="p">[</span><span class="n">mem</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">]</span> - <span class="p">)</span> + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">""</span><span class="p">,</span> <span class="s2">"max_"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="n">x</span> <span class="o">+</span> <span class="s2">"memory_use_per_thread"</span><span class="p">]</span> <span class="o">=</span> <span class="n">multiprocessing</span><span class="o">.</span><span class="n">Array</span><span class="p">(</span> + <span class="s2">"d"</span><span class="p">,</span> <span class="p">[</span><span class="n">mem</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]</span> + <span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># set and check default directory locations</span> + <span class="c1">############################################################</span> + + <span class="c1"># check tmp_dir exists</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">]</span> + <span class="p">):</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"grid_options['tmp_dir'] is not set or it is not a directory : this should point to a temporary directory location, preferably local to your CPUs"</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># check any HPC requirements are met</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job</span><span class="p">()</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_check_requirements</span><span class="p">()[</span><span class="mi">0</span><span class="p">]:</span> + <span class="nb">print</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">HPC_check_requirements</span><span class="p">()[</span><span class="mi">1</span><span class="p">])</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># default status_dir and cache_dir to be in tmp_dir</span> + <span class="c1">#</span> + <span class="c1"># NOTE: binary_c-python uses its own status_dir, which is not</span> + <span class="c1"># the same dir as HPC jobs use (so tmp_dir can be local</span> + <span class="c1"># to an HPC job, while the HPC status dir is common to</span> + <span class="c1"># all jobs)</span> + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"status"</span><span class="p">,</span> <span class="s2">"cache"</span><span class="p">]:</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">x</span> <span class="o">+</span> <span class="s2">"_dir"</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">x</span> <span class="o">+</span> <span class="s2">"_dir"</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="n">x</span> + <span class="p">)</span> + + <span class="c1"># make list of directories we want to use</span> + <span class="n">dirs</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">,</span> <span class="s2">"status_dir"</span><span class="p">,</span> <span class="s2">"cache_dir"</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_dirs</span><span class="p">()</span> + + <span class="k">for</span> <span class="nb">dir</span> <span class="ow">in</span> <span class="n">dirs</span><span class="p">:</span> + <span class="c1"># try to make directories if they don't exist</span> + <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="nb">dir</span><span class="p">]</span> + <span class="k">if</span> <span class="n">path</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + + <span class="c1"># check directories exist and can be written to</span> + <span class="k">if</span> <span class="n">path</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">dir_ok</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Directory </span><span class="si">{dir}</span><span class="s2"> currently set to </span><span class="si">{path}</span><span class="s2"> cannot be written to. Please check that this directory is correct and you have write access."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">dir</span><span class="o">=</span><span class="nb">dir</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># Make sure the subdirs of the tmp dir exist</span> + <span class="n">subdirs</span> <span class="o">=</span> <span class="p">[</span> + <span class="s2">"failed_systems"</span><span class="p">,</span> + <span class="s2">"process_summary"</span><span class="p">,</span> + <span class="s2">"runtime_systems"</span><span class="p">,</span> + <span class="s2">"snapshots"</span><span class="p">,</span> + <span class="p">]</span> + <span class="k">for</span> <span class="n">subdir</span> <span class="ow">in</span> <span class="n">subdirs</span><span class="p">:</span> + <span class="n">path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="n">subdir</span><span class="p">)</span> + <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dir_ok</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Sub-Directory </span><span class="si">{subdir}</span><span class="s2"> (in tmp_dir) currently set to </span><span class="si">{path}</span><span class="s2"> cannot be written to. Please check that this directory is correct and you have write access."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">subdir</span><span class="o">=</span><span class="n">subdir</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># make sure the arg logging directory exists if we need it</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_args"</span><span class="p">]:</span> + <span class="n">path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_args_dir"</span><span class="p">]</span> + <span class="p">)</span> + <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dir_ok</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Failed to make directory at </span><span class="si">{log_args_dir}</span><span class="s2"> for output of system arguments. Please check that this directory is correct and you have write access."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">subdir</span><span class="o">=</span><span class="n">subdir</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># restore from existing HPC files</span> + <span class="bp">self</span><span class="o">.</span><span class="n">HPC_restore</span><span class="p">()</span> + + <span class="c1"># set up function cache</span> + <span class="bp">self</span><span class="o">.</span><span class="n">setup_function_cache</span><span class="p">()</span> + + <span class="k">return</span> <div class="viewcode-block" id="Population.clean"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.clean">[docs]</a> <span class="k">def</span> <span class="nf">clean</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="sd">"""</span> <span class="sd"> Clean the contents of the population object so it can be reused.</span> -<span class="sd"> Calling _pre_run_cleanup()</span> +<span class="sd"> Calling _pre_run_setup()</span> <span class="sd"> TODO: decide to deprecate this function</span> <span class="sd"> """</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_pre_run_cleanup</span><span class="p">()</span></div> + <span class="bp">self</span><span class="o">.</span><span class="n">_pre_run_setup</span><span class="p">()</span></div> <div class="viewcode-block" id="Population.evolve"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.evolve">[docs]</a> <span class="k">def</span> <span class="nf">evolve</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="sd">"""</span> <span class="sd"> Entry point function of the whole object. From here, based on the settings,</span> -<span class="sd"> we set up a SLURM or CONDOR grid, or if no setting is given we go straight</span> -<span class="sd"> to evolving the population.</span> +<span class="sd"> we set up a grid and (probably) evolve the population.</span> -<span class="sd"> There are no direct arguments to this function, rather it is based on the grid_options settings:</span> -<span class="sd"> grid_options['slurm']: integer Boolean whether to use a slurm_grid evolution</span> -<span class="sd"> grid_options['condor']: integer Boolean whether to use a condor_grid evolution</span> +<span class="sd"> There are no direct arguments to this function, the grid_options</span> +<span class="sd"> contain all the relevant settings.</span> -<span class="sd"> If neither of the above is set, we continue without using HPC routines</span> -<span class="sd"> (that doesn't mean this cannot be run on a server with many cores)</span> - -<span class="sd"> Returns an dictionary containing the analytics of the run</span> - -<span class="sd"> TODO: change the way this is done. Slurm & CONDOR should probably do this differently</span> -<span class="sd"> NOTE: SLURM and CONDOR options are not working properly yet</span> +<span class="sd"> Returns:</span> +<span class="sd"> a dictionary containing the analytics of the run.</span> <span class="sd"> """</span> <span class="c1"># Just to make sure we don't have stuff from a previous run hanging around</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_pre_run_cleanup</span><span class="p">()</span> - - <span class="c1"># Check which type:</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="c1"># Execute Slurm subroutines</span> - <span class="c1"># self._slurm_grid()</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Slurm evolution not available at this moment"</span><span class="p">)</span> - - <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="c1"># Execute condor subroutines</span> - <span class="c1"># self._condor_grid()</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Condor evolution not available at this moment"</span><span class="p">)</span> - - <span class="k">else</span><span class="p">:</span> - <span class="c1"># Execute population evolution subroutines</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_evolve_population</span><span class="p">()</span> - - <span class="c1"># Put all interesting stuff in a variable and output that afterwards, as analytics of the run.</span> - <span class="n">analytics_dict</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"population_name"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_population_id"</span><span class="p">],</span> - <span class="s2">"evolution_type"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">],</span> - <span class="s2">"failed_count"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_count"</span><span class="p">],</span> - <span class="s2">"failed_prob"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_prob"</span><span class="p">],</span> - <span class="s2">"failed_systems_error_codes"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> - <span class="s2">"_failed_systems_error_codes"</span> - <span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> - <span class="s2">"errors_exceeded"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_exceeded"</span><span class="p">],</span> - <span class="s2">"errors_found"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_found"</span><span class="p">],</span> - <span class="s2">"total_probability"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_probtot"</span><span class="p">],</span> - <span class="s2">"total_count"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">],</span> - <span class="s2">"start_timestamp"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_start_time_evolution"</span><span class="p">],</span> - <span class="s2">"end_timestamp"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_end_time_evolution"</span><span class="p">],</span> - <span class="s2">"total_mass_run"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_mass_run"</span><span class="p">],</span> - <span class="s2">"total_probability_weighted_mass_run"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> - <span class="s2">"_total_probability_weighted_mass_run"</span> - <span class="p">],</span> - <span class="s2">"zero_prob_stars_skipped"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_zero_prob_stars_skipped"</span><span class="p">],</span> - <span class="p">}</span> - - <span class="c1"># Add analytics dict to the metadata too:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">analytics_dict</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_pre_run_setup</span><span class="p">()</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job</span><span class="p">():</span> + <span class="c1"># run HPC grid: if this returns True, then exit immediately</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"symlink_latest_gridcode"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_grid</span><span class="p">():</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"join"</span><span class="p">:</span> + <span class="c1"># join previously calculated data and return immediately</span> + <span class="bp">self</span><span class="o">.</span><span class="n">HPC_join_previous</span><span class="p">()</span> + <span class="k">return</span> + + <span class="c1"># Execute population evolution subroutines</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_evolve_population</span><span class="p">()</span> + + <span class="c1"># make analytics information</span> + <span class="n">analytics_dict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">make_analytics_dict</span><span class="p">()</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job</span><span class="p">():</span> + <span class="bp">self</span><span class="o">.</span><span class="n">HPC_dump_status</span><span class="p">(</span><span class="s2">"HPC grid after analytics"</span><span class="p">)</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="s2">"save_snapshot"</span><span class="p">]:</span> + <span class="c1"># we must save a snapshot, not the population object</span> + <span class="c1"># ... also save the new starting point: this has to take into</span> + <span class="c1"># account where we originally started, and that the modulo may</span> + <span class="c1"># not be == 1.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]</span> + <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"modulo"</span><span class="p">]</span> + <span class="p">)</span> + <span class="c1"># then save the snapshot</span> + <span class="bp">self</span><span class="o">.</span><span class="n">save_snapshot</span><span class="p">()</span> + <span class="n">exitcode</span> <span class="o">=</span> <span class="mi">1</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">was_killed</span><span class="p">()</span> <span class="k">else</span> <span class="mi">0</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="n">exitcode</span><span class="p">)</span> + + <span class="c1"># Save object to a pickle file</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"save_population_object"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">save_population_object</span><span class="p">()</span> + + <span class="c1"># if we're running an HPC grid, exit here</span> + <span class="c1"># unless we're joining</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job</span><span class="p">()</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">"join"</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span> <span class="c1">##</span> <span class="c1"># Clean up code: remove files, unset values, unload interpolators etc. This is placed in the general evolve function,</span> @@ -1245,22 +1022,20 @@ <span class="sd"> - TODO: include options for different ways of generating a population here. (i.e. MC or source file)</span> <span class="sd"> """</span> - <span class="c1">##</span> + <span class="c1">############################################################</span> <span class="c1"># Prepare code/initialise grid.</span> <span class="c1"># set custom logging, set up store_memaddr, build grid code. dry run grid code.</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_setup</span><span class="p">()</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_setup</span><span class="p">()</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span> + <span class="k">return</span> - <span class="c1">##</span> - <span class="c1"># Evolve systems: via grid_options one can choose to do this linearly, or</span> - <span class="c1"># multiprocessing method.</span> + <span class="c1">############################################################</span> + <span class="c1"># Evolve systems</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_time</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> <span class="k">if</span> <span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_evolution_type_options"</span><span class="p">]</span> <span class="p">):</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"grid"</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_evolve_population_grid</span><span class="p">()</span> - <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"custom_generator"</span><span class="p">:</span> - <span class="c1"># Use the same as the normal grid evolution but just a different generator</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"grid"</span><span class="p">,</span> <span class="s2">"custom_generator"</span><span class="p">]:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_evolve_population_grid</span><span class="p">()</span> <span class="c1"># elif self.grid_options["evolution_type"] == "mc":</span> @@ -1272,30 +1047,40 @@ <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_evolution_type_options"</span><span class="p">]</span> <span class="p">)</span> <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_time</span><span class="p">(</span><span class="s2">"end"</span><span class="p">)</span> - <span class="c1"># finished!</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_end_time_evolution"</span><span class="p">]</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> - + <span class="c1">############################################################</span> <span class="c1"># Log and print some information</span> - <span class="n">dtsecs</span> <span class="o">=</span> <span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_end_time_evolution"</span><span class="p">]</span> - <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_start_time_evolution"</span><span class="p">]</span> - <span class="p">)</span> <span class="n">string1</span> <span class="o">=</span> <span class="s2">"Population-</span><span class="si">{}</span><span class="s2"> finished!</span><span class="se">\n</span><span class="s2">The total probability is </span><span class="si">{:g}</span><span class="s2">."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_population_id"</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_probtot"</span><span class="p">]</span> <span class="p">)</span> - <span class="n">string2</span> <span class="o">=</span> <span class="s2">"It took a total of </span><span class="si">{dtsecs}</span><span class="s2"> to run </span><span class="si">{starcount}</span><span class="s2"> systems on </span><span class="si">{ncores}</span><span class="s2"> cores</span><span class="se">\n</span><span class="s2"> = </span><span class="si">{totaldtsecs}</span><span class="s2"> of CPU time.</span><span class="se">\n</span><span class="s2">Maximum memory use </span><span class="si">{memuse:.3f}</span><span class="s2"> MB"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">dtsecs</span><span class="o">=</span><span class="n">timedelta</span><span class="p">(</span><span class="n">dtsecs</span><span class="p">),</span> - <span class="n">starcount</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">],</span> - <span class="n">ncores</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">],</span> - <span class="n">totaldtsecs</span><span class="o">=</span><span class="n">timedelta</span><span class="p">(</span><span class="n">dtsecs</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">]),</span> + <span class="n">string2</span> <span class="o">=</span> <span class="s2">"It took a total of </span><span class="si">{dtsecs}</span><span class="s2"> to run </span><span class="si">{starcount}</span><span class="s2"> systems on </span><span class="si">{ncores}</span><span class="s2"> cores</span><span class="se">\n</span><span class="s2"> = </span><span class="si">{CPUtime}</span><span class="s2"> of CPU time.</span><span class="se">\n</span><span class="s2">Maximum memory use </span><span class="si">{memuse:.3f}</span><span class="s2"> MB"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">dtsecs</span><span class="o">=</span><span class="n">timedelta</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_time_elapsed"</span><span class="p">]),</span> + <span class="n">starcount</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"_count"</span> + <span class="p">],</span> <span class="c1"># not _total_count! we may have ended the run early...</span> + <span class="n">ncores</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">],</span> + <span class="n">CPUtime</span><span class="o">=</span><span class="n">timedelta</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CPU_time</span><span class="p">()),</span> <span class="n">memuse</span><span class="o">=</span><span class="nb">sum</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"max_memory_use_per_thread"</span><span class="p">]),</span> <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_boxed</span><span class="p">(</span><span class="n">string1</span><span class="p">,</span> <span class="n">string2</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">0</span><span class="p">)</span> + <span class="c1">############################################################</span> + <span class="c1"># add warning about a grid that was killed</span> + <span class="c1">############################################################</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">was_killed</span><span class="p">():</span> + <span class="n">string2</span> <span class="o">+=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">>>> Grid was killed <<<"</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_status</span><span class="p">(</span><span class="s2">"killed"</span><span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_boxed</span><span class="p">(</span><span class="n">string1</span><span class="p">,</span> <span class="n">string2</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">0</span> + <span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># handle errors</span> + <span class="c1">############################################################</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_found"</span><span class="p">]:</span> <span class="c1"># Some information afterwards</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">_boxed</span><span class="p">(</span> <span class="s2">"During the run </span><span class="si">{}</span><span class="s2"> failed systems were found</span><span class="se">\n</span><span class="s2">with a total probability of </span><span class="si">{:g}</span><span class="se">\n</span><span class="s2">with the following unique error codes: </span><span class="si">{}</span><span class="s2"> "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_count"</span><span class="p">],</span> @@ -1307,7 +1092,7 @@ <span class="mi">0</span><span class="p">,</span> <span class="p">)</span> <span class="c1"># Some information afterwards</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"The full argline commands for </span><span class="si">{}</span><span class="s2"> these systems have been written to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="s2">"ALL"</span> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_exceeded"</span><span class="p">]</span> @@ -1323,37 +1108,27 @@ <span class="mi">0</span><span class="p">,</span> <span class="p">)</span> <span class="k">else</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"There were no errors found in this run."</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"No failed systems were found in this run."</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> <span class="p">)</span> - <span class="k">def</span> <span class="nf">_get_stream_logger</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">):</span> - <span class="sd">"""Return logger with configured StreamHandler."""</span> - <span class="n">stream_logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"stream_logger"</span><span class="p">)</span> - <span class="n">stream_logger</span><span class="o">.</span><span class="n">handlers</span> <span class="o">=</span> <span class="p">[]</span> - <span class="n">stream_logger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">level</span><span class="p">)</span> - <span class="n">sh</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">()</span> - <span class="n">sh</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">level</span><span class="p">)</span> - <span class="n">fmt</span> <span class="o">=</span> <span class="s2">"[</span><span class="si">%(asctime)s</span><span class="s2"> </span><span class="si">%(levelname)-8s</span><span class="s2"> </span><span class="si">%(processName)s</span><span class="s2">] --- </span><span class="si">%(message)s</span><span class="s2">"</span> - <span class="n">formatter</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span><span class="n">fmt</span><span class="p">)</span> - <span class="n">sh</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span> - <span class="n">stream_logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">sh</span><span class="p">)</span> - - <span class="k">return</span> <span class="n">stream_logger</span> - - <span class="k">def</span> <span class="nf">_system_queue_filler</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">job_queue</span><span class="p">,</span> <span class="n">num_cores</span><span class="p">):</span> + <span class="k">return</span> + + <span class="k">def</span> <span class="nf">_system_queue_filler</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">job_queue</span><span class="p">,</span> <span class="n">num_processes</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Function that is responsible for keeping the queue filled.</span> <span class="sd"> This will generate the systems until it is full, and then keeps trying to fill it.</span> <span class="sd"> Will have to play with the size of this.</span> + +<span class="sd"> This function is called as part of the parent process.</span> <span class="sd"> """</span> <span class="n">stream_logger</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_stream_logger</span><span class="p">()</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">:</span> - <span class="n">stream_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">f</span><span class="s2">"setting up the system_queue_filler now"</span><span class="p">)</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">:</span> + <span class="n">stream_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"setting up the system_queue_filler now"</span><span class="p">)</span> <span class="c1"># Setup of the generator</span> <span class="c1"># Check again if we use custom generator or not:</span> @@ -1368,35 +1143,73 @@ <span class="bp">self</span><span class="p">,</span> <span class="n">print_results</span><span class="o">=</span><span class="kc">False</span> <span class="p">)</span> - <span class="c1"># TODO: build in method to handle with the HPC.</span> - <span class="c1"># Continuously fill the queue</span> + <span class="c1"># start_at can be an expression : we should eval it</span> + <span class="c1"># prior to running the loop</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]))</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Starting at model </span><span class="si">{}</span><span class="s2"> "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]))</span> + + <span class="c1"># Continuously fill the queue while we are allowed to</span> <span class="k">for</span> <span class="n">system_number</span><span class="p">,</span> <span class="n">system_dict</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">generator</span><span class="p">):</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"stop_queue"</span><span class="p">]:</span> + <span class="k">break</span> + + <span class="c1"># skip systems before start_at</span> + <span class="k">elif</span> <span class="n">system_number</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"skip system </span><span class="si">{n}</span><span class="s2"> because < start_at = </span><span class="si">{start}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">n</span><span class="o">=</span><span class="n">system_number</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">continue</span> - <span class="c1"># skip systems before start_at, and apply modulo</span> + <span class="c1"># apply modulo</span> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span> - <span class="n">system_number</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]</span> - <span class="ow">and</span> <span class="p">(</span><span class="n">system_number</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">])</span> + <span class="p">(</span><span class="n">system_number</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">])</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"modulo"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span> <span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"skip system </span><span class="si">{n}</span><span class="s2"> because modulo </span><span class="si">{mod}</span><span class="s2"> == </span><span class="si">{donemod}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">n</span><span class="o">=</span><span class="n">system_number</span><span class="p">,</span> + <span class="n">mod</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"modulo"</span><span class="p">],</span> + <span class="n">donemod</span><span class="o">=</span><span class="p">(</span><span class="n">system_number</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">])</span> + <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"modulo"</span><span class="p">],</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">continue</span> <span class="c1"># Put job in queue</span> - <span class="n">job_queue</span><span class="o">.</span><span class="n">put</span><span class="p">((</span><span class="n">system_number</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">))</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"stop_queue"</span><span class="p">]:</span> + <span class="k">break</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">job_queue</span><span class="o">.</span><span class="n">put</span><span class="p">((</span><span class="n">system_number</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">),</span> <span class="n">block</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="c1"># error on queueing : stop the queue</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"stop_queue"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="c1"># Print some info</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Queue produced system </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">system_number</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> - <span class="c1"># Print some info</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Queue produced system </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">system_number</span><span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">3</span><span class="p">,</span> - <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_queue_done"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> <span class="c1"># Send closing signal to workers. When they receive this they will terminate</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">:</span> - <span class="n">stream_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">f</span><span class="s2">"Signaling stop to processes"</span><span class="p">)</span> <span class="c1"># DEBUG</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">:</span> + <span class="n">stream_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Signalling processes to stop"</span><span class="p">)</span> <span class="c1"># DEBUG</span> - <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">num_cores</span><span class="p">):</span> - <span class="n">job_queue</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="s2">"STOP"</span><span class="p">)</span> + <span class="k">if</span> <span class="kc">True</span><span class="p">:</span> <span class="c1"># not self.grid_options['stop_queue']:</span> + <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">num_processes</span><span class="p">):</span> + <span class="n">job_queue</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="s2">"STOP"</span><span class="p">)</span> <span class="k">def</span> <span class="nf">_evolve_population_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> @@ -1404,7 +1217,7 @@ <span class="sd"> First we set up the multiprocessing manager and the job and result queue.</span> -<span class="sd"> Then we spawn <self.grid_options["num_cores"]> number of process instances,</span> +<span class="sd"> Then we spawn <self.grid_options["num_processes"]> number of process instances,</span> <span class="sd"> and signal them to start.</span> <span class="sd"> While the processes are waiting for their instructions, we start the queue filler,</span> @@ -1415,25 +1228,35 @@ <span class="sd"> When all the systems have been put in the queue we pass a STOP signal</span> <span class="sd"> that will make the processes wrap up.</span> +<span class="sd"> We then add any previous population</span> + <span class="sd"> We read out the information in the result queue and store them in the grid object</span> <span class="sd"> """</span> <span class="c1"># Set process name</span> <span class="n">setproctitle</span><span class="o">.</span><span class="n">setproctitle</span><span class="p">(</span><span class="s2">"binarycpython parent process"</span><span class="p">)</span> + <span class="c1"># if max_queue_size is zero, calculate automatically</span> + <span class="c1"># to be double the number of processes - you don't want to</span> + <span class="c1"># make the queue too large because when it's killed you</span> + <span class="c1"># want to end quickly</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"max_queue_size"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"max_queue_size"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]</span> + <span class="c1"># Set up the manager object that can share info between processes</span> <span class="n">manager</span> <span class="o">=</span> <span class="n">multiprocessing</span><span class="o">.</span><span class="n">Manager</span><span class="p">()</span> <span class="n">job_queue</span> <span class="o">=</span> <span class="n">manager</span><span class="o">.</span><span class="n">Queue</span><span class="p">(</span><span class="n">maxsize</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"max_queue_size"</span><span class="p">])</span> + <span class="n">result_queue</span> <span class="o">=</span> <span class="n">manager</span><span class="o">.</span><span class="n">Queue</span><span class="p">(</span><span class="n">maxsize</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">])</span> - <span class="c1"># backwards compatibility</span> - <span class="k">if</span> <span class="s2">"amt_cores"</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"amt_cores"</span><span class="p">]</span> - - <span class="n">result_queue</span> <span class="o">=</span> <span class="n">manager</span><span class="o">.</span><span class="n">Queue</span><span class="p">(</span><span class="n">maxsize</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">])</span> + <span class="c1"># data to be sent to signal handlers</span> + <span class="n">signal_data</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"where"</span><span class="p">:</span> <span class="s2">"_evolve_population_grid"</span><span class="p">,</span> + <span class="s2">"queue"</span><span class="p">:</span> <span class="n">job_queue</span><span class="p">,</span> + <span class="p">}</span> - <span class="c1"># Create process instances</span> + <span class="c1"># Create process instances to run the stars</span> <span class="n">processes</span> <span class="o">=</span> <span class="p">[]</span> - <span class="k">for</span> <span class="n">ID</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">]):</span> + <span class="k">for</span> <span class="n">ID</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]):</span> <span class="n">processes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> <span class="n">multiprocessing</span><span class="o">.</span><span class="n">Process</span><span class="p">(</span> <span class="n">target</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_process_run_population_grid</span><span class="p">,</span> @@ -1445,34 +1268,102 @@ <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">processes</span><span class="p">:</span> <span class="n">p</span><span class="o">.</span><span class="n">start</span><span class="p">()</span> - <span class="c1"># Set up the system_queue</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_system_queue_filler</span><span class="p">(</span><span class="n">job_queue</span><span class="p">,</span> <span class="n">num_cores</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">])</span> + <span class="c1"># activate signal handlers</span> + <span class="c1"># * the child processes ignore these signals</span> + <span class="c1"># * the parent will be in _system_queue_filler when these are caught</span> + <span class="n">signal</span><span class="o">.</span><span class="n">signal</span><span class="p">(</span> + <span class="n">signal</span><span class="o">.</span><span class="n">SIGTERM</span><span class="p">,</span> <span class="n">functools</span><span class="o">.</span><span class="n">partial</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parent_signal_handler</span><span class="p">,</span> <span class="n">signal_data</span><span class="p">)</span> + <span class="p">)</span> + <span class="n">signal</span><span class="o">.</span><span class="n">signal</span><span class="p">(</span> + <span class="n">signal</span><span class="o">.</span><span class="n">SIGINT</span><span class="p">,</span> <span class="n">functools</span><span class="o">.</span><span class="n">partial</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parent_signal_handler</span><span class="p">,</span> <span class="n">signal_data</span><span class="p">)</span> + <span class="p">)</span> + + <span class="c1"># Set up the system_queue in the parent process</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_system_queue_filler</span><span class="p">(</span> + <span class="n">job_queue</span><span class="p">,</span> <span class="n">num_processes</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]</span> + <span class="p">)</span> <span class="c1"># Join the processes</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Do join of subprocesses ..."</span><span class="p">)</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">processes</span><span class="p">:</span> <span class="n">p</span><span class="o">.</span><span class="n">join</span><span class="p">()</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Joined subprocesses."</span><span class="p">)</span> + + <span class="c1"># todo: error codes</span> <span class="c1"># Handle the results by merging all the dictionaries. How that merging happens exactly is</span> <span class="c1"># described in the merge_dicts description.</span> - <span class="n">combined_output_dict</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">()</span> + <span class="c1">#</span> + <span class="c1"># If there is a preloaded_population, we add this first,</span> + <span class="c1"># then we add the populations run just now</span> + + <span class="c1"># 1)</span> + <span class="c1"># use preloaded population's data as a basis</span> + <span class="c1"># for our combined_output_dict</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">preloaded_population</span><span class="p">:</span> + <span class="n">combined_output_dict</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"ensemble_results"</span><span class="p">:</span> <span class="n">keys_to_floats</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">preloaded_population</span><span class="o">.</span><span class="n">grid_ensemble_results</span> + <span class="p">),</span> + <span class="s2">"results"</span><span class="p">:</span> <span class="n">keys_to_floats</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">preloaded_population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">),</span> + <span class="p">}</span> + + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_metadata_keylist</span><span class="p">():</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">combined_output_dict</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">preloaded_population</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Tried to set combined_output_dict key"</span><span class="p">,</span> + <span class="n">x</span><span class="p">,</span> + <span class="s2">"from preloaded_popuation, but this failed:"</span><span class="p">,</span> + <span class="n">e</span><span class="p">,</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Pre-loaded data from </span><span class="si">{}</span><span class="s2"> stars"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">])</span> + <span class="p">)</span> + <span class="c1"># do not propagate _killed</span> + <span class="c1"># combined_output_dict['results']['_killed'] = False</span> + <span class="c1"># combined_output_dict['_killed'] = False</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">preloaded_population</span> <span class="o">=</span> <span class="kc">None</span> + <span class="n">gc</span><span class="o">.</span><span class="n">collect</span><span class="p">()</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># new empty combined output</span> + <span class="n">combined_output_dict</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">()</span> + <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"ensemble_results"</span><span class="p">]</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">()</span> + <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"results"</span><span class="p">]</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">()</span> + + <span class="c1"># 2)</span> + <span class="c1"># combine the dicts that were output from our</span> + <span class="c1"># subprocesses</span> <span class="n">sentinel</span> <span class="o">=</span> <span class="nb">object</span><span class="p">()</span> <span class="k">for</span> <span class="n">output_dict</span> <span class="ow">in</span> <span class="nb">iter</span><span class="p">(</span><span class="n">result_queue</span><span class="o">.</span><span class="n">get</span><span class="p">,</span> <span class="n">sentinel</span><span class="p">):</span> - <span class="n">combined_output_dict</span> <span class="o">=</span> <span class="n">merge_dicts</span><span class="p">(</span><span class="n">combined_output_dict</span><span class="p">,</span> <span class="n">output_dict</span><span class="p">)</span> + <span class="k">if</span> <span class="n">output_dict</span><span class="p">:</span> + <span class="c1"># don't let Xinit be added</span> + <span class="k">if</span> <span class="p">(</span> + <span class="s2">"ensemble_results"</span> <span class="ow">in</span> <span class="n">combined_output_dict</span> + <span class="ow">and</span> <span class="s2">"ensemble"</span> <span class="ow">in</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"ensemble_results"</span><span class="p">]</span> + <span class="ow">and</span> <span class="s2">"Xinit"</span> <span class="ow">in</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"ensemble_results"</span><span class="p">][</span><span class="s2">"ensemble"</span><span class="p">]</span> + <span class="p">):</span> + <span class="k">del</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"ensemble_results"</span><span class="p">][</span><span class="s2">"ensemble"</span><span class="p">][</span><span class="s2">"Xinit"</span><span class="p">]</span> + + <span class="c1"># merge dicts</span> + <span class="n">combined_output_dict</span> <span class="o">=</span> <span class="n">merge_dicts</span><span class="p">(</span> + <span class="n">combined_output_dict</span><span class="p">,</span> <span class="n">keys_to_floats</span><span class="p">(</span><span class="n">output_dict</span><span class="p">)</span> + <span class="p">)</span> <span class="k">if</span> <span class="n">result_queue</span><span class="o">.</span><span class="n">empty</span><span class="p">():</span> <span class="k">break</span> <span class="c1"># Extra ensemble result manipulation:</span> - <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"ensemble_results"</span><span class="p">][</span><span class="s2">"ensemble"</span><span class="p">]</span> <span class="o">=</span> <span class="n">format_ensemble_results</span><span class="p">(</span> - <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"ensemble_results"</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble"</span><span class="p">,</span> <span class="p">{})</span> - <span class="p">)</span> + <span class="k">if</span> <span class="s2">"ensemble_results"</span> <span class="ow">in</span> <span class="n">combined_output_dict</span><span class="p">:</span> + <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"ensemble_results"</span><span class="p">][</span> + <span class="s2">"ensemble"</span> + <span class="p">]</span> <span class="o">=</span> <span class="n">format_ensemble_results</span><span class="p">(</span> + <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"ensemble_results"</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble"</span><span class="p">,</span> <span class="p">{})</span> + <span class="p">)</span> <span class="n">gc</span><span class="o">.</span><span class="n">collect</span><span class="p">()</span> - <span class="c1"># Take into account that we run this on multiple cores</span> - <span class="n">combined_output_dict</span><span class="p">[</span> - <span class="s2">"_total_probability_weighted_mass_run"</span> - <span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">]</span> - <span class="c1"># Put the values back as object properties</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_results</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"results"</span><span class="p">]</span> @@ -1483,57 +1374,11 @@ <span class="p">]</span> <span class="c1"># Ensemble results are also passed as output from that dictionary</span> <span class="c1"># Add metadata</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"population_id"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> - <span class="s2">"_population_id"</span> - <span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> - <span class="s2">"total_probability_weighted_mass"</span> - <span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> - <span class="s2">"factored_in_probability_weighted_mass"</span> - <span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"ensemble_factor_in_probability_weighted_mass"</span><span class="p">]:</span> - <span class="n">multiply_values_dict</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"ensemble"</span><span class="p">],</span> - <span class="mi">1</span> - <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> - <span class="s2">"total_probability_weighted_mass"</span> - <span class="p">],</span> - <span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> - <span class="s2">"factored_in_probability_weighted_mass"</span> - <span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_ensemble_metadata</span><span class="p">(</span><span class="n">combined_output_dict</span><span class="p">)</span> - <span class="c1"># Add settings of the populations</span> - <span class="n">all_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">return_all_info</span><span class="p">(</span> - <span class="n">include_population_settings</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> - <span class="n">include_binary_c_defaults</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> - <span class="n">include_binary_c_version_info</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> - <span class="n">include_binary_c_help_all</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> - <span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"settings"</span><span class="p">]</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span> - <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">all_info</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">binaryc_json_serializer</span><span class="p">)</span> - <span class="p">)</span> - - <span class="c1">##############################</span> - <span class="c1"># Update grid options</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_count"</span><span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_failed_count"</span><span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_prob"</span><span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_failed_prob"</span><span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_systems_error_codes"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span> - <span class="nb">set</span><span class="p">(</span><span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_failed_systems_error_codes"</span><span class="p">])</span> - <span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_exceeded"</span><span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_errors_exceeded"</span><span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_found"</span><span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_errors_found"</span><span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_probtot"</span><span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_probtot"</span><span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_mass_run"</span><span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_total_mass_run"</span><span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> - <span class="s2">"_total_probability_weighted_mass_run"</span> - <span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_zero_prob_stars_skipped"</span><span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span> - <span class="s2">"_zero_prob_stars_skipped"</span> - <span class="p">]</span> + <span class="c1"># if we were killed, save snapshot</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"save_snapshots"</span><span class="p">]</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_killed"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="s2">"save_snapshot"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> <span class="k">def</span> <span class="nf">_evolve_system_mp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">full_system_dict</span><span class="p">):</span> <span class="sd">"""</span> @@ -1573,6 +1418,84 @@ <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="s2">"parameter_dict"</span><span class="p">]</span> <span class="o">=</span> <span class="n">full_system_dict</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"parse_function"</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="n">out</span><span class="p">)</span> + <span class="k">return</span> + + <span class="k">def</span> <span class="nf">_parent_signal_handler</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">signal_data</span><span class="p">,</span> <span class="n">signum</span><span class="p">,</span> <span class="n">frame</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Signal handling function for the parent process.</span> +<span class="sd"> """</span> + + <span class="c1"># this function is called by both queues when they</span> + <span class="c1"># catch a signal</span> + <span class="n">sigstring</span> <span class="o">=</span> <span class="n">signal</span><span class="o">.</span><span class="n">Signals</span><span class="p">(</span><span class="n">signum</span><span class="p">)</span><span class="o">.</span><span class="n">name</span> + + <span class="k">if</span> <span class="n">sigstring</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span><span class="p">[</span><span class="n">sigstring</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span><span class="p">[</span><span class="n">sigstring</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span><span class="p">[</span><span class="n">sigstring</span><span class="p">]</span> <span class="o">></span> <span class="mi">3</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"caught > 3 times : exit"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> + + <span class="c1"># tell the user what has happened</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Parent signal </span><span class="si">{}</span><span class="s2"> caught (count </span><span class="si">{}</span><span class="s2">) handler set in </span><span class="si">{}</span><span class="s2"> [ keys </span><span class="si">{}</span><span class="s2"> ]"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">sigstring</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span><span class="p">[</span><span class="n">sigstring</span><span class="p">],</span> + <span class="n">signal_data</span><span class="p">[</span><span class="s2">"where"</span><span class="p">],</span> + <span class="s2">","</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">signal_data</span><span class="o">.</span><span class="n">keys</span><span class="p">()),</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1"># set status files</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_status</span><span class="p">(</span><span class="s2">"signal </span><span class="si">{sig}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">sig</span><span class="o">=</span><span class="n">sigstring</span><span class="p">))</span> + + <span class="k">if</span> <span class="n">signum</span> <span class="o">==</span> <span class="n">signal</span><span class="o">.</span><span class="n">SIGINT</span><span class="p">:</span> + <span class="c1"># caught SIGINT: e.g. CTRL-C or HPC job manager</span> + <span class="c1"># shutting us down</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Parent set stop_queue to True"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"stop_queue"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="s2">"save_snapshot"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_killed"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + <span class="k">return</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># what to do?</span> + <span class="k">return</span> + + <span class="k">def</span> <span class="nf">_child_signal_handler</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">signal_data</span><span class="p">,</span> <span class="n">signum</span><span class="p">,</span> <span class="n">frame</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Signal handler for child processes.</span> +<span class="sd"> """</span> + <span class="n">sigstring</span> <span class="o">=</span> <span class="n">signal</span><span class="o">.</span><span class="n">Signals</span><span class="p">(</span><span class="n">signum</span><span class="p">)</span><span class="o">.</span><span class="n">name</span> + + <span class="k">if</span> <span class="n">sigstring</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span><span class="p">[</span><span class="n">sigstring</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span><span class="p">[</span><span class="n">sigstring</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> + + <span class="c1"># if we receive the signal three times, exit</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span><span class="p">[</span><span class="n">sigstring</span><span class="p">]</span> <span class="o">></span> <span class="mi">3</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"caught > 3 times : exit"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> + + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Child signal </span><span class="si">{}</span><span class="s2"> caught (count </span><span class="si">{}</span><span class="s2">) handler set in </span><span class="si">{}</span><span class="s2"> [ keys </span><span class="si">{}</span><span class="s2"> ]"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">sigstring</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">signal_count</span><span class="p">[</span><span class="n">sigstring</span><span class="p">],</span> + <span class="n">signal_data</span><span class="p">[</span><span class="s2">"where"</span><span class="p">],</span> + <span class="s2">","</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">signal_data</span><span class="o">.</span><span class="n">keys</span><span class="p">()),</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1"># SIGINT should stop the queue nicely</span> + <span class="k">if</span> <span class="n">signum</span> <span class="o">==</span> <span class="n">signal</span><span class="o">.</span><span class="n">SIGINT</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"stop_queue"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_killed"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="c1"># propagate signal to parent</span> + <span class="n">os</span><span class="o">.</span><span class="n">kill</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_main_pid"</span><span class="p">],</span> <span class="n">signum</span><span class="p">)</span> + <span class="k">def</span> <span class="nf">_process_run_population_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">job_queue</span><span class="p">,</span> <span class="n">result_queue</span><span class="p">,</span> <span class="n">ID</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Worker process that gets items from the job_queue and runs those systems.</span> @@ -1585,43 +1508,46 @@ <span class="sd"> """</span> + <span class="c1"># ignore SIGINT and SIGTERM : these are</span> + <span class="c1"># handled by our parent process (hence in</span> + <span class="c1"># _evolve_population_grid)</span> + <span class="n">signal</span><span class="o">.</span><span class="n">signal</span><span class="p">(</span> + <span class="n">signal</span><span class="o">.</span><span class="n">SIGTERM</span><span class="p">,</span> + <span class="n">functools</span><span class="o">.</span><span class="n">partial</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_child_signal_handler</span><span class="p">,</span> <span class="p">{</span><span class="s2">"where"</span><span class="p">:</span> <span class="s2">"_process_run_population_grid"</span><span class="p">}</span> + <span class="p">),</span> + <span class="p">)</span> + <span class="n">signal</span><span class="o">.</span><span class="n">signal</span><span class="p">(</span> + <span class="n">signal</span><span class="o">.</span><span class="n">SIGINT</span><span class="p">,</span> + <span class="n">functools</span><span class="o">.</span><span class="n">partial</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_child_signal_handler</span><span class="p">,</span> <span class="p">{</span><span class="s2">"where"</span><span class="p">:</span> <span class="s2">"_process_run_population_grid"</span><span class="p">}</span> + <span class="p">),</span> + <span class="p">)</span> + <span class="c1"># set start timer</span> <span class="n">start_process_time</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span> - <span class="c1">#</span> - <span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span> <span class="o">=</span> <span class="p">(</span> - <span class="n">ID</span> <span class="c1"># Store the ID as a object property again, lets see if that works.</span> - <span class="p">)</span> + <span class="c1"># set the process ID</span> + <span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span> <span class="o">=</span> <span class="n">ID</span> <span class="n">stream_logger</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_stream_logger</span><span class="p">()</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">:</span> - <span class="n">stream_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">f</span><span class="s2">"Setting up processor: process-</span><span class="si">{self.process_ID}</span><span class="s2">"</span><span class="p">)</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">:</span> + <span class="n">stream_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Setting up processor: process-</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="c1"># Set the process names</span> - <span class="n">name</span> <span class="o">=</span> <span class="s2">"binarycpython population thread </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ID</span><span class="p">)</span> <span class="n">name_proc</span> <span class="o">=</span> <span class="s2">"binarycpython population process </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ID</span><span class="p">)</span> <span class="n">setproctitle</span><span class="o">.</span><span class="n">setproctitle</span><span class="p">(</span><span class="n">name_proc</span><span class="p">)</span> - <span class="c1"># setproctitle.setthreadtitle(name)</span> <span class="c1"># Set to starting up</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> - <span class="s2">"process_status"</span><span class="p">,</span> - <span class="s2">"process_</span><span class="si">{}</span><span class="s2">.txt"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">),</span> - <span class="p">),</span> - <span class="s2">"w"</span><span class="p">,</span> - <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> - <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"STARTING"</span><span class="p">)</span> - <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_status</span><span class="p">(</span><span class="s2">"starting"</span><span class="p">)</span> <span class="c1"># lets try out making stores for all the grids:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_store_memaddr"</span><span class="p">]</span> <span class="o">=</span> <span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">return_store_memaddr</span><span class="p">()</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Process </span><span class="si">{}</span><span class="s2"> started at </span><span class="si">{}</span><span class="s2">.</span><span class="se">\t</span><span class="s2">Using store memaddr </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="n">ID</span><span class="p">,</span> - <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">isoformat</span><span class="p">(),</span> + <span class="n">now</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_store_memaddr"</span><span class="p">],</span> <span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> @@ -1639,7 +1565,7 @@ <span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">:</span> <span class="n">persistent_data_memaddr</span> <span class="p">}</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Using persistent_data memaddr: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">persistent_data_memaddr</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">3</span><span class="p">,</span> @@ -1653,12 +1579,10 @@ <span class="mi">0</span> <span class="c1"># counter for the probability of the actual systems this tread ran</span> <span class="p">)</span> <span class="n">number_of_systems_run</span> <span class="o">=</span> <span class="p">(</span> - <span class="mi">0</span> <span class="c1"># counter for the actual amt of systems this thread ran</span> + <span class="mi">0</span> <span class="c1"># counter for the actual number of systems this thread ran</span> <span class="p">)</span> <span class="n">zero_prob_stars_skipped</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">total_time_calling_binary_c</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">total_mass_run</span> <span class="o">=</span> <span class="mi">0</span> <span class="n">total_probability_weighted_mass_run</span> <span class="o">=</span> <span class="mi">0</span> @@ -1669,23 +1593,24 @@ <span class="p">)</span> <span class="n">next_mem_update_time</span> <span class="o">=</span> <span class="n">start_grid_time</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_dt"</span><span class="p">]</span> + <span class="c1"># Set status to running</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_status</span><span class="p">(</span><span class="s2">"running"</span><span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># Run stellar systems in the queue</span> <span class="c1">############################################################</span> - <span class="c1"># Go over the queue</span> <span class="k">for</span> <span class="n">system_number</span><span class="p">,</span> <span class="n">system_dict</span> <span class="ow">in</span> <span class="nb">iter</span><span class="p">(</span><span class="n">job_queue</span><span class="o">.</span><span class="n">get</span><span class="p">,</span> <span class="s2">"STOP"</span><span class="p">):</span> - <span class="c1"># At the first system set the status of the thread to running</span> - <span class="k">if</span> <span class="n">localcounter</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> - <span class="c1"># Set status to running</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> - <span class="s2">"process_status"</span><span class="p">,</span> - <span class="s2">"process_</span><span class="si">{}</span><span class="s2">.txt"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">),</span> - <span class="p">),</span> - <span class="s2">"w"</span><span class="p">,</span> - <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> - <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"RUNNING"</span><span class="p">)</span> - <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="k">if</span> <span class="kc">False</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Child: Job Queue system_number = </span><span class="si">{}</span><span class="s2">, dict=</span><span class="si">{}</span><span class="s2">, n=</span><span class="si">{}</span><span class="s2"> check </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">system_number</span><span class="p">,</span> + <span class="n">system_dict</span><span class="p">,</span> + <span class="n">number_of_systems_run</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"stop_queue"</span><span class="p">],</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span> <span class="c1"># Combine that with the other settings</span> <span class="n">full_system_dict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> @@ -1716,26 +1641,16 @@ <span class="p">)</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - <span class="c1"># self._print_info(</span> - <span class="c1"># i + 1, self.grid_options["_total_starcount"], full_system_dict</span> - <span class="c1"># )</span> - - <span class="c1"># verbose_print(</span> - <span class="c1"># "Process {} is handling system {}".format(ID, system_number),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 1,</span> - <span class="c1"># )</span> - <span class="c1">######################</span> <span class="c1"># Print status of runs</span> <span class="c1"># save the current time (used often)</span> - <span class="n">now</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> + <span class="n">time_now</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="c1"># update memory use stats every log_dt seconds (not every time, this is likely a bit expensive)</span> - <span class="k">if</span> <span class="n">now</span> <span class="o">></span> <span class="n">next_mem_update_time</span><span class="p">:</span> + <span class="k">if</span> <span class="n">time_now</span> <span class="o">></span> <span class="n">next_mem_update_time</span><span class="p">:</span> <span class="n">m</span> <span class="o">=</span> <span class="n">mem_use</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"memory_use_per_thread"</span><span class="p">][</span><span class="n">ID</span><span class="p">]</span> <span class="o">=</span> <span class="n">m</span> - <span class="n">next_mem_update_time</span> <span class="o">=</span> <span class="n">now</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_dt"</span><span class="p">]</span> + <span class="n">next_mem_update_time</span> <span class="o">=</span> <span class="n">time_now</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_dt"</span><span class="p">]</span> <span class="k">if</span> <span class="n">m</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"max_memory_use_per_thread"</span><span class="p">][</span><span class="n">ID</span><span class="p">]:</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"max_memory_use_per_thread"</span><span class="p">][</span><span class="n">ID</span><span class="p">]</span> <span class="o">=</span> <span class="n">m</span> @@ -1746,16 +1661,16 @@ <span class="c1"># Check if we need to log info again</span> <span class="c1"># TODO: Check if we can put this functionality elsewhere</span> - <span class="k">if</span> <span class="n">now</span> <span class="o">></span> <span class="n">next_log_time</span><span class="p">:</span> + <span class="k">if</span> <span class="n">time_now</span> <span class="o">></span> <span class="n">next_log_time</span><span class="p">:</span> <span class="c1"># we have exceeded the next log time : output and update timers</span> <span class="c1"># Lock the threads. TODO: Do we need to release this?</span> <span class="n">lock</span> <span class="o">=</span> <span class="n">multiprocessing</span><span class="o">.</span><span class="n">Lock</span><span class="p">()</span> <span class="c1"># Do the printing itself</span> - <span class="bp">self</span><span class="o">.</span><span class="n">vb1print</span><span class="p">(</span><span class="n">ID</span><span class="p">,</span> <span class="n">now</span><span class="p">,</span> <span class="n">system_number</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">vb1print</span><span class="p">(</span><span class="n">ID</span><span class="p">,</span> <span class="n">time_now</span><span class="p">,</span> <span class="n">system_number</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">)</span> <span class="c1"># Set some values for next time</span> - <span class="n">next_log_time</span> <span class="o">=</span> <span class="n">now</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_dt"</span><span class="p">]</span> + <span class="n">next_log_time</span> <span class="o">=</span> <span class="n">time_now</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_dt"</span><span class="p">]</span> <span class="c1"># print("PREV ",self.shared_memory["prev_log_time"])</span> <span class="c1"># print("N LOG STATS",self.shared_memory["n_saved_log_stats"].value)</span> @@ -1773,7 +1688,7 @@ <span class="p">]</span> <span class="c1"># set the current time and system number</span> - <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_time"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">now</span> + <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_time"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">time_now</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_system_number"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">system_number</span> <span class="c1"># increase the number of stats</span> @@ -1792,16 +1707,17 @@ <span class="c1"># that was on, we log each current system to a file (each thread has one).</span> <span class="c1"># Each new system overrides the previous</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_args"</span><span class="p">]:</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_args_dir"</span><span class="p">],</span> - <span class="s2">"current_system"</span><span class="p">,</span> - <span class="s2">"process_</span><span class="si">{}</span><span class="s2">.txt"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">),</span> - <span class="p">),</span> - <span class="s2">"w"</span><span class="p">,</span> + <span class="n">argfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_args_dir"</span><span class="p">],</span> + <span class="s2">"process_</span><span class="si">{}</span><span class="s2">.txt"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">jobID</span><span class="p">()),</span> + <span class="p">)</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> + <span class="n">argfile</span><span class="p">,</span> + <span class="s2">"w"</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> - <span class="n">binary_cmdline_string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_argline</span><span class="p">(</span><span class="n">full_system_dict</span><span class="p">)</span> - <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">binary_cmdline_string</span><span class="p">)</span> + <span class="n">binary_c_cmdline_string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_argline</span><span class="p">(</span><span class="n">full_system_dict</span><span class="p">)</span> + <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">binary_c_cmdline_string</span><span class="p">)</span> <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> <span class="c1">##############</span> @@ -1833,13 +1749,14 @@ <span class="c1"># Debug line: logging all the lines</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_runtime_systems"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"runtime_systems"</span><span class="p">,</span> <span class="s2">"process_</span><span class="si">{}</span><span class="s2">.txt"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">),</span> <span class="p">),</span> <span class="s2">"a+"</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> <span class="n">binary_cmdline_string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_argline</span><span class="p">(</span><span class="n">full_system_dict</span><span class="p">)</span> <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span> @@ -1871,20 +1788,23 @@ <span class="n">total_mass_system</span> <span class="o">*</span> <span class="n">full_system_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"probability"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="p">)</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"stop_queue"</span><span class="p">]:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Child: Stop queue at system </span><span class="si">{n}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="n">number_of_systems_run</span><span class="p">))</span> + <span class="k">break</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"stop_queue"</span><span class="p">]:</span> + <span class="c1"># any remaining jobs should be ignored</span> + <span class="k">try</span><span class="p">:</span> + <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> + <span class="n">job_queue</span><span class="o">.</span><span class="n">get_nowait</span><span class="p">()</span> + <span class="k">except</span> <span class="n">queue</span><span class="o">.</span><span class="n">Empty</span><span class="p">:</span> + <span class="k">pass</span> + <span class="c1"># Set status to finishing</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> - <span class="s2">"process_status"</span><span class="p">,</span> - <span class="s2">"process_</span><span class="si">{}</span><span class="s2">.txt"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">),</span> - <span class="p">),</span> - <span class="s2">"w"</span><span class="p">,</span> - <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> - <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"FINISHING"</span><span class="p">)</span> - <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_status</span><span class="p">(</span><span class="s2">"finishing"</span><span class="p">)</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">:</span> - <span class="n">stream_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">f</span><span class="s2">"Process-</span><span class="si">{self.process_ID}</span><span class="s2"> is finishing."</span><span class="p">)</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">:</span> + <span class="n">stream_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Process-</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="si">}</span><span class="s2"> is finishing."</span><span class="p">)</span> <span class="c1">###########################</span> <span class="c1"># Handle ensemble outut</span> @@ -1892,7 +1812,7 @@ <span class="c1"># if ensemble==1, then either directly write that data to a file, or combine everything into 1 file.</span> <span class="n">ensemble_json</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># Make sure it exists already</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Process </span><span class="si">{}</span><span class="s2">: is freeing ensemble output (using persistent_data memaddr </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="n">ID</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">persistent_data_memory_dict</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">]</span> <span class="p">),</span> @@ -1907,11 +1827,15 @@ <span class="p">)</span> <span class="k">if</span> <span class="n">ensemble_raw_output</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Process </span><span class="si">{}</span><span class="s2">: Warning! Ensemble output is empty. "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ID</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">,</span> <span class="p">)</span> + <span class="n">ensemble_output</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># convert ensemble_raw_output to a dictionary</span> + <span class="n">ensemble_output</span> <span class="o">=</span> <span class="n">extract_ensemble_json_from_string</span><span class="p">(</span><span class="n">ensemble_raw_output</span><span class="p">)</span> <span class="c1"># save the ensemble chunk to a file</span> <span class="k">if</span> <span class="p">(</span> @@ -1925,7 +1849,7 @@ <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_population_id"</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span> <span class="p">),</span> <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Writing process </span><span class="si">{}</span><span class="s2"> JSON ensemble chunk output to </span><span class="si">{}</span><span class="s2"> "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="n">ID</span><span class="p">,</span> <span class="n">output_file</span> <span class="p">),</span> @@ -1934,26 +1858,20 @@ <span class="p">)</span> <span class="n">ensemble_output</span> <span class="o">=</span> <span class="n">extract_ensemble_json_from_string</span><span class="p">(</span><span class="n">ensemble_raw_output</span><span class="p">)</span> - - <span class="n">ensemble_output</span> <span class="o">=</span> <span class="n">extract_ensemble_json_from_string</span><span class="p">(</span><span class="n">ensemble_raw_output</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">write_ensemble</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="n">ensemble_output</span><span class="p">)</span> <span class="c1"># combine ensemble chunks</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"combine_ensemble_with_thread_joining"</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Process </span><span class="si">{}</span><span class="s2">: Extracting ensemble info from raw string"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ID</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">,</span> <span class="p">)</span> - - <span class="n">ensemble_json</span><span class="p">[</span><span class="s2">"ensemble"</span><span class="p">]</span> <span class="o">=</span> <span class="n">extract_ensemble_json_from_string</span><span class="p">(</span> - <span class="n">ensemble_raw_output</span> - <span class="p">)</span> <span class="c1"># Load this into a dict so that we can combine it later</span> + <span class="n">ensemble_json</span><span class="p">[</span><span class="s2">"ensemble"</span><span class="p">]</span> <span class="o">=</span> <span class="n">ensemble_output</span> <span class="c1">##########################</span> <span class="c1"># Clean up and return</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"process </span><span class="si">{}</span><span class="s2"> free memory and return "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ID</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">,</span> @@ -1977,15 +1895,18 @@ <span class="s2">"_total_mass_run"</span><span class="p">:</span> <span class="n">total_mass_run</span><span class="p">,</span> <span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">:</span> <span class="n">total_probability_weighted_mass_run</span><span class="p">,</span> <span class="s2">"_zero_prob_stars_skipped"</span><span class="p">:</span> <span class="n">zero_prob_stars_skipped</span><span class="p">,</span> + <span class="s2">"_killed"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_killed"</span><span class="p">],</span> <span class="p">}</span> <span class="n">end_process_time</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span> + <span class="n">killed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">was_killed</span><span class="p">()</span> + <span class="c1"># thread end message</span> <span class="n">colour</span> <span class="o">=</span> <span class="s2">"cyan on black"</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">_boxed</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{colour}</span><span class="s2">Process </span><span class="si">{ID}</span><span class="s2"> finished:</span><span class="se">\n</span><span class="s2">generator started at </span><span class="si">{start}</span><span class="se">\n</span><span class="s2">generator finished at </span><span class="si">{end}</span><span class="se">\n</span><span class="s2">total: </span><span class="si">{timesecs}</span><span class="se">\n</span><span class="s2">of which </span><span class="si">{binary_c_secs}</span><span class="s2"> with binary_c</span><span class="se">\n</span><span class="s2">Ran </span><span class="si">{nsystems}</span><span class="s2"> systems</span><span class="se">\n</span><span class="s2">with a total probability of </span><span class="si">{psystems:g}</span><span class="se">\n</span><span class="si">{failcolour}</span><span class="s2">This thread had </span><span class="si">{nfail}</span><span class="s2"> failing systems</span><span class="si">{colour}</span><span class="se">\n</span><span class="si">{failcolour}</span><span class="s2">with a total failed probability of </span><span class="si">{pfail}{colour}</span><span class="se">\n</span><span class="si">{zerocolour}</span><span class="s2">Skipped a total of </span><span class="si">{nzero}</span><span class="s2"> zero-probability systems</span><span class="si">{zeroreset}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{colour}</span><span class="s2">Process </span><span class="si">{ID}</span><span class="s2"> finished:</span><span class="se">\n</span><span class="s2">generator started at </span><span class="si">{start}</span><span class="se">\n</span><span class="s2">generator finished at </span><span class="si">{end}</span><span class="se">\n</span><span class="s2">total: </span><span class="si">{timesecs}</span><span class="se">\n</span><span class="s2">of which </span><span class="si">{binary_c_secs}</span><span class="s2"> with binary_c</span><span class="se">\n</span><span class="s2">Ran </span><span class="si">{nsystems}</span><span class="s2"> systems</span><span class="se">\n</span><span class="s2">with a total probability of </span><span class="si">{psystems:g}</span><span class="se">\n</span><span class="si">{failcolour}</span><span class="s2">This thread had </span><span class="si">{nfail}</span><span class="s2"> failing systems</span><span class="si">{colour}</span><span class="se">\n</span><span class="si">{failcolour}</span><span class="s2">with a total failed probability of </span><span class="si">{pfail}{colour}</span><span class="se">\n</span><span class="si">{zerocolour}</span><span class="s2">Skipped a total of </span><span class="si">{nzero}</span><span class="s2"> zero-probability systems</span><span class="si">{zeroreset}</span><span class="se">\n</span><span class="si">{failednotice}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="n">colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="n">colour</span><span class="p">],</span> <span class="n">ID</span><span class="o">=</span><span class="n">ID</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="n">start_process_time</span><span class="o">.</span><span class="n">isoformat</span><span class="p">(),</span> @@ -2011,6 +1932,7 @@ <span class="n">zeroreset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="n">colour</span><span class="p">]</span> <span class="k">if</span> <span class="n">zero_prob_stars_skipped</span> <span class="o">></span> <span class="mi">0</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> + <span class="n">failednotice</span><span class="o">=</span><span class="s2">">>> Process was killed <<<</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="n">killed</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> <span class="p">),</span> <span class="n">colour</span><span class="o">=</span><span class="n">colour</span><span class="p">,</span> <span class="p">),</span> @@ -2034,44 +1956,35 @@ <span class="p">],</span> <span class="s2">"zero_prob_stars_skipped"</span><span class="p">:</span> <span class="n">zero_prob_stars_skipped</span><span class="p">,</span> <span class="p">}</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"process_summary"</span><span class="p">,</span> <span class="s2">"process_</span><span class="si">{}</span><span class="s2">.json"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">),</span> <span class="p">),</span> <span class="s2">"w"</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> - <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">summary_dict</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">))</span> - <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="n">json</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">summary_dict</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="c1"># Set status to finished</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> - <span class="s2">"process_status"</span><span class="p">,</span> - <span class="s2">"process_</span><span class="si">{}</span><span class="s2">.txt"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">),</span> - <span class="p">),</span> - <span class="s2">"w"</span><span class="p">,</span> - <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> - <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"FINISHED"</span><span class="p">)</span> - <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">was_killed</span><span class="p">():</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_status</span><span class="p">(</span><span class="s2">"killed"</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_status</span><span class="p">(</span><span class="s2">"finished"</span><span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"process </span><span class="si">{}</span><span class="s2"> queue put output_dict "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ID</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">,</span> <span class="p">)</span> - <span class="n">result_queue</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">output_dict</span><span class="p">)</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">:</span> - <span class="n">stream_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">f</span><span class="s2">"Process-</span><span class="si">{self.process_ID}</span><span class="s2"> is finished."</span><span class="p">)</span> + <span class="n">result_queue</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">output_dict</span><span class="p">)</span> - <span class="c1"># Don't do this : Clean up the interpolators if they exist</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_LOGGER_VERBOSITY_LEVEL</span><span class="p">:</span> + <span class="n">stream_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Process-</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="si">}</span><span class="s2"> is finished."</span><span class="p">)</span> - <span class="c1"># TODO: make a cleanup function for the individual threads</span> - <span class="c1"># TODO: make sure this is necessary. Actually its probably not, because we have a centralised queue</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"process </span><span class="si">{}</span><span class="s2"> return "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ID</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">,</span> @@ -2101,7 +2014,7 @@ <span class="c1"># Get argument line and</span> <span class="n">argline</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_argline</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Running </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">argline</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span> <span class="p">)</span> @@ -2139,6 +2052,10 @@ <span class="sd"> Since we have different methods of running a population, this setup function</span> <span class="sd"> will do different things depending on different settings</span> +<span class="sd"> Returns:</span> +<span class="sd"> True if we want to continue.</span> +<span class="sd"> False if we should return to the original calling script.</span> + <span class="sd"> Tasks:</span> <span class="sd"> TODO: Make other kinds of populations possible. i.e, read out type of grid,</span> <span class="sd"> and set up accordingly</span> @@ -2146,22 +2063,9 @@ <span class="sd"> function</span> <span class="sd"> """</span> - <span class="c1"># Make sure the subdirs of the tmp dir exist:</span> - <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"failed_systems"</span><span class="p">),</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span> - <span class="p">)</span> - <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"current_system"</span><span class="p">),</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span> - <span class="p">)</span> - <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"process_status"</span><span class="p">),</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span> - <span class="p">)</span> - <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"process_summary"</span><span class="p">),</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span> - <span class="p">)</span> - <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"runtime_systems"</span><span class="p">),</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span> - <span class="p">)</span> + <span class="c1"># Check for restore</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"restore_from_snapshot_file"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">load_snapshot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"restore_from_snapshot_file"</span><span class="p">])</span> <span class="c1"># Check for parse function</span> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"parse_function"</span><span class="p">]:</span> @@ -2175,24 +2079,25 @@ <span class="c1">## check the settings and set all the warnings.</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble_defer"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Error, if you want to run an ensemble in a population, the output needs to be deferred. Please set 'ensemble_defer' to 1"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"BSE"</span><span class="p">,</span><span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">)</span> <span class="k">raise</span> <span class="ne">ValueError</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">any</span><span class="p">(</span> <span class="p">[</span><span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"ensemble_filter_"</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">]</span> <span class="p">):</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Warning: Running the ensemble without any filter requires a lot of available RAM"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> <span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble_filters_off"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Warning: Running the ensemble without any filter requires a lot of available RAM"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> @@ -2200,7 +2105,7 @@ <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"combine_ensemble_with_thread_joining"</span><span class="p">]</span> <span class="o">==</span> <span class="kc">False</span><span class="p">:</span> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"data_dir"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="s2">"Error: chosen to write the ensemble output directly to files but data_dir isn't set"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> @@ -2213,15 +2118,22 @@ <span class="c1">## Check which type of population generation</span> <span class="c1"># grid type</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"grid"</span><span class="p">:</span> - <span class="c1">#######################</span> - <span class="c1"># Dry run and getting starcount</span> + <span class="c1">##################################################</span> + <span class="c1"># Grid run</span> + <span class="c1">############################################################</span> + <span class="c1"># Set up LRU cache</span> + <span class="bp">self</span><span class="o">.</span><span class="n">setup_function_cache</span><span class="p">()</span> + <span class="c1">############################################################</span> + <span class="c1"># Dry run and getting starcount</span> + <span class="c1">############################################################</span> <span class="c1"># Put in check</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"Error: you haven't defined any grid variables! Aborting"</span><span class="p">)</span> <span class="k">raise</span> <span class="ne">ValueError</span> <span class="c1"># Set up the grid code with a dry run option to see total probability</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Do dry run? </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"do_dry_run"</span><span class="p">]))</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"do_dry_run"</span><span class="p">]:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"Doing dry run to calculate total starcount and probability"</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_generate_grid_code</span><span class="p">(</span><span class="n">dry_run</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> @@ -2232,9 +2144,10 @@ <span class="c1"># Do a dry run</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dry_run</span><span class="p">()</span> - <span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">_boxed</span><span class="p">(</span> - <span class="s2">"Total starcount for this run is </span><span class="si">{starcount}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">"Dry run"</span><span class="p">,</span> + <span class="s2">"Total starcount is </span><span class="si">{starcount}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="n">starcount</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> <span class="p">),</span> <span class="s2">"Total probability is </span><span class="si">{probtot:g}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> @@ -2245,16 +2158,25 @@ <span class="mi">0</span><span class="p">,</span> <span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"exit_after_dry_run"</span><span class="p">]:</span> - <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Exiting after dry run </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"exit_after_dry_run"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"return_after_dry_run"</span><span class="p">]:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Returning after dry run </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"exit_after_dry_run"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">return</span> <span class="kc">False</span> <span class="c1">#######################</span> <span class="c1"># Reset values and prepare the grid function</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> <span class="s2">"_probtot"</span> <span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># To make sure that the values are reset. TODO: fix this in a cleaner way</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> - <span class="s2">"_start_time_evolution"</span> - <span class="p">]</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="c1"># Setting start time of grid</span> <span class="c1"># # Making sure the loaded grid code isn't lingering in the main PID</span> <span class="c1"># self._generate_grid_code(dry_run=False)</span> @@ -2283,14 +2205,14 @@ <span class="c1"># TODO: fix this function</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"This functionality is not available yet"</span><span class="p">)</span> - <span class="c1"># Source file</span> + <span class="c1"># Monte-carlo</span> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"montecarlo"</span><span class="p">:</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"do_dry_run"</span><span class="p">]:</span> <span class="c1"># Do a dry run</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dry_run_source_file</span><span class="p">()</span> <span class="nb">print</span><span class="p">(</span> - <span class="s2">"Total starcount for this run will be: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">"Total starcount will be: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> <span class="p">)</span> <span class="p">)</span> @@ -2300,9 +2222,6 @@ <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> <span class="s2">"_probtot"</span> <span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># To make sure that the values are reset. TODO: fix this in a cleaner way</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> - <span class="s2">"_start_time_evolution"</span> - <span class="p">]</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="c1"># Setting start time of grid</span> <span class="c1">#</span> <span class="c1"># TODO: fix this function</span> @@ -2313,9 +2232,8 @@ <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> <span class="s2">"_probtot"</span> <span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># To make sure that the values are reset. TODO: fix this in a cleaner way</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> - <span class="s2">"_start_time_evolution"</span> - <span class="p">]</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="c1"># Setting start time of grid</span> + + <span class="k">return</span> <span class="kc">True</span> <span class="k">def</span> <span class="nf">_cleanup</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> @@ -2329,2848 +2247,288 @@ <span class="sd"> """</span> <span class="c1"># Reset values</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_probtot"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span> + <span class="s2">"_count"</span><span class="p">,</span> + <span class="s2">"_probtot"</span><span class="p">,</span> + <span class="s2">"_failed_count"</span><span class="p">,</span> + <span class="s2">"_failed_prob"</span><span class="p">,</span> + <span class="s2">"_total_mass_run"</span><span class="p">,</span> + <span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">,</span> + <span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"_errors_found"</span><span class="p">,</span> <span class="s2">"_errors_exceeded"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_count"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_prob"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_found"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_exceeded"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_systems_error_codes"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_mass_run"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> - - <span class="c1"># Remove files</span> - <span class="c1"># TODO: remove files</span> - <span class="c1"># Unload functions</span> - <span class="c1"># TODO: unload functions</span> + <span class="k">def</span> <span class="nf">_dry_run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to dry run the grid and know how many stars it will run</span> - <span class="c1"># Unload/free custom_logging_code</span> - <span class="c1"># TODO: cleanup custom logging code.</span> +<span class="sd"> Requires the grid to be built as a dry run grid</span> +<span class="sd"> """</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Doing a dry run of the grid."</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span> + <span class="p">)</span> + <span class="n">system_generator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> + <span class="n">total_starcount</span> <span class="o">=</span> <span class="n">system_generator</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> <span class="o">=</span> <span class="n">total_starcount</span> <span class="c1">###################################################</span> - <span class="c1"># Grid code functions</span> + <span class="c1"># Population from file functions</span> <span class="c1">#</span> - <span class="c1"># Function below are used to run populations with</span> - <span class="c1"># a variable grid</span> + <span class="c1"># Functions below are used to run populations from</span> + <span class="c1"># a file containing binary_c calls</span> <span class="c1">###################################################</span> - - <span class="k">def</span> <span class="nf">_add_code</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> + <span class="k">def</span> <span class="nf">_dry_run_source_file</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> -<span class="sd"> Function to add code to the grid code string</span> - -<span class="sd"> add code to the code_string</span> - -<span class="sd"> indent (=0) is added once at the beginning</span> -<span class="sd"> mindent (=0) is added for every line</span> - -<span class="sd"> don't use both!</span> +<span class="sd"> Function to go through the source_file and count the number of lines and the total probability</span> <span class="sd"> """</span> - <span class="n">indent_block</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_indent_block</span><span class="p">(</span><span class="n">indent</span><span class="p">)</span> - <span class="k">for</span> <span class="n">thing</span> <span class="ow">in</span> <span class="n">args</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">code_string</span> <span class="o">+=</span> <span class="n">indent_block</span> <span class="o">+</span> <span class="n">thing</span> + <span class="n">system_generator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> + <span class="n">total_starcount</span> <span class="o">=</span> <span class="mi">0</span> - <span class="k">def</span> <span class="nf">_indent_block</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">n</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> return an indent block, with n extra blocks in it</span> -<span class="sd"> """</span> + <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">system_generator</span><span class="p">:</span> + <span class="n">total_starcount</span> <span class="o">+=</span> <span class="mi">1</span> - <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent_depth</span> <span class="o">+</span> <span class="n">n</span><span class="p">)</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent_string</span> + <span class="n">total_starcount</span> <span class="o">=</span> <span class="n">system_generator</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> <span class="o">=</span> <span class="n">total_starcount</span> - <span class="k">def</span> <span class="nf">_increment_indent_depth</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">delta</span><span class="p">):</span> + <span class="k">def</span> <span class="nf">_load_source_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">check</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> <span class="sd">"""</span> -<span class="sd"> increment the indent indent_depth by delta</span> +<span class="sd"> Function that loads the source_file that contains a binary_c calls</span> <span class="sd"> """</span> - <span class="bp">self</span><span class="o">.</span><span class="n">indent_depth</span> <span class="o">+=</span> <span class="n">delta</span> - - <span class="k">def</span> <span class="nf">_generate_grid_code</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dry_run</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function that generates the code from which the population will be made.</span> - -<span class="sd"> dry_run: when True, it will return the starcount at the end so that we know</span> -<span class="sd"> what the total number of systems is.</span> - -<span class="sd"> The phasevol values are handled by generating a second array</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"source_file_filename"</span><span class="p">]):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Source file doesnt exist"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">0</span> + <span class="p">)</span> -<span class="sd"> # TODO: Add correct logging everywhere</span> -<span class="sd"> # TODO: add part to handle separation if orbital_period is added. Idea. use default values</span> -<span class="sd"> # for orbital parameters and possibly overwrite those or something.</span> -<span class="sd"> # TODO: add sensible description to this function.</span> -<span class="sd"> # TODO: Check whether all the probability and phasevol values are correct.</span> -<span class="sd"> # TODO: import only the necessary packages/functions</span> -<span class="sd"> # TODO: Put all the masses, eccentricities and periods in there already</span> -<span class="sd"> # TODO: Put the certain blocks that are repeated in some sub functions</span> -<span class="sd"> # TODO: make sure running systems with multiplicity 3+ is also possible.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="n">message</span><span class="o">=</span><span class="s2">"Loading source file from </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"gridcode_filename"</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="n">minimal_verbosity</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> -<span class="sd"> Results in a generated file that contains a system_generator function.</span> -<span class="sd"> """</span> + <span class="c1"># We can choose to perform a check on the source file, which checks if the lines start with 'binary_c'</span> + <span class="k">if</span> <span class="n">check</span><span class="p">:</span> + <span class="n">source_file_check_filehandle</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"source_file_filename"</span><span class="p">],</span> <span class="s2">"r"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span> + <span class="p">)</span> + <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">source_file_check_filehandle</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"binary_c"</span><span class="p">):</span> + <span class="n">failed</span> <span class="o">=</span> <span class="kc">True</span> + <span class="k">break</span> + <span class="k">if</span> <span class="n">failed</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Error, sourcefile contains lines that do not start with binary_c"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span> - <span class="n">verbose_print</span><span class="p">(</span><span class="s2">"Generating grid code"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">)</span> - - <span class="n">total_grid_variables</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">])</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="c1"># Import packages</span> - <span class="s2">"import math</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"import numpy as np</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"from collections import OrderedDict</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"from binarycpython.utils.distribution_functions import *</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"from binarycpython.utils.spacing_functions import *</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"from binarycpython.utils.useful_funcs import *</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"</span><span class="se">\n\n</span><span class="s2">"</span><span class="p">,</span> - <span class="c1"># Make the function</span> - <span class="s2">"def grid_code(self, print_results=True):</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="n">source_file_filehandle</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"source_file_filename"</span><span class="p">],</span> <span class="s2">"r"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span> <span class="p">)</span> - <span class="c1"># Increase indent_depth</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="c1"># Write some info in the function</span> - <span class="s2">"# Grid code generated on </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()),</span> - <span class="s2">"# This function generates the systems that will be evolved with binary_c</span><span class="se">\n\n</span><span class="s2">"</span> - <span class="c1"># Set some values in the generated code:</span> - <span class="s2">"# Setting initial values</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"_total_starcount = 0</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"starcounts = [0 for i in range(</span><span class="si">{}</span><span class="s2">)]</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">total_grid_variables</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> - <span class="s2">"probabilities = </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"probabilities_list = [0 for i in range(</span><span class="si">{}</span><span class="s2">)]</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">total_grid_variables</span> <span class="o">+</span> <span class="mi">1</span> - <span class="p">),</span> - <span class="s2">"probabilities_sum = [0 for i in range(</span><span class="si">{}</span><span class="s2">)]</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">total_grid_variables</span> <span class="o">+</span> <span class="mi">1</span> - <span class="p">),</span> - <span class="s2">"parameter_dict = </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"phasevol = 1</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> <span class="o">=</span> <span class="n">source_file_filehandle</span> - <span class="c1"># Set up the system parameters</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"M_1 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"M_2 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"M_3 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"M_4 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"orbital_period = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"orbital_period_triple = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"orbital_period_quadruple = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"eccentricity = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"eccentricity2 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"eccentricity3 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="c1"># Prepare the probability</span> - <span class="s2">"# setting probability lists</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span><span class="s2">"Source file loaded"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">)</span> - <span class="k">for</span> <span class="n">grid_variable_el</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span> - <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> - <span class="p">):</span> - <span class="c1"># Make probabilities dict</span> - <span class="n">grid_variable</span> <span class="o">=</span> <span class="n">grid_variable_el</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s1">'probabilities["</span><span class="si">{}</span><span class="s1">"] = 0</span><span class="se">\n</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]))</span> - - <span class="c1">#################################################################################</span> - <span class="c1"># Start of code generation</span> - <span class="c1">#################################################################################</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - - <span class="c1"># turn vb to True to have debugging output</span> - <span class="n">vb</span> <span class="o">=</span> <span class="kc">False</span> - - <span class="c1"># Generate code</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"Generating grid code"</span><span class="p">)</span> - <span class="k">for</span> <span class="n">loopnr</span><span class="p">,</span> <span class="n">grid_variable_el</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span> - <span class="nb">sorted</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span> - <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> - <span class="p">)</span> - <span class="p">):</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Constructing/adding: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable_el</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">2</span><span class="p">,</span> - <span class="p">)</span> - <span class="n">grid_variable</span> <span class="o">=</span> <span class="n">grid_variable_el</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> - - <span class="c1">####################</span> - <span class="c1"># top code</span> - <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"topcode"</span><span class="p">]:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"topcode"</span><span class="p">])</span> - - <span class="c1">#########################</span> - <span class="c1"># Setting up the for loop</span> - <span class="c1"># Add comment for for loop</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"# for loop for </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">])</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"sampled_values_</span><span class="si">{}</span><span class="s2"> = </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"samplerfunc"</span><span class="p">]</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"print('samples','</span><span class="si">{}</span><span class="s2">',':',sampled_values_</span><span class="si">{}</span><span class="s2">)</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">)</span> - <span class="p">)</span> - - <span class="c1"># # Some print statement</span> - <span class="c1"># self._add_code((</span> - <span class="c1"># "print('phasevol_{}:', phasevol_{})".format(grid_variable["name"],</span> - <span class="c1"># grid_variable["name"])</span> - <span class="c1"># + "\n"</span> - <span class="c1"># )</span> - - <span class="c1"># TODO: make sure this works</span> - <span class="c1"># Adding for loop structure</span> - <span class="c1"># self._add_code((</span> - <span class="c1"># "for {} in sampled_values_{}:".format(</span> - <span class="c1"># grid_variable["name"], grid_variable["name"]</span> - <span class="c1"># )</span> - <span class="c1"># + "\n"</span> - <span class="c1"># )</span> - - <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"print('sample </span><span class="si">{}</span><span class="s2"> from',sampled_values_</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - - <span class="c1"># if grid_variable["resolution"] == 0:</span> - <span class="c1"># sample from the sampled_values</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"for </span><span class="si">{}</span><span class="s2">_sample_number in range(max(0,len(sampled_values_</span><span class="si">{}</span><span class="s2">)-1)):"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - - <span class="c1"># old code: use resolution passed in</span> - <span class="c1"># else:</span> - <span class="c1"># # use resolution passed in</span> - <span class="c1"># self._add_code(</span> - <span class="c1"># "for {}_sample_number in range({} if {} != 0 else max(0,len(sampled_values_{})-1)):".format(</span> - <span class="c1"># grid_variable["name"],</span> - <span class="c1"># grid_variable["resolution"],</span> - <span class="c1"># grid_variable["resolution"],</span> - <span class="c1"># grid_variable["name"],</span> - <span class="c1"># )</span> - <span class="c1"># + "\n"</span> - <span class="c1"># )</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> - - <span class="c1"># {}_this and {}_next are this grid point's index and the next</span> - <span class="c1"># grid point's index, used in many calculations below</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"if </span><span class="si">{}</span><span class="s2">_sample_number == 0:</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]))</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">_this = 0;</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]),</span> <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"else:</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{}</span><span class="s2">_this = </span><span class="si">{}</span><span class="s2">_sample_number; "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"</span><span class="si">{}</span><span class="s2">_next = </span><span class="si">{}</span><span class="s2">_this + 1"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">),</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># TODO: Make clear that the phasevol only works good</span> - <span class="c1"># TODO: add option to ignore this phasevol calculation and set it to 1</span> - <span class="c1"># if you sample linearly in that thing.</span> - <span class="c1"># if phasevol is <= 0 then we SKIP that whole loop. Its not working then.</span> - <span class="k">if</span> <span class="p">(</span> - <span class="ow">not</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"dphasevol"</span><span class="p">]</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span> - <span class="p">):</span> <span class="c1"># A method to turn off this calculation and allow a phasevol = 1</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"phasevol_</span><span class="si">{}</span><span class="s2"> = sampled_values_</span><span class="si">{}</span><span class="s2">[</span><span class="si">{}</span><span class="s2">_next]-sampled_values_</span><span class="si">{}</span><span class="s2">[</span><span class="si">{}</span><span class="s2">_this]"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"phasevol_</span><span class="si">{}</span><span class="s2"> = 1</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]))</span> - - <span class="c1">##############</span> - <span class="c1"># Add phasevol check:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"if phasevol_</span><span class="si">{}</span><span class="s2"> <= 0:</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]))</span> - - <span class="c1"># TODO: We might actually want to add the starcount and probability to the totals regardless.</span> - <span class="c1"># n that case we need another local variable which will prevent it from being run but will track those parameters</span> - <span class="c1"># Add phasevol check action:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s1">'print("Grid generator: phasevol_</span><span class="si">{}</span><span class="s1"> <= 0! (this=",</span><span class="si">{}</span><span class="s1">_this,"=",sampled_values_</span><span class="si">{}</span><span class="s1">[</span><span class="si">{}</span><span class="s1">_this],", next=",</span><span class="si">{}</span><span class="s1">_next,"=",sampled_values_</span><span class="si">{}</span><span class="s1">[</span><span class="si">{}</span><span class="s1">_next],") Skipping current sample.")'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"continue</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"print('sample </span><span class="si">{}</span><span class="s2"> from ',sampled_values_</span><span class="si">{}</span><span class="s2">,' at this=',</span><span class="si">{}</span><span class="s2">_this,', next=',</span><span class="si">{}</span><span class="s2">_next)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - - <span class="c1"># select point location based on gridtype (left, centre or right)</span> - <span class="k">if</span> <span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"edge"</span> - <span class="ow">or</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"left"</span> - <span class="ow">or</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"left edge"</span> - <span class="p">):</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{}</span><span class="s2"> = sampled_values_</span><span class="si">{}</span><span class="s2">[</span><span class="si">{}</span><span class="s2">_this]"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - <span class="k">elif</span> <span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"right"</span> - <span class="ow">or</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"right edge"</span> - <span class="p">):</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="o">+</span><span class="s2">"</span><span class="si">{}</span><span class="s2"> = sampled_values_</span><span class="si">{}</span><span class="s2">[</span><span class="si">{}</span><span class="s2">_next]"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - <span class="k">elif</span> <span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"centred"</span> - <span class="ow">or</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"centre"</span> - <span class="ow">or</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"center"</span> - <span class="p">):</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{}</span><span class="s2"> = 0.5 * (sampled_values_</span><span class="si">{}</span><span class="s2">[</span><span class="si">{}</span><span class="s2">_next] + sampled_values_</span><span class="si">{}</span><span class="s2">[</span><span class="si">{}</span><span class="s2">_this])"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Unknown gridtype value. PLease choose a different one"</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"print('hence </span><span class="si">{}</span><span class="s2"> = ',</span><span class="si">{}</span><span class="s2">)</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">)</span> - <span class="p">)</span> - - <span class="c1">#################################################################################</span> - <span class="c1"># Check condition and generate for loop</span> - - <span class="c1"># If the grid variable has a condition, write the check and the action</span> - <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"condition"</span><span class="p">]:</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="c1"># Add comment</span> - <span class="s2">"# Condition for </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]),</span> - <span class="c1"># Add condition check</span> - <span class="s2">"if not </span><span class="si">{}</span><span class="s2">:</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"condition"</span><span class="p">]),</span> - <span class="n">indent</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Add condition failed action:</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="mi">3</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s1">'print("Grid generator: Condition for </span><span class="si">{}</span><span class="s1"> not met!")'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"continue"</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"continue"</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1"># Add some whitespace</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - - <span class="c1"># # Add debugging:</span> - <span class="c1"># if grid_variable['name']=='q':</span> - <span class="c1"># self._add_code((</span> - <span class="c1"># indent=1,</span> - <span class="c1"># 'print("sampling:", sampled_values_{}, M_1)'.format(</span> - <span class="c1"># grid_variable["name"], grid_variable["name"]</span> - <span class="c1"># )</span> - <span class="c1"># + "\n"</span> - <span class="c1"># )</span> - - <span class="c1"># Add some whitespace</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - - <span class="c1">#########################</span> - <span class="c1"># Setting up pre-code and value in some cases</span> - <span class="c1"># Add pre-code</span> - <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"precode"</span><span class="p">]:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"precode"</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_indent_block</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> - <span class="p">)</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - - <span class="c1"># Set phasevol</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"phasevol *= phasevol_</span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="p">)</span> - <span class="p">)</span> - - <span class="c1">#######################</span> - <span class="c1"># Probabilities</span> - <span class="c1"># Calculate probability</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"# Setting probabilities</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"d</span><span class="si">{}</span><span class="s2"> = phasevol_</span><span class="si">{}</span><span class="s2"> * (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"probdist"</span><span class="p">],</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="c1"># Save probability sum</span> - <span class="s2">"probabilities_sum[</span><span class="si">{}</span><span class="s2">] += d</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"probabilities_list[0] = d</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">])</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"probabilities_list[</span><span class="si">{}</span><span class="s2">] = probabilities_list[</span><span class="si">{}</span><span class="s2">] * d</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - - <span class="c1">##############</span> - <span class="c1"># postcode</span> - <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"postcode"</span><span class="p">]:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"postcode"</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_indent_block</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> - <span class="p">)</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - - <span class="c1">#######################</span> - <span class="c1"># Increment starcount for this parameter</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"# Increment starcount for </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]),</span> - <span class="s2">"starcounts[</span><span class="si">{}</span><span class="s2">] += 1"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="c1"># Add value to dict</span> - <span class="s1">'parameter_dict["</span><span class="si">{}</span><span class="s1">"] = </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"parameter_name"</span><span class="p">],</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"parameter_name"</span><span class="p">]</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="p">)</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> - - <span class="c1"># The final parts of the code, where things are returned, are within the deepest loop,</span> - <span class="c1"># but in some cases code from a higher loop needs to go under it again</span> - <span class="c1"># SO I think its better to put an if statement here that checks</span> - <span class="c1"># whether this is the last loop.</span> - <span class="k">if</span> <span class="n">loopnr</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_write_gridcode_system_call</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">,</span> - <span class="n">dry_run</span><span class="p">,</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchpoint"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchcode"</span><span class="p">],</span> - <span class="p">)</span> - - <span class="c1"># increment indent_depth</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> - - <span class="c1">####################</span> - <span class="c1"># bottom code</span> - <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"bottomcode"</span><span class="p">]:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"bottomcode"</span><span class="p">])</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - - <span class="c1"># Write parts to write below the part that yield the results.</span> - <span class="c1"># this has to go in a reverse order:</span> - <span class="c1"># Here comes the stuff that is put after the deepest nested part that calls returns stuff.</span> - <span class="c1"># Here we will have a</span> - <span class="n">reverse_sorted_grid_variables</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span> - <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> - <span class="n">reverse</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">for</span> <span class="n">loopnr</span><span class="p">,</span> <span class="n">grid_variable_el</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">reverse_sorted_grid_variables</span><span class="p">):</span> - <span class="n">grid_variable</span> <span class="o">=</span> <span class="n">grid_variable_el</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"#"</span> <span class="o">*</span> <span class="mi">40</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"# Code below is for finalising the handling of this iteration of the parameter </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">),</span> - <span class="p">)</span> - - <span class="c1"># Set phasevol</span> - <span class="c1"># TODO: fix. this isn't supposed to be the value that we give it here. discuss</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"phasevol /= phasevol_</span><span class="si">{}</span><span class="se">\n\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]))</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">)</span> - - <span class="c1"># Check the branchpoint part here. The branchpoint makes sure that we can construct</span> - <span class="c1"># a grid with several multiplicities and still can make the system calls for each</span> - <span class="c1"># multiplicity without reconstructing the grid each time</span> - <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchpoint"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="c1"># Add comment</span> - <span class="s2">"# Condition for branchpoint at </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">reverse_sorted_grid_variables</span><span class="p">[</span><span class="n">loopnr</span> <span class="o">+</span> <span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">][</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="c1"># # Add condition check</span> - <span class="c1"># "if not {}:".format(grid_variable["condition"])</span> - <span class="c1"># + "\n"</span> - <span class="c1"># Add branchpoint</span> - <span class="s2">"if multiplicity==</span><span class="si">{}</span><span class="s2">:"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchpoint"</span><span class="p">])</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="p">)</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_write_gridcode_system_call</span><span class="p">(</span> - <span class="n">reverse_sorted_grid_variables</span><span class="p">[</span><span class="n">loopnr</span> <span class="o">+</span> <span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="n">dry_run</span><span class="p">,</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchpoint"</span><span class="p">],</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchcode"</span><span class="p">],</span> - <span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - - <span class="c1">###############################</span> - <span class="c1"># Finalising print statements</span> - <span class="c1">#</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"#"</span> <span class="o">*</span> <span class="mi">40</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"if print_results:</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"print('Grid has handled </span><span class="si">{}</span><span class="s2"> stars with a total probability of </span><span class="si">{:g}</span><span class="s2">'.format(_total_starcount,self.grid_options['_probtot']))</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1">################</span> - <span class="c1"># Finalising return statement for dry run.</span> - <span class="c1">#</span> - <span class="k">if</span> <span class="n">dry_run</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"return _total_starcount</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> - <span class="c1">#################################################################################</span> - <span class="c1"># Stop of code generation. Here the code is saved and written</span> - - <span class="c1"># Save the grid code to the grid_options</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Saving grid code to grid_options"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span> - <span class="p">)</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"code_string"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">code_string</span> - - <span class="c1"># Write to file</span> - <span class="n">gridcode_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> - <span class="s2">"binary_c_grid_</span><span class="si">{}</span><span class="s2">.py"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_population_id"</span><span class="p">]),</span> - <span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"gridcode_filename"</span><span class="p">]</span> <span class="o">=</span> <span class="n">gridcode_filename</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{}</span><span class="s2">Writing grid code to </span><span class="si">{}</span><span class="s2"> [dry_run = </span><span class="si">{}</span><span class="s2">]</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"blue"</span><span class="p">],</span> - <span class="n">gridcode_filename</span><span class="p">,</span> - <span class="n">dry_run</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">gridcode_filename</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span> - <span class="n">file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">code_string</span><span class="p">)</span> - - <span class="c1"># perhaps create symlink</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"symlink latest gridcode"</span><span class="p">]:</span> - <span class="k">global</span> <span class="n">_count</span> - <span class="n">symlink</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"binary_c_grid-latest"</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">_count</span><span class="p">)</span> - <span class="p">)</span> - <span class="n">_count</span> <span class="o">+=</span> <span class="mi">1</span> - <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">symlink</span><span class="p">):</span> - <span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">symlink</span><span class="p">)</span> - - <span class="k">try</span><span class="p">:</span> - <span class="n">os</span><span class="o">.</span><span class="n">symlink</span><span class="p">(</span><span class="n">gridcode_filename</span><span class="p">,</span> <span class="n">symlink</span><span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{}</span><span class="s2">Symlinked grid code to </span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"blue"</span><span class="p">],</span> <span class="n">symlink</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">]</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"symlink failed"</span><span class="p">)</span> - - <span class="k">def</span> <span class="nf">_write_gridcode_system_call</span><span class="p">(</span> - <span class="bp">self</span><span class="p">,</span> <span class="n">grid_variable</span><span class="p">,</span> <span class="n">dry_run</span><span class="p">,</span> <span class="n">branchpoint</span><span class="p">,</span> <span class="n">branchcode</span> - <span class="p">):</span> - <span class="c1">#################################################################################</span> - <span class="c1"># Here are the calls to the queuing or other solution. this part is for every system</span> - <span class="c1"># Add comment</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"#"</span> <span class="o">*</span> <span class="mi">40</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - - <span class="k">if</span> <span class="n">branchcode</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"# Branch code</span><span class="se">\n</span><span class="s2">if </span><span class="si">{}</span><span class="s2">:</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">branchcode</span><span class="p">)</span> - - <span class="k">if</span> <span class="n">branchpoint</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"# Code below will get evaluated for every system at this level of multiplicity (last one of that being </span><span class="si">{}</span><span class="s2">)</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> - <span class="p">)</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"# Code below will get evaluated for every generated system</span><span class="se">\n</span><span class="s2">"</span> - <span class="p">)</span> - - <span class="c1"># Factor in the custom weight input</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"# Weigh the probability by a custom weighting factor</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s1">'probability = self.grid_options["weight"] * probabilities_list[</span><span class="si">{}</span><span class="s1">]'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">]</span> - <span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="c1"># Take into account the multiplicity fraction:</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"# Factor the multiplicity fraction into the probability</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"probability = probability * self._calculate_multiplicity_fraction(parameter_dict)"</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="c1"># Add division by number of repeats</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"# Divide the probability by the number of repeats</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s1">'probability = probability / self.grid_options["repeat"]'</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="c1"># Now we yield the system self.grid_options["repeat"] times.</span> - <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s2">"# Loop over the repeats</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s1">'for _ in range(self.grid_options["repeat"]):'</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> - <span class="s2">"_total_starcount += 1</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="c1"># set probability and phasevol values into the system dict</span> - <span class="s1">'parameter_dict["</span><span class="si">{}</span><span class="s1">"] = </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s2">"probability"</span><span class="p">,</span> <span class="s2">"probability"</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="s1">'parameter_dict["</span><span class="si">{}</span><span class="s1">"] = </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s2">"phasevol"</span><span class="p">,</span> <span class="s2">"phasevol"</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="c1"># Increment total probability</span> - <span class="s2">"self._increment_probtot(probability)</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> - <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">if</span> <span class="ow">not</span> <span class="n">dry_run</span><span class="p">:</span> - <span class="c1"># Handling of what is returned, or what is not.</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"yield(parameter_dict)</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> - - <span class="c1"># If its a dry run, dont do anything with it</span> - <span class="k">else</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"pass</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"#"</span> <span class="o">*</span> <span class="mi">40</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> - - <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">code_string</span> - - <span class="k">def</span> <span class="nf">_load_grid_function</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function that loads the script containing the grid code.</span> - -<span class="sd"> TODO: Update this description</span> -<span class="sd"> Test function to run grid stuff. mostly to test the import</span> -<span class="sd"> """</span> - - <span class="c1"># Code to load the</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="n">message</span><span class="o">=</span><span class="s2">"Loading grid code function from </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"gridcode_filename"</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="n">minimal_verbosity</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="n">spec</span> <span class="o">=</span> <span class="n">importlib</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">spec_from_file_location</span><span class="p">(</span> - <span class="s2">"binary_c_python_grid"</span><span class="p">,</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"gridcode_filename"</span><span class="p">]),</span> - <span class="p">)</span> - <span class="n">grid_file</span> <span class="o">=</span> <span class="n">importlib</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">module_from_spec</span><span class="p">(</span><span class="n">spec</span><span class="p">)</span> - <span class="n">spec</span><span class="o">.</span><span class="n">loader</span><span class="o">.</span><span class="n">exec_module</span><span class="p">(</span><span class="n">grid_file</span><span class="p">)</span> - <span class="n">generator</span> <span class="o">=</span> <span class="n">grid_file</span><span class="o">.</span><span class="n">grid_code</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> <span class="o">=</span> <span class="n">generator</span> - - <span class="n">verbose_print</span><span class="p">(</span><span class="s2">"Grid code loaded"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">)</span> - - <span class="k">def</span> <span class="nf">_dry_run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to dry run the grid and know how many stars it will run</span> - -<span class="sd"> Requires the grid to be built as a dry run grid</span> -<span class="sd"> """</span> - <span class="n">verbose_print</span><span class="p">(</span><span class="s2">"Dry run of the grid"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">)</span> - <span class="n">system_generator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> - <span class="n">total_starcount</span> <span class="o">=</span> <span class="n">system_generator</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> <span class="o">=</span> <span class="n">total_starcount</span> - - <span class="k">def</span> <span class="nf">_print_info</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">run_number</span><span class="p">,</span> <span class="n">total_systems</span><span class="p">,</span> <span class="n">full_system_dict</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to print info about the current system and the progress of the grid.</span> - -<span class="sd"> # color info tricks from https://ozzmaker.com/add-colour-to-text-in-python/</span> -<span class="sd"> https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python</span> -<span class="sd"> """</span> - - <span class="c1"># Define frequency</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="n">print_freq</span> <span class="o">=</span> <span class="mi">1</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">print_freq</span> <span class="o">=</span> <span class="mi">10</span> - - <span class="c1"># Calculate amount of time left</span> - <span class="c1"># calculate amount of time passed</span> - <span class="c1"># time_passed = time.time() - self.grid_options["_start_time_evolution"]</span> - - <span class="k">if</span> <span class="n">run_number</span> <span class="o">%</span> <span class="n">print_freq</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> - <span class="n">binary_cmdline_string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_argline</span><span class="p">(</span><span class="n">full_system_dict</span><span class="p">)</span> - <span class="n">info_string</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{color_part_1}</span><span class="s2"> </span><span class="se">\</span> -<span class="s2"> </span><span class="si">{text_part_1}{end_part_1}{color_part_2}</span><span class="s2"> </span><span class="se">\</span> -<span class="s2"> </span><span class="si">{text_part_2}{end_part_2}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">color_part_1</span><span class="o">=</span><span class="s2">"</span><span class="se">\033</span><span class="s2">[1;32;41m"</span><span class="p">,</span> - <span class="n">text_part_1</span><span class="o">=</span><span class="s2">"</span><span class="si">{}</span><span class="s2">/</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">run_number</span><span class="p">,</span> <span class="n">total_systems</span><span class="p">),</span> - <span class="n">end_part_1</span><span class="o">=</span><span class="s2">"</span><span class="se">\033</span><span class="s2">[0m"</span><span class="p">,</span> - <span class="n">color_part_2</span><span class="o">=</span><span class="s2">"</span><span class="se">\033</span><span class="s2">[1;32;42m"</span><span class="p">,</span> - <span class="n">text_part_2</span><span class="o">=</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">binary_cmdline_string</span><span class="p">),</span> - <span class="n">end_part_2</span><span class="o">=</span><span class="s2">"</span><span class="se">\033</span><span class="s2">[0m"</span><span class="p">,</span> - <span class="p">)</span> - <span class="nb">print</span><span class="p">(</span><span class="n">info_string</span><span class="p">)</span> - - <span class="c1">###################################################</span> - <span class="c1"># Monte Carlo functions</span> - <span class="c1">#</span> - <span class="c1"># Functions below are used to run populations with</span> - <span class="c1"># Monte Carlo</span> - <span class="c1">###################################################</span> - - <span class="c1">###################################################</span> - <span class="c1"># Population from file functions</span> - <span class="c1">#</span> - <span class="c1"># Functions below are used to run populations from</span> - <span class="c1"># a file containing binary_c calls</span> - <span class="c1">###################################################</span> - <span class="k">def</span> <span class="nf">_dry_run_source_file</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to go through the source_file and count the number of lines and the total probability</span> -<span class="sd"> """</span> - - <span class="n">system_generator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> - - <span class="n">total_starcount</span> <span class="o">=</span> <span class="mi">0</span> - <span class="n">total_probability</span> <span class="o">=</span> <span class="mi">0</span> - - <span class="n">contains_probability</span> <span class="o">=</span> <span class="kc">False</span> - - <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">system_generator</span><span class="p">:</span> - <span class="n">total_starcount</span> <span class="o">+=</span> <span class="mi">1</span> - - <span class="n">total_starcount</span> <span class="o">=</span> <span class="n">system_generator</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> <span class="o">=</span> <span class="n">total_starcount</span> - - <span class="k">def</span> <span class="nf">_load_source_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">check</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function that loads the source_file that contains a binary_c calls</span> -<span class="sd"> """</span> - - <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"source_file_filename"</span><span class="p">]):</span> - <span class="n">verbose_print</span><span class="p">(</span><span class="s2">"Source file doesnt exist"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">0</span><span class="p">)</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="n">message</span><span class="o">=</span><span class="s2">"Loading source file from </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"gridcode_filename"</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="n">minimal_verbosity</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># We can choose to perform a check on the source file, which checks if the lines start with 'binary_c'</span> - <span class="k">if</span> <span class="n">check</span><span class="p">:</span> - <span class="n">source_file_check_filehandle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"source_file_filename"</span><span class="p">],</span> <span class="s2">"r"</span> - <span class="p">)</span> - <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">source_file_check_filehandle</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"binary_c"</span><span class="p">):</span> - <span class="n">failed</span> <span class="o">=</span> <span class="kc">True</span> - <span class="k">break</span> - <span class="k">if</span> <span class="n">failed</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Error, sourcefile contains lines that do not start with binary_c"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">0</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span> - - <span class="n">source_file_filehandle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"source_file_filename"</span><span class="p">],</span> <span class="s2">"r"</span><span class="p">)</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> <span class="o">=</span> <span class="n">source_file_filehandle</span> - - <span class="n">verbose_print</span><span class="p">(</span><span class="s2">"Source file loaded"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">)</span> - - <span class="k">def</span> <span class="nf">_dict_from_line_source_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function that creates a dict from a binary_c arg line</span> -<span class="sd"> """</span> - - <span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"binary_c "</span><span class="p">):</span> - <span class="n">line</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"binary_c "</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> - - <span class="n">split_line</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> - <span class="n">arg_dict</span> <span class="o">=</span> <span class="p">{}</span> - - <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">split_line</span><span class="p">),</span> <span class="mi">2</span><span class="p">):</span> - <span class="k">if</span> <span class="s2">"."</span> <span class="ow">in</span> <span class="n">split_line</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]:</span> - <span class="n">arg_dict</span><span class="p">[</span><span class="n">split_line</span><span class="p">[</span><span class="n">i</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">split_line</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">arg_dict</span><span class="p">[</span><span class="n">split_line</span><span class="p">[</span><span class="n">i</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">split_line</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> - - <span class="k">return</span> <span class="n">arg_dict</span> - - <span class="c1">###################################################</span> - <span class="c1"># SLURM functions</span> - <span class="c1">#</span> - <span class="c1"># subroutines to run SLURM grids</span> - <span class="c1">###################################################</span> - - <span class="c1"># def _slurm_grid(self):</span> - <span class="c1"># """</span> - <span class="c1"># Main function that manages the SLURM setup.</span> - - <span class="c1"># Has three stages:</span> - - <span class="c1"># - setup</span> - <span class="c1"># - evolve</span> - <span class="c1"># - join</span> - - <span class="c1"># Which stage is used is determined by the value of grid_options['slurm_command']:</span> - - <span class="c1"># <empty>: the function will know its the user that executed the script and</span> - <span class="c1"># it will set up the necessary condor stuff</span> - - <span class="c1"># 'evolve': evolve_population is called to evolve the population of stars</span> - - <span class="c1"># 'join': We will attempt to join the output</span> - <span class="c1"># """</span> - - <span class="c1"># # Check version</span> - <span class="c1"># # TODO: Put in function</span> - <span class="c1"># slurm_version = get_slurm_version()</span> - <span class="c1"># if not slurm_version:</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "SLURM: Error: No installation of slurm found",</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 0,</span> - <span class="c1"># )</span> - <span class="c1"># else:</span> - <span class="c1"># major_version = int(slurm_version.split(".")[0])</span> - <span class="c1"># minor_version = int(slurm_version.split(".")[1])</span> - - <span class="c1"># if major_version > 17:</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "SLURM: Found version {} which is new enough".format(slurm_version),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 1,</span> - <span class="c1"># )</span> - <span class="c1"># else:</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "SLURM: Found version {} which is too old (we require 17+)".format(</span> - <span class="c1"># slurm_version</span> - <span class="c1"># ),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 0,</span> - <span class="c1"># )</span> - - <span class="c1"># verbose_print(</span> - <span class="c1"># "SLURM: Running slurm grid. command={}".format(</span> - <span class="c1"># self.grid_options["slurm_command"]</span> - <span class="c1"># ),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 1,</span> - <span class="c1"># )</span> - - <span class="c1"># if not self.grid_options["slurm_command"]:</span> - <span class="c1"># # Setting up</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "SLURM: Main controller script. Setting up",</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 1,</span> - <span class="c1"># )</span> - - <span class="c1"># # Set up working directories:</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "SLURM: creating working directories", self.grid_options["verbosity"], 1</span> - <span class="c1"># )</span> - <span class="c1"># create_directories_hpc(self.grid_options["slurm_dir"])</span> - - <span class="c1"># # Create command</span> - <span class="c1"># python_details = get_python_details()</span> - <span class="c1"># scriptname = path_of_calling_script()</span> - <span class="c1"># command = "{} {}".format(python_details["executable"], scriptname)</span> - <span class="c1"># command += '{}'.format(</span> - <span class="c1"># " ".join(</span> - <span class="c1"># [</span> - <span class="c1"># "{}".format(self.grid_options["_commandline_input"]),</span> - <span class="c1"># "offset=$jobarrayindex",</span> - <span class="c1"># "modulo={}".format(self.grid_options["slurm_njobs"]),</span> - <span class="c1"># "vb={}".format(self.grid_options["verbosity"]),</span> - <span class="c1"># "slurm_jobid=$jobid",</span> - <span class="c1"># "slurm_jobarrayindex=$jobarrayindex",</span> - <span class="c1"># "slurm_jobname='binary_grid_'$jobid'.'$jobarrayindex",</span> - <span class="c1"># "slurm_njobs={}".format(self.grid_options["slurm_njobs"]),</span> - <span class="c1"># "slurm_dir={}".format(self.grid_options["slurm_dir"]),</span> - <span class="c1"># "rungrid=1",</span> - <span class="c1"># "slurm_command=evolve",</span> - <span class="c1"># ]</span> - <span class="c1"># ).strip()</span> - <span class="c1"># )</span> - - <span class="c1"># # Construct dict with settings for the script while checking the settings at the same time</span> - <span class="c1"># # Check settings:</span> - <span class="c1"># # TODO: check settings</span> - <span class="c1"># # Create SLURM_DIR script:</span> - <span class="c1"># slurm_script_options = {}</span> - <span class="c1"># slurm_script_options["n"] = self.grid_options["slurm_njobs"]</span> - <span class="c1"># slurm_script_options["njobs"] = self.grid_options["slurm_njobs"]</span> - <span class="c1"># slurm_script_options["dir"] = self.grid_options["slurm_dir"]</span> - <span class="c1"># slurm_script_options["memory"] = self.grid_options["slurm_memory"]</span> - <span class="c1"># slurm_script_options["working_dir"] = self.grid_options[</span> - <span class="c1"># "slurm_dir"</span> - <span class="c1"># ] # TODO: check this</span> - <span class="c1"># slurm_script_options["command"] = command</span> - <span class="c1"># # slurm_script_options['streams'] = self.grid_options['streams']</span> - - <span class="c1"># # Construct the script</span> - <span class="c1"># slurm_script_contents = ""</span> - <span class="c1"># slurm_script_contents += "#!/bin/bash\n"</span> - <span class="c1"># slurm_script_contents += "# Slurm file for binary_grid and slurm\n"</span> - <span class="c1"># slurm_script_contents += "#SBATCH --error={}/stderr/%A.%a\n".format(</span> - <span class="c1"># self.grid_options["slurm_dir"]</span> - <span class="c1"># )</span> - <span class="c1"># slurm_script_contents += "#SBATCH --output={}/stdout/%A.%a\n".format(</span> - <span class="c1"># self.grid_options["slurm_dir"]</span> - <span class="c1"># )</span> - <span class="c1"># slurm_script_contents += "#SBATCH --job-name={}\n".format(</span> - <span class="c1"># self.grid_options["slurm_jobname"]</span> - <span class="c1"># )</span> - <span class="c1"># slurm_script_contents += "#SBATCH --partition={}\n".format(</span> - <span class="c1"># self.grid_options["slurm_partition"]</span> - <span class="c1"># )</span> - <span class="c1"># slurm_script_contents += "#SBATCH --time={}\n".format(</span> - <span class="c1"># self.grid_options["slurm_time"]</span> - <span class="c1"># )</span> - <span class="c1"># slurm_script_contents += "#SBATCH --mem={}\n".format(</span> - <span class="c1"># self.grid_options["slurm_memory"]</span> - <span class="c1"># )</span> - <span class="c1"># slurm_script_contents += "#SBATCH --ntasks={}\n".format(</span> - <span class="c1"># self.grid_options["slurm_ntasks"]</span> - <span class="c1"># )</span> - <span class="c1"># slurm_script_contents += "#SBATCH --array={}\n".format(</span> - <span class="c1"># self.grid_options["slurm_array"]</span> - <span class="c1"># )</span> - <span class="c1"># slurm_script_contents += "\n"</span> - - <span class="c1"># if self.grid_options["slurm_extra_settings"]:</span> - <span class="c1"># slurm_script_contents += "# Extra settings by user:"</span> - <span class="c1"># slurm_script_contents += "\n".join(</span> - <span class="c1"># [</span> - <span class="c1"># "--{}={}".format(</span> - <span class="c1"># key, self.grid_options["slurm_extra_settings"][key]</span> - <span class="c1"># )</span> - <span class="c1"># for key in self.grid_options["slurm_extra_settings"]</span> - <span class="c1"># ]</span> - <span class="c1"># )</span> - - <span class="c1"># slurm_script_contents += '# set status to "running"\n'</span> - <span class="c1"># slurm_script_contents += (</span> - <span class="c1"># 'echo "running" > {}/status/$jobid.$jobarrayindex\n\n'.format(</span> - <span class="c1"># self.grid_options["slurm_dir"]</span> - <span class="c1"># )</span> - <span class="c1"># )</span> - <span class="c1"># slurm_script_contents += "# run grid of stars\n"</span> - <span class="c1"># slurm_script_contents += "{}\n\n".format(command)</span> - <span class="c1"># slurm_script_contents += '# set status to "finished"\n'</span> - <span class="c1"># slurm_script_contents += (</span> - <span class="c1"># 'echo "finished" > {}/status/$jobid.$jobarrayindex\n'.format(</span> - <span class="c1"># self.grid_options["slurm_dir"]</span> - <span class="c1"># )</span> - <span class="c1"># )</span> - <span class="c1"># slurm_script_contents += "\n"</span> - - <span class="c1"># if self.grid_options["slurm_postpone_join"]:</span> - <span class="c1"># slurm_script_contents += "{} rungrid=0 results_hash_dumpfile={}/results/$jobid.all slurm_command=join\n".format(</span> - <span class="c1"># command, self.grid_options["slurm_dir"]</span> - <span class="c1"># )</span> - - <span class="c1"># # Write script to file</span> - <span class="c1"># slurm_script_filename = os.path.join(</span> - <span class="c1"># self.grid_options["slurm_dir"], "slurm_script"</span> - <span class="c1"># )</span> - <span class="c1"># with open(slurm_script_filename, "w") as slurm_script_file:</span> - <span class="c1"># slurm_script_file.write(slurm_script_contents)</span> - - <span class="c1"># # Execute or postpone</span> - <span class="c1"># if self.grid_options["slurm_postpone_sbatch"]:</span> - <span class="c1"># # Execute or postpone the real call to sbatch</span> - <span class="c1"># sbatch_command = "sbatch {}".format(slurm_script_filename)</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "running slurm script {}".format(slurm_script_filename),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 0,</span> - <span class="c1"># )</span> - <span class="c1"># # subprocess.Popen(sbatch_command, close_fds=True)</span> - <span class="c1"># # subprocess.Popen(sbatch_command, creationflags=subprocess.DETACHED_PROCESS)</span> - <span class="c1"># verbose_print("Submitted scripts.", self.grid_options["verbosity"], 0)</span> - <span class="c1"># else:</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "Slurm script is in {} but hasnt been executed".format(</span> - <span class="c1"># slurm_script_filename</span> - <span class="c1"># ),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 0,</span> - <span class="c1"># )</span> - - <span class="c1"># verbose_print("all done!", self.grid_options["verbosity"], 0)</span> - <span class="c1"># sys.exit()</span> - - <span class="c1"># elif self.grid_options["slurm_command"] == "evolve":</span> - <span class="c1"># # Part to evolve the population.</span> - <span class="c1"># # TODO: decide how many CPUs</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "SLURM: Evolving population", self.grid_options["verbosity"], 1</span> - <span class="c1"># )</span> - - <span class="c1"># #</span> - <span class="c1"># self.evolve_population()</span> - - <span class="c1"># elif self.grid_options["slurm_command"] == "join":</span> - <span class="c1"># # Joining the output.</span> - <span class="c1"># verbose_print("SLURM: Joining results", self.grid_options["verbosity"], 1)</span> - - <span class="c1">###################################################</span> - <span class="c1"># CONDOR functions</span> - <span class="c1">#</span> - <span class="c1"># subroutines to run CONDOR grids</span> - <span class="c1">###################################################</span> - - <span class="c1"># def _condor_grid(self):</span> - <span class="c1"># """</span> - <span class="c1"># Main function that manages the CONDOR setup.</span> - - <span class="c1"># Has three stages:</span> - - <span class="c1"># - setup</span> - <span class="c1"># - evolve</span> - <span class="c1"># - join</span> - - <span class="c1"># Which stage is used is determined by the value of grid_options['condor_command']:</span> - - <span class="c1"># <empty>: the function will know its the user that executed the script and</span> - <span class="c1"># it will set up the necessary condor stuff</span> - - <span class="c1"># 'evolve': evolve_population is called to evolve the population of stars</span> - - <span class="c1"># 'join': We will attempt to join the output</span> - <span class="c1"># """</span> - - <span class="c1"># # TODO: Put in function</span> - <span class="c1"># condor_version = get_condor_version()</span> - <span class="c1"># if not condor_version:</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "CONDOR: Error: No installation of condor found",</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 0,</span> - <span class="c1"># )</span> - <span class="c1"># else:</span> - <span class="c1"># major_version = int(condor_version.split(".")[0])</span> - <span class="c1"># minor_version = int(condor_version.split(".")[1])</span> - - <span class="c1"># if (major_version == 8) and (minor_version > 4):</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "CONDOR: Found version {} which is new enough".format(</span> - <span class="c1"># condor_version</span> - <span class="c1"># ),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 0,</span> - <span class="c1"># )</span> - <span class="c1"># elif major_version > 9:</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "CONDOR: Found version {} which is new enough".format(</span> - <span class="c1"># condor_version</span> - <span class="c1"># ),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 0,</span> - <span class="c1"># )</span> - <span class="c1"># else:</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "CONDOR: Found version {} which is too old (we require 8.3/8.4+)".format(</span> - <span class="c1"># condor_version</span> - <span class="c1"># ),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 0,</span> - <span class="c1"># )</span> - - <span class="c1"># verbose_print(</span> - <span class="c1"># "Running Condor grid. command={}".format(</span> - <span class="c1"># self.grid_options["condor_command"]</span> - <span class="c1"># ),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 1,</span> - <span class="c1"># )</span> - <span class="c1"># if not self.grid_options["condor_command"]:</span> - <span class="c1"># # Setting up</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "CONDOR: Main controller script. Setting up",</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 1,</span> - <span class="c1"># )</span> - - <span class="c1"># # Set up working directories:</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "CONDOR: creating working directories",</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 1,</span> - <span class="c1"># )</span> - <span class="c1"># create_directories_hpc(self.grid_options["condor_dir"])</span> - - <span class="c1"># # Create command</span> - <span class="c1"># current_workingdir = os.getcwd()</span> - <span class="c1"># python_details = get_python_details()</span> - <span class="c1"># scriptname = path_of_calling_script()</span> - <span class="c1"># # command = "".join([</span> - <span class="c1"># # "{}".python_details['executable'],</span> - <span class="c1"># # "{}".scriptname,</span> - <span class="c1"># # "offset=$jobarrayindex",</span> - <span class="c1"># # "modulo={}".format(self.grid_options['condor_njobs']),</span> - <span class="c1"># # "vb={}".format(self.grid_options['verbosity'])</span> - - <span class="c1"># # "results_hash_dumpfile=$self->{_grid_options}{slurm_dir}/results/$jobid.$jobarrayindex",</span> - <span class="c1"># # 'slurm_jobid='.$jobid,</span> - <span class="c1"># # 'slurm_jobarrayindex='.$jobarrayindex,</span> - <span class="c1"># # 'slurm_jobname=binary_grid_'.$jobid.'.'.$jobarrayindex,</span> - <span class="c1"># # "slurm_njobs=$njobs",</span> - <span class="c1"># # "slurm_dir=$self->{_grid_options}{slurm_dir}",</span> - <span class="c1"># # );</span> - - <span class="c1"># # Create directory with info for the condor script. By creating this directory we also check whether all the values are set correctly</span> - <span class="c1"># # TODO: create the condor script.</span> - <span class="c1"># condor_script_options = {}</span> - <span class="c1"># # condor_script_options['n'] =</span> - <span class="c1"># condor_script_options["njobs"] = self.grid_options["condor_njobs"]</span> - <span class="c1"># condor_script_options["dir"] = self.grid_options["condor_dir"]</span> - <span class="c1"># condor_script_options["memory"] = self.grid_options["condor_memory"]</span> - <span class="c1"># condor_script_options["working_dir"] = self.grid_options[</span> - <span class="c1"># "condor_working_dir"</span> - <span class="c1"># ]</span> - <span class="c1"># condor_script_options["command"] = self.grid_options["command"]</span> - <span class="c1"># condor_script_options["streams"] = self.grid_options["streams"]</span> - - <span class="c1"># # TODO: condor works with running an executable.</span> - - <span class="c1"># # Create script contents</span> - <span class="c1"># condor_script_contents = ""</span> - <span class="c1"># condor_script_contents += """</span> - <span class="c1"># #################################################</span> - <span class="c1"># #</span> - <span class="c1"># # Condor script to run a binary_grid via python</span> - <span class="c1"># #</span> - <span class="c1"># #################################################</span> - <span class="c1"># """</span> - <span class="c1"># condor_script_contents += "Executable\t= {}".format(executable)</span> - <span class="c1"># condor_script_contents += "arguments\t= {}".format(arguments)</span> - <span class="c1"># condor_script_contents += "environment\t= {}".format(environment)</span> - <span class="c1"># condor_script_contents += "universe\t= {}".format(</span> - <span class="c1"># self.grid_options["condor_universe"]</span> - <span class="c1"># )</span> - <span class="c1"># condor_script_contents += "\n"</span> - <span class="c1"># condor_script_contents += "output\t= {}/stdout/$id\n".format(</span> - <span class="c1"># self.grid_options["condor_dir"]</span> - <span class="c1"># )</span> - <span class="c1"># condor_script_contents += "error\t={}/sterr/$id".format(</span> - <span class="c1"># self.grid_options["condor_dir"]</span> - <span class="c1"># )</span> - <span class="c1"># condor_script_contents += "log\t={}\n".format(</span> - <span class="c1"># self.grid_options["condor_dir"]</span> - <span class="c1"># )</span> - <span class="c1"># condor_script_contents += "initialdir\t={}\n".format(current_workingdir)</span> - <span class="c1"># condor_script_contents += "remote_initialdir\t={}\n".format(</span> - <span class="c1"># current_workingdir</span> - <span class="c1"># )</span> - <span class="c1"># condor_script_contents += "\n"</span> - <span class="c1"># condor_script_contents += "steam_output\t={}".format(stream)</span> - <span class="c1"># condor_script_contents += "steam_error\t={}".format(stream)</span> - <span class="c1"># condor_script_contents += "+WantCheckpoint = False"</span> - <span class="c1"># condor_script_contents += "\n"</span> - <span class="c1"># condor_script_contents += "request_memory\t={}".format(</span> - <span class="c1"># self.grid_options["condor_memory"]</span> - <span class="c1"># )</span> - <span class="c1"># condor_script_contents += "ImageSize\t={}".format(</span> - <span class="c1"># self.grid_options["condor_memory"]</span> - <span class="c1"># )</span> - <span class="c1"># condor_script_contents += "\n"</span> - - <span class="c1"># if self.grid_options["condor_extra_settings"]:</span> - <span class="c1"># slurm_script_contents += "# Extra settings by user:"</span> - <span class="c1"># slurm_script_contents += "\n".join(</span> - <span class="c1"># [</span> - <span class="c1"># "{}\t={}".format(</span> - <span class="c1"># key, self.grid_options["condor_extra_settings"][key]</span> - <span class="c1"># )</span> - <span class="c1"># for key in self.grid_options["condor_extra_settings"]</span> - <span class="c1"># ]</span> - <span class="c1"># )</span> - - <span class="c1"># condor_script_contents += "\n"</span> - - <span class="c1"># # request_memory = $_[0]{memory}</span> - <span class="c1"># # ImageSize = $_[0]{memory}</span> - - <span class="c1"># # Requirements = (1) \&\& (".</span> - <span class="c1"># # $self->{_grid_options}{condor_requirements}.")\n";</span> - - <span class="c1"># #</span> - <span class="c1"># # file name: my_program.condor</span> - <span class="c1"># # Condor submit description file for my_program</span> - <span class="c1"># # Executable = my_program</span> - <span class="c1"># # Universe = vanilla</span> - <span class="c1"># # Error = logs/err.$(cluster)</span> - <span class="c1"># # Output = logs/out.$(cluster)</span> - <span class="c1"># # Log = logs/log.$(cluster)</span> - - <span class="c1"># # should_transfer_files = YES</span> - <span class="c1"># # when_to_transfer_output = ON_EXIT</span> - <span class="c1"># # transfer_input_files = files/in1,files/in2</span> - - <span class="c1"># # Arguments = files/in1 files/in2 files/out1</span> - <span class="c1"># # Queue</span> - - <span class="c1"># # Write script contents to file</span> - <span class="c1"># if self.grid_options["condor_postpone_join"]:</span> - <span class="c1"># condor_script_contents += "{} rungrid=0 results_hash_dumpfile={}/results/$jobid.all condor_command=join\n".format(</span> - <span class="c1"># command, self.grid_options["condor_dir"]</span> - <span class="c1"># )</span> - - <span class="c1"># condor_script_filename = os.path.join(</span> - <span class="c1"># self.grid_options["condor_dir"], "condor_script"</span> - <span class="c1"># )</span> - <span class="c1"># with open(condor_script_filename, "w") as condor_script_file:</span> - <span class="c1"># condor_script_file.write(condor_script_contents)</span> - - <span class="c1"># if self.grid_options["condor_postpone_sbatch"]:</span> - <span class="c1"># # Execute or postpone the real call to sbatch</span> - <span class="c1"># submit_command = "condor_submit {}".format(condor_script_filename)</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "running condor script {}".format(condor_script_filename),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 0,</span> - <span class="c1"># )</span> - <span class="c1"># # subprocess.Popen(sbatch_command, close_fds=True)</span> - <span class="c1"># # subprocess.Popen(sbatch_command, creationflags=subprocess.DETACHED_PROCESS)</span> - <span class="c1"># verbose_print("Submitted scripts.", self.grid_options["verbosity"], 0)</span> - <span class="c1"># else:</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "Condor script is in {} but hasnt been executed".format(</span> - <span class="c1"># condor_script_filename</span> - <span class="c1"># ),</span> - <span class="c1"># self.grid_options["verbosity"],</span> - <span class="c1"># 0,</span> - <span class="c1"># )</span> - - <span class="c1"># verbose_print("all done!", self.grid_options["verbosity"], 0)</span> - <span class="c1"># sys.exit()</span> - - <span class="c1"># elif self.grid_options["condor_command"] == "evolve":</span> - <span class="c1"># # TODO: write this function</span> - <span class="c1"># # Part to evolve the population.</span> - <span class="c1"># # TODO: decide how many CPUs</span> - <span class="c1"># verbose_print(</span> - <span class="c1"># "CONDOR: Evolving population", self.grid_options["verbosity"], 1</span> - <span class="c1"># )</span> - - <span class="c1"># #</span> - <span class="c1"># self.evolve_population()</span> - - <span class="c1"># elif self.grid_options["condor_command"] == "join":</span> - <span class="c1"># # TODO: write this function</span> - <span class="c1"># # Joining the output.</span> - <span class="c1"># verbose_print("CONDOR: Joining results", self.grid_options["verbosity"], 1)</span> - - <span class="c1"># pass</span> - <span class="c1">###################################################</span> - <span class="c1"># Unordered functions</span> - <span class="c1">#</span> - <span class="c1"># Functions that aren't ordered yet</span> - <span class="c1">###################################################</span> - -<div class="viewcode-block" id="Population.write_ensemble"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.write_ensemble">[docs]</a> <span class="k">def</span> <span class="nf">write_ensemble</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output_file</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">sort_keys</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> write_ensemble : Write ensemble results to a file.</span> - -<span class="sd"> Args:</span> -<span class="sd"> output_file : the output filename.</span> - -<span class="sd"> If the filename has an extension that we recognise,</span> -<span class="sd"> e.g. .gz or .bz2, we compress the output appropriately.</span> - -<span class="sd"> The filename should contain .json or .msgpack, the two</span> -<span class="sd"> currently-supported formats.</span> - -<span class="sd"> Usually you'll want to output to JSON, but we can</span> -<span class="sd"> also output to msgpack.</span> - -<span class="sd"> data : the data dictionary to be converted and written to the file.</span> -<span class="sd"> If not set, this defaults to self.grid_ensemble_results.</span> - -<span class="sd"> sort_keys : if True, and output is to JSON, the keys will be sorted.</span> -<span class="sd"> (default: True, passed to json.dumps)</span> - -<span class="sd"> indent : number of space characters used in the JSON indent. (Default: 4,</span> -<span class="sd"> passed to json.dumps)</span> -<span class="sd"> """</span> - <span class="c1"># TODO: consider writing this in a formatted structure</span> - - <span class="c1"># get the file type</span> - <span class="n">file_type</span> <span class="o">=</span> <span class="n">ensemble_file_type</span><span class="p">(</span><span class="n">output_file</span><span class="p">)</span> - - <span class="c1"># choose compression algorithm based on file extension</span> - <span class="n">compression</span> <span class="o">=</span> <span class="n">ensemble_compression</span><span class="p">(</span><span class="n">output_file</span><span class="p">)</span> - - <span class="c1"># default to using grid_ensemble_results if no data is given</span> - <span class="k">if</span> <span class="n">data</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> - <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span> - - <span class="k">if</span> <span class="ow">not</span> <span class="n">file_type</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"Unable to determine file type from ensemble filename </span><span class="si">{}</span><span class="s2"> : it should be .json or .msgpack."</span> - <span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">output_file</span><span class="p">)</span> - <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span> - <span class="k">elif</span> <span class="n">file_type</span> <span class="ow">is</span> <span class="s2">"JSON"</span><span class="p">:</span> - <span class="c1"># JSON output</span> - <span class="k">if</span> <span class="n">compression</span> <span class="o">==</span> <span class="s2">"gzip"</span><span class="p">:</span> - <span class="c1"># gzip</span> - <span class="n">f</span> <span class="o">=</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"wt"</span><span class="p">)</span> - <span class="k">elif</span> <span class="n">compression</span> <span class="o">==</span> <span class="s2">"bzip2"</span><span class="p">:</span> - <span class="c1"># bzip2</span> - <span class="n">f</span> <span class="o">=</span> <span class="n">bz2</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"wt"</span><span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="c1"># raw output (not compressed)</span> - <span class="n">f</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"wt"</span><span class="p">)</span> - <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">sort_keys</span><span class="o">=</span><span class="n">sort_keys</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="n">indent</span><span class="p">))</span> - - <span class="k">elif</span> <span class="n">file_type</span> <span class="ow">is</span> <span class="s2">"msgpack"</span><span class="p">:</span> - <span class="c1"># msgpack output</span> - <span class="k">if</span> <span class="n">compression</span> <span class="o">==</span> <span class="s2">"gzip"</span><span class="p">:</span> - <span class="n">f</span> <span class="o">=</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"wb"</span><span class="p">)</span> - <span class="k">elif</span> <span class="n">compression</span> <span class="o">==</span> <span class="s2">"bzip2"</span><span class="p">:</span> - <span class="n">f</span> <span class="o">=</span> <span class="n">bz2</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"wb"</span><span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">f</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"wb"</span><span class="p">)</span> - <span class="n">msgpack</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span> - <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> - - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"Thread </span><span class="si">{thread}</span><span class="s2">: Wrote ensemble results to file: </span><span class="si">{colour}{file}{reset}</span><span class="s2"> (file type </span><span class="si">{file_type}</span><span class="s2">, compression </span><span class="si">{compression}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">thread</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">,</span> - <span class="n">file</span><span class="o">=</span><span class="n">output_file</span><span class="p">,</span> - <span class="n">colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"green"</span><span class="p">],</span> - <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> - <span class="n">file_type</span><span class="o">=</span><span class="n">file_type</span><span class="p">,</span> - <span class="n">compression</span><span class="o">=</span><span class="n">compression</span><span class="p">,</span> - <span class="p">)</span> - <span class="p">)</span></div> - - <span class="c1">############################################################</span> -<div class="viewcode-block" id="Population.write_binary_c_calls_to_file"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.write_binary_c_calls_to_file">[docs]</a> <span class="k">def</span> <span class="nf">write_binary_c_calls_to_file</span><span class="p">(</span> - <span class="bp">self</span><span class="p">,</span> - <span class="n">output_dir</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> - <span class="n">output_filename</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> - <span class="n">include_defaults</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> - <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Function that loops over the grid code and writes the generated parameters to a file.</span> -<span class="sd"> In the form of a command line call</span> - -<span class="sd"> Only useful when you have a variable grid as system_generator. MC wouldn't be that useful</span> - -<span class="sd"> Also, make sure that in this export there are the basic parameters</span> -<span class="sd"> like m1,m2,sep, orb-per, ecc, probability etc.</span> - -<span class="sd"> On default this will write to the datadir, if it exists</span> - -<span class="sd"> Tasks:</span> -<span class="sd"> - TODO: test this function</span> -<span class="sd"> - TODO: make sure the binary_c_python .. output file has a unique name</span> - -<span class="sd"> Args:</span> -<span class="sd"> output_dir: (optional, default = None) directory where to write the file to. If custom_options['data_dir'] is present, then that one will be used first, and then the output_dir</span> -<span class="sd"> output_filename: (optional, default = None) filename of the output. If not set it will be called "binary_c_calls.txt"</span> -<span class="sd"> include_defaults: (optional, default = None) whether to include the defaults of binary_c in the lines that are written. Beware that this will result in very long lines, and it might be better to just export the binary_c defaults and keep them in a separate file.</span> - -<span class="sd"> Returns:</span> -<span class="sd"> filename: filename that was used to write the calls to</span> -<span class="sd"> """</span> - - <span class="c1"># Check if there is no compiled grid yet. If not, lets try to build it first.</span> - <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]:</span> - - <span class="c1">## check the settings:</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">[</span><span class="s2">"ensemble"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble_defer"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Error, if you want to run an ensemble in a population, the output needs to be deferred"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">0</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span> - - <span class="c1"># Put in check</span> - <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"Error: you haven't defined any grid variables! Aborting"</span><span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span> - - <span class="c1">#</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_generate_grid_code</span><span class="p">(</span><span class="n">dry_run</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> - - <span class="c1">#</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_load_grid_function</span><span class="p">()</span> - - <span class="c1"># then if the _system_generator is present, we go through it</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]:</span> - <span class="c1"># Check if there is an output dir configured</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"data_dir"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">binary_c_calls_output_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="s2">"data_dir"</span><span class="p">]</span> - <span class="c1"># otherwise check if there's one passed to the function</span> - <span class="k">else</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">output_dir</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"Error. No data_dir configured and you gave no output_dir. Aborting"</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span> - <span class="n">binary_c_calls_output_dir</span> <span class="o">=</span> <span class="n">output_dir</span> - - <span class="c1"># check if there's a filename passed to the function</span> - <span class="k">if</span> <span class="n">output_filename</span><span class="p">:</span> - <span class="n">binary_c_calls_filename</span> <span class="o">=</span> <span class="n">output_filename</span> - <span class="c1"># otherwise use default value</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">binary_c_calls_filename</span> <span class="o">=</span> <span class="s2">"binary_c_calls.txt"</span> - - <span class="n">binary_c_calls_full_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="n">binary_c_calls_output_dir</span><span class="p">,</span> <span class="n">binary_c_calls_filename</span> - <span class="p">)</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"Writing binary_c calls to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">binary_c_calls_full_filename</span><span class="p">))</span> - - <span class="c1"># Write to file</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">binary_c_calls_full_filename</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span> - <span class="c1"># Get defaults and clean them, then overwrite them with the set values.</span> - <span class="k">if</span> <span class="n">include_defaults</span><span class="p">:</span> - <span class="c1"># TODO: make sure that the defaults here are cleaned up properly</span> - <span class="n">cleaned_up_defaults</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cleaned_up_defaults</span> - <span class="n">full_system_dict</span> <span class="o">=</span> <span class="n">cleaned_up_defaults</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> - <span class="n">full_system_dict</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">copy</span><span class="p">())</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">full_system_dict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> - - <span class="k">for</span> <span class="n">system</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">](</span><span class="bp">self</span><span class="p">):</span> - <span class="c1"># update values with current system values</span> - <span class="n">full_system_dict</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">system</span><span class="p">)</span> - - <span class="n">binary_cmdline_string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_argline</span><span class="p">(</span><span class="n">full_system_dict</span><span class="p">)</span> - <span class="n">file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">binary_cmdline_string</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"Error. No grid function found!"</span><span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span> - - <span class="k">return</span> <span class="n">binary_c_calls_full_filename</span></div> - - <span class="k">def</span> <span class="nf">_cleanup_defaults</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to clean up the default values:</span> - -<span class="sd"> from a dictionary, removes the entries that have the following values:</span> -<span class="sd"> - "NULL"</span> -<span class="sd"> - ""</span> -<span class="sd"> - "Function"</span> - -<span class="sd"> Uses the function from utils.functions</span> - -<span class="sd"> TODO: Rethink this functionality. seems a bit double, could also be just outside of the class</span> -<span class="sd"> """</span> - - <span class="n">binary_c_defaults</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">return_binary_c_defaults</span><span class="p">()</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> - <span class="n">cleaned_dict</span> <span class="o">=</span> <span class="n">filter_arg_dict</span><span class="p">(</span><span class="n">binary_c_defaults</span><span class="p">)</span> - - <span class="k">return</span> <span class="n">cleaned_dict</span> - - <span class="k">def</span> <span class="nf">_clean_up_custom_logging</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">evol_type</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to clean up the custom logging.</span> -<span class="sd"> Has two types:</span> -<span class="sd"> 'single':</span> -<span class="sd"> - removes the compiled shared library</span> -<span class="sd"> (which name is stored in grid_options['_custom_logging_shared_library_file'])</span> -<span class="sd"> - TODO: unloads/frees the memory allocated to that shared library</span> -<span class="sd"> (which is stored in grid_options['custom_logging_func_memaddr'])</span> -<span class="sd"> - sets both to None</span> -<span class="sd"> 'multiple':</span> -<span class="sd"> - TODO: make this and design this</span> -<span class="sd"> """</span> - - <span class="k">if</span> <span class="n">evol_type</span> <span class="o">==</span> <span class="s2">"single"</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Cleaning up the custom logging stuff. type: single"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># TODO: Explicitly unload the library</span> - - <span class="c1"># Reset the memory adress location</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"custom_logging_func_memaddr"</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> - - <span class="c1"># remove shared library files</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">]:</span> - <span class="n">remove_file</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> - - <span class="k">if</span> <span class="n">evol_type</span> <span class="o">==</span> <span class="s2">"population"</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Cleaning up the custom logging stuffs. type: population"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># TODO: make sure that these also work. not fully sure if necessary tho.</span> - <span class="c1"># whether its a single file, or a dict of files/mem addresses</span> - - <span class="k">if</span> <span class="n">evol_type</span> <span class="o">==</span> <span class="s2">"MC"</span><span class="p">:</span> - <span class="k">pass</span> - - <span class="k">def</span> <span class="nf">_increment_probtot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prob</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to add to the total probability. For now not used</span> -<span class="sd"> """</span> - - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_probtot"</span><span class="p">]</span> <span class="o">+=</span> <span class="n">prob</span> - - <span class="k">def</span> <span class="nf">_increment_count</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to add to the total number of stars. For now not used</span> -<span class="sd"> """</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> - - <span class="k">def</span> <span class="nf">_set_loggers</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to set the loggers for the execution of the grid</span> -<span class="sd"> """</span> - - <span class="c1"># Set log file</span> - <span class="n">binary_c_logfile</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_file"</span><span class="p">]</span> - - <span class="c1"># Create directory</span> - <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">binary_c_logfile</span><span class="p">),</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> - - <span class="c1"># Set up logger</span> - <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"binary_c_python_logger"</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">])</span> - - <span class="c1"># Reset handlers</span> - <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">handlers</span> <span class="o">=</span> <span class="p">[]</span> - - <span class="c1"># Set formatting of output</span> - <span class="n">log_formatter</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span> - <span class="s2">"</span><span class="si">%(asctime)s</span><span class="s2"> - </span><span class="si">%(name)s</span><span class="s2"> - </span><span class="si">%(levelname)s</span><span class="s2"> - </span><span class="si">%(message)s</span><span class="s2">"</span> - <span class="p">)</span> - - <span class="c1"># Make and add file handlers</span> - <span class="c1"># make handler for output to file</span> - <span class="n">handler_file</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">FileHandler</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">binary_c_logfile</span><span class="p">))</span> - <span class="n">handler_file</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">log_formatter</span><span class="p">)</span> - <span class="n">handler_file</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span> - - <span class="c1"># Make handler for output to stdout</span> - <span class="n">handler_stdout</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">)</span> - <span class="n">handler_stdout</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">log_formatter</span><span class="p">)</span> - <span class="n">handler_stdout</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span> - - <span class="c1"># Add the loggers</span> - <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">handler_file</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">handler_stdout</span><span class="p">)</span> - - <span class="k">def</span> <span class="nf">_check_binary_c_error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">binary_c_output</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to check whether binary_c throws an error and handle accordingly.</span> -<span class="sd"> """</span> - - <span class="k">if</span> <span class="n">binary_c_output</span><span class="p">:</span> - <span class="k">if</span> <span class="p">(</span><span class="n">binary_c_output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"SYSTEM_ERROR"</span><span class="p">))</span> <span class="ow">or</span> <span class="p">(</span> - <span class="n">binary_c_output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"SYSTEM_ERROR"</span><span class="p">)</span> - <span class="p">):</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"FAILING SYSTEM FOUND"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">0</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Keep track of the amount of failed systems and their error codes</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_prob"</span><span class="p">]</span> <span class="o">+=</span> <span class="n">system_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"probability"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_count"</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_found"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> - - <span class="c1"># Try catching the error code and keep track of the unique ones.</span> - <span class="k">try</span><span class="p">:</span> - <span class="n">error_code</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span> - <span class="n">binary_c_output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> - <span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"with error code"</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> - <span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> - <span class="o">.</span><span class="n">strip</span><span class="p">()</span> - <span class="p">)</span> - - <span class="k">if</span> <span class="p">(</span> - <span class="ow">not</span> <span class="n">error_code</span> - <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_systems_error_codes"</span><span class="p">]</span> - <span class="p">):</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_systems_error_codes"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> - <span class="n">error_code</span> - <span class="p">)</span> - <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Failed to extract the error-code"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Check if we have exceeded the number of errors</span> - <span class="k">if</span> <span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_count"</span><span class="p">]</span> - <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"failed_systems_threshold"</span><span class="p">]</span> - <span class="p">):</span> - <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_exceeded"</span><span class="p">]:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_boxed</span><span class="p">(</span> - <span class="s2">"Process </span><span class="si">{}</span><span class="s2"> exceeded the maximum (</span><span class="si">{}</span><span class="s2">) number of failing systems. Stopped logging them to files now"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"failed_systems_threshold"</span><span class="p">],</span> - <span class="p">)</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_exceeded"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> - - <span class="c1"># If not, write the failing systems to files unique to each process</span> - <span class="k">else</span><span class="p">:</span> - <span class="c1"># Write arg lines to file</span> - <span class="n">argstring</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_argline</span><span class="p">(</span><span class="n">system_dict</span><span class="p">)</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> - <span class="s2">"failed_systems"</span><span class="p">,</span> - <span class="s2">"process_</span><span class="si">{}</span><span class="s2">.txt"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">),</span> - <span class="p">),</span> - <span class="s2">"a+"</span><span class="p">,</span> - <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> - <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">argstring</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> - <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"binary_c output nothing - this is strange. If there is ensemble output being generated then this is fine."</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">3</span><span class="p">,</span> - <span class="p">)</span> - -<div class="viewcode-block" id="Population.set_moe_di_stefano_settings"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.set_moe_di_stefano_settings">[docs]</a> <span class="k">def</span> <span class="nf">set_moe_di_stefano_settings</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to set user input configurations for the Moe & di Stefano methods</span> - -<span class="sd"> If nothing is passed then we just use the default options</span> -<span class="sd"> """</span> - - <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="p">:</span> - <span class="n">options</span> <span class="o">=</span> <span class="p">{}</span> - - <span class="c1"># Take the option dictionary that was given and override.</span> - <span class="n">options</span> <span class="o">=</span> <span class="n">update_dicts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">],</span> <span class="n">options</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">options</span><span class="p">)</span> - - <span class="c1"># Write options to a file</span> - <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> - <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> - <span class="s2">"moeopts.dat"</span><span class="p">,</span> - <span class="p">),</span> - <span class="s2">"w"</span><span class="p">,</span> - <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> - <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">],</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">))</span> - <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div> - - <span class="k">def</span> <span class="nf">_load_moe_di_stefano_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> Function to load the moe & di stefano data</span> -<span class="sd"> """</span> - - <span class="c1"># Only if the grid is loaded and Moecache contains information</span> - <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_loaded_Moe2017_data"</span><span class="p">]:</span> <span class="c1"># and not Moecache:</span> - - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_Moe2017_JSON_data"</span><span class="p">]:</span> - <span class="c1"># Use the existing (perhaps modified) JSON data</span> - <span class="n">json_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_Moe2017_JSON_data"</span><span class="p">]</span> - - <span class="k">else</span><span class="p">:</span> - <span class="c1"># Load the JSON data from a file</span> - <span class="n">json_data</span> <span class="o">=</span> <span class="n">get_moe_di_stefano_dataset</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">],</span> - <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="p">)</span> - - <span class="c1"># entry of log10M1 is a list containing 1 dict.</span> - <span class="c1"># We can take the dict out of the list</span> - <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">],</span> <span class="nb">list</span><span class="p">):</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">]</span> <span class="o">=</span> <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - - <span class="c1"># save this data in case we want to modify it later</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_Moe2017_JSON_data"</span><span class="p">]</span> <span class="o">=</span> <span class="n">json_data</span> - - <span class="c1"># Get all the masses</span> - <span class="n">logmasses</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">logmasses</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"The table does not contain masses."</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">0</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="c1"># Write to file</span> - <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> - <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> - <span class="s2">"moe.log"</span><span class="p">,</span> - <span class="p">),</span> - <span class="s2">"w"</span><span class="p">,</span> - <span class="p">)</span> <span class="k">as</span> <span class="n">logfile</span><span class="p">:</span> - <span class="n">logfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"logâ‚â‚€Masses(M☉) </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logmasses</span><span class="p">))</span> - - <span class="c1"># Get all the periods and see if they are all consistently present</span> - <span class="n">logperiods</span> <span class="o">=</span> <span class="p">[]</span> - <span class="k">for</span> <span class="n">logmass</span> <span class="ow">in</span> <span class="n">logmasses</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">logperiods</span><span class="p">:</span> - <span class="n">logperiods</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> - <span class="n">dlog10P</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">logperiods</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">-</span> <span class="nb">float</span><span class="p">(</span><span class="n">logperiods</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> - - <span class="n">current_logperiods</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">])</span> - <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">logperiods</span> <span class="o">==</span> <span class="n">current_logperiods</span><span class="p">):</span> - <span class="n">msg</span> <span class="o">=</span> <span class="p">(</span> - <span class="s2">"Period values are not consistent throughout the dataset\logperiods = "</span> - <span class="o">+</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">logperiods</span><span class="p">)</span> - <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">Current periods = "</span> - <span class="o">+</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">current_logperiods</span><span class="p">)</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">0</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="c1">############################################################</span> - <span class="c1"># log10period binwidth : of course this assumes a fixed</span> - <span class="c1"># binwidth, so we check for this too.</span> - <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">current_logperiods</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">):</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">dlog10P</span> <span class="o">==</span> <span class="p">(</span> - <span class="nb">float</span><span class="p">(</span><span class="n">current_logperiods</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> <span class="o">-</span> <span class="nb">float</span><span class="p">(</span><span class="n">current_logperiods</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> - <span class="p">):</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Period spacing is not consistent throughout the dataset"</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">0</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="c1"># save the logperiods list in the cache:</span> - <span class="c1"># this is used in the renormalization integration</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"logperiods"</span><span class="p">]</span> <span class="o">=</span> <span class="n">logperiods</span> - - <span class="c1"># Write to file</span> - <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> - <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">,</span> <span class="s2">"moe.log"</span><span class="p">),</span> - <span class="s2">"a"</span><span class="p">,</span> - <span class="p">)</span> <span class="k">as</span> <span class="n">logfile</span><span class="p">:</span> - <span class="n">logfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"logâ‚â‚€Periods(days) </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logperiods</span><span class="p">))</span> - - <span class="c1"># Fill the global dict</span> - <span class="k">for</span> <span class="n">logmass</span> <span class="ow">in</span> <span class="n">logmasses</span><span class="p">:</span> - <span class="c1"># Create the multiplicity table</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"multiplicity_table"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"multiplicity_table"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> - - <span class="c1"># multiplicity as a function of primary mass</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"multiplicity_table"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> - <span class="p">[</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"f_multi"</span><span class="p">],</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"single star fraction"</span><span class="p">],</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"binary star fraction"</span><span class="p">],</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"triple/quad star fraction"</span><span class="p">],</span> - <span class="p">]</span> - <span class="p">)</span> - - <span class="c1">############################################################</span> - <span class="c1"># a small log10period which we can shift just outside the</span> - <span class="c1"># table to force integration out there to zero</span> - <span class="n">epslog10P</span> <span class="o">=</span> <span class="mf">1e-8</span> <span class="o">*</span> <span class="n">dlog10P</span> - - <span class="c1">############################################################</span> - <span class="c1"># loop over either binary or triple-outer periods</span> - <span class="n">first</span> <span class="o">=</span> <span class="mi">1</span> - - <span class="c1"># Go over the periods</span> - <span class="k">for</span> <span class="n">logperiod</span> <span class="ow">in</span> <span class="n">logperiods</span><span class="p">:</span> - <span class="c1">############################################################</span> - <span class="c1"># distributions of binary and triple star fractions</span> - <span class="c1"># as a function of mass, period.</span> - <span class="c1">#</span> - <span class="c1"># Note: these should be per unit log10P, hence we</span> - <span class="c1"># divide by dlog10P</span> - - <span class="k">if</span> <span class="n">first</span><span class="p">:</span> - <span class="n">first</span> <span class="o">=</span> <span class="mi">0</span> - - <span class="c1"># Create the multiplicity table</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"period_distributions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> - - <span class="c1">############################################################</span> - <span class="c1"># lower bound the period distributions to zero probability</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> - <span class="p">[</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logperiod</span><span class="p">)</span> <span class="o">-</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">dlog10P</span> <span class="o">-</span> <span class="n">epslog10P</span><span class="p">,</span> - <span class="mf">0.0</span><span class="p">,</span> - <span class="mf">0.0</span><span class="p">,</span> - <span class="p">]</span> - <span class="p">)</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> - <span class="p">[</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logperiod</span><span class="p">)</span> <span class="o">-</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">dlog10P</span><span class="p">,</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span> - <span class="s2">"normed_bin_frac_p_dist"</span> - <span class="p">]</span> - <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span> - <span class="s2">"normed_tripquad_frac_p_dist"</span> - <span class="p">]</span> - <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> - <span class="p">]</span> - <span class="p">)</span> - - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> - <span class="p">[</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logperiod</span><span class="p">),</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span> - <span class="s2">"normed_bin_frac_p_dist"</span> - <span class="p">]</span> - <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span> - <span class="s2">"normed_tripquad_frac_p_dist"</span> - <span class="p">]</span> - <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> - <span class="p">]</span> - <span class="p">)</span> - - <span class="c1">############################################################</span> - <span class="c1"># distributions as a function of mass, period, q</span> - <span class="c1">#</span> - <span class="c1"># First, get a list of the qs given by Moe</span> - <span class="c1">#</span> - <span class="n">qs</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span><span class="s2">"q"</span><span class="p">])</span> - - <span class="c1"># Fill the data and 'normalise'</span> - <span class="n">qdata</span> <span class="o">=</span> <span class="n">fill_data</span><span class="p">(</span> - <span class="n">qs</span><span class="p">,</span> <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span><span class="s2">"q"</span><span class="p">]</span> - <span class="p">)</span> - - <span class="c1"># Create the multiplicity table</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q_distributions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"q_distributions"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> - - <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">qs</span><span class="p">:</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"q_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> - <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> <span class="nb">float</span><span class="p">(</span><span class="n">logperiod</span><span class="p">),</span> <span class="nb">float</span><span class="p">(</span><span class="n">q</span><span class="p">),</span> <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]]</span> - <span class="p">)</span> - - <span class="c1">############################################################</span> - <span class="c1"># eccentricity distributions as a function of mass, period, ecc</span> - <span class="n">eccs</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span><span class="s2">"e"</span><span class="p">])</span> - - <span class="c1"># Fill the data and 'normalise'</span> - <span class="n">ecc_data</span> <span class="o">=</span> <span class="n">fill_data</span><span class="p">(</span> - <span class="n">eccs</span><span class="p">,</span> <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span><span class="s2">"e"</span><span class="p">]</span> - <span class="p">)</span> - - <span class="c1"># Create the multiplicity table</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc_distributions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"ecc_distributions"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> - - <span class="k">for</span> <span class="n">ecc</span> <span class="ow">in</span> <span class="n">eccs</span><span class="p">:</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"ecc_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> - <span class="p">[</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logperiod</span><span class="p">),</span> - <span class="nb">float</span><span class="p">(</span><span class="n">ecc</span><span class="p">),</span> - <span class="n">ecc_data</span><span class="p">[</span><span class="n">ecc</span><span class="p">],</span> - <span class="p">]</span> - <span class="p">)</span> - - <span class="c1">############################################################</span> - <span class="c1"># upper bound the period distributions to zero probability</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> - <span class="p">[</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logperiods</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">dlog10P</span><span class="p">,</span> <span class="c1"># TODO: why this shift?</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiods</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span> - <span class="s2">"normed_bin_frac_p_dist"</span> - <span class="p">]</span> - <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> - <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiods</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span> - <span class="s2">"normed_tripquad_frac_p_dist"</span> - <span class="p">]</span> - <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> - <span class="p">]</span> - <span class="p">)</span> - <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> - <span class="p">[</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> - <span class="nb">float</span><span class="p">(</span><span class="n">logperiods</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">dlog10P</span> <span class="o">+</span> <span class="n">epslog10P</span><span class="p">,</span> - <span class="mf">0.0</span><span class="p">,</span> - <span class="mf">0.0</span><span class="p">,</span> - <span class="p">]</span> - <span class="p">)</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Length period_distributions table: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="nb">len</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">])</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Length multiplicity table: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="nb">len</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"multiplicity_table"</span><span class="p">])</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Length q table: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="nb">len</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"q_distributions"</span><span class="p">])</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Length ecc table: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="nb">len</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"ecc_distributions"</span><span class="p">])</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Write to log file</span> - <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> - <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> - <span class="s2">"moecache.json"</span><span class="p">,</span> - <span class="p">),</span> - <span class="s2">"w"</span><span class="p">,</span> - <span class="p">)</span> <span class="k">as</span> <span class="n">cache_filehandle</span><span class="p">:</span> - <span class="n">cache_filehandle</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">Moecache</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">))</span> - - <span class="c1"># Signal that the data has been loaded</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_loaded_Moe2017_data"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> - - <span class="k">def</span> <span class="nf">_set_moe_di_stefano_distributions</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="k">def</span> <span class="nf">_dict_from_line_source_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span> <span class="sd">"""</span> -<span class="sd"> Function to set the Moe & di Stefano distribution</span> +<span class="sd"> Function that creates a dict from a binary_c arg line</span> <span class="sd"> """</span> + <span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"binary_c "</span><span class="p">):</span> + <span class="n">line</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"binary_c "</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> - <span class="c1">############################################################</span> - <span class="c1"># first, the multiplicity, this is 1,2,3,4, ...</span> - <span class="c1"># for singles, binaries, triples, quadruples, ...</span> - - <span class="n">max_multiplicity</span> <span class="o">=</span> <span class="n">get_max_multiplicity</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"multiplicity_modulator"</span><span class="p">]</span> - <span class="p">)</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Max multiplicity = </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">max_multiplicity</span><span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> - <span class="c1">######</span> - <span class="c1"># Setting up the grid variables</span> - - <span class="c1"># Multiplicity</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"multiplicity"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"multiplicity"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"multiplicity"</span><span class="p">,</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="n">max_multiplicity</span><span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"const(1, </span><span class="si">{n}</span><span class="s2">, </span><span class="si">{n}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="n">max_multiplicity</span><span class="p">),</span> - <span class="n">precode</span><span class="o">=</span><span class="s1">'self.grid_options["multiplicity"] = multiplicity; self.bse_options["multiplicity"] = multiplicity; options=</span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="p">),</span> - <span class="n">condition</span><span class="o">=</span><span class="s2">"(</span><span class="si">{}</span><span class="s2">[multiplicity-1] > 0)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"multiplicity_modulator"</span><span class="p">])</span> - <span class="p">),</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"edge"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=-</span><span class="mi">1</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1">############################################################</span> - <span class="c1"># always require M1, for all systems</span> - <span class="c1">#</span> - <span class="c1"># log-spaced m1 with given resolution</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"lnm1"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"Primary mass"</span><span class="p">,</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="ow">or</span> <span class="s2">"const(np.log(</span><span class="si">{}</span><span class="s2">), np.log(</span><span class="si">{}</span><span class="s2">), </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> - <span class="p">),</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> - <span class="s2">"np.log(</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="p">),</span> - <span class="s2">"np.log(</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> - <span class="p">),</span> - <span class="p">],</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dlnm1"</span><span class="p">,</span> - <span class="n">precode</span><span class="o">=</span><span class="s1">'M_1 = np.exp(lnm1); options["M_1"]=M_1'</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="s2">"Moe_di_Stefano_2017_pdf({{</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">}}, verbosity=self.grid_options['verbosity'])['total_probdens'] if multiplicity == 1 else 1"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="nb">str</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]))[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> - <span class="s2">"'multiplicity': multiplicity"</span><span class="p">,</span> - <span class="s2">"'M_1': M_1"</span><span class="p">,</span> - <span class="p">),</span> - <span class="p">)</span> - - <span class="c1"># Go to higher multiplicities</span> - <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> - <span class="c1"># binaries: period</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"log10per"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"orbital_period"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"log10(Orbital_Period)"</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> - <span class="n">condition</span><span class="o">=</span><span class="s1">'(self.grid_options["multiplicity"] >= 2)'</span><span class="p">,</span> - <span class="n">branchpoint</span><span class="o">=</span><span class="mi">1</span> - <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">></span> <span class="mi">1</span> - <span class="k">else</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Signal here to put a branchpoint if we have a max multiplicity higher than 1.</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"(</span><span class="si">{}</span><span class="s2"> * dlog10per)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">LOG_LN_CONVERTER</span><span class="p">),</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span> - <span class="s2">"logP"</span> - <span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="ow">or</span> <span class="s2">"const(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> - <span class="p">),</span> - <span class="n">precode</span><span class="o">=</span><span class="s2">"""orbital_period = 10.0**log10per</span> -<span class="s2">qmin=</span><span class="si">{}</span><span class="s2">/M_1</span> -<span class="s2">qmax=maximum_mass_ratio_for_RLOF(M_1, orbital_period)</span> -<span class="s2">"""</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"Mmin"</span><span class="p">]</span> - <span class="p">),</span> - <span class="p">)</span> <span class="c1"># TODO: change the maximum_mass_ratio_for_RLOF</span> - - <span class="c1"># binaries: mass ratio</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"q"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_2"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"Mass ratio"</span><span class="p">,</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="k">else</span> <span class="s2">"options['Mmin']/M_1"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="k">else</span> <span class="s2">"qmax"</span><span class="p">,</span> - <span class="p">],</span> - <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dq"</span><span class="p">,</span> - <span class="n">precode</span><span class="o">=</span><span class="s2">"""</span> -<span class="s2">M_2 = q * M_1</span> -<span class="s2">sep = calc_sep_from_period(M_1, M_2, orbital_period)</span> -<span class="s2"> """</span><span class="p">,</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> - <span class="ow">or</span> <span class="s2">"const(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span> - <span class="k">else</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">/M_1"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"Mmin"</span><span class="p">]),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">])[</span><span class="mi">1</span><span class="p">]</span> - <span class="k">else</span> <span class="s2">"qmax"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="p">),</span> - <span class="p">)</span> - - <span class="c1"># (optional) binaries: eccentricity</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"ecc"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"eccentricity"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"Eccentricity"</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"decc"</span><span class="p">,</span> - <span class="n">precode</span><span class="o">=</span><span class="s2">"eccentricity=ecc"</span><span class="p">,</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> - <span class="mi">0</span> - <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span> - <span class="s2">"ecc"</span> - <span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="ow">or</span> <span class="s2">"const(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> - <span class="mi">0</span> - <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> - <span class="p">),</span> - <span class="p">)</span> - - <span class="c1"># Now for triples and quadruples</span> - <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">>=</span> <span class="mi">3</span><span class="p">:</span> - <span class="c1"># Triple: period</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"log10per2"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"orbital_period_triple"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"log10(Orbital_Period2)"</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> - <span class="n">condition</span><span class="o">=</span><span class="s1">'(self.grid_options["multiplicity"] >= 3)'</span><span class="p">,</span> - <span class="n">branchpoint</span><span class="o">=</span><span class="mi">2</span> - <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">></span> <span class="mi">2</span> - <span class="k">else</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Signal here to put a branchpoint if we have a max multiplicity higher than 1.</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"(</span><span class="si">{}</span><span class="s2"> * dlog10per2)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">LOG_LN_CONVERTER</span><span class="p">),</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span> - <span class="s2">"logP"</span> - <span class="p">][</span><span class="mi">1</span><span class="p">]</span> - <span class="ow">or</span> <span class="s2">"const(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="p">),</span> - <span class="n">precode</span><span class="o">=</span><span class="s2">"""orbital_period_triple = 10.0**log10per2</span> -<span class="s2">q2min=</span><span class="si">{}</span><span class="s2">/(M_1+M_2)</span> -<span class="s2">q2max=maximum_mass_ratio_for_RLOF(M_1+M_2, orbital_period_triple)</span> -<span class="s2"> """</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"Mmin"</span><span class="p">]</span> - <span class="p">),</span> - <span class="p">)</span> - - <span class="c1"># Triples: mass ratio</span> - <span class="c1"># Note, the mass ratio is M_outer/M_inner</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"q2"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_3"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"Mass ratio outer/inner"</span><span class="p">,</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="k">else</span> <span class="s2">"options['Mmin']/(M_1+M_2)"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="k">else</span> <span class="s2">"q2max"</span><span class="p">,</span> - <span class="p">],</span> - <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dq2"</span><span class="p">,</span> - <span class="n">precode</span><span class="o">=</span><span class="s2">"""</span> -<span class="s2">M_3 = q2 * (M_1 + M_2)</span> -<span class="s2">sep2 = calc_sep_from_period((M_1+M_2), M_3, orbital_period_triple)</span> -<span class="s2">eccentricity2=0</span> -<span class="s2">"""</span><span class="p">,</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span> - <span class="s2">"M"</span> - <span class="p">][</span><span class="mi">2</span><span class="p">]</span> - <span class="ow">or</span> <span class="s2">"const(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="k">else</span> <span class="s2">"options['Mmin']/(M_1+M_2)"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="k">else</span> <span class="s2">"q2max"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">2</span><span class="p">],</span> - <span class="p">),</span> - <span class="p">)</span> + <span class="n">split_line</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> + <span class="n">arg_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="c1"># (optional) triples: eccentricity</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"ecc2"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"eccentricity2"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"Eccentricity of the triple"</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"decc2"</span><span class="p">,</span> - <span class="n">precode</span><span class="o">=</span><span class="s2">"eccentricity2=ecc2"</span><span class="p">,</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> - <span class="mi">0</span> - <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span> - <span class="s2">"samplerfuncs"</span> - <span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> - <span class="ow">or</span> <span class="s2">"const(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> - <span class="mi">0</span> - <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> - <span class="mi">1</span> - <span class="p">],</span> - <span class="p">),</span> - <span class="p">)</span> + <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">split_line</span><span class="p">),</span> <span class="mi">2</span><span class="p">):</span> + <span class="k">if</span> <span class="s2">"."</span> <span class="ow">in</span> <span class="n">split_line</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]:</span> + <span class="n">arg_dict</span><span class="p">[</span><span class="n">split_line</span><span class="p">[</span><span class="n">i</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">split_line</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">arg_dict</span><span class="p">[</span><span class="n">split_line</span><span class="p">[</span><span class="n">i</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">split_line</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> - <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span> - <span class="c1"># Quadruple: period</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"log10per3"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"orbital_period_quadruple"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"log10(Orbital_Period3)"</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> - <span class="n">condition</span><span class="o">=</span><span class="s1">'(self.grid_options["multiplicity"] >= 4)'</span><span class="p">,</span> - <span class="n">branchpoint</span><span class="o">=</span><span class="mi">3</span> - <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">></span> <span class="mi">3</span> - <span class="k">else</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Signal here to put a branchpoint if we have a max multiplicity higher than 1.</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"(</span><span class="si">{}</span><span class="s2"> * dlog10per3)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">LOG_LN_CONVERTER</span><span class="p">),</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span> - <span class="s2">"samplerfuncs"</span> - <span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> - <span class="ow">or</span> <span class="s2">"const(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span> - <span class="mi">2</span> - <span class="p">],</span> - <span class="p">),</span> - <span class="n">precode</span><span class="o">=</span><span class="s2">"""orbital_period_quadruple = 10.0**log10per3</span> -<span class="s2">q3min=</span><span class="si">{}</span><span class="s2">/(M_3)</span> -<span class="s2">q3max=maximum_mass_ratio_for_RLOF(M_3, orbital_period_quadruple)</span> -<span class="s2"> """</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"Mmin"</span><span class="p">]</span> - <span class="p">),</span> - <span class="p">)</span> + <span class="k">return</span> <span class="n">arg_dict</span> - <span class="c1"># Quadruple: mass ratio : M_outer / M_inner</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"q3"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_4"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"Mass ratio outer low/outer high"</span><span class="p">,</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="k">else</span> <span class="s2">"options['Mmin']/(M_3)"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="k">else</span> <span class="s2">"q3max"</span><span class="p">,</span> - <span class="p">],</span> - <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dq3"</span><span class="p">,</span> - <span class="n">precode</span><span class="o">=</span><span class="s2">"""</span> -<span class="s2">M_4 = q3 * M_3</span> -<span class="s2">sep3 = calc_sep_from_period((M_3), M_4, orbital_period_quadruple)</span> -<span class="s2">eccentricity3=0</span> -<span class="s2">"""</span><span class="p">,</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span> - <span class="s2">"samplerfuncs"</span> - <span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">3</span><span class="p">]</span> - <span class="ow">or</span> <span class="s2">"const(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="k">else</span> <span class="s2">"options['Mmin']/(M_3)"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> - <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="k">else</span> <span class="s2">"q3max"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">2</span><span class="p">],</span> - <span class="p">),</span> - <span class="p">)</span> + <span class="c1">###################################################</span> + <span class="c1"># Unordered functions</span> + <span class="c1">#</span> + <span class="c1"># Functions that aren't ordered yet</span> + <span class="c1">###################################################</span> - <span class="c1"># (optional) triples: eccentricity</span> - <span class="k">if</span> <span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> - <span class="o">></span> <span class="mi">0</span> - <span class="p">):</span> - <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"ecc3"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"eccentricity3"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"Eccentricity of the triple+quadruple/outer binary"</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"decc3"</span><span class="p">,</span> - <span class="n">precode</span><span class="o">=</span><span class="s2">"eccentricity3=ecc3"</span><span class="p">,</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> - <span class="mi">0</span> - <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> - <span class="mi">1</span> - <span class="p">],</span> - <span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span> - <span class="s2">"samplerfuncs"</span> - <span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> - <span class="ow">or</span> <span class="s2">"const(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> - <span class="mi">0</span> - <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> - <span class="mi">1</span> - <span class="p">],</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span> - <span class="s2">"ecc"</span> - <span class="p">][</span><span class="mi">2</span><span class="p">],</span> - <span class="p">),</span> - <span class="p">)</span> + <span class="k">def</span> <span class="nf">_cleanup_defaults</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to clean up the default values:</span> - <span class="c1"># Now we are at the last part.</span> - <span class="c1"># Here we should combine all the information that we calculate and update the options</span> - <span class="c1"># dictionary. This will then be passed to the Moe_di_Stefano_2017_pdf to calculate</span> - <span class="c1"># the real probability. The trick we use is to strip the options_dict as a string</span> - <span class="c1"># and add some keys to it:</span> - - <span class="n">updated_options</span> <span class="o">=</span> <span class="s2">"{{</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">}}"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="nb">str</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]))[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> - <span class="s1">'"multiplicity": multiplicity'</span><span class="p">,</span> - <span class="s1">'"M_1": M_1'</span><span class="p">,</span> - <span class="s1">'"M_2": M_2'</span><span class="p">,</span> - <span class="s1">'"M_3": M_3'</span><span class="p">,</span> - <span class="s1">'"M_4": M_4'</span><span class="p">,</span> - <span class="s1">'"P": orbital_period'</span><span class="p">,</span> - <span class="s1">'"P2": orbital_period_triple'</span><span class="p">,</span> - <span class="s1">'"P3": orbital_period_quadruple'</span><span class="p">,</span> - <span class="s1">'"ecc": eccentricity'</span><span class="p">,</span> - <span class="s1">'"ecc2": eccentricity2'</span><span class="p">,</span> - <span class="s1">'"ecc3": eccentricity3'</span><span class="p">,</span> - <span class="p">)</span> +<span class="sd"> from a dictionary, removes the entries that have the following values:</span> +<span class="sd"> - "NULL"</span> +<span class="sd"> - ""</span> +<span class="sd"> - "Function"</span> - <span class="n">probdist_addition</span> <span class="o">=</span> <span class="s2">"Moe_di_Stefano_2017_pdf(</span><span class="si">{}</span><span class="s2">, verbosity=self.grid_options['verbosity'])['total_probdens']"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">updated_options</span> - <span class="p">)</span> +<span class="sd"> Uses the function from utils.functions</span> - <span class="c1"># and finally the probability calculator</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="bp">self</span><span class="o">.</span><span class="n">_last_grid_variable</span><span class="p">()][</span> - <span class="s2">"probdist"</span> - <span class="p">]</span> <span class="o">=</span> <span class="n">probdist_addition</span> +<span class="sd"> TODO: Rethink this functionality. seems a bit double, could also be just outside of the class</span> +<span class="sd"> """</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Added final call to the pdf function"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> - <span class="p">)</span> + <span class="n">binary_c_defaults</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">return_binary_c_defaults</span><span class="p">()</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> + <span class="n">cleaned_dict</span> <span class="o">=</span> <span class="n">filter_arg_dict</span><span class="p">(</span><span class="n">binary_c_defaults</span><span class="p">)</span> - <span class="c1"># Signal that the MOE2017 grid has been set</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_set_Moe2017_grid"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + <span class="k">return</span> <span class="n">cleaned_dict</span> - <span class="c1">################################################################################################</span> -<div class="viewcode-block" id="Population.Moe_di_Stefano_2017"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.Moe_di_Stefano_2017">[docs]</a> <span class="k">def</span> <span class="nf">Moe_di_Stefano_2017</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="k">def</span> <span class="nf">_increment_probtot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prob</span><span class="p">):</span> <span class="sd">"""</span> -<span class="sd"> Function to handle setting the user input settings,</span> -<span class="sd"> set up the data and load that into interpolators and</span> -<span class="sd"> then set the distribution functions</span> - -<span class="sd"> Takes a dictionary as its only argument</span> +<span class="sd"> Function to add to the total probability. For now not used</span> <span class="sd"> """</span> - <span class="n">default_options</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"apply settings"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> - <span class="s2">"setup grid"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> - <span class="s2">"load data"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> - <span class="s2">"clean cache"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> - <span class="s2">"clean load flag"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> - <span class="s2">"clean all"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> - <span class="p">}</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="p">:</span> - <span class="n">options</span> <span class="o">=</span> <span class="p">{}</span> - <span class="n">options</span> <span class="o">=</span> <span class="n">update_dicts</span><span class="p">(</span><span class="n">default_options</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span> - - <span class="c1"># clean cache?</span> - <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"clean all"</span><span class="p">]</span> <span class="ow">or</span> <span class="n">options</span><span class="p">[</span><span class="s2">"clean cache"</span><span class="p">]:</span> - <span class="n">Moecache</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span> - - <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"clean all"</span><span class="p">]</span> <span class="ow">or</span> <span class="n">options</span><span class="p">[</span><span class="s2">"clean load flag"</span><span class="p">]:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_loaded_Moe2017_data"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> - - <span class="c1"># Set the user input</span> - <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"apply settings"</span><span class="p">]:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">set_moe_di_stefano_settings</span><span class="p">(</span><span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> - - <span class="c1"># Load the data</span> - <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"load data"</span><span class="p">]:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_load_moe_di_stefano_data</span><span class="p">()</span> - - <span class="c1"># construct the grid here</span> - <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"setup grid"</span><span class="p">]:</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_set_moe_di_stefano_distributions</span><span class="p">()</span></div> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_probtot"</span><span class="p">]</span> <span class="o">+=</span> <span class="n">prob</span> - <span class="k">def</span> <span class="nf">_clean_interpolators</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="k">def</span> <span class="nf">_increment_count</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> -<span class="sd"> Function to clean up the interpolators after a run</span> - -<span class="sd"> We look in the Moecache global variable for items that are interpolators.</span> -<span class="sd"> Should be called by the general cleanup function AND the thread cleanup function</span> +<span class="sd"> Function to add to the total number of stars. For now not used</span> <span class="sd"> """</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> - <span class="n">interpolator_keys</span> <span class="o">=</span> <span class="p">[]</span> - <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> - <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">):</span> - <span class="n">interpolator_keys</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> - - <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">interpolator_keys</span><span class="p">:</span> - <span class="n">Moecache</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">destroy</span><span class="p">()</span> - <span class="k">del</span> <span class="n">Moecache</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> - <span class="n">gc</span><span class="o">.</span><span class="n">collect</span><span class="p">()</span> - - <span class="c1">##### Unsorted functions</span> - <span class="k">def</span> <span class="nf">_calculate_multiplicity_fraction</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">):</span> +<div class="viewcode-block" id="Population.was_killed"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.was_killed">[docs]</a> <span class="k">def</span> <span class="nf">was_killed</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> -<span class="sd"> Function to calculate multiplicity fraction</span> - -<span class="sd"> Makes use of the self.bse_options['multiplicity'] value. If its not set, it will raise an error</span> - -<span class="sd"> grid_options['multiplicity_fraction_function'] will be checked for the choice</span> - -<span class="sd"> TODO: add option to put a manual binary fraction in here (solve via negative numbers being the functions)</span> +<span class="sd"> Function to determine if the process was killed. Returns True if so, false otherwise.</span> <span class="sd"> """</span> + <span class="n">killed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_killed"</span><span class="p">]</span> - <span class="c1"># Just return 1 if no option has been chosen</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"multiplicity_fraction_function"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="s2">"None"</span><span class="p">]:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction."</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">3</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">return</span> <span class="mi">1</span> - - <span class="c1"># Raise an error if the multiplicity is not set</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">system_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"multiplicity"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Multiplicity value has not been set. When using a specific multiplicity fraction function please set the multiplicity"</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="c1"># Go over the chosen options</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"multiplicity_fraction_function"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="s2">"Arenou2010"</span><span class="p">]:</span> - <span class="c1"># Arenou 2010 will be used</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"_calculate_multiplicity_fraction: Using Arenou 2010 to calculate multiplicity fractions"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">3</span><span class="p">,</span> - <span class="p">)</span> - - <span class="n">binary_fraction</span> <span class="o">=</span> <span class="n">Arenou2010_binary_fraction</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">])</span> - <span class="n">multiplicity_fraction_dict</span> <span class="o">=</span> <span class="p">{</span> - <span class="mi">1</span><span class="p">:</span> <span class="mi">1</span> <span class="o">-</span> <span class="n">binary_fraction</span><span class="p">,</span> - <span class="mi">2</span><span class="p">:</span> <span class="n">binary_fraction</span><span class="p">,</span> - <span class="mi">3</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> - <span class="mi">4</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> - <span class="p">}</span> - - <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"multiplicity_fraction_function"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="s2">"Raghavan2010"</span><span class="p">]:</span> - <span class="c1"># Raghavan 2010 will be used</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"_calculate_multiplicity_fraction: Using Raghavan (2010) to calculate multiplicity fractions"</span><span class="p">,</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">3</span><span class="p">,</span> - <span class="p">)</span> - - <span class="n">binary_fraction</span> <span class="o">=</span> <span class="n">raghavan2010_binary_fraction</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">])</span> - <span class="n">multiplicity_fraction_dict</span> <span class="o">=</span> <span class="p">{</span> - <span class="mi">1</span><span class="p">:</span> <span class="mi">1</span> <span class="o">-</span> <span class="n">binary_fraction</span><span class="p">,</span> - <span class="mi">2</span><span class="p">:</span> <span class="n">binary_fraction</span><span class="p">,</span> - <span class="mi">3</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> - <span class="mi">4</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> - <span class="p">}</span> + <span class="k">if</span> <span class="s2">"_killed"</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"metadata"</span><span class="p">,</span> <span class="p">{}):</span> + <span class="n">killed</span> <span class="o">=</span> <span class="n">killed</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"_killed"</span><span class="p">]</span> - <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"multiplicity_fraction_function"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="s2">"Moe2017"</span><span class="p">]:</span> - <span class="c1"># We need to check several things now here:</span> + <span class="k">return</span> <span class="n">killed</span></div> - <span class="c1"># First, are the options for the MOE2017 grid set? On start it is filled with the default settings</span> - <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"The MOE2017 options do not seem to be set properly. The value is </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> - <span class="p">)</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + <span class="k">def</span> <span class="nf">_check_binary_c_error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">binary_c_output</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to check whether binary_c throws an error and handle accordingly.</span> +<span class="sd"> """</span> - <span class="c1"># Second: is the Moecache filled.</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="p">:</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"_calculate_multiplicity_fraction: Moecache is empty. It needs to be filled with the data for the interpolators. Loading the data now"</span><span class="p">,</span> + <span class="k">if</span> <span class="n">binary_c_output</span><span class="p">:</span> + <span class="k">if</span> <span class="p">(</span><span class="n">binary_c_output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"SYSTEM_ERROR"</span><span class="p">))</span> <span class="ow">or</span> <span class="p">(</span> + <span class="n">binary_c_output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"SYSTEM_ERROR"</span><span class="p">)</span> + <span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"FAILING SYSTEM FOUND"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">3</span><span class="p">,</span> + <span class="mi">0</span><span class="p">,</span> <span class="p">)</span> - <span class="c1"># Load the data</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_load_moe_di_stefano_data</span><span class="p">()</span> - - <span class="c1"># record the prev value</span> - <span class="n">prev_M1_value_ms</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_1"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - - <span class="c1"># Set value of M1 of the current system</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="o">=</span> <span class="n">system_dict</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> + <span class="c1"># Keep track of the amount of failed systems and their error codes</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_prob"</span><span class="p">]</span> <span class="o">+=</span> <span class="n">system_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"probability"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_count"</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_found"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> - <span class="c1"># Calculate the multiplicity fraction</span> - <span class="n">multiplicity_fraction_list</span> <span class="o">=</span> <span class="n">Moe_di_Stefano_2017_multiplicity_fractions</span><span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> - <span class="p">)</span> + <span class="c1"># Try catching the error code and keep track of the unique ones.</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">error_code</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span> + <span class="n">binary_c_output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> + <span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"with error code"</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> + <span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + <span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="p">)</span> - <span class="c1"># Turn into dict</span> - <span class="n">multiplicity_fraction_dict</span> <span class="o">=</span> <span class="p">{</span> - <span class="n">el</span> <span class="o">+</span> <span class="mi">1</span><span class="p">:</span> <span class="n">multiplicity_fraction_list</span><span class="p">[</span><span class="n">el</span><span class="p">]</span> - <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">multiplicity_fraction_list</span><span class="p">))</span> - <span class="p">}</span> + <span class="k">if</span> <span class="p">(</span> + <span class="ow">not</span> <span class="n">error_code</span> + <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_systems_error_codes"</span><span class="p">]</span> + <span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_systems_error_codes"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> + <span class="n">error_code</span> + <span class="p">)</span> + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Failed to extract the error-code"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> - <span class="c1"># Set the prev value back</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="o">=</span> <span class="n">prev_M1_value_ms</span> + <span class="c1"># Check if we have exceeded the number of errors</span> + <span class="k">if</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_count"</span><span class="p">]</span> + <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"failed_systems_threshold"</span><span class="p">]</span> + <span class="p">):</span> + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_exceeded"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_boxed</span><span class="p">(</span> + <span class="s2">"Process </span><span class="si">{}</span><span class="s2"> exceeded the maximum (</span><span class="si">{}</span><span class="s2">) number of failing systems. Stopped logging them to files now"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"failed_systems_threshold"</span><span class="p">],</span> + <span class="p">)</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_exceeded"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> - <span class="c1"># we don't know what to do next</span> + <span class="c1"># If not, write the failing systems to files unique to each process</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># Write arg lines to file</span> + <span class="n">argstring</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_argline</span><span class="p">(</span><span class="n">system_dict</span><span class="p">)</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> + <span class="s2">"failed_systems"</span><span class="p">,</span> + <span class="s2">"process_</span><span class="si">{}</span><span class="s2">.txt"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">),</span> + <span class="p">),</span> + <span class="s2">"a+"</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> + <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> + <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">argstring</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> <span class="k">else</span><span class="p">:</span> - <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Chosen value for the multiplicity fraction function is not known."</span> - <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> - - <span class="c1"># To make sure we normalize the dictionary</span> - <span class="n">multiplicity_fraction_dict</span> <span class="o">=</span> <span class="n">normalize_dict</span><span class="p">(</span> - <span class="n">multiplicity_fraction_dict</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> - <span class="p">)</span> - - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"Multiplicity: </span><span class="si">{}</span><span class="s2"> multiplicity_fraction: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">system_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">],</span> - <span class="n">multiplicity_fraction_dict</span><span class="p">[</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">]],</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">3</span><span class="p">,</span> - <span class="p">)</span> - - <span class="k">return</span> <span class="n">multiplicity_fraction_dict</span><span class="p">[</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">]]</span> - - <span class="c1">######################</span> - <span class="c1"># Status logging</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"binary_c output nothing - this is strange. If there is ensemble output being generated then this is fine."</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> -<div class="viewcode-block" id="Population.vb1print"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.vb1print">[docs]</a> <span class="k">def</span> <span class="nf">vb1print</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ID</span><span class="p">,</span> <span class="n">now</span><span class="p">,</span> <span class="n">system_number</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">):</span> + <span class="k">def</span> <span class="nf">_new_grid_ensemble_results</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> -<span class="sd"> Verbosity-level 1 printing, to keep an eye on a grid.</span> -<span class="sd"> Arguments:</span> -<span class="sd"> ID: thread ID for debugging (int)</span> -<span class="sd"> now: the time now as a UNIX-style epoch in seconds (float)</span> -<span class="sd"> system_number: the system number</span> - -<span class="sd"> TODO: add information about the number of cores. the TPR shows the dt/dn but i want to see the number per core too</span> +<span class="sd"> Function to return a new grid_ensemble_results dict: this should</span> +<span class="sd"> be pre-filled by sub-dicts to prevent later errors.</span> <span class="sd"> """</span> - - <span class="c1"># calculate estimated time of arrive (eta and eta_secs), time per run (tpr)</span> - <span class="n">localtime</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">localtime</span><span class="p">(</span><span class="n">now</span><span class="p">)</span> - - <span class="c1"># calculate stats</span> - <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"n_saved_log_stats"</span><span class="p">]</span><span class="o">.</span><span class="n">value</span> - <span class="k">if</span> <span class="n">n</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> - <span class="c1"># simple 1-system calculation: inaccurate</span> - <span class="c1"># but best for small n</span> - <span class="n">dt</span> <span class="o">=</span> <span class="n">now</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_time"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="n">dn</span> <span class="o">=</span> <span class="n">system_number</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_system_number"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="k">else</span><span class="p">:</span> - <span class="c1"># average over n_saved_log_stats</span> - <span class="n">dt</span> <span class="o">=</span> <span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_time"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_time"</span><span class="p">][</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> - <span class="p">)</span> - <span class="n">dn</span> <span class="o">=</span> <span class="p">(</span> - <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_system_number"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> - <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_system_number"</span><span class="p">][</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> - <span class="p">)</span> - - <span class="n">eta</span><span class="p">,</span> <span class="n">units</span><span class="p">,</span> <span class="n">tpr</span><span class="p">,</span> <span class="n">eta_secs</span> <span class="o">=</span> <span class="n">trem</span><span class="p">(</span> - <span class="n">dt</span><span class="p">,</span> <span class="n">system_number</span><span class="p">,</span> <span class="n">dn</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> - <span class="p">)</span> - - <span class="c1"># compensate for multithreading and modulo</span> - <span class="n">tpr</span> <span class="o">*=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"modulo"</span><span class="p">]</span> - - <span class="k">if</span> <span class="n">eta_secs</span> <span class="o"><</span> <span class="n">secs_per_day</span><span class="p">:</span> - <span class="n">fintime</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">localtime</span><span class="p">(</span><span class="n">now</span> <span class="o">+</span> <span class="n">eta_secs</span><span class="p">)</span> - <span class="n">etf</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{hours:02d}</span><span class="s2">:</span><span class="si">{minutes:02d}</span><span class="s2">:</span><span class="si">{seconds:02d}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">hours</span><span class="o">=</span><span class="n">fintime</span><span class="o">.</span><span class="n">tm_hour</span><span class="p">,</span> <span class="n">minutes</span><span class="o">=</span><span class="n">fintime</span><span class="o">.</span><span class="n">tm_min</span><span class="p">,</span> <span class="n">seconds</span><span class="o">=</span><span class="n">fintime</span><span class="o">.</span><span class="n">tm_sec</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">d</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">eta_secs</span> <span class="o">/</span> <span class="n">secs_per_day</span><span class="p">)</span> - <span class="k">if</span> <span class="n">d</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="n">etf</span> <span class="o">=</span> <span class="s2">"Tomorrow"</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">etf</span> <span class="o">=</span> <span class="s2">"In </span><span class="si">{}</span><span class="s2"> days"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> - - <span class="c1"># modulo information</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"modulo"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> - <span class="n">modulo</span> <span class="o">=</span> <span class="s2">""</span> <span class="c1"># usual case</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">modulo</span> <span class="o">=</span> <span class="s2">"%"</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"modulo"</span><span class="p">])</span> - - <span class="c1"># add up memory use from each thread</span> - <span class="n">total_mem_use</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"memory_use_per_thread"</span><span class="p">])</span> - - <span class="c1"># make a string to describe the system e.g. M1, M2, etc.</span> - <span class="n">system_string</span> <span class="o">=</span> <span class="s2">""</span> - - <span class="c1"># use the multiplicity if given</span> - <span class="k">if</span> <span class="s2">"multiplicity"</span> <span class="ow">in</span> <span class="n">system_dict</span><span class="p">:</span> - <span class="n">nmult</span> <span class="o">=</span> <span class="n">system_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">]</span> - <span class="k">else</span><span class="p">:</span> - <span class="n">nmult</span> <span class="o">=</span> <span class="mi">4</span> - - <span class="c1"># masses</span> - <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nmult</span><span class="p">):</span> - <span class="n">i1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> - <span class="k">if</span> <span class="s2">"M_"</span> <span class="o">+</span> <span class="n">i1</span> <span class="ow">in</span> <span class="n">system_dict</span><span class="p">:</span> - <span class="n">system_string</span> <span class="o">+=</span> <span class="p">(</span> - <span class="s2">"M</span><span class="si">{}</span><span class="s2">="</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i1</span><span class="p">)</span> <span class="o">+</span> <span class="n">format_number</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"M_"</span> <span class="o">+</span> <span class="n">i1</span><span class="p">])</span> <span class="o">+</span> <span class="s2">" "</span> - <span class="p">)</span> - - <span class="c1"># separation and orbital period</span> - <span class="k">if</span> <span class="s2">"separation"</span> <span class="ow">in</span> <span class="n">system_dict</span><span class="p">:</span> - <span class="n">system_string</span> <span class="o">+=</span> <span class="s2">"a="</span> <span class="o">+</span> <span class="n">format_number</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"separation"</span><span class="p">])</span> - <span class="k">if</span> <span class="s2">"orbital_period"</span> <span class="ow">in</span> <span class="n">system_dict</span><span class="p">:</span> - <span class="n">system_string</span> <span class="o">+=</span> <span class="s2">"P="</span> <span class="o">+</span> <span class="n">format_number</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"orbital_period"</span><span class="p">])</span> - - <span class="c1"># do the print</span> - <span class="n">verbose_print</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{opening_colour}{system_number}</span><span class="s2">/</span><span class="si">{total_starcount}{modulo}</span><span class="s2"> </span><span class="si">{pc_colour}{pc_complete:5.1f}% c</span><span class="s2">omplete </span><span class="si">{time_colour}{hours:02d}</span><span class="s2">:</span><span class="si">{minutes:02d}</span><span class="s2">:</span><span class="si">{seconds:02d}</span><span class="s2"> </span><span class="si">{ETA_colour}</span><span class="s2">ETA=</span><span class="si">{ETA:7.1f}{units}</span><span class="s2"> tpr=</span><span class="si">{tpr:2.2e}</span><span class="s2"> </span><span class="si">{ETF_colour}</span><span class="s2">ETF=</span><span class="si">{ETF}</span><span class="s2"> </span><span class="si">{mem_use_colour}</span><span class="s2">mem:</span><span class="si">{mem_use:.1f}</span><span class="s2">MB </span><span class="si">{system_string_colour}{system_string}{closing_colour}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">opening_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">]</span> - <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"yellow on black"</span><span class="p">],</span> - <span class="n">system_number</span><span class="o">=</span><span class="n">system_number</span><span class="p">,</span> - <span class="n">total_starcount</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">],</span> - <span class="n">modulo</span><span class="o">=</span><span class="n">modulo</span><span class="p">,</span> - <span class="n">pc_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"blue on black"</span><span class="p">],</span> - <span class="n">pc_complete</span><span class="o">=</span><span class="p">(</span><span class="mf">100.0</span> <span class="o">*</span> <span class="n">system_number</span><span class="p">)</span> - <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">])</span> - <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> - <span class="k">else</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> - <span class="n">time_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"green on black"</span><span class="p">],</span> - <span class="n">hours</span><span class="o">=</span><span class="n">localtime</span><span class="o">.</span><span class="n">tm_hour</span><span class="p">,</span> - <span class="n">minutes</span><span class="o">=</span><span class="n">localtime</span><span class="o">.</span><span class="n">tm_min</span><span class="p">,</span> - <span class="n">seconds</span><span class="o">=</span><span class="n">localtime</span><span class="o">.</span><span class="n">tm_sec</span><span class="p">,</span> - <span class="n">ETA_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"red on black"</span><span class="p">],</span> - <span class="n">ETA</span><span class="o">=</span><span class="n">eta</span><span class="p">,</span> - <span class="n">units</span><span class="o">=</span><span class="n">units</span><span class="p">,</span> - <span class="n">tpr</span><span class="o">=</span><span class="n">tpr</span><span class="p">,</span> - <span class="n">ETF_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"blue"</span><span class="p">],</span> - <span class="n">ETF</span><span class="o">=</span><span class="n">etf</span><span class="p">,</span> - <span class="n">mem_use_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"magenta"</span><span class="p">],</span> - <span class="n">mem_use</span><span class="o">=</span><span class="n">total_mem_use</span><span class="p">,</span> - <span class="n">system_string_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"yellow"</span><span class="p">],</span> - <span class="n">system_string</span><span class="o">=</span><span class="n">system_string</span><span class="p">,</span> - <span class="n">closing_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> - <span class="p">),</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> - <span class="mi">1</span><span class="p">,</span> - <span class="p">)</span></div> - -<div class="viewcode-block" id="Population.vb2print"><a class="viewcode-back" href="../../../grid.html#binarycpython.utils.grid.Population.vb2print">[docs]</a> <span class="k">def</span> <span class="nf">vb2print</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">,</span> <span class="n">cmdline_string</span><span class="p">):</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"Running this system now on thread </span><span class="si">{ID}</span><span class="se">\n</span><span class="si">{blue}{cmdline}{reset}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">ID</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">,</span> - <span class="n">blue</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"blue"</span><span class="p">],</span> - <span class="n">cmdline</span><span class="o">=</span><span class="n">cmdline_string</span><span class="p">,</span> - <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> - <span class="p">)</span> - <span class="p">)</span></div></div> + <span class="k">return</span> <span class="p">{</span> + <span class="s1">'metadata'</span> <span class="p">:</span> <span class="p">{},</span> + <span class="s1">'ensemble'</span> <span class="p">:</span> <span class="p">{}</span> + <span class="p">}</span></div> </pre></div> </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/grid_options_defaults.html b/docs/build/html/_modules/binarycpython/utils/grid_options_defaults.html deleted file mode 100644 index 1dda4b9cbf87938d45f8741cd2db88d651813665..0000000000000000000000000000000000000000 --- a/docs/build/html/_modules/binarycpython/utils/grid_options_defaults.html +++ /dev/null @@ -1,1053 +0,0 @@ - - -<!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> -<head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>binarycpython.utils.grid_options_defaults — binary_c-python documentation</title> - - - - - - - - - <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script> - <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> - <script src="../../../_static/jquery.js"></script> - <script src="../../../_static/underscore.js"></script> - <script src="../../../_static/doctools.js"></script> - <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="../../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="index" title="Index" href="../../../genindex.html" /> - <link rel="search" title="Search" href="../../../search.html" /> -</head> - -<body class="wy-body-for-nav"> - - - <div class="wy-grid-for-nav"> - - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> - <div class="wy-side-scroll"> - <div class="wy-side-nav-search" > - - - - <a href="../../../index.html" class="icon icon-home"> binary_c-python - - - - </a> - - - - - - - -<div role="search"> - <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> - <input type="text" name="q" placeholder="Search docs" /> - <input type="hidden" name="check_keywords" value="yes" /> - <input type="hidden" name="area" value="default" /> - </form> -</div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - - <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> -<ul> -<li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../modules.html">Binarycpython code</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../example_notebooks.html">Example notebooks</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../binary_c_parameters.html">Binary_c parameters</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../grid_options_descriptions.html">Population grid code options</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> -</ul> - - - - </div> - </div> - </nav> - - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - - <i data-toggle="wy-nav-top" class="fa fa-bars"></i> - <a href="../../../index.html">binary_c-python</a> - - </nav> - - - <div class="wy-nav-content"> - - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - - <ul class="wy-breadcrumbs"> - - <li><a href="../../../index.html">Docs</a> »</li> - - <li><a href="../../index.html">Module code</a> »</li> - - <li>binarycpython.utils.grid_options_defaults</li> - - - <li class="wy-breadcrumbs-aside"> - - </li> - - </ul> - - - <hr/> -</div> - <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> - <div itemprop="articleBody"> - - <h1>Source code for binarycpython.utils.grid_options_defaults</h1><div class="highlight"><pre> -<span></span><span class="sd">"""</span> -<span class="sd">Module that contains the default options for the population grid code along with the description for these options, in the form of dictionaries:</span> -<span class="sd"> - grid_options_defaults_dict: dictionary containing the default values for all the options</span> -<span class="sd"> - grid_options_descriptions: dictionary containing the description for these options.</span> - -<span class="sd">There are several other functions in this module, mostly to generate help texts or documents:</span> -<span class="sd"> - grid_options_help: interactive function for the user to get descriptions for options</span> -<span class="sd"> - grid_options_description_checker: function that checks that checks which options have a description.</span> -<span class="sd"> - write_grid_options_to_rst_file: function to generate the .rst document for the docs</span> - -<span class="sd">With this its also possible to automatically generate a document containing all the setting names + descriptions.</span> - -<span class="sd">All the options starting with _ should not be changed by the user except when you really know what you're doing (which is probably hacking the code :P)</span> -<span class="sd">"""</span> - -<span class="kn">import</span> <span class="nn">os</span> - -<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="k">import</span> <span class="n">temp_dir</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">return_binary_c_version_info</span> - -<span class="n">_LOGGER_VERBOSITY_LEVEL</span> <span class="o">=</span> <span class="mi">1</span> -<span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">=</span> <span class="mi">2</span> -<span class="n">_MOE2017_VERBOSITY_LEVEL</span> <span class="o">=</span> <span class="mi">5</span> -<span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">=</span> <span class="mi">6</span> -<span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_EXTRA_LEVEL</span> <span class="o">=</span> <span class="mi">7</span> - -<span class="c1"># Options dict</span> -<span class="n">grid_options_defaults_dict</span> <span class="o">=</span> <span class="p">{</span> - <span class="c1">##########################</span> - <span class="c1"># general (or unordered..)</span> - <span class="c1">##########################</span> - <span class="s2">"num_cores"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="c1"># total number of cores used to evolve the population</span> - <span class="s2">"parse_function"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Function to parse the output with.</span> - <span class="s2">"multiplicity_fraction_function"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: Moe and di Stefano 2017</span> - <span class="s2">"tmp_dir"</span><span class="p">:</span> <span class="n">temp_dir</span><span class="p">(),</span> <span class="c1"># Setting the temp dir of the program</span> - <span class="s2">"_main_pid"</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># Placeholder for the main process id of the run.</span> - <span class="s2">"save_ensemble_chunks"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># Force the ensemble chunk to be saved even if we are joining a thread (just in case the joining fails)</span> - <span class="s2">"combine_ensemble_with_thread_joining"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># 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</span> - <span class="s2">"_commandline_input"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> - <span class="s2">"log_runtime_systems"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># whether to log the runtime of the systems (1 file per thread. stored in the tmp_dir)</span> - <span class="s2">"_actually_evolve_system"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># Whether to actually evolve the systems of just act as if. for testing. used in _process_run_population_grid</span> - <span class="s2">"max_queue_size"</span><span class="p">:</span> <span class="mi">1000</span><span class="p">,</span> <span class="c1"># Maximum size of the system call queue.</span> - <span class="s2">"run_zero_probability_system"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># Whether to run the zero probability systems</span> - <span class="s2">"_zero_prob_stars_skipped"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> - <span class="s2">"ensemble_factor_in_probability_weighted_mass"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Whether to multiply the ensemble results by 1/probability_weighted_mass</span> - <span class="s2">"do_dry_run"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># Whether to do a dry run to calculate the total probability for this run</span> - <span class="s2">"custom_generator"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Place for the custom system generator</span> - <span class="s2">"exit_after_dry_run"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Exit after dry run?</span> - <span class="c1">##########################</span> - <span class="c1"># Execution log:</span> - <span class="c1">##########################</span> - <span class="s2">"verbosity"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Level of verbosity of the simulation</span> - <span class="s2">"log_file"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="n">temp_dir</span><span class="p">(),</span> <span class="s2">"binary_c_python.log"</span> - <span class="p">),</span> <span class="c1"># Set to None to not log to file. The directory will be created</span> - <span class="s2">"log_dt"</span><span class="p">:</span> <span class="mi">5</span><span class="p">,</span> <span class="c1"># time between vb=1 logging outputs</span> - <span class="s2">"n_logging_stats"</span><span class="p">:</span> <span class="mi">50</span><span class="p">,</span> <span class="c1"># number of logging stats used to calculate time remaining (etc.) default = 50</span> - <span class="c1">##########################</span> - <span class="c1"># binary_c files</span> - <span class="c1">##########################</span> - <span class="s2">"_binary_c_executable"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C"</span><span class="p">],</span> <span class="s2">"binary_c"</span> - <span class="p">),</span> <span class="c1"># TODO: make this more robust</span> - <span class="s2">"_binary_c_shared_library"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C"</span><span class="p">],</span> <span class="s2">"src"</span><span class="p">,</span> <span class="s2">"libbinary_c.so"</span> - <span class="p">),</span> <span class="c1"># TODO: make this more robust</span> - <span class="s2">"_binary_c_config_executable"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> - <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C"</span><span class="p">],</span> <span class="s2">"binary_c-config"</span> - <span class="p">),</span> <span class="c1"># TODO: make this more robust</span> - <span class="s2">"_binary_c_dir"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C"</span><span class="p">],</span> - <span class="c1">##########################</span> - <span class="c1"># Moe and di Stefano (2017) internal settings</span> - <span class="c1">##########################</span> - <span class="s2">"_loaded_Moe2017_data"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Holds flag whether the Moe and di Stefano (2017) data is loaded into memory</span> - <span class="s2">"_set_Moe2017_grid"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Whether the Moe and di Stefano (2017) grid has been loaded</span> - <span class="s2">"Moe2017_options"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Holds the Moe and di Stefano (2017) options.</span> - <span class="s2">"_Moe2017_JSON_data"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Stores the data</span> - <span class="c1">##########################</span> - <span class="c1"># Custom logging</span> - <span class="c1">##########################</span> - <span class="s2">"C_auto_logging"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Should contain a dictionary where the keys are they headers</span> - <span class="c1"># and the values are lists of parameters that should be logged.</span> - <span class="c1"># This will get parsed by autogen_C_logging_code in custom_logging_functions.py</span> - <span class="s2">"C_logging_code"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Should contain a string which holds the logging code.</span> - <span class="s2">"custom_logging_func_memaddr"</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># Contains the custom_logging functions memory address</span> - <span class="s2">"_custom_logging_shared_library_file"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># file containing the .so file</span> - <span class="c1">##########################</span> - <span class="c1"># Store pre-loading:</span> - <span class="c1">##########################</span> - <span class="s2">"_store_memaddr"</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># Contains the store object memory address, useful for pre loading.</span> - <span class="c1"># defaults to -1 and isn't used if that's the default then.</span> - <span class="c1">##########################</span> - <span class="c1"># Log args: logging of arguments</span> - <span class="c1">##########################</span> - <span class="s2">"log_args"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># unused</span> - <span class="s2">"log_args_dir"</span><span class="p">:</span> <span class="s2">"/tmp/"</span><span class="p">,</span> <span class="c1"># unused</span> - <span class="c1">##########################</span> - <span class="c1"># Population evolution</span> - <span class="c1">##########################</span> - <span class="c1">## General</span> - <span class="s2">"evolution_type"</span><span class="p">:</span> <span class="s2">"grid"</span><span class="p">,</span> <span class="c1"># Flag for type of population evolution</span> - <span class="s2">"_evolution_type_options"</span><span class="p">:</span> <span class="p">[</span> - <span class="s2">"grid"</span><span class="p">,</span> - <span class="s2">"custom_generator"</span><span class="p">,</span> - <span class="p">],</span> <span class="c1"># available choices for type of population evolution. # TODO: fill later with Monte Carlo, source file</span> - <span class="s2">"_system_generator"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># value that holds the function that generates the system</span> - <span class="c1"># (result of building the grid script)</span> - <span class="s2">"source_file_filename"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># filename for the source</span> - <span class="s2">"_count"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># count of systems</span> - <span class="s2">"_total_starcount"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Total count of systems in this generator</span> - <span class="s2">"_probtot"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># total probability</span> - <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">1.0</span><span class="p">,</span> <span class="c1"># weighting for the probability</span> - <span class="s2">"repeat"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="c1"># number of times to repeat each system (probability is adjusted to be 1/repeat)</span> - <span class="s2">"_start_time_evolution"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Start time of the grid</span> - <span class="s2">"_end_time_evolution"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># end time of the grid</span> - <span class="s2">"_errors_found"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Flag whether there are any errors from binary_c</span> - <span class="s2">"_errors_exceeded"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Flag whether the number of errors have exceeded the limit</span> - <span class="s2">"_failed_count"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># number of failed systems</span> - <span class="s2">"_failed_prob"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Summed probability of failed systems</span> - <span class="s2">"failed_systems_threshold"</span><span class="p">:</span> <span class="mi">20</span><span class="p">,</span> <span class="c1"># Maximum failed systems per process allowed to fail before the process stops logging the failing systems.</span> - <span class="s2">"_failed_systems_error_codes"</span><span class="p">:</span> <span class="p">[],</span> <span class="c1"># List to store the unique error codes</span> - <span class="s2">"_population_id"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Random id of this grid/population run, Unique code for the population. Should be set only once by the controller process.</span> - <span class="s2">"_total_mass_run"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># To count the total mass that thread/process has ran</span> - <span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># To count the total mass * probability for each system that thread/process has ran</span> - <span class="s2">"modulo"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="c1"># run modulo n of the grid.</span> - <span class="s2">"start_at"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># start at the first model</span> - <span class="c1">## Grid type evolution</span> - <span class="s2">"_grid_variables"</span><span class="p">:</span> <span class="p">{},</span> <span class="c1"># grid variables</span> - <span class="s2">"gridcode_filename"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># filename of gridcode</span> - <span class="s2">"symlink latest gridcode"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># symlink to latest gridcode</span> - <span class="c1">## Monte carlo type evolution</span> - <span class="c1"># TODO: make MC options</span> - <span class="c1">## Evolution from source file</span> - <span class="c1"># TODO: make run from sourcefile options.</span> - <span class="c1">## Other no yet implemented parts for the population evolution part</span> - <span class="c1"># # start at this model number: handy during debugging</span> - <span class="c1"># # to skip large parts of the grid</span> - <span class="c1"># start_at => 0</span> - <span class="c1"># global_error_string => undef,</span> - <span class="c1"># monitor_files => [],</span> - <span class="c1"># nextlogtime => 0,</span> - <span class="c1"># nthreads => 1, # number of threads</span> - <span class="c1"># # start at model offset (0-based, so first model is zero)</span> - <span class="c1"># offset => 0,</span> - <span class="c1"># resolution=>{</span> - <span class="c1"># shift =>0,</span> - <span class="c1"># previous=>0,</span> - <span class="c1"># n =>{} # per-variable resolution</span> - <span class="c1"># },</span> - <span class="c1"># thread_q => undef,</span> - <span class="c1"># threads => undef, # array of threads objects</span> - <span class="c1"># tstart => [gettimeofday], # flexigrid start time</span> - <span class="c1"># __nvar => 0, # number of grid variables</span> - <span class="c1"># _varstub => undef,</span> - <span class="c1"># _lock => undef,</span> - <span class="c1"># _evcode_pids => [],</span> - <span class="c1"># };</span> - <span class="c1">########################################</span> - <span class="c1"># Slurm stuff</span> - <span class="c1">########################################</span> - <span class="s2">"slurm"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># dont use the slurm by default. 1 = use slurm</span> - <span class="c1"># "slurm_ntasks": 1, # CPUs required per array job: usually only need this</span> - <span class="c1"># "slurm_command": "", # Command that slurm runs (e.g. evolve or join_datafiles)</span> - <span class="c1"># "slurm_dir": "", # working directory containing scripts output logs etc.</span> - <span class="c1"># "slurm_njobs": 0, # number of scripts; set to 0 as default</span> - <span class="c1"># "slurm_jobid": "", # slurm job id (%A)</span> - <span class="c1"># "slurm_memory": 512, # in MB, the memory use of the job</span> - <span class="c1"># "slurm_warn_max_memory": 1024, # in MB : warn if mem req. > this</span> - <span class="c1"># "slurm_use_all_node_CPUs": 0, # 1 = use all of a node's CPUs. 0 = use a given number of CPUs</span> - <span class="c1"># "slurm_postpone_join": 0, # if 1 do not join on slurm, join elsewhere. want to do it off the slurm grid (e.g. with more RAM)</span> - <span class="c1"># "slurm_jobarrayindex": "", # slurm job array index (%a)</span> - <span class="c1"># "slurm_jobname": "binary_grid", # default</span> - <span class="c1"># "slurm_partition": None,</span> - <span class="c1"># "slurm_time": 0, # total time. 0 = infinite time</span> - <span class="c1"># "slurm_postpone_sbatch": 0, # if 1: don't submit, just make the script</span> - <span class="c1"># "slurm_array": None, # override for --array, useful for rerunning jobs</span> - <span class="c1"># "slurm_use_all_node_CPUs": 0, # if given nodes, set to 1</span> - <span class="c1"># # if given CPUs, set to 0</span> - <span class="c1"># # you will want to use this if your Slurm SelectType is e.g. linear</span> - <span class="c1"># # which means it allocates all the CPUs in a node to the job</span> - <span class="c1"># "slurm_control_CPUs": 0, # if so, leave this many for Pythons control (0)</span> - <span class="c1"># "slurm_array": None, # override for --array, useful for rerunning jobs</span> - <span class="c1"># "slurm_partition": None, # MUST be defined</span> - <span class="c1"># "slurm_extra_settings": {}, # Place to put extra configuration for the SLURM batch file. The key and value of the dict will become the key and value of the line in te slurm batch file. Will be put in after all the other settings (and before the command). Take care not to overwrite something without really meaning to do so.</span> - <span class="c1">########################################</span> - <span class="c1"># Condor stuff</span> - <span class="c1">########################################</span> - <span class="s2">"condor"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># 1 to use condor, 0 otherwise</span> - <span class="c1"># "condor_command": "", # condor command e.g. "evolve", "join"</span> - <span class="c1"># "condor_dir": "", # working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all)</span> - <span class="c1"># "condor_njobs": "", # number of scripts/jobs that CONDOR will run in total</span> - <span class="c1"># "condor_jobid": "", # condor job id</span> - <span class="c1"># "condor_postpone_join": 0, # if 1, data is not joined, e.g. if you want to do it off the condor grid (e.g. with more RAM)</span> - <span class="c1"># # "condor_join_machine": None, # if defined then this is the machine on which the join command should be launched (must be sshable and not postponed)</span> - <span class="c1"># "condor_join_pwd": "", # directory the join should be in (defaults to $ENV{PWD} if undef)</span> - <span class="c1"># "condor_memory": 1024, # in MB, the memory use (ImageSize) of the job</span> - <span class="c1"># "condor_universe": "vanilla", # usually vanilla universe</span> - <span class="c1"># "condor_extra_settings": {}, # Place to put extra configuration for the CONDOR submit file. The key and value of the dict will become the key and value of the line in te slurm batch file. Will be put in after all the other settings (and before the command). Take care not to overwrite something without really meaning to do so.</span> - <span class="c1"># snapshots and checkpoints</span> - <span class="c1"># condor_snapshot_on_kill=>0, # if 1 snapshot on SIGKILL before exit</span> - <span class="c1"># condor_load_from_snapshot=>0, # if 1 check for snapshot .sv file and load it if found</span> - <span class="c1"># condor_checkpoint_interval=>0, # checkpoint interval (seconds)</span> - <span class="c1"># condor_checkpoint_stamp_times=>0, # if 1 then files are given timestamped names</span> - <span class="c1"># (warning: lots of files!), otherwise just store the lates</span> - <span class="c1"># condor_streams=>0, # stream stderr/stdout by default (warning: might cause heavy network load)</span> - <span class="c1"># condor_save_joined_file=>0, # if 1 then results/joined contains the results</span> - <span class="c1"># (useful for debugging, otherwise a lot of work)</span> - <span class="c1"># condor_requirements=>'', # used?</span> - <span class="c1"># # resubmit options : if the status of a condor script is</span> - <span class="c1"># # either 'finished','submitted','running' or 'crashed',</span> - <span class="c1"># # decide whether to resubmit it.</span> - <span class="c1"># # NB Normally the status is empty, e.g. on the first run.</span> - <span class="c1"># # These are for restarting runs.</span> - <span class="c1"># condor_resubmit_finished=>0,</span> - <span class="c1"># condor_resubmit_submitted=>0,</span> - <span class="c1"># condor_resubmit_running=>0,</span> - <span class="c1"># condor_resubmit_crashed=>0,</span> - <span class="c1">##########################</span> - <span class="c1"># Unordered. Need to go through this. Copied from the perl implementation.</span> - <span class="c1">##########################</span> - <span class="c1">##</span> - <span class="c1"># return_array_refs=>1, # quicker data parsing mode</span> - <span class="c1"># sort_args=>1,</span> - <span class="c1"># save_args=>1,</span> - <span class="c1"># nice=>'nice -n +20', # nice command e.g. 'nice -n +10' or ''</span> - <span class="c1"># timeout=>15, # seconds until timeout</span> - <span class="c1"># log_filename=>"/scratch/davidh/results_simulations/tmp/log.txt",</span> - <span class="c1"># # current_log_filename=>"/scratch/davidh/results_simulations/tmp/grid_errors.log",</span> - <span class="c1">############################################################</span> - <span class="c1"># Set default grid properties (in %self->{_grid_options}}</span> - <span class="c1"># and %{$self->{_bse_options}})</span> - <span class="c1"># This is the first thing that should be called by the user!</span> - <span class="c1">############################################################</span> - <span class="c1"># # set signal handlers for timeout</span> - <span class="c1"># $self->set_class_signal_handlers();</span> - <span class="c1"># # set operating system</span> - <span class="c1"># my $os = rob_misc::operating_system();</span> - <span class="c1"># %{$self->{_grid_options}}=(</span> - <span class="c1"># # save operating system</span> - <span class="c1"># operating_system=>$os,</span> - <span class="c1"># # process name</span> - <span class="c1"># process_name => 'binary_grid'.$VERSION,</span> - <span class="c1"># grid_defaults_set=>1, # so we know the grid_defaults function has been called</span> - <span class="c1"># # grid suspend files: assume binary_c by default</span> - <span class="c1"># suspend_files=>[$tmp.'/force_binary_c_suspend',</span> - <span class="c1"># './force_binary_c_suspend'],</span> - <span class="c1"># snapshot_file=>$tmp.'/binary_c-snapshot',</span> - <span class="c1"># ########################################</span> - <span class="c1"># # infomration about the running grid script</span> - <span class="c1"># ########################################</span> - <span class="c1"># working_directory=>cwd(), # the starting directory</span> - <span class="c1"># perlscript=>$0, # the name of the perlscript</span> - <span class="c1"># perlscript_arguments=>join(' ',@ARGV), # arguments as a string</span> - <span class="c1"># perl_executable=>$^X, # the perl executable</span> - <span class="c1"># command_line=>join(' ',$0,@ARGV), # full command line</span> - <span class="c1"># process_ID=>$$, # process ID of the main perl script</span> - <span class="c1"># ########################################</span> - <span class="c1"># # GRID</span> - <span class="c1"># ########################################</span> - <span class="c1"># # if undef, generate gridcode, otherwise load the gridcode</span> - <span class="c1"># # from this file. useful for debugging</span> - <span class="c1"># gridcode_from_file => undef,</span> - <span class="c1"># # assume binary_grid perl backend by default</span> - <span class="c1"># backend =></span> - <span class="c1"># $self->{_grid_options}->{backend} //</span> - <span class="c1"># $binary_grid2::backend //</span> - <span class="c1"># 'binary_grid::Perl',</span> - <span class="c1"># # custom C function for output : this automatically</span> - <span class="c1"># # binds if a function is available.</span> - <span class="c1"># C_logging_code => undef,</span> - <span class="c1"># C_auto_logging => undef,</span> - <span class="c1"># custom_output_C_function_pointer => binary_c_function_bind(),</span> - <span class="c1"># # control flow</span> - <span class="c1"># rungrid=>1, # usually run the grid, but can be 0</span> - <span class="c1"># # to skip it (e.g. for condor/slurm runs)</span> - <span class="c1"># merge_datafiles=>'',</span> - <span class="c1"># merge_datafiles_filelist=>'',</span> - <span class="c1"># # parameter space options</span> - <span class="c1"># binary=>0, # set to 0 for single stars, 1 for binaries</span> - <span class="c1"># # if use_full_resolution is 1, then run a dummy grid to</span> - <span class="c1"># # calculate the resolution. this could be slow...</span> - <span class="c1"># use_full_resolution => 1,</span> - <span class="c1"># # the probability in any distribution must be within</span> - <span class="c1"># # this tolerance of 1.0, ignored if undef (if you want</span> - <span class="c1"># # to run *part* of the parameter space then this *must* be undef)</span> - <span class="c1"># probability_tolerance=>undef,</span> - <span class="c1"># # how to deal with a failure of the probability tolerance:</span> - <span class="c1"># # 0 = nothing</span> - <span class="c1"># # 1 = warning</span> - <span class="c1"># # 2 = stop</span> - <span class="c1"># probability_tolerance_failmode=>1,</span> - <span class="c1"># # add up and log system error count and probability</span> - <span class="c1"># add_up_system_errors=>1,</span> - <span class="c1"># log_system_errors=>1,</span> - <span class="c1"># # codes, paths, executables etc.</span> - <span class="c1"># # assume binary_c by default, and set its defaults</span> - <span class="c1"># code=>'binary_c',</span> - <span class="c1"># arg_prefix=>'--',</span> - <span class="c1"># prog=>'binary_c', # executable</span> - <span class="c1"># nice=>'nice -n +0', # nice command</span> - <span class="c1"># ionice=>'',</span> - <span class="c1"># # compress output?</span> - <span class="c1"># binary_c_compression=>0,</span> - <span class="c1"># # get output as array of pre-split array refs</span> - <span class="c1"># return_array_refs=>1,</span> - <span class="c1"># # environment</span> - <span class="c1"># shell_environment=>undef,</span> - <span class="c1"># libpath=>undef, # for backwards compatibility</span> - <span class="c1"># # where is binary_c? need this to get the values of some counters</span> - <span class="c1"># rootpath=>$self->okdir($ENV{BINARY_C_ROOTPATH}) //</span> - <span class="c1"># $self->okdir($ENV{HOME}.'/progs/stars/binary_c') //</span> - <span class="c1"># '.' , # last option is a fallback ... will fail if it doesn't exist</span> - <span class="c1"># srcpath=>$self->okdir($ENV{BINARY_C_SRCPATH}) //</span> - <span class="c1"># $self->okdir($ENV{BINARY_C_ROOTPATH}.'/src') //</span> - <span class="c1"># $self->okdir($ENV{HOME}.'/progs/stars/binary_c/src') //</span> - <span class="c1"># './src' , # last option is fallback... will fail if it doesn't exist</span> - <span class="c1"># # stack size per thread in megabytes</span> - <span class="c1"># threads_stack_size=>50,</span> - <span class="c1"># # thread sleep time between starting the evolution code and starting</span> - <span class="c1"># # the grid</span> - <span class="c1"># thread_presleep=>0,</span> - <span class="c1"># # threads</span> - <span class="c1"># # Max time a thread can sit looping (with calls to tbse_line)</span> - <span class="c1"># # before a warning is issued : NB this does not catch real freezes,</span> - <span class="c1"># # just infinite loops (which still output)</span> - <span class="c1"># thread_max_freeze_time_before_warning=>10,</span> - <span class="c1"># # run all models by default: modulo=1, offset=0</span> - <span class="c1"># modulo=>1,</span> - <span class="c1"># offset=>0,</span> - <span class="c1"># # max number of stars on the queue</span> - <span class="c1"># maxq_per_thread => 100,</span> - <span class="c1"># # data dump file : undef by default (do nothing)</span> - <span class="c1"># results_hash_dumpfile => '',</span> - <span class="c1"># # compress files with bzip2 by default</span> - <span class="c1"># compress_results_hash => 1,</span> - <span class="c1"># ########################################</span> - <span class="c1"># # CPU</span> - <span class="c1"># ########################################</span> - <span class="c1"># cpu_cap=>0, # if 1, limits to one CPU</span> - <span class="c1"># cpu_affinity => 0, # do not bind to a CPU by default</span> - <span class="c1"># ########################################</span> - <span class="c1"># # Code, Timeouts, Signals</span> - <span class="c1"># ########################################</span> - <span class="c1"># binary_grid_code_filtering=>1, # you want this, it's (MUCH!) faster</span> - <span class="c1"># pre_filter_file=>undef, # dump pre filtered code to this file</span> - <span class="c1"># post_filter_file=>undef, # dump post filtered code to this file</span> - <span class="c1"># timeout=>30, # timeout in seconds</span> - <span class="c1"># timeout_vb=>0, # no timeout logging</span> - <span class="c1"># tvb=>0, # no thread logging</span> - <span class="c1"># nfs_sleep=>1, # time to wait for NFS to catch up with file accesses</span> - <span class="c1"># # flexigrid checks the timeouts every</span> - <span class="c1"># # flexigrid_timeout_check_interval seconds</span> - <span class="c1"># flexigrid_timeout_check_interval=>0.01,</span> - <span class="c1"># # this is set to 1 when the grid is finished</span> - <span class="c1"># flexigrid_finished=>0,</span> - <span class="c1"># # allow signals by default</span> - <span class="c1"># 'no signals'=>0,</span> - <span class="c1"># # but perhaps disable specific signals?</span> - <span class="c1"># 'disable signal'=>{INT=>0,ALRM=>0,CONT=>0,USR1=>0,STOP=>0},</span> - <span class="c1"># # dummy variables</span> - <span class="c1"># single_star_period=>1e50, # orbital period of a single star</span> - <span class="c1"># #### timers : set timers to 0 (or empty list) to ignore,</span> - <span class="c1"># #### NB these must be given context (e.g. main::xyz)</span> - <span class="c1"># #### for functions not in binary_grid</span> - <span class="c1"># timers=>0,</span> - <span class="c1"># timer_subroutines=>[</span> - <span class="c1"># # this is a suggested default list</span> - <span class="c1"># 'flexigrid',</span> - <span class="c1"># 'set_next_alarm',</span> - <span class="c1"># 'vbout',</span> - <span class="c1"># 'vbout_fast',</span> - <span class="c1"># 'run_flexigrid_thread',</span> - <span class="c1"># 'thread_vb'</span> - <span class="c1"># ],</span> - <span class="c1"># ########################################</span> - <span class="c1"># # INPUT/OUTPUT</span> - <span class="c1"># ########################################</span> - <span class="c1"># blocking=>undef, # not yet set</span> - <span class="c1"># # prepend command with stdbuf to stop buffering (if available)</span> - <span class="c1"># stdbuf_command=>`stdbuf --version`=~/stdbuf \(GNU/ ? ' stdbuf -i0 -o0 -e0 ' : undef,</span> - <span class="c1"># vb=>("@ARGV"=~/\Wvb=(\d+)\W/)[0] // 0, # set to 1 (or more) for verbose output to the screen</span> - <span class="c1"># log_dt_secs=>1, # log output to stdout~every log_dt_secs seconds</span> - <span class="c1"># nmod=>10, # every nmod models there is output to the screen,</span> - <span class="c1"># # if log_dt_secs has been exceeded also (ignored if 0)</span> - <span class="c1"># colour=>1, # set to 1 to use the ANSIColor module for colour output</span> - <span class="c1"># log_args=>0, # do not log args in files</span> - <span class="c1"># log_fins=>0, # log end of runs too</span> - <span class="c1"># sort_args=>0, # do not sort args</span> - <span class="c1"># save_args=>0, # do not save args in a string</span> - <span class="c1"># log_args_dir=>$tmp, # where to output the args files</span> - <span class="c1"># always_reopen_arg_files=>0, # if 1 then arg files are always closed and reopened</span> - <span class="c1"># (may cause a lot of disk I/O)</span> - <span class="c1"># lazy_arg_sending=>1, # if 1, the previous args are remembered and</span> - <span class="c1"># # only args that changed are sent (except M1, M2 etc. which always</span> - <span class="c1"># # need sending)</span> - <span class="c1"># # force output files to open on a local disk (not an NFS partion)</span> - <span class="c1"># # not sure how to do this on another OS</span> - <span class="c1"># force_local_hdd_use=>($os eq 'unix'),</span> - <span class="c1"># # for verbose output, define the newline</span> - <span class="c1"># # For terminals use "\x0d", for files use "\n", in the</span> - <span class="c1"># # case of multiple threads this will be set to \n</span> - <span class="c1"># newline=> "\x0d",</span> - <span class="c1"># # use reset_stars_defaults</span> - <span class="c1"># reset_stars_defaults=>1,</span> - <span class="c1"># # set signal captures: argument determines behaviour when the code locks up</span> - <span class="c1"># # 0: exit</span> - <span class="c1"># # 1: reset and try the next star (does this work?!)</span> - <span class="c1"># alarm_procedure=>1,</span> - <span class="c1"># # exit on eval failure?</span> - <span class="c1"># exit_on_eval_failure=>1,</span> - <span class="c1"># ## functions: these should be set by perl lexical name</span> - <span class="c1"># ## (they are automatically converted to function pointers</span> - <span class="c1"># ## at runtime)</span> - <span class="c1"># # function to be called just before a thread is created</span> - <span class="c1"># thread_precreate_function=>undef,</span> - <span class="c1"># thread_precreate_function_pointer=>undef,</span> - <span class="c1"># # function to be called just after a thread is created</span> - <span class="c1"># # (from inside the thread just before *grid () call)</span> - <span class="c1"># threads_entry_function=>undef,</span> - <span class="c1"># threads_entry_function_pointer=>undef,</span> - <span class="c1"># # function to be called just after a thread is finished</span> - <span class="c1"># # (from inside the thread just after *grid () call)</span> - <span class="c1"># threads_flush_function=>undef,</span> - <span class="c1"># threads_flush_function_pointer=>undef,</span> - <span class="c1"># # function to be called just after a thread is created</span> - <span class="c1"># # (but external to the thread)</span> - <span class="c1"># thread_postrun_function=>undef,</span> - <span class="c1"># thread_postrun_function_pointer=>undef,</span> - <span class="c1"># # function to be called just before a thread join</span> - <span class="c1"># # (external to the thread)</span> - <span class="c1"># thread_prejoin_function=>undef,</span> - <span class="c1"># thread_prejoin_function_pointer=>undef,</span> - <span class="c1"># # default to using the internal join_flexigrid_thread function</span> - <span class="c1"># threads_join_function=>'binary_grid2::join_flexigrid_thread',</span> - <span class="c1"># threads_join_function_pointer=>sub{return $self->join_flexigrid_thread(@_)},</span> - <span class="c1"># # function to be called just after a thread join</span> - <span class="c1"># # (external to the thread)</span> - <span class="c1"># thread_postjoin_function=>undef,</span> - <span class="c1"># thread_postjoin_function_pointer=>undef,</span> - <span class="c1"># # usually, parse_bse in the main script is called</span> - <span class="c1"># parse_bse_function=>'main::parse_bse',</span> - <span class="c1"># parse_bse_function_pointer=>undef,</span> - <span class="c1"># # if starting_snapshot_file is defined, load initial</span> - <span class="c1"># # values for the grid from the snapshot file rather</span> - <span class="c1"># # than a normal initiation: this enables you to</span> - <span class="c1"># # stop and start a grid</span> - <span class="c1"># starting_snapshot_file=>undef,</span> -<span class="p">}</span> - -<span class="c1"># Grid containing the descriptions of the options # TODO: add input types for all of them</span> -<span class="n">grid_options_descriptions</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"tmp_dir"</span><span class="p">:</span> <span class="s2">"Directory where certain types of output are stored. The grid code is stored in that directory, as well as the custom logging libraries. Log files and other diagnostics will usually be written to this location, unless specified otherwise"</span><span class="p">,</span> <span class="c1"># TODO: improve this</span> - <span class="s2">"_binary_c_dir"</span><span class="p">:</span> <span class="s2">"Director where binary_c is stored. This options are not really used"</span><span class="p">,</span> - <span class="s2">"_binary_c_config_executable"</span><span class="p">:</span> <span class="s2">"Full path of the binary_c-config executable. This options is not used in the population object."</span><span class="p">,</span> - <span class="s2">"_binary_c_executable"</span><span class="p">:</span> <span class="s2">"Full path to the binary_c executable. This options is not used in the population object."</span><span class="p">,</span> - <span class="s2">"_binary_c_shared_library"</span><span class="p">:</span> <span class="s2">"Full path to the libbinary_c file. This options is not used in the population object"</span><span class="p">,</span> - <span class="s2">"verbosity"</span><span class="p">:</span> <span class="s2">"Verbosity of the population code. Default is 0, by which only errors will be printed. Higher values will show more output, which is good for debugging."</span><span class="p">,</span> - <span class="s2">"binary"</span><span class="p">:</span> <span class="s2">"Set this to 1 if the population contains binaries. Input: int"</span><span class="p">,</span> <span class="c1"># TODO: write what effect this has.</span> - <span class="s2">"num_cores"</span><span class="p">:</span> <span class="s2">"The number of cores that the population grid will use. The multiprocessing is useful but make sure to figure out how many logical cores the machine has (use e.g. psutil.cpu_count(logical=False) to find the true number of cores, psutil.cpu_count(logical=True) to find the number of logical cores). The core is multi processed, not multi threaded, and will gain no extra speed when num_cores exceeds the number of logical cores. Input: int"</span><span class="p">,</span> - <span class="s2">"_start_time_evolution"</span><span class="p">:</span> <span class="s2">"Variable storing the start timestamp of the population evolution. Set by the object itself."</span><span class="p">,</span> <span class="c1"># TODO: make sure this is logged to a file</span> - <span class="s2">"_end_time_evolution"</span><span class="p">:</span> <span class="s2">"Variable storing the end timestamp of the population evolution. Set by the object itself"</span><span class="p">,</span> <span class="c1"># TODO: make sure this is logged to a file</span> - <span class="s2">"_total_starcount"</span><span class="p">:</span> <span class="s2">"Variable storing the total number of systems in the generator. Used and set by the population object."</span><span class="p">,</span> - <span class="s2">"_custom_logging_shared_library_file"</span><span class="p">:</span> <span class="s2">"filename for the custom_logging shared library. Used and set by the population object"</span><span class="p">,</span> - <span class="s2">"_errors_found"</span><span class="p">:</span> <span class="s2">"Variable storing a Boolean flag whether errors by binary_c are encountered."</span><span class="p">,</span> - <span class="s2">"_errors_exceeded"</span><span class="p">:</span> <span class="s2">"Variable storing a Boolean flag whether the number of errors was higher than the set threshold (failed_systems_threshold). If True, then the command line arguments of the failing systems will not be stored in the failed_system_log files."</span><span class="p">,</span> - <span class="s2">"source_file_filename"</span><span class="p">:</span> <span class="s2">"Variable containing the source file containing lines of binary_c command line calls. These all have to start with binary_c."</span><span class="p">,</span> <span class="c1"># TODO: Expand</span> - <span class="s2">"C_auto_logging"</span><span class="p">:</span> <span class="s2">"Dictionary containing parameters to be logged by binary_c. The structure of this dictionary is as follows: the key is used as the headline which the user can then catch. The value at that key is a list of binary_c system parameters (like star[0].mass)"</span><span class="p">,</span> - <span class="s2">"C_logging_code"</span><span class="p">:</span> <span class="s2">"Variable to store the exact code that is used for the custom_logging. In this way the user can do more complex logging, as well as putting these logging strings in files."</span><span class="p">,</span> - <span class="s2">"_failed_count"</span><span class="p">:</span> <span class="s2">"Variable storing the number of failed systems."</span><span class="p">,</span> - <span class="s2">"_evolution_type_options"</span><span class="p">:</span> <span class="s2">"List containing the evolution type options."</span><span class="p">,</span> - <span class="s2">"_failed_prob"</span><span class="p">:</span> <span class="s2">"Variable storing the total probability of all the failed systems"</span><span class="p">,</span> - <span class="s2">"_failed_systems_error_codes"</span><span class="p">:</span> <span class="s2">"List storing the unique error codes raised by binary_c of the failed systems"</span><span class="p">,</span> - <span class="s2">"_grid_variables"</span><span class="p">:</span> <span class="s2">"Dictionary storing the grid_variables. These contain properties which are accessed by the _generate_grid_code function"</span><span class="p">,</span> - <span class="s2">"_population_id"</span><span class="p">:</span> <span class="s2">"Variable storing a unique 32-char hex string."</span><span class="p">,</span> - <span class="s2">"_commandline_input"</span><span class="p">:</span> <span class="s2">"String containing the arguments passed to the population object via the command line. Set and used by the population object."</span><span class="p">,</span> - <span class="s2">"_system_generator"</span><span class="p">:</span> <span class="s2">"Function object that contains the system generator function. This can be from a grid, or a source file, or a Monte Carlo grid."</span><span class="p">,</span> - <span class="s2">"gridcode_filename"</span><span class="p">:</span> <span class="s2">"Filename for the grid code. Set and used by the population object. TODO: allow the user to provide their own function, rather than only a generated function."</span><span class="p">,</span> - <span class="s2">"log_args"</span><span class="p">:</span> <span class="s2">"Boolean to log the arguments. Unused "</span><span class="p">,</span> <span class="c1"># TODO: fix the functionality for this and describe it properly</span> - <span class="s2">"log_args_dir"</span><span class="p">:</span> <span class="s2">"Directory to log the arguments to. Unused"</span><span class="p">,</span> <span class="c1"># TODO: fix the functionality for this and describe it properly</span> - <span class="s2">"log_file"</span><span class="p">:</span> <span class="s2">"Log file for the population object. Unused"</span><span class="p">,</span> <span class="c1"># TODO: fix the functionality for this and describe it properly</span> - <span class="s2">"custom_logging_func_memaddr"</span><span class="p">:</span> <span class="s2">"Memory address where the custom_logging_function is stored. Input: int"</span><span class="p">,</span> - <span class="s2">"_count"</span><span class="p">:</span> <span class="s2">"Counter tracking which system the generator is on."</span><span class="p">,</span> - <span class="s2">"_probtot"</span><span class="p">:</span> <span class="s2">"Total probability of the population."</span><span class="p">,</span> <span class="c1"># TODO: check whether this is used properly throughout</span> - <span class="s2">"_main_pid"</span><span class="p">:</span> <span class="s2">"Main process ID of the master process. Used and set by the population object."</span><span class="p">,</span> - <span class="s2">"_store_memaddr"</span><span class="p">:</span> <span class="s2">"Memory address of the store object for binary_c."</span><span class="p">,</span> - <span class="s2">"failed_systems_threshold"</span><span class="p">:</span> <span class="s2">"Variable storing the maximum number of systems that are allowed to fail before logging their command line arguments to failed_systems log files"</span><span class="p">,</span> - <span class="s2">"parse_function"</span><span class="p">:</span> <span class="s2">"Function that the user can provide to handle the output the binary_c. This function has to take the arguments (self, output). Its best not to return anything in this function, and just store stuff in the self.grid_results dictionary, or just output results to a file"</span><span class="p">,</span> - <span class="s2">"condor"</span><span class="p">:</span> <span class="s2">"Int flag whether to use a condor type population evolution. Not implemented yet."</span><span class="p">,</span> <span class="c1"># TODO: describe this in more detail</span> - <span class="s2">"slurm"</span><span class="p">:</span> <span class="s2">"Int flag whether to use a Slurm type population evolution."</span><span class="p">,</span> <span class="c1"># TODO: describe this in more detail</span> - <span class="s2">"weight"</span><span class="p">:</span> <span class="s2">"Weight factor for each system. The calculated probability is multiplied by this. If the user wants each system to be repeated several times, then this variable should not be changed, rather change the _repeat variable instead, as that handles the reduction in probability per system. This is useful for systems that have a process with some random element in it."</span><span class="p">,</span> <span class="c1"># TODO: add more info here, regarding the evolution splitting.</span> - <span class="s2">"repeat"</span><span class="p">:</span> <span class="s2">"Factor of how many times a system should be repeated. Consider the evolution splitting binary_c argument for supernovae kick repeating."</span><span class="p">,</span> <span class="c1"># TODO: make sure this is used.</span> - <span class="s2">"evolution_type"</span><span class="p">:</span> <span class="s2">"Variable containing the type of evolution used of the grid. Multiprocessing or linear processing"</span><span class="p">,</span> - <span class="s2">"combine_ensemble_with_thread_joining"</span><span class="p">:</span> <span class="s2">"Boolean flag on whether to combine everything and return it to the user or if false: write it to data_dir/ensemble_output_</span><span class="si">{population_id}</span><span class="s2">_</span><span class="si">{thread_id}</span><span class="s2">.json"</span><span class="p">,</span> - <span class="s2">"log_runtime_systems"</span><span class="p">:</span> <span class="s2">"Whether to log the runtime of the systems . Each systems run by the thread is logged to a file and is stored in the tmp_dir. (1 file per thread). Don't use this if you are planning to run a lot of systems. This is mostly for debugging and finding systems that take long to run. Integer, default = 0. if value is 1 then the systems are logged"</span><span class="p">,</span> - <span class="s2">"_total_mass_run"</span><span class="p">:</span> <span class="s2">"To count the total mass that thread/process has ran"</span><span class="p">,</span> - <span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">:</span> <span class="s2">"To count the total mass * probability for each system that thread/process has ran"</span><span class="p">,</span> - <span class="s2">"_actually_evolve_system"</span><span class="p">:</span> <span class="s2">"Whether to actually evolve the systems of just act as if. for testing. used in _process_run_population_grid"</span><span class="p">,</span> - <span class="s2">"max_queue_size"</span><span class="p">:</span> <span class="s2">"Maximum size of the queue that is used to feed the processes. Don't make this too big! Default: 1000. Input: int"</span><span class="p">,</span> - <span class="s2">"_set_Moe2017_grid"</span><span class="p">:</span> <span class="s2">"Internal flag whether the Moe and di Stefano (2017) grid has been loaded"</span><span class="p">,</span> - <span class="s2">"run_zero_probability_system"</span><span class="p">:</span> <span class="s2">"Whether to run the zero probability systems. Default: True. Input: Boolean"</span><span class="p">,</span> - <span class="s2">"_zero_prob_stars_skipped"</span><span class="p">:</span> <span class="s2">"Internal counter to track how many systems are skipped because they have 0 probability"</span><span class="p">,</span> - <span class="s2">"ensemble_factor_in_probability_weighted_mass"</span><span class="p">:</span> <span class="s2">"Flag to multiply all the ensemble results with 1/probability_weighted_mass"</span><span class="p">,</span> - <span class="s2">"multiplicity_fraction_function"</span><span class="p">:</span> <span class="s2">"Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: Moe and di Stefano (2017) 2017"</span><span class="p">,</span> - <span class="s2">"m&s_options"</span><span class="p">:</span> <span class="s2">"Internal variable that holds the Moe and di Stefano (2017) options. Don't write to this your self"</span><span class="p">,</span> - <span class="s2">"_loaded_Moe2017_data"</span><span class="p">:</span> <span class="s2">"Internal variable storing whether the Moe and di Stefano (2017) data has been loaded into memory"</span><span class="p">,</span> - <span class="s2">"do_dry_run"</span><span class="p">:</span> <span class="s2">"Whether to do a dry run to calculate the total probability for this run"</span><span class="p">,</span> - <span class="s2">"_Moe2017_JSON_data"</span><span class="p">:</span> <span class="s2">"Location to store the loaded Moe&diStefano2017 dataset"</span><span class="p">,</span> <span class="c1"># Stores the data</span> -<span class="p">}</span> - -<span class="c1">###</span> -<span class="c1">#</span> - -<span class="n">MIN_MASS_BINARY_C</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span> - <span class="n">return_binary_c_version_info</span><span class="p">(</span><span class="n">parsed</span><span class="o">=</span><span class="kc">True</span><span class="p">)[</span><span class="s2">"macros"</span><span class="p">][</span><span class="s2">"BINARY_C_MINIMUM_STELLAR_MASS"</span><span class="p">]</span> -<span class="p">)</span> - - -<span class="c1"># Default options for the Moe & di Stefano grid</span> -<span class="n">moe_di_stefano_default_options</span> <span class="o">=</span> <span class="p">{</span> - <span class="c1"># place holder for the JSON data to be used if a file</span> - <span class="c1"># isn't specified</span> - <span class="s2">"JSON"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> - <span class="c1"># resolution data</span> - <span class="s2">"resolutions"</span><span class="p">:</span> <span class="p">{</span> - <span class="s2">"M"</span><span class="p">:</span> <span class="p">[</span> - <span class="mi">20</span><span class="p">,</span> <span class="c1"># M1</span> - <span class="mi">20</span><span class="p">,</span> <span class="c1"># M2 (i.e. q)</span> - <span class="mi">0</span><span class="p">,</span> <span class="c1"># M3 currently unused</span> - <span class="mi">0</span><span class="p">,</span> <span class="c1"># M4 currently unused</span> - <span class="p">],</span> - <span class="s2">"logP"</span><span class="p">:</span> <span class="p">[</span> - <span class="mi">20</span><span class="p">,</span> <span class="c1"># P2 (binary period)</span> - <span class="mi">0</span><span class="p">,</span> <span class="c1"># P3 (triple period) currently unused</span> - <span class="mi">0</span><span class="p">,</span> <span class="c1"># P4 (quadruple period) currently unused</span> - <span class="p">],</span> - <span class="s2">"ecc"</span><span class="p">:</span> <span class="p">[</span> - <span class="mi">10</span><span class="p">,</span> <span class="c1"># e (binary eccentricity)</span> - <span class="mi">0</span><span class="p">,</span> <span class="c1"># e2 (triple eccentricity) currently unused</span> - <span class="mi">0</span><span class="p">,</span> <span class="c1"># e3 (quadruple eccentricity) currently unused</span> - <span class="p">],</span> - <span class="p">},</span> - <span class="s2">"samplerfuncs"</span><span class="p">:</span> <span class="p">{</span> - <span class="s2">"M"</span><span class="p">:</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">],</span> - <span class="s2">"logP"</span><span class="p">:</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">],</span> - <span class="s2">"ecc"</span><span class="p">:</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">],</span> - <span class="p">},</span> - <span class="s2">"ranges"</span><span class="p">:</span> <span class="p">{</span> - <span class="c1"># stellar masses (Msun)</span> - <span class="s2">"M"</span><span class="p">:</span> <span class="p">[</span> - <span class="n">MIN_MASS_BINARY_C</span> - <span class="o">*</span> <span class="mf">1.05</span><span class="p">,</span> <span class="c1"># 0.08 is a tad bit above the minimum mass. Don't sample at 0.07, otherwise the first row of q values will have a phasevol of 0. Anything higher is fine.</span> - <span class="mf">80.0</span><span class="p">,</span> <span class="c1"># (rather arbitrary) upper mass cutoff</span> - <span class="p">],</span> - <span class="s2">"q"</span><span class="p">:</span> <span class="p">[</span> - <span class="kc">None</span><span class="p">,</span> <span class="c1"># artificial qmin : set to None to use default</span> - <span class="kc">None</span><span class="p">,</span> <span class="c1"># artificial qmax : set to None to use default</span> - <span class="p">],</span> - <span class="s2">"logP"</span><span class="p">:</span> <span class="p">[</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">8.0</span><span class="p">],</span> <span class="c1"># 0 = log10(1 day) # 8 = log10(10^8 days)</span> - <span class="s2">"ecc"</span><span class="p">:</span> <span class="p">[</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.99</span><span class="p">],</span> - <span class="p">},</span> - <span class="c1"># minimum stellar mass</span> - <span class="s2">"Mmin"</span><span class="p">:</span> <span class="n">MIN_MASS_BINARY_C</span><span class="p">,</span> <span class="c1"># We take the value that binary_c has set as the default</span> - <span class="c1"># multiplicity model (as a function of log10M1)</span> - <span class="c1">#</span> - <span class="c1"># You can use 'Poisson' which uses the system multiplicity</span> - <span class="c1"># given by Moe and maps this to single/binary/triple/quad</span> - <span class="c1"># fractions.</span> - <span class="c1">#</span> - <span class="c1"># Alternatively, 'data' takes the fractions directly</span> - <span class="c1"># from the data, but then triples and quadruples are</span> - <span class="c1"># combined (and there are NO quadruples).</span> - <span class="s2">"multiplicity_model"</span><span class="p">:</span> <span class="s2">"Poisson"</span><span class="p">,</span> - <span class="c1"># multiplicity modulator:</span> - <span class="c1"># [single, binary, triple, quadruple]</span> - <span class="c1">#</span> - <span class="c1"># e.g. [1,0,0,0] for single stars only</span> - <span class="c1"># [0,1,0,0] for binary stars only</span> - <span class="c1">#</span> - <span class="c1"># defaults to [1,1,0,0] i.e. all types</span> - <span class="c1">#</span> - <span class="s2">"multiplicity_modulator"</span><span class="p">:</span> <span class="p">[</span> - <span class="mi">1</span><span class="p">,</span> <span class="c1"># single</span> - <span class="mi">1</span><span class="p">,</span> <span class="c1"># binary</span> - <span class="mi">0</span><span class="p">,</span> <span class="c1"># triple</span> - <span class="mi">0</span><span class="p">,</span> <span class="c1"># quadruple</span> - <span class="p">],</span> - <span class="c1"># given a mix of multiplicities, you can either (noting that</span> - <span class="c1"># here (S,B,T,Q) = appropriate modulator * model(S,B,T,Q) )</span> - <span class="c1">#</span> - <span class="c1"># 'norm' : normalise so the whole population is 1.0</span> - <span class="c1"># after implementing the appropriate fractions</span> - <span class="c1"># S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q)</span> - <span class="c1">#</span> - <span class="c1"># 'raw' : stick to what is predicted, i.e.</span> - <span class="c1"># S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q)</span> - <span class="c1"># without normalisation</span> - <span class="c1"># (in which case the total probability < 1.0 unless</span> - <span class="c1"># all you use single, binary, triple and quadruple)</span> - <span class="c1">#</span> - <span class="c1"># 'merge' : e.g. if you only have single and binary,</span> - <span class="c1"># add the triples and quadruples to the binaries, so</span> - <span class="c1"># binaries represent all multiple systems</span> - <span class="c1"># ...</span> - <span class="c1"># *** this is canonical binary population synthesis ***</span> - <span class="c1">#</span> - <span class="c1"># Note: if multiplicity_modulator == [1,1,1,1] this</span> - <span class="c1"># option does nothing (equivalent to 'raw').</span> - <span class="c1">#</span> - <span class="c1">#</span> - <span class="c1"># note: if you only set one multiplicity_modulator</span> - <span class="c1"># to 1, and all the others to 0, then normalising</span> - <span class="c1"># will mean that you effectively have the same number</span> - <span class="c1"># of stars as single, binary, triple or quad (whichever</span> - <span class="c1"># is non-zero) i.e. the multiplicity fraction is ignored.</span> - <span class="c1"># This is probably not useful except for</span> - <span class="c1"># testing purposes or comparing to old grids.</span> - <span class="s2">"normalize_multiplicities"</span><span class="p">:</span> <span class="s2">"merge"</span><span class="p">,</span> - <span class="c1"># q extrapolation (below 0.15 and above 0.9) method. We can choose from ['flat', 'linear', 'plaw2', 'nolowq']</span> - <span class="s2">"q_low_extrapolation_method"</span><span class="p">:</span> <span class="s2">"linear"</span><span class="p">,</span> - <span class="s2">"q_high_extrapolation_method"</span><span class="p">:</span> <span class="s2">"linear"</span><span class="p">,</span> -<span class="p">}</span> - -<span class="n">moe_di_stefano_default_options_description</span> <span class="o">=</span> <span class="p">{</span> - <span class="s2">"resolutions"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> - <span class="s2">"ranges"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> - <span class="s2">"Mmin"</span><span class="p">:</span> <span class="s2">"Minimum stellar mass"</span><span class="p">,</span> - <span class="s2">"multiplicity_model"</span><span class="p">:</span> <span class="s2">"""</span> -<span class="s2">multiplicity model (as a function of log10M1)</span> - -<span class="s2">You can use 'Poisson' which uses the system multiplicity</span> -<span class="s2">given by Moe and maps this to single/binary/triple/quad</span> -<span class="s2">fractions.</span> - -<span class="s2">Alternatively, 'data' takes the fractions directly</span> -<span class="s2">from the data, but then triples and quadruples are</span> -<span class="s2">combined (and there are NO quadruples).</span> -<span class="s2">"""</span><span class="p">,</span> - <span class="s2">"multiplicity_modulator"</span><span class="p">:</span> <span class="s2">"""</span> -<span class="s2">[single, binary, triple, quadruple]</span> - -<span class="s2">e.g. [1,0,0,0] for single stars only</span> -<span class="s2"> [0,1,0,0] for binary stars only</span> - -<span class="s2">defaults to [1,1,0,0] i.e. singles and binaries</span> -<span class="s2">"""</span><span class="p">,</span> - <span class="s2">"normalize_multiplicities"</span><span class="p">:</span> <span class="s2">"""</span> -<span class="s2">'norm': normalise so the whole population is 1.0</span> -<span class="s2"> after implementing the appropriate fractions</span> -<span class="s2"> S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q)</span> -<span class="s2"> given a mix of multiplicities, you can either (noting that</span> -<span class="s2"> here (S,B,T,Q) = appropriate modulator * model(S,B,T,Q) )</span> -<span class="s2"> note: if you only set one multiplicity_modulator</span> -<span class="s2"> to 1, and all the others to 0, then normalising</span> -<span class="s2"> will mean that you effectively have the same number</span> -<span class="s2"> of stars as single, binary, triple or quad (whichever</span> -<span class="s2"> is non-zero) i.e. the multiplicity fraction is ignored.</span> -<span class="s2"> This is probably not useful except for</span> -<span class="s2"> testing purposes or comparing to old grids.</span> - -<span class="s2">'raw' : stick to what is predicted, i.e.</span> -<span class="s2"> S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q)</span> -<span class="s2"> without normalisation</span> -<span class="s2"> (in which case the total probability < 1.0 unless</span> -<span class="s2"> all you use single, binary, triple and quadruple)</span> - -<span class="s2">'merge' : e.g. if you only have single and binary,</span> -<span class="s2"> add the triples and quadruples to the binaries, so</span> -<span class="s2"> binaries represent all multiple systems</span> -<span class="s2"> ...</span> -<span class="s2"> *** this is canonical binary population synthesis ***</span> - -<span class="s2"> It only takes the maximum multiplicity into account,</span> -<span class="s2"> i.e. it doesn't multiply the resulting array by the multiplicity modulator again.</span> -<span class="s2"> This prevents the resulting array to always be 1 if only 1 multiplicity modulator element is nonzero</span> - -<span class="s2"> Note: if multiplicity_modulator == [1,1,1,1]. this option does nothing (equivalent to 'raw').</span> -<span class="s2">"""</span><span class="p">,</span> - <span class="s2">"q_low_extrapolation_method"</span><span class="p">:</span> <span class="s2">"""</span> -<span class="s2">q extrapolation (below 0.15) method</span> -<span class="s2"> none</span> -<span class="s2"> flat</span> -<span class="s2"> linear2</span> -<span class="s2"> plaw2</span> -<span class="s2"> nolowq</span> -<span class="s2">"""</span><span class="p">,</span> - <span class="s2">"q_high_extrapolation_method"</span><span class="p">:</span> <span class="s2">"Same as q_low_extrapolation_method"</span><span class="p">,</span> -<span class="p">}</span> - - -<span class="c1">#################################</span> -<span class="c1"># Grid options functions</span> - -<span class="c1"># Utility functions</span> -<div class="viewcode-block" id="grid_options_help"><a class="viewcode-back" href="../../../grid_options_defaults.html#binarycpython.utils.grid_options_defaults.grid_options_help">[docs]</a><span class="k">def</span> <span class="nf">grid_options_help</span><span class="p">(</span><span class="n">option</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Function that prints out the description of a grid option. Useful function for the user.</span> - -<span class="sd"> Args:</span> -<span class="sd"> option: which option you want to have the description of</span> - -<span class="sd"> returns:</span> -<span class="sd"> dict containing the option, the description if its there, otherwise empty string. And if the key doesnt exist, the dict is empty</span> -<span class="sd"> """</span> - - <span class="n">option_keys</span> <span class="o">=</span> <span class="n">grid_options_defaults_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> - <span class="n">description_keys</span> <span class="o">=</span> <span class="n">grid_options_descriptions</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> - - <span class="k">if</span> <span class="ow">not</span> <span class="n">option</span> <span class="ow">in</span> <span class="n">option_keys</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"Error: This is an invalid entry. Option does not exist, please choose from the following options:</span><span class="se">\n\t</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">option_keys</span><span class="p">)</span> - <span class="p">)</span> - <span class="p">)</span> - <span class="k">return</span> <span class="p">{}</span> - - <span class="k">else</span><span class="p">:</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">option</span> <span class="ow">in</span> <span class="n">description_keys</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"This option has not been described properly yet. Please contact on of the authors"</span> - <span class="p">)</span> - <span class="k">return</span> <span class="p">{</span><span class="n">option</span><span class="p">:</span> <span class="s2">""</span><span class="p">}</span> - <span class="k">else</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span><span class="n">grid_options_descriptions</span><span class="p">[</span><span class="n">option</span><span class="p">])</span> - <span class="k">return</span> <span class="p">{</span><span class="n">option</span><span class="p">:</span> <span class="n">grid_options_descriptions</span><span class="p">[</span><span class="n">option</span><span class="p">]}</span></div> - - -<div class="viewcode-block" id="grid_options_description_checker"><a class="viewcode-back" href="../../../grid_options_defaults.html#binarycpython.utils.grid_options_defaults.grid_options_description_checker">[docs]</a><span class="k">def</span> <span class="nf">grid_options_description_checker</span><span class="p">(</span><span class="n">print_info</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Function that checks which descriptions are missing</span> - -<span class="sd"> Args:</span> -<span class="sd"> print_info: whether to print out information about which options contain proper descriptions and which do not</span> - -<span class="sd"> Returns:</span> -<span class="sd"> the number of undescribed keys</span> -<span class="sd"> """</span> - - <span class="c1"># Get the keys</span> - <span class="n">option_keys</span> <span class="o">=</span> <span class="n">grid_options_defaults_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> - <span class="n">description_keys</span> <span class="o">=</span> <span class="n">grid_options_descriptions</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> - - <span class="c1">#</span> - <span class="n">undescribed_keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">option_keys</span><span class="p">)</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">description_keys</span><span class="p">))</span> - - <span class="k">if</span> <span class="n">undescribed_keys</span><span class="p">:</span> - <span class="k">if</span> <span class="n">print_info</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"Warning: the following keys have no description yet:</span><span class="se">\n\t</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">undescribed_keys</span><span class="p">))</span> - <span class="p">)</span> - <span class="p">)</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"Total description progress: </span><span class="si">{:.2f}%%</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="mi">100</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">description_keys</span><span class="p">)</span> <span class="o">/</span> <span class="nb">len</span><span class="p">(</span><span class="n">option_keys</span><span class="p">)</span> - <span class="p">)</span> - <span class="p">)</span> - <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="n">undescribed_keys</span><span class="p">)</span></div> - - -<div class="viewcode-block" id="write_grid_options_to_rst_file"><a class="viewcode-back" href="../../../grid_options_defaults.html#binarycpython.utils.grid_options_defaults.write_grid_options_to_rst_file">[docs]</a><span class="k">def</span> <span class="nf">write_grid_options_to_rst_file</span><span class="p">(</span><span class="n">output_file</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Function that writes the descriptions of the grid options to a rst file</span> - -<span class="sd"> Tasks:</span> -<span class="sd"> TODO: separate things into private and public options</span> - -<span class="sd"> Args:</span> -<span class="sd"> output_file: target file where the grid options descriptions are written to</span> -<span class="sd"> """</span> - - <span class="c1"># Get the options and the description</span> - <span class="n">options</span> <span class="o">=</span> <span class="n">grid_options_defaults_dict</span> - <span class="n">descriptions</span> <span class="o">=</span> <span class="n">grid_options_descriptions</span> - - <span class="c1"># Get those that do not have a description</span> - <span class="n">not_described_yet</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">options</span><span class="p">)</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">descriptions</span><span class="p">))</span> - - <span class="c1"># separate public and private options</span> - <span class="n">public_options</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">options</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"_"</span><span class="p">)]</span> - <span class="n">private_options</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">options</span> <span class="k">if</span> <span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"_"</span><span class="p">)]</span> - - <span class="c1"># Check input</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">output_file</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".rst"</span><span class="p">):</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"Filename doesn't end with .rst, please provide a proper filename"</span><span class="p">)</span> - <span class="k">return</span> <span class="kc">None</span> - - <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"Population grid code options"</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s2">"="</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="s2">"Population grid code options"</span><span class="p">)),</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"The following chapter contains all grid code options, along with their descriptions"</span><span class="p">,</span> - <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> - <span class="p">)</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"There are </span><span class="si">{}</span><span class="s2"> options that are not described yet."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="nb">len</span><span class="p">(</span><span class="n">not_described_yet</span><span class="p">)</span> - <span class="p">),</span> - <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> - <span class="p">)</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> - - <span class="c1"># Start public options part</span> - <span class="n">print_option_descriptions</span><span class="p">(</span> - <span class="n">f</span><span class="p">,</span> - <span class="n">public_options</span><span class="p">,</span> - <span class="n">descriptions</span><span class="p">,</span> - <span class="s2">"Public options"</span><span class="p">,</span> - <span class="s2">"The following options are meant to be changed by the user."</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Moe & di Stefano options:</span> - <span class="n">print_option_descriptions</span><span class="p">(</span> - <span class="n">f</span><span class="p">,</span> - <span class="n">moe_di_stefano_default_options</span><span class="p">,</span> - <span class="n">moe_di_stefano_default_options_description</span><span class="p">,</span> - <span class="s2">"Moe & di Stefano sampler options"</span><span class="p">,</span> - <span class="s2">"The following options are meant to be changed by the user."</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># Start private options part</span> - <span class="n">print_option_descriptions</span><span class="p">(</span> - <span class="n">f</span><span class="p">,</span> - <span class="n">private_options</span><span class="p">,</span> - <span class="n">descriptions</span><span class="p">,</span> - <span class="s2">"Private options"</span><span class="p">,</span> - <span class="s2">"The following options are not meant to be changed by the user, as these options are used and set internally by the object itself. The description still is provided, but just for documentation purposes."</span><span class="p">,</span> - <span class="p">)</span></div> - - -<div class="viewcode-block" id="print_option_descriptions"><a class="viewcode-back" href="../../../grid_options_defaults.html#binarycpython.utils.grid_options_defaults.print_option_descriptions">[docs]</a><span class="k">def</span> <span class="nf">print_option_descriptions</span><span class="p">(</span><span class="n">filehandle</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="n">descriptions</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">extra_text</span><span class="p">):</span> - <span class="c1"># Start public options part</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">title</span><span class="p">),</span> <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">)</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s2">"-"</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">title</span><span class="p">))),</span> <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">)</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">extra_text</span><span class="p">),</span> <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">)</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">)</span> - - <span class="k">for</span> <span class="n">option</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">options</span><span class="p">):</span> - <span class="k">if</span> <span class="n">option</span> <span class="ow">in</span> <span class="n">descriptions</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"| **</span><span class="si">{}</span><span class="s2">**: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">option</span><span class="p">,</span> <span class="n">descriptions</span><span class="p">[</span><span class="n">option</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n\t</span><span class="s2">"</span><span class="p">)</span> - <span class="p">),</span> - <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">,</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"| **</span><span class="si">{}</span><span class="s2">**: No description available yet"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">option</span><span class="p">),</span> - <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">,</span> - <span class="p">)</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">)</span></div> -</pre></div> - - </div> - - </div> - <footer> - - - <hr/> - - <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> - </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. -<br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. -<br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. - - - -</footer> - - </div> - </div> - - </section> - - </div> - - - - <script type="text/javascript"> - jQuery(function () { - SphinxRtdTheme.Navigation.enable(true); - }); - </script> - - - - - - -</body> -</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/plot_functions.html b/docs/build/html/_modules/binarycpython/utils/plot_functions.html index 6f7e30cb68d553127f423f1b656ba333d42ca157..573253c8dde895bd2720597628f3706e747c5494 100644 --- a/docs/build/html/_modules/binarycpython/utils/plot_functions.html +++ b/docs/build/html/_modules/binarycpython/utils/plot_functions.html @@ -1,68 +1,33 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>binarycpython.utils.plot_functions — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - - - <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script> <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> <script src="../../../_static/jquery.js"></script> <script src="../../../_static/underscore.js"></script> + <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../../../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="../../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <script src="../../../_static/js/theme.js"></script> <link rel="index" title="Index" href="../../../genindex.html" /> <link rel="search" title="Search" href="../../../search.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../../../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -70,17 +35,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> @@ -92,71 +47,35 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../../../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../../../index.html">Docs</a> »</li> - + <li><a href="../../../index.html" class="icon icon-home"></a> »</li> <li><a href="../../index.html">Module code</a> »</li> - <li>binarycpython.utils.plot_functions</li> - - <li class="wy-breadcrumbs-aside"> - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <h1>Source code for binarycpython.utils.plot_functions</h1><div class="highlight"><pre> <span></span><span class="sd">"""</span> -<span class="sd">Module that contains functionality to plot some properties of (binary) systems. </span> +<span class="sd">Module that contains functionality to plot some properties of (binary) systems.</span> -<span class="sd">Different routines are defined here to plot orbits, masses, angular momenta etc. </span> +<span class="sd">Different routines are defined here to plot orbits, masses, angular momenta etc.</span> <span class="sd">Structure of file:</span> <span class="sd"> custom logging strings</span> @@ -168,8 +87,8 @@ <span class="sd">There is no pre loaded matplotlib rc, you should do that yourself</span> -<span class="sd">These plotting routines are designed for binary systems, and admittedly they are here mostly for </span> -<span class="sd">inspirational purposes, since one would probably want to customise the plots. </span> +<span class="sd">These plotting routines are designed for binary systems, and admittedly they are here mostly for</span> +<span class="sd">inspirational purposes, since one would probably want to customise the plots.</span> <span class="sd">Regardless, having some plotting routines in here seemed like a nice idea</span> <span class="sd">Tasks</span> @@ -187,9 +106,9 @@ <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">output_lines</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.run_system_wrapper</span> <span class="k">import</span> <span class="n">run_system</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="k">import</span> <span class="n">binary_c_log_code</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">output_lines</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.run_system_wrapper</span> <span class="kn">import</span> <span class="n">run_system</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="kn">import</span> <span class="n">binary_c_log_code</span> <span class="c1"># Define the custom_logging_strings.</span> <span class="c1"># These are kept to the minimum necessary for each plotting routine.</span> @@ -319,10 +238,10 @@ <span class="n">prefactor</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">/</span> <span class="p">(</span><span class="mi">4</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">omega_sb</span><span class="p">))</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="mi">4</span><span class="p">)</span> <span class="k">if</span> <span class="n">show_stellar_types</span><span class="p">:</span> - <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">20</span><span class="p">))</span> - <span class="n">fig</span><span class="p">,</span> <span class="n">colors</span> <span class="o">=</span> <span class="n">add_stellar_types_bar</span><span class="p">(</span><span class="n">df</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">ax_index</span><span class="o">=-</span><span class="mi">1</span><span class="p">,</span> <span class="n">only_colorbar</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <span class="n">fig</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">20</span><span class="p">))</span> + <span class="c1"># fig, colors = add_stellar_types_bar(df, fig, ax_index=-1, only_colorbar=True)</span> <span class="k">else</span><span class="p">:</span> - <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">20</span><span class="p">))</span> + <span class="n">fig</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">20</span><span class="p">))</span> <span class="n">df</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">assign</span><span class="p">(</span> <span class="n">teff_1</span><span class="o">=</span><span class="n">prefactor</span> @@ -384,8 +303,7 @@ <span class="c1"># Show or return</span> <span class="k">if</span> <span class="n">show_plot</span><span class="p">:</span> <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> - <span class="k">else</span><span class="p">:</span> - <span class="k">return</span> <span class="n">fig</span></div> + <span class="k">return</span> <span class="n">fig</span></div> <div class="viewcode-block" id="plot_orbit"><a class="viewcode-back" href="../../../plot_functions.html#binarycpython.utils.plot_functions.plot_orbit">[docs]</a><span class="k">def</span> <span class="nf">plot_orbit</span><span class="p">(</span><span class="n">df</span><span class="p">,</span> <span class="n">show_stellar_types</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">show_plot</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">):</span> @@ -409,10 +327,10 @@ <span class="sd"> """</span> <span class="k">if</span> <span class="n">show_stellar_types</span><span class="p">:</span> - <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">10</span><span class="p">))</span> + <span class="n">fig</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">10</span><span class="p">))</span> <span class="n">fig</span><span class="o">.</span><span class="n">subplots_adjust</span><span class="p">(</span><span class="n">hspace</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> <span class="k">else</span><span class="p">:</span> - <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">10</span><span class="p">),</span> <span class="n">sharex</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <span class="n">fig</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">10</span><span class="p">),</span> <span class="n">sharex</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="n">fig</span><span class="o">.</span><span class="n">subplots_adjust</span><span class="p">(</span><span class="n">hspace</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> <span class="c1">#</span> @@ -441,8 +359,7 @@ <span class="c1"># Show or return</span> <span class="k">if</span> <span class="n">show_plot</span><span class="p">:</span> <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> - <span class="k">else</span><span class="p">:</span> - <span class="k">return</span> <span class="n">fig</span></div> + <span class="k">return</span> <span class="n">fig</span></div> <div class="viewcode-block" id="plot_masses"><a class="viewcode-back" href="../../../plot_functions.html#binarycpython.utils.plot_functions.plot_masses">[docs]</a><span class="k">def</span> <span class="nf">plot_masses</span><span class="p">(</span><span class="n">df</span><span class="p">,</span> <span class="n">show_stellar_types</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">show_plot</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">):</span> @@ -477,10 +394,10 @@ <span class="sd"> """</span> <span class="k">if</span> <span class="n">show_stellar_types</span><span class="p">:</span> - <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">10</span><span class="p">))</span> + <span class="n">fig</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">10</span><span class="p">))</span> <span class="n">fig</span><span class="o">.</span><span class="n">subplots_adjust</span><span class="p">(</span><span class="n">hspace</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> <span class="k">else</span><span class="p">:</span> - <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">10</span><span class="p">))</span> + <span class="n">fig</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">10</span><span class="p">))</span> <span class="n">max_total_mass</span> <span class="o">=</span> <span class="p">(</span> <span class="n">df</span><span class="p">[</span><span class="s2">"pms_mass_1"</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="o">.</span><span class="n">tolist</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">df</span><span class="p">[</span><span class="s2">"pms_mass_2"</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="o">.</span><span class="n">tolist</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> @@ -548,14 +465,16 @@ <span class="c1"># Show or return</span> <span class="k">if</span> <span class="n">show_plot</span><span class="p">:</span> <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> - <span class="k">else</span><span class="p">:</span> - <span class="k">return</span> <span class="n">fig</span></div> + <span class="k">return</span> <span class="n">fig</span></div> <span class="c1"># Define the parse functions for the plotting routines</span> <div class="viewcode-block" id="dummy"><a class="viewcode-back" href="../../../plot_functions.html#binarycpython.utils.plot_functions.dummy">[docs]</a><span class="k">def</span> <span class="nf">dummy</span><span class="p">():</span> - <span class="sd">"""Placeholder"""</span> - <span class="k">pass</span></div> + <span class="sd">"""</span> +<span class="sd"> Placeholder function</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="kc">None</span></div> <div class="viewcode-block" id="parse_function_hr_diagram"><a class="viewcode-back" href="../../../plot_functions.html#binarycpython.utils.plot_functions.parse_function_hr_diagram">[docs]</a><span class="k">def</span> <span class="nf">parse_function_hr_diagram</span><span class="p">(</span><span class="n">output</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> @@ -698,11 +617,6 @@ <span class="sd"> - orbit_evolution</span> <span class="sd"> - hr_diagram</span> -<span class="sd"> Tasks:</span> -<span class="sd"> - TODO: Complex Function!</span> -<span class="sd"> - TODO: make sure this way of passing args works correctly.</span> -<span class="sd"> - TODO: make the plotting specific keywords available via the inspect stuff</span> - <span class="sd"> All keywords are considered kwargs, except for plot_type</span> <span class="sd"> Args:</span> @@ -757,15 +671,15 @@ <span class="c1"># run_system will handle the rest</span> <span class="n">run_system_arg_dict</span> <span class="o">=</span> <span class="p">{}</span> - <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> + <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s2">"show_plot"</span><span class="p">:</span> - <span class="n">show_plot</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="n">show_plot</span> <span class="o">=</span> <span class="n">value</span> <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s2">"show_stellar_types"</span><span class="p">:</span> - <span class="n">show_stellar_types</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="n">show_stellar_types</span> <span class="o">=</span> <span class="n">value</span> <span class="c1"># The rest will be passed to run_system</span> <span class="k">else</span><span class="p">:</span> - <span class="n">run_system_arg_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="n">run_system_arg_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span> <span class="c1"># TODO: When a list of plot_types is passed, make it so that the strings are chained,</span> <span class="c1"># and that the output of the binary_c call is handled by multiple parsers</span> @@ -783,70 +697,40 @@ <span class="n">binary_c_output_df</span><span class="p">,</span> <span class="n">show_plot</span><span class="o">=</span><span class="n">show_plot</span><span class="p">,</span> <span class="n">show_stellar_types</span><span class="o">=</span><span class="n">show_stellar_types</span> <span class="p">)</span> - <span class="k">if</span> <span class="ow">not</span> <span class="n">show_plot</span><span class="p">:</span> - <span class="k">return</span> <span class="n">fig</span></div> - - -<span class="c1"># from david_phd_functions.plotting.custom_mpl_settings import load_mpl_rc</span> -<span class="c1"># load_mpl_rc()</span> - -<span class="c1"># fig = plot_system(</span> -<span class="c1"># plot_type="mass_evolution",</span> -<span class="c1"># M_1=10,</span> -<span class="c1"># M_2=5,</span> -<span class="c1"># separation=1000000,</span> -<span class="c1"># orbital_period=100000000,</span> -<span class="c1"># max_evolution_time=15000,</span> -<span class="c1"># show_plot=True,</span> -<span class="c1"># )</span> - -<span class="c1"># fig.axes[0].set_xlim(0, 150)</span> -<span class="c1"># plt.show()</span> + <span class="k">return</span> <span class="n">fig</span></div> </pre></div> </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/HPC.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/HPC.html new file mode 100644 index 0000000000000000000000000000000000000000..96fd86646a1ebb52822a275d368e607e9bca4901 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/HPC.html @@ -0,0 +1,846 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.HPC — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.HPC</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.HPC</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">Module containing the functions to HPC functionality</span> + +<span class="sd">These functions form a single API through which you can access HPC resources.</span> + +<span class="sd">Generally, you should call an HPC function rather than the Slurm or Condor interface</span> +<span class="sd">directly. The HPC function then decides which interface to use, so that all the</span> +<span class="sd">other modules can use a single API rather than have to choose to use the Slurm or</span> +<span class="sd">Condor API.</span> + +<span class="sd">This class object is an extension to the population grid object</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">glob</span> +<span class="kn">import</span> <span class="nn">json</span> +<span class="kn">import</span> <span class="nn">os</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">now</span><span class="p">,</span> +<span class="p">)</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.slurm</span> <span class="kn">import</span> <span class="n">slurm</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.condor</span> <span class="kn">import</span> <span class="n">condor</span> + + +<div class="viewcode-block" id="HPC"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC">[docs]</a><span class="k">class</span> <span class="nc">HPC</span><span class="p">(</span><span class="n">condor</span><span class="p">,</span> <span class="n">slurm</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Extension to the population grid object that contains functionality to handle handle the Moe & distefano distributions</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the gridcode class</span> +<span class="sd"> """</span> + + <span class="n">condor</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + <span class="n">slurm</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> + +<div class="viewcode-block" id="HPC.HPC_njobs"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_njobs">[docs]</a> <span class="k">def</span> <span class="nf">HPC_njobs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the number of jobs this HPC jobs will use, as an int.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_njobs"</span><span class="p">]</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_njobs"</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">n</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="n">n</span><span class="p">)</span></div> + +<div class="viewcode-block" id="HPC.HPC_make_joiningfile"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_make_joiningfile">[docs]</a> <span class="k">def</span> <span class="nf">HPC_make_joiningfile</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">hpc_jobid</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">hpc_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">n</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">overwrite</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">error_on_overwrite</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to make the joiningfile file that contains the filenames of results from each job. When all these exist, we can join.</span> + +<span class="sd"> Note: you normally don't need to set any of the option arguments.</span> + +<span class="sd"> Args:</span> +<span class="sd"> hpc_jobid : the job ID number, or self.HPC_jobID_tuple()[0] if None (default=None).</span> +<span class="sd"> hpc_dir : the HPC directory, or self.HPC_dir() if None (default=None).</span> +<span class="sd"> n : the number of jobs, or self.HPC_njobs() if None (default=None).</span> +<span class="sd"> overwrite : if True, overwrite an existing joiningfile (default=False)</span> +<span class="sd"> error_on_overwite : if True, and we try to overwrite, issue and error and exit (default=False)</span> + +<span class="sd"> Returns:</span> +<span class="sd"> True if the file is made, False otherwise.</span> + +<span class="sd"> """</span> + + <span class="c1"># defaults</span> + <span class="k">if</span> <span class="n">hpc_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">hpc_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_dir</span><span class="p">()</span> + <span class="k">if</span> <span class="n">n</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_njobs</span><span class="p">()</span> + <span class="k">if</span> <span class="n">hpc_jobid</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">hpc_jobid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_jobID_tuple</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> + + <span class="c1"># make path and filename</span> + <span class="n">prefix</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">hpc_dir</span><span class="p">,</span> <span class="s2">"results"</span><span class="p">)</span> + <span class="n">file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">prefix</span><span class="p">,</span> <span class="n">hpc_jobid</span> <span class="o">+</span> <span class="s2">".all"</span><span class="p">)</span> + + <span class="c1"># make the output before checking anything, we do</span> + <span class="c1"># this to remove any asynchronicity</span> + <span class="n">lines</span> <span class="o">=</span> <span class="p">[]</span> + <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job_id_range</span><span class="p">():</span> + <span class="n">lines</span> <span class="o">+=</span> <span class="p">[</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="n">prefix</span><span class="p">,</span> <span class="s2">"</span><span class="si">{hpc_jobid}</span><span class="s2">.</span><span class="si">{i}</span><span class="s2">.gz</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">hpc_jobid</span><span class="o">=</span><span class="n">hpc_jobid</span><span class="p">,</span> <span class="n">i</span><span class="o">=</span><span class="n">i</span><span class="p">)</span> + <span class="p">)</span> + <span class="p">]</span> + <span class="n">string</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> + + <span class="c1"># check the joiningfile doesn't exist</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">overwrite</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">file</span><span class="p">):</span> + <span class="c1"># file already exists</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Cannot make joiningfile at </span><span class="si">{file}</span><span class="s2"> because it already exists, instead I am waiting for it to be unlocked."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">file</span><span class="o">=</span><span class="n">file</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">wait_for_unlock</span><span class="p">(</span><span class="n">file</span><span class="p">)</span> + <span class="n">joinfiles</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_load_joinfiles_list</span><span class="p">(</span><span class="n">joinlist</span><span class="o">=</span><span class="n">file</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Unlocked and got </span><span class="si">{}</span><span class="s2"> should be </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">len</span><span class="p">(</span><span class="n">joinfiles</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_njobs</span><span class="p">()</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="c1"># perhaps exit here? (e.g. for debugging)</span> + <span class="k">if</span> <span class="n">error_on_overwrite</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + <span class="n">x</span> <span class="o">=</span> <span class="kc">False</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># open the file, but locked so we have first unique access</span> + <span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">lock</span><span class="p">)</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locked_open_for_write</span><span class="p">(</span><span class="n">file</span><span class="p">)</span> + + <span class="c1"># write to it if we are first to obtain unique access</span> + <span class="k">if</span> <span class="n">lock</span> <span class="ow">and</span> <span class="n">f</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Making joiningfile list range (0,</span><span class="si">{}</span><span class="s2">) at </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">file</span><span class="p">))</span> + <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">string</span><span class="p">)</span> + <span class="n">f</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span> + <span class="n">os</span><span class="o">.</span><span class="n">fsync</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">fileno</span><span class="p">())</span> + <span class="n">x</span> <span class="o">=</span> <span class="kc">True</span> + <span class="bp">self</span><span class="o">.</span><span class="n">locked_close</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">lock</span><span class="p">)</span> + <span class="n">os</span><span class="o">.</span><span class="n">sync</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">file</span><span class="p">)</span> + + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Checking joiningfile </span><span class="si">{}</span><span class="s2"> length (size = </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">file</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">getsize</span><span class="p">(</span><span class="n">file</span><span class="p">)</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="n">joinfiles</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_load_joinfiles_list</span><span class="p">(</span><span class="n">joinlist</span><span class="o">=</span><span class="n">file</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Got </span><span class="si">{}</span><span class="s2"> should be </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">joinfiles</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_njobs</span><span class="p">()))</span> + + <span class="k">else</span><span class="p">:</span> + <span class="n">x</span> <span class="o">=</span> <span class="kc">False</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Joiningfile failed to get lock: waiting for it to be unlocked"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">wait_for_unlock</span><span class="p">(</span><span class="n">file</span><span class="p">)</span> + <span class="k">return</span> <span class="n">x</span></div> + +<div class="viewcode-block" id="HPC.HPC_joinlist"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_joinlist">[docs]</a> <span class="k">def</span> <span class="nf">HPC_joinlist</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">joinlist</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the default HPC joinlist file.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">joinlist</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">joinlist</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"joinlist"</span><span class="p">]</span> + <span class="k">return</span> <span class="n">joinlist</span></div> + +<div class="viewcode-block" id="HPC.HPC_load_joinfiles_list"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_load_joinfiles_list">[docs]</a> <span class="k">def</span> <span class="nf">HPC_load_joinfiles_list</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">joinlist</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to load in the list of files we should join, and return it.</span> + +<span class="sd"> If grid_options['HPC_rebuild_joinlist'] is True, we rebuild it.</span> +<span class="sd"> """</span> + + <span class="n">prefix</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">HPC_dir</span><span class="p">(),</span> <span class="s2">"results"</span><span class="p">)</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"HPC_rebuild_joinlist"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="c1"># we should rebuild the joinlist from the</span> + <span class="c1"># files we find at the prefix directory</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Rebuild joinlist from existing files"</span><span class="p">)</span> + <span class="n">joinlist</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">prefix</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"/*.gz"</span><span class="p">)</span> + <span class="k">return</span> <span class="n">joinlist</span> + + <span class="n">joinlist</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_joinlist</span><span class="p">(</span><span class="n">joinlist</span><span class="o">=</span><span class="n">joinlist</span><span class="p">)</span> + <span class="k">try</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">wait_for_unlock</span><span class="p">(</span><span class="n">joinlist</span><span class="p">)</span> + <span class="n">f</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">joinlist</span><span class="p">,</span> <span class="s2">"r"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> + <span class="n">joinlist</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span> + <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + + <span class="k">if</span> <span class="kc">False</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"HPC_load_joinfiles_list read joinlist </span><span class="si">{joinlist}</span><span class="s2"> -> gave file joinlist of length </span><span class="si">{len_joinlist}</span><span class="s2"> with contents </span><span class="si">{joinlist}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">joinlist</span><span class="o">=</span><span class="n">joinlist</span><span class="p">,</span> <span class="n">len_joinlist</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">joinlist</span><span class="p">)</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Failed to open joinlist at </span><span class="si">{joinlist}</span><span class="s2"> : </span><span class="si">{e}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">joinlist</span><span class="o">=</span><span class="n">joinlist</span><span class="p">,</span> <span class="n">e</span><span class="o">=</span><span class="n">e</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="k">return</span> <span class="n">joinlist</span></div> + +<div class="viewcode-block" id="HPC.HPC_join_from_files"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_join_from_files">[docs]</a> <span class="k">def</span> <span class="nf">HPC_join_from_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">newobj</span><span class="p">,</span> <span class="n">joinfiles</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Merge the results from the list joinfiles into newobj.</span> +<span class="sd"> """</span> + <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">joinfiles</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Join data in"</span><span class="p">,</span> <span class="n">file</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">merge_populations_from_file</span><span class="p">(</span><span class="n">newobj</span><span class="p">,</span> <span class="n">file</span><span class="p">)</span> + <span class="k">return</span> <span class="n">newobj</span></div> + +<div class="viewcode-block" id="HPC.HPC_can_join"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_can_join">[docs]</a> <span class="k">def</span> <span class="nf">HPC_can_join</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">joinfiles</span><span class="p">,</span> <span class="n">joiningfile</span><span class="p">,</span> <span class="n">vb</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Check the joinfiles to make sure they all exist</span> +<span class="sd"> and their .saved equivalents also exist</span> +<span class="sd"> """</span> + + <span class="nb">print</span><span class="p">(</span><span class="s2">"HPC check if we can join at </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">now</span><span class="p">()))</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"HPC_force_join"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">joiningfile</span><span class="p">):</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"cannot join : joiningfile exists at </span><span class="si">{}</span><span class="s2"> (check 1)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">joiningfile</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">return</span> <span class="kc">False</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"joiningfile (at </span><span class="si">{}</span><span class="s2">) does not exist"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">joiningfile</span><span class="p">))</span> + + <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">joinfiles</span><span class="p">:</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"check for </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">file</span><span class="p">))</span> + + <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">file</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s1">'cannot join : file "</span><span class="si">{}</span><span class="s1">" does not exist'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">file</span><span class="p">))</span> + <span class="k">return</span> <span class="kc">False</span> + + <span class="n">savedfile</span> <span class="o">=</span> <span class="n">file</span> <span class="o">+</span> <span class="s2">".saved"</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"check for </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">savedfile</span><span class="p">))</span> + + <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">savedfile</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s1">'cannot join : savedfile "</span><span class="si">{}</span><span class="s1">" does not exist'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">savedfile</span><span class="p">)</span> + <span class="p">)</span> + <span class="k">return</span> <span class="kc">False</span> + + <span class="c1"># found both files</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"found </span><span class="si">{}</span><span class="s2"> and </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">savedfile</span><span class="p">))</span> + + <span class="c1"># check for joiningfile again</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"HPC_force_join"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Forcing join because HPC_force_join is set"</span><span class="p">)</span> + <span class="n">x</span> <span class="o">=</span> <span class="kc">True</span> + <span class="k">elif</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">joiningfile</span><span class="p">):</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"cannot join: joiningfile exists at </span><span class="si">{}</span><span class="s2"> (check 2)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">joiningfile</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="n">x</span> <span class="o">=</span> <span class="kc">False</span> + <span class="k">elif</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"joiningfile at </span><span class="si">{}</span><span class="s2"> does not exist : can join"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">joiningfile</span><span class="p">))</span> + <span class="n">x</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"returning </span><span class="si">{}</span><span class="s2"> from HPC_can_join()"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> + + <span class="k">return</span> <span class="n">x</span></div> + +<div class="viewcode-block" id="HPC.HPC_job"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_job">[docs]</a> <span class="k">def</span> <span class="nf">HPC_job</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return True if we're running an HPC (Slurm or Condor) job, False otherwise.</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span></div> + +<div class="viewcode-block" id="HPC.HPC_job_task"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_job_task">[docs]</a> <span class="k">def</span> <span class="nf">HPC_job_task</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the HPC task number, which is 1 when setting</span> +<span class="sd"> up and running the scripts, 2 when joining data.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">x</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">return</span> <span class="n">x</span></div> + +<div class="viewcode-block" id="HPC.HPC_job_type"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_job_type">[docs]</a> <span class="k">def</span> <span class="nf">HPC_job_type</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return a string telling us the type of an HPC job, i.e.</span> +<span class="sd"> "slurm", "condor" or "None".</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">hpc_type</span> <span class="o">=</span> <span class="s2">"slurm"</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">hpc_type</span> <span class="o">=</span> <span class="s2">"condor"</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">hpc_type</span> <span class="o">=</span> <span class="s2">"None"</span> + <span class="k">return</span> <span class="n">hpc_type</span></div> + +<div class="viewcode-block" id="HPC.HPC_jobID"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_jobID">[docs]</a> <span class="k">def</span> <span class="nf">HPC_jobID</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return an HPC (Slurm or Condor) job id in the form of a string, x.y. Returns None if not an HPC job.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">hpc_jobid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">slurmID</span><span class="p">()</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">hpc_jobid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">condorID</span><span class="p">()</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># not an HPC job</span> + <span class="n">hpc_jobid</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">return</span> <span class="n">hpc_jobid</span></div> + +<div class="viewcode-block" id="HPC.HPC_jobID_tuple"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_jobID_tuple">[docs]</a> <span class="k">def</span> <span class="nf">HPC_jobID_tuple</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Return the job ID as a tuple of ints, (x,y), or (None,None) on failure</span> +<span class="sd"> """</span> + + <span class="n">hpc_jobid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_jobID</span><span class="p">()</span> + + <span class="k">if</span> <span class="n">hpc_jobid</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">hpc_jobid</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"None"</span><span class="p">):</span> + <span class="n">split_hpc_jobid</span> <span class="o">=</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">split_hpc_jobid</span> <span class="o">=</span> <span class="n">hpc_jobid</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"."</span><span class="p">)</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">split_hpc_jobid</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span> + <span class="n">split_hpc_jobid</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">split_hpc_jobid</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span> + <span class="n">split_hpc_jobid</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">return</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">split_hpc_jobid</span><span class="p">)</span></div> + +<div class="viewcode-block" id="HPC.HPC_set_status"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_set_status">[docs]</a> <span class="k">def</span> <span class="nf">HPC_set_status</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">string</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Set the appropriate HPC job (Condor or Slurm) status file to whatever is given in string.</span> + +<span class="sd"> Arguments:</span> +<span class="sd"> string : the new contents of the status file</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_slurm_status</span><span class="p">(</span><span class="n">string</span><span class="p">)</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_condor_status</span><span class="p">(</span><span class="n">string</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">pass</span></div> + +<div class="viewcode-block" id="HPC.HPC_get_status"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_get_status">[docs]</a> <span class="k">def</span> <span class="nf">HPC_get_status</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">job_id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">job_index</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">hpc_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Get and return the appropriate HPC job (Condor or Slurm) status string for this job (or, if given, the job at id.index)</span> + +<span class="sd"> Args:</span> +<span class="sd"> hpc_dir : optional HPC run directory. If not set, the default (e.g. slurm_dir or condor_dir)</span> +<span class="sd"> is used.</span> +<span class="sd"> job_id,job_index : the id and index of the job to be queried</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">status</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_slurm_status</span><span class="p">(</span> + <span class="n">jobid</span><span class="o">=</span><span class="n">job_id</span><span class="p">,</span> <span class="n">jobarrayindex</span><span class="o">=</span><span class="n">job_index</span><span class="p">,</span> <span class="n">slurm_dir</span><span class="o">=</span><span class="n">hpc_dir</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">status</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_condor_status</span><span class="p">(</span> + <span class="n">ClusterID</span><span class="o">=</span><span class="n">job_id</span><span class="p">,</span> <span class="n">Process</span><span class="o">=</span><span class="n">job_index</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="n">hpc_dir</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">status</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">return</span> <span class="n">status</span></div> + +<div class="viewcode-block" id="HPC.HPC_dirs"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_dirs">[docs]</a> <span class="k">def</span> <span class="nf">HPC_dirs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return a list of directories required for this HPC job.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">dirs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">slurm_dirs</span><span class="p">()</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">dirs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">condor_dirs</span><span class="p">()</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">dirs</span> <span class="o">=</span> <span class="p">[]</span> + <span class="k">return</span> <span class="n">dirs</span></div> + +<div class="viewcode-block" id="HPC.HPC_grid"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_grid">[docs]</a> <span class="k">def</span> <span class="nf">HPC_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">makejoiningfile</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> <span class="c1"># pragma: no cover</span> + <span class="sd">"""</span> +<span class="sd"> Function to call the appropriate HPC grid function</span> +<span class="sd"> (e.g. Slurm or Condor) and return what it returns.</span> + +<span class="sd"> Args:</span> +<span class="sd"> makejoiningfile : if True, and we're the first job with self.HPC_task() == 2, we build the joiningfile. (default=True) This option exists in case you don't want to overwrite an existing joiningfile, or want to build it in another way (e.g. in the HPC scripts).</span> + +<span class="sd"> TODO: Exclude this function from testing for now</span> +<span class="sd"> TODO: Comment this function better</span> +<span class="sd"> """</span> + + <span class="n">jobid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_jobID_tuple</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> + + <span class="c1"># give some current status about the HPC run</span> + <span class="bp">self</span><span class="o">.</span><span class="n">HPC_dump_status</span><span class="p">(</span><span class="s2">"HPC grid before"</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">makejoiningfile</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job_task</span><span class="p">()</span> <span class="o">==</span> <span class="mi">2</span> <span class="ow">and</span> <span class="n">jobid</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">HPC_make_joiningfile</span><span class="p">()</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">slurm_grid</span><span class="p">()</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">condor_grid</span><span class="p">()</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">x</span> <span class="o">=</span> <span class="kc">None</span> <span class="c1"># should not happen</span> + + <span class="c1"># give some current status about the HPC run</span> + <span class="bp">self</span><span class="o">.</span><span class="n">HPC_dump_status</span><span class="p">(</span><span class="s2">"HPC grid after"</span><span class="p">)</span> + + <span class="k">return</span> <span class="n">x</span></div> + +<div class="viewcode-block" id="HPC.HPC_check_requirements"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_check_requirements">[docs]</a> <span class="k">def</span> <span class="nf">HPC_check_requirements</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to check HPC option requirements have been met. Returns a tuple: (True,"") if all is ok, (False,<warning string>) otherwise.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">slurm_check_requirements</span><span class="p">()</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">condor_check_requirements</span><span class="p">()</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">t</span> <span class="o">=</span> <span class="p">(</span><span class="kc">True</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> + <span class="k">return</span> <span class="n">t</span></div> + +<div class="viewcode-block" id="HPC.HPC_id_filename"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_id_filename">[docs]</a> <span class="k">def</span> <span class="nf">HPC_id_filename</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> HPC jobs have a filename in their directory which specifies the job id. This function returns the contents of that file as a string, or None on failure.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">filename</span> <span class="o">=</span> <span class="s2">"jobid"</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">filename</span> <span class="o">=</span> <span class="s2">"ClusterID"</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">filename</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">return</span> <span class="n">filename</span></div> + +<div class="viewcode-block" id="HPC.HPC_id_from_dir"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_id_from_dir">[docs]</a> <span class="k">def</span> <span class="nf">HPC_id_from_dir</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hpc_dir</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the ID of an HPC run given its (already existing) directory.</span> +<span class="sd"> """</span> + + <span class="n">filename</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_id_filename</span><span class="p">()</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">filename</span><span class="p">:</span> + <span class="k">return</span> <span class="kc">None</span> + + <span class="n">file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">hpc_dir</span><span class="p">,</span> <span class="n">filename</span><span class="p">)</span> + <span class="n">f</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="s2">"r"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">f</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Error: could not open </span><span class="si">{file}</span><span class="s2"> to read the HPC jobid of the directory </span><span class="si">{hpc_dir}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">file</span><span class="o">=</span><span class="n">file</span><span class="p">,</span> <span class="n">hpc_dir</span><span class="o">=</span><span class="n">hpc_dir</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="n">oldjobid</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">oldjobid</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Error: could not find jobid in </span><span class="si">{hpc_dir}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">hpc_dir</span><span class="o">=</span><span class="n">hpc_dir</span><span class="p">))</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="k">return</span> <span class="n">oldjobid</span></div> + +<div class="viewcode-block" id="HPC.HPC_restore"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_restore">[docs]</a> <span class="k">def</span> <span class="nf">HPC_restore</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Set grid_options['restore_from_snapshot_file'] so that we restore data from existing</span> +<span class="sd"> an HPC run if self.grid_options[hpc_job_type+'_restart_dir'], where hpc_job_type is "slurm" or "condor",</span> +<span class="sd"> is provided, otherwise do nothing. This only works if grid_options[hpc_job_type] == self.HPC_job_task() == 2, which is</span> +<span class="sd"> the run-grid stage of the process.</span> +<span class="sd"> """</span> + + <span class="n">hpc_job_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job_type</span><span class="p">()</span> + <span class="k">if</span> <span class="n">hpc_job_type</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="k">return</span> + + <span class="n">key</span> <span class="o">=</span> <span class="n">hpc_job_type</span> <span class="o">+</span> <span class="s2">"_restart_dir"</span> + <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">:</span> + <span class="k">return</span> + + <span class="c1"># get restart directory</span> + <span class="n">hpc_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">hpc_job_type</span> <span class="o">+</span> <span class="s2">"_restart_dir"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">hpc_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="k">return</span> + + <span class="c1"># get HPC job index</span> + <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_jobID_tuple</span><span class="p">()[</span><span class="mi">1</span><span class="p">]</span> + <span class="k">if</span> <span class="n">index</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="k">return</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job_task</span><span class="p">()</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> <span class="c1"># (same as) self.grid_options[hpc_job_type] == 2:</span> + <span class="n">old_id</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_id_from_dir</span><span class="p">(</span><span class="n">hpc_dir</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Restart from hpc_dir </span><span class="si">{hpc_dir}</span><span class="s2"> which was has (old) ID </span><span class="si">{old_id}</span><span class="s2">, we are job index </span><span class="si">{index}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">hpc_dir</span><span class="o">=</span><span class="n">hpc_dir</span><span class="p">,</span> <span class="n">old_id</span><span class="o">=</span><span class="n">old_id</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="n">index</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1"># check status: if "finished", we don't have to do anything</span> + <span class="n">status</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_get_status</span><span class="p">(</span><span class="n">hpc_dir</span><span class="o">=</span><span class="n">hpc_dir</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">status</span> <span class="o">==</span> <span class="s2">"finished"</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Status is finished, cannot and do not need to restart."</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> + + <span class="n">file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="nb">dir</span><span class="p">,</span> <span class="s2">"snapshots"</span><span class="p">,</span> <span class="s2">"</span><span class="si">{id}</span><span class="s2">.</span><span class="si">{index}</span><span class="s2">.gz"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">old_id</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="n">index</span><span class="p">)</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">file</span><span class="p">):</span> + <span class="c1"># have data from which we can restore, set it in</span> + <span class="c1"># the appropriate grid option</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Restore this run from snapshot </span><span class="si">{file}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">file</span><span class="o">=</span><span class="n">file</span><span class="p">))</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"restore_from_snapshot_file"</span><span class="p">]</span> <span class="o">=</span> <span class="n">file</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># no snapshot: so no need to restore, just exit</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Expected snapshot at </span><span class="si">{file}</span><span class="s2"> but none was found"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">file</span><span class="o">=</span><span class="n">file</span><span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> + <span class="k">return</span></div> + +<div class="viewcode-block" id="HPC.HPC_join_previous"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_join_previous">[docs]</a> <span class="k">def</span> <span class="nf">HPC_join_previous</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to join previously generated datasets.</span> +<span class="sd"> """</span> + <span class="c1"># check that our job has finished</span> + <span class="n">status</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_get_status</span><span class="p">()</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Job status"</span><span class="p">,</span> <span class="n">status</span><span class="p">)</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"HPC_force_join"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">status</span> <span class="o">!=</span> <span class="s2">"finished"</span><span class="p">:</span> + <span class="c1"># job did not finish : save a snapshot</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"This job did not finish (status is </span><span class="si">{status}</span><span class="s2">) : cannot join"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">status</span><span class="o">=</span><span class="n">status</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># our job has finished</span> + <span class="n">HPC_status</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_status</span><span class="p">()</span> + + <span class="c1"># HPC_queue_stats = self.HPC_queue_stats()</span> + + <span class="k">if</span> <span class="n">HPC_status</span><span class="p">[</span><span class="s2">"status"</span><span class="p">][</span><span class="s2">"finished"</span><span class="p">]</span> <span class="o">!=</span> <span class="n">HPC_status</span><span class="p">[</span><span class="s2">"njobs"</span><span class="p">]:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"HPC_status reports </span><span class="si">{}</span><span class="s2"> finished jobs out of </span><span class="si">{}</span><span class="s2">. We cannot join because not all the jobs are finished. Exiting."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">HPC_status</span><span class="p">[</span><span class="s2">"status"</span><span class="p">][</span><span class="s2">"finished"</span><span class="p">],</span> <span class="n">HPC_status</span><span class="p">[</span><span class="s2">"njobs"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> + + <span class="n">joinfiles</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_load_joinfiles_list</span><span class="p">()</span> + <span class="n">joiningfile</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_path</span><span class="p">(</span><span class="s2">"joining"</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Joinfile list n=</span><span class="si">{n}</span><span class="s2"> (should be </span><span class="si">{m}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">n</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">joinfiles</span><span class="p">),</span> <span class="n">m</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">HPC_njobs</span><span class="p">()</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Joingingfile path : "</span><span class="p">,</span> <span class="n">joiningfile</span><span class="p">)</span> + + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">joinfiles</span><span class="p">)</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_njobs</span><span class="p">():</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Number of joinfiles != njobs : this is wrong, exiting."</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_can_join</span><span class="p">(</span><span class="n">joinfiles</span><span class="p">,</span> <span class="n">joiningfile</span><span class="p">,</span> <span class="n">vb</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> + <span class="c1"># join object files</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"We can join"</span><span class="p">)</span> + <span class="k">try</span><span class="p">:</span> + <span class="c1"># touch joiningfile</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"HPC_force_join"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Making joiningfile at </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">joiningfile</span><span class="p">))</span> + <span class="bp">self</span><span class="o">.</span><span class="n">HPC_touch</span><span class="p">(</span><span class="n">joiningfile</span><span class="p">)</span> + <span class="k">try</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Calling HPC_join_from_files()"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">HPC_join_from_files</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">joinfiles</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Join gave exception"</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> + <span class="c1"># disable analytics calculations : use the</span> + <span class="c1"># values we just loaded</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"do_analytics"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> + <span class="k">return</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"pass </span><span class="si">{}</span><span class="s2">"</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> + <span class="k">pass</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"cannot join : other tasks are not yet finished</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Finished this job : exiting"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span></div> + +<div class="viewcode-block" id="HPC.HPC_path"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_path">[docs]</a> <span class="k">def</span> <span class="nf">HPC_path</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to file the filename of this HPC job's file at path.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">p</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">slurmpath</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">p</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">condorpath</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">p</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">return</span> <span class="n">p</span></div> + +<div class="viewcode-block" id="HPC.HPC_snapshot_filename"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_snapshot_filename">[docs]</a> <span class="k">def</span> <span class="nf">HPC_snapshot_filename</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return an HPC job's snapshot filename.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job</span><span class="p">():</span> + <span class="n">file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">HPC_dir</span><span class="p">,</span> <span class="s2">"snapshots"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_jobID</span><span class="p">()</span> <span class="o">+</span> <span class="s2">".gz"</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">file</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">return</span> <span class="n">file</span></div> + +<div class="viewcode-block" id="HPC.HPC_dir"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_dir">[docs]</a> <span class="k">def</span> <span class="nf">HPC_dir</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return an HPC job's directory.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">]</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">d</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">return</span> <span class="n">d</span></div> + +<div class="viewcode-block" id="HPC.HPC_touch"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_touch">[docs]</a> <span class="k">def</span> <span class="nf">HPC_touch</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">string</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to touch the file at filename, put into it the job number</span> +<span class="sd"> and (if given) the string passed in.</span> +<span class="sd"> """</span> + + <span class="k">try</span><span class="p">:</span> + <span class="n">f</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">f</span><span class="p">:</span> + <span class="n">job</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_jobID</span><span class="p">()</span> + <span class="n">jobtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job_type</span><span class="p">()</span> + <span class="k">if</span> <span class="n">job</span><span class="p">:</span> + <span class="n">s</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">job</span><span class="p">)</span> + <span class="k">if</span> <span class="n">jobtype</span><span class="p">:</span> + <span class="n">s</span> <span class="o">+=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">jobtype</span><span class="p">)</span> + <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">s</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="k">if</span> <span class="n">string</span><span class="p">:</span> + <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">string</span><span class="p">)</span> + <span class="n">f</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span> + <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> + <span class="k">except</span><span class="p">:</span> + <span class="k">pass</span></div> + +<div class="viewcode-block" id="HPC.HPC_status"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_status">[docs]</a> <span class="k">def</span> <span class="nf">HPC_status</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Return a dict of useful information about the current status</span> +<span class="sd"> of this HPC run.</span> +<span class="sd"> """</span> + <span class="n">d</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># returned</span> + <span class="n">_id</span><span class="p">,</span> <span class="n">_index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_jobID_tuple</span><span class="p">()</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"job_id"</span><span class="p">]</span> <span class="o">=</span> <span class="n">_id</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"job_index"</span><span class="p">]</span> <span class="o">=</span> <span class="n">_index</span> + <span class="k">if</span> <span class="n">_id</span> <span class="ow">and</span> <span class="n">_index</span><span class="p">:</span> + <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_njobs</span><span class="p">()</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"njobs"</span><span class="p">]</span> <span class="o">=</span> <span class="n">n</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"job_task"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job_task</span><span class="p">()</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"job_type"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job_type</span><span class="p">()</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"job_status"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_get_status</span><span class="p">()</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"dir"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_dir</span><span class="p">()</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"dirs"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_dirs</span><span class="p">()</span> + + <span class="c1"># get fellow jobs' status</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"status"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"joblist"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="c1"># default types</span> + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"running"</span><span class="p">,</span> <span class="s2">"starting"</span><span class="p">,</span> <span class="s2">"finishing"</span><span class="p">,</span> <span class="s2">"finished"</span><span class="p">,</span> <span class="s2">"killed"</span><span class="p">]:</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"status"</span><span class="p">][</span><span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"joblist"</span><span class="p">][</span><span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> + + <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job_id_range</span><span class="p">():</span> + <span class="n">s</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_get_status</span><span class="p">(</span><span class="n">job_id</span><span class="o">=</span><span class="n">_id</span><span class="p">,</span> <span class="n">job_index</span><span class="o">=</span><span class="n">i</span><span class="p">)</span> + <span class="c1">#print("HPC get job",_id,':',i," status=",s)</span> + <span class="k">if</span> <span class="n">s</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">s</span> <span class="o">=</span> <span class="s2">"unknown"</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">d</span><span class="p">[</span><span class="s2">"status"</span><span class="p">]:</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"status"</span><span class="p">][</span><span class="n">s</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"status"</span><span class="p">][</span><span class="n">s</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">d</span><span class="p">[</span><span class="s2">"joblist"</span><span class="p">]:</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"joblist"</span><span class="p">][</span><span class="n">s</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">_id</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"."</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">d</span><span class="p">[</span><span class="s2">"joblist"</span><span class="p">][</span><span class="n">s</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">_id</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"."</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)]</span> + + <span class="k">return</span> <span class="n">d</span></div> + +<div class="viewcode-block" id="HPC.HPC_dump_status"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_dump_status">[docs]</a> <span class="k">def</span> <span class="nf">HPC_dump_status</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">string</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to print the status of the HPC grid</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">string</span><span class="p">:</span> + <span class="n">string</span> <span class="o">=</span> <span class="s2">""</span> + + <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_status</span><span class="p">()</span> + + <span class="nb">print</span><span class="p">(</span><span class="s2">"############################################################"</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"HPC job status "</span> <span class="o">+</span> <span class="n">string</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">))</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"############################################################"</span><span class="p">)</span></div> + +<div class="viewcode-block" id="HPC.HPC_queue_stats"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_queue_stats">[docs]</a> <span class="k">def</span> <span class="nf">HPC_queue_stats</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="c1"># pragma: no cover</span> + <span class="sd">"""</span> +<span class="sd"> Function that returns the queue stats for the HPC grid</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">slurm_queue_stats</span><span class="p">()</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">condor_queue_stats</span><span class="p">()</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">x</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">return</span> <span class="n">x</span></div> + +<div class="viewcode-block" id="HPC.HPC_job_id_range"><a class="viewcode-back" href="../../../../population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_job_id_range">[docs]</a> <span class="k">def</span> <span class="nf">HPC_job_id_range</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_njobs</span><span class="p">()</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="k">return</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">n</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="k">return</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Called HPC_job_id_range when not running an HPC grid : you cannot do this."</span><span class="p">)</span> + <span class="k">raise</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.html new file mode 100644 index 0000000000000000000000000000000000000000..2cbea64e47b604d37d4f4c55446e86e0c9393c63 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.html @@ -0,0 +1,1339 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.Moe_di_Stefano_2017 — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.Moe_di_Stefano_2017</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.Moe_di_Stefano_2017</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">Module containing the functions to handle the Moe&Distrefano data</span> + +<span class="sd">This class object is an extension to the population grid object</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">os</span> +<span class="kn">import</span> <span class="nn">gc</span> +<span class="kn">import</span> <span class="nn">copy</span> +<span class="kn">import</span> <span class="nn">json</span> + +<span class="kn">import</span> <span class="nn">py_rinterpolate</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">verbose_print</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.dicts</span> <span class="kn">import</span> <span class="n">update_dicts</span><span class="p">,</span> <span class="n">normalize_dict</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.distribution_functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">Moecache</span><span class="p">,</span> + <span class="n">LOG_LN_CONVERTER</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.grid_options_defaults</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils</span> <span class="kn">import</span> <span class="n">moe_di_stefano_2017_data</span> + + +<div class="viewcode-block" id="Moe_di_Stefano_2017"><a class="viewcode-back" href="../../../../population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017">[docs]</a><span class="k">class</span> <span class="nc">Moe_di_Stefano_2017</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Extension to the population grid object that contains functionality to handle handle the Moe & distefano distributions</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the Moe_di_Stefano_2017 class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + +<div class="viewcode-block" id="Moe_di_Stefano_2017.set_moe_di_stefano_settings"><a class="viewcode-back" href="../../../../population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.set_moe_di_stefano_settings">[docs]</a> <span class="k">def</span> <span class="nf">set_moe_di_stefano_settings</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to set user input configurations for the Moe & di Stefano methods</span> + +<span class="sd"> If nothing is passed then we just use the default options</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="p">:</span> + <span class="n">options</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="c1"># Take the option dictionary that was given and override.</span> + <span class="n">options</span> <span class="o">=</span> <span class="n">update_dicts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">],</span> <span class="n">options</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">options</span><span class="p">)</span> + + <span class="c1"># Write options to a file</span> + <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> + <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> + <span class="s2">"moeopts.dat"</span><span class="p">,</span> + <span class="p">),</span> + <span class="s2">"w"</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> + <span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> + <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span> + <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">],</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div> + + <span class="k">def</span> <span class="nf">_load_moe_di_stefano_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to load the moe & di stefano data</span> +<span class="sd"> """</span> + + <span class="c1"># Only if the grid is loaded and Moecache contains information</span> + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_loaded_Moe2017_data"</span><span class="p">]:</span> <span class="c1"># and not Moecache:</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_Moe2017_JSON_data"</span><span class="p">]:</span> + <span class="c1"># Use the existing (perhaps modified) JSON data</span> + <span class="n">json_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_Moe2017_JSON_data"</span><span class="p">]</span> + + <span class="k">else</span><span class="p">:</span> + <span class="c1"># Load the JSON data from a file</span> + <span class="n">json_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_moe_di_stefano_dataset</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">],</span> + <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="p">)</span> + + <span class="c1"># entry of log10M1 is a list containing 1 dict.</span> + <span class="c1"># We can take the dict out of the list</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">],</span> <span class="nb">list</span><span class="p">):</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">]</span> <span class="o">=</span> <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + + <span class="c1"># save this data in case we want to modify it later</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_Moe2017_JSON_data"</span><span class="p">]</span> <span class="o">=</span> <span class="n">json_data</span> + + <span class="c1"># Get all the masses</span> + <span class="n">logmasses</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">logmasses</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"The table does not contain masses."</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Write to file</span> + <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> + <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> + <span class="s2">"moe.log"</span><span class="p">,</span> + <span class="p">),</span> + <span class="s2">"w"</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> + <span class="p">)</span> <span class="k">as</span> <span class="n">logfile</span><span class="p">:</span> + <span class="n">logfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"logâ‚â‚€Masses(M☉) </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logmasses</span><span class="p">))</span> + + <span class="c1"># Get all the periods and see if they are all consistently present</span> + <span class="n">logperiods</span> <span class="o">=</span> <span class="p">[]</span> + <span class="k">for</span> <span class="n">logmass</span> <span class="ow">in</span> <span class="n">logmasses</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">logperiods</span><span class="p">:</span> + <span class="n">logperiods</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> + <span class="n">dlog10P</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">logperiods</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">-</span> <span class="nb">float</span><span class="p">(</span><span class="n">logperiods</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> + + <span class="n">current_logperiods</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">])</span> + <span class="k">if</span> <span class="n">logperiods</span> <span class="o">!=</span> <span class="n">current_logperiods</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="p">(</span> + <span class="s2">"Period values are not consistent throughout the dataset logperiods = "</span> + <span class="o">+</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">logperiods</span><span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">Current periods = "</span> + <span class="o">+</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">current_logperiods</span><span class="p">)</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># log10period binwidth : of course this assumes a fixed</span> + <span class="c1"># binwidth, so we check for this too.</span> + <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">current_logperiods</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">):</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">dlog10P</span> <span class="o">==</span> <span class="p">(</span> + <span class="nb">float</span><span class="p">(</span><span class="n">current_logperiods</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> <span class="o">-</span> <span class="nb">float</span><span class="p">(</span><span class="n">current_logperiods</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> + <span class="p">):</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Period spacing is not consistent throughout the dataset"</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># save the logperiods list in the cache:</span> + <span class="c1"># this is used in the renormalization integration</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"logperiods"</span><span class="p">]</span> <span class="o">=</span> <span class="n">logperiods</span> + + <span class="c1"># Write to file</span> + <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> + <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">,</span> <span class="s2">"moe.log"</span><span class="p">),</span> + <span class="s2">"a"</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> + <span class="p">)</span> <span class="k">as</span> <span class="n">logfile</span><span class="p">:</span> + <span class="n">logfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"logâ‚â‚€Periods(days) </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logperiods</span><span class="p">))</span> + + <span class="c1"># Fill the global dict</span> + <span class="k">for</span> <span class="n">logmass</span> <span class="ow">in</span> <span class="n">logmasses</span><span class="p">:</span> + <span class="c1"># Create the multiplicity table</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"multiplicity_table"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"multiplicity_table"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> + + <span class="c1"># multiplicity as a function of primary mass</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"multiplicity_table"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> + <span class="p">[</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"f_multi"</span><span class="p">],</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"single star fraction"</span><span class="p">],</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"binary star fraction"</span><span class="p">],</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"triple/quad star fraction"</span><span class="p">],</span> + <span class="p">]</span> + <span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># a small log10period which we can shift just outside the</span> + <span class="c1"># table to force integration out there to zero</span> + <span class="n">epslog10P</span> <span class="o">=</span> <span class="mf">1e-8</span> <span class="o">*</span> <span class="n">dlog10P</span> + + <span class="c1">############################################################</span> + <span class="c1"># loop over either binary or triple-outer periods</span> + <span class="n">first</span> <span class="o">=</span> <span class="mi">1</span> + + <span class="c1"># Go over the periods</span> + <span class="k">for</span> <span class="n">logperiod</span> <span class="ow">in</span> <span class="n">logperiods</span><span class="p">:</span> + <span class="c1">############################################################</span> + <span class="c1"># distributions of binary and triple star fractions</span> + <span class="c1"># as a function of mass, period.</span> + <span class="c1">#</span> + <span class="c1"># Note: these should be per unit log10P, hence we</span> + <span class="c1"># divide by dlog10P</span> + + <span class="k">if</span> <span class="n">first</span><span class="p">:</span> + <span class="n">first</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="c1"># Create the multiplicity table</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"period_distributions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> + + <span class="c1">############################################################</span> + <span class="c1"># lower bound the period distributions to zero probability</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> + <span class="p">[</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logperiod</span><span class="p">)</span> <span class="o">-</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">dlog10P</span> <span class="o">-</span> <span class="n">epslog10P</span><span class="p">,</span> + <span class="mf">0.0</span><span class="p">,</span> + <span class="mf">0.0</span><span class="p">,</span> + <span class="p">]</span> + <span class="p">)</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> + <span class="p">[</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logperiod</span><span class="p">)</span> <span class="o">-</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">dlog10P</span><span class="p">,</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span> + <span class="s2">"normed_bin_frac_p_dist"</span> + <span class="p">]</span> + <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span> + <span class="s2">"normed_tripquad_frac_p_dist"</span> + <span class="p">]</span> + <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> + <span class="p">]</span> + <span class="p">)</span> + + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> + <span class="p">[</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logperiod</span><span class="p">),</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span> + <span class="s2">"normed_bin_frac_p_dist"</span> + <span class="p">]</span> + <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span> + <span class="s2">"normed_tripquad_frac_p_dist"</span> + <span class="p">]</span> + <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> + <span class="p">]</span> + <span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># distributions as a function of mass, period, q</span> + <span class="c1">#</span> + <span class="c1"># First, get a list of the qs given by Moe</span> + <span class="c1">#</span> + <span class="n">qs</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span><span class="s2">"q"</span><span class="p">])</span> + + <span class="c1"># Fill the data and 'normalise'</span> + <span class="n">qdata</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fill_data</span><span class="p">(</span> + <span class="n">qs</span><span class="p">,</span> <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span><span class="s2">"q"</span><span class="p">]</span> + <span class="p">)</span> + + <span class="c1"># Create the multiplicity table</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q_distributions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"q_distributions"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> + + <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">qs</span><span class="p">:</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"q_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> + <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> <span class="nb">float</span><span class="p">(</span><span class="n">logperiod</span><span class="p">),</span> <span class="nb">float</span><span class="p">(</span><span class="n">q</span><span class="p">),</span> <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]]</span> + <span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># eccentricity distributions as a function of mass, period, ecc</span> + <span class="n">eccs</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span><span class="s2">"e"</span><span class="p">])</span> + + <span class="c1"># Fill the data and 'normalise'</span> + <span class="n">ecc_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fill_data</span><span class="p">(</span> + <span class="n">eccs</span><span class="p">,</span> <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiod</span><span class="p">][</span><span class="s2">"e"</span><span class="p">]</span> + <span class="p">)</span> + + <span class="c1"># Create the multiplicity table</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc_distributions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"ecc_distributions"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> + + <span class="k">for</span> <span class="n">ecc</span> <span class="ow">in</span> <span class="n">eccs</span><span class="p">:</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"ecc_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> + <span class="p">[</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logperiod</span><span class="p">),</span> + <span class="nb">float</span><span class="p">(</span><span class="n">ecc</span><span class="p">),</span> + <span class="n">ecc_data</span><span class="p">[</span><span class="n">ecc</span><span class="p">],</span> + <span class="p">]</span> + <span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># upper bound the period distributions to zero probability</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> + <span class="p">[</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logperiods</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> + <span class="o">+</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">dlog10P</span><span class="p">,</span> <span class="c1"># TODO: why this shift? to center it?</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiods</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span> + <span class="s2">"normed_bin_frac_p_dist"</span> + <span class="p">]</span> + <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> + <span class="n">json_data</span><span class="p">[</span><span class="s2">"log10M1"</span><span class="p">][</span><span class="n">logmass</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="n">logperiods</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span> + <span class="s2">"normed_tripquad_frac_p_dist"</span> + <span class="p">]</span> + <span class="o">/</span> <span class="n">dlog10P</span><span class="p">,</span> + <span class="p">]</span> + <span class="p">)</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> + <span class="p">[</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logmass</span><span class="p">),</span> + <span class="nb">float</span><span class="p">(</span><span class="n">logperiods</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">dlog10P</span> <span class="o">+</span> <span class="n">epslog10P</span><span class="p">,</span> + <span class="mf">0.0</span><span class="p">,</span> + <span class="mf">0.0</span><span class="p">,</span> + <span class="p">]</span> + <span class="p">)</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Length period_distributions table: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">len</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"period_distributions"</span><span class="p">])</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Length multiplicity table: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">len</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"multiplicity_table"</span><span class="p">])</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Length q table: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">len</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"q_distributions"</span><span class="p">])</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Length ecc table: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">len</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"ecc_distributions"</span><span class="p">])</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Write to log file</span> + <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> + <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">with</span> <span class="nb">open</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"moe_distefano"</span><span class="p">),</span> + <span class="s2">"moecache.json"</span><span class="p">,</span> + <span class="p">),</span> + <span class="s2">"w"</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> + <span class="p">)</span> <span class="k">as</span> <span class="n">cache_filehandle</span><span class="p">:</span> + <span class="n">cache_filehandle</span><span class="o">.</span><span class="n">write</span><span class="p">(</span> + <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">Moecache</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> + <span class="p">)</span> + + <span class="c1"># Signal that the data has been loaded</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_loaded_Moe2017_data"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="k">def</span> <span class="nf">_set_moe_di_stefano_distributions</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to set the Moe & di Stefano distribution</span> +<span class="sd"> """</span> + + <span class="c1">############################################################</span> + <span class="c1"># first, the multiplicity, this is 1,2,3,4, ...</span> + <span class="c1"># for singles, binaries, triples, quadruples, ...</span> + + <span class="n">max_multiplicity</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_max_multiplicity</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"multiplicity_modulator"</span><span class="p">]</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Max multiplicity = </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">max_multiplicity</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1">######</span> + <span class="c1"># Setting up the grid variables</span> + + <span class="c1"># Multiplicity</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"multiplicity"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"multiplicity"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"multiplicity"</span><span class="p">,</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="n">max_multiplicity</span><span class="p">],</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_int(1, </span><span class="si">{n}</span><span class="s2">, </span><span class="si">{n}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="n">max_multiplicity</span><span class="p">),</span> + <span class="n">precode</span><span class="o">=</span><span class="s1">'self.grid_options["multiplicity"] = multiplicity; self.bse_options["multiplicity"] = multiplicity; options=</span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">condition</span><span class="o">=</span><span class="s2">"(</span><span class="si">{}</span><span class="s2">[int(multiplicity)-1] > 0)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"multiplicity_modulator"</span><span class="p">])</span> + <span class="p">),</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"discrete"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># always require M1, for all systems</span> + <span class="c1">#</span> + <span class="c1"># log-spaced m1 with given resolution</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"lnM_1"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"Primary mass"</span><span class="p">,</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="ow">or</span> <span class="s2">"self.const_linear(np.log(</span><span class="si">{}</span><span class="s2">), np.log(</span><span class="si">{}</span><span class="s2">), </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> + <span class="p">),</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> + <span class="s2">"np.log(</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="p">),</span> + <span class="s2">"np.log(</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> + <span class="p">),</span> + <span class="p">],</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dlnM_1"</span><span class="p">,</span> + <span class="n">precode</span><span class="o">=</span><span class="s1">'M_1 = np.exp(lnM_1); options["M_1"]=M_1'</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="s2">"self.Moe_di_Stefano_2017_pdf({{</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">}}, verbosity=self.grid_options['verbosity'])['total_probdens'] if multiplicity == 1 else 1"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">str</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]))[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> + <span class="s2">"'multiplicity': multiplicity"</span><span class="p">,</span> + <span class="s2">"'M_1': M_1"</span><span class="p">,</span> + <span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># Go to higher multiplicities</span> + <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> + <span class="c1"># binaries: period</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"log10per"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"orbital_period"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"log10(Orbital_Period)"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> + <span class="n">condition</span><span class="o">=</span><span class="s1">'(self.grid_options["multiplicity"] >= 2)'</span><span class="p">,</span> + <span class="n">branchpoint</span><span class="o">=</span><span class="mi">1</span> + <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">></span> <span class="mi">1</span> + <span class="k">else</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Signal here to put a branchpoint if we have a max multiplicity higher than 1.</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"(</span><span class="si">{}</span><span class="s2"> * dlog10per)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">LOG_LN_CONVERTER</span><span class="p">),</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="p">],</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span> + <span class="s2">"logP"</span> + <span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="ow">or</span> <span class="s2">"self.const_linear(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> + <span class="p">),</span> + <span class="n">precode</span><span class="o">=</span><span class="s2">"""orbital_period = 10.0**log10per</span> +<span class="s2">qmin=</span><span class="si">{}</span><span class="s2">/M_1</span> +<span class="s2">qmax=maximum_mass_ratio_for_RLOF(M_1, orbital_period)</span> +<span class="s2">"""</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"Mmin"</span><span class="p">]</span> + <span class="p">),</span> + <span class="p">)</span> <span class="c1"># TODO: change the maximum_mass_ratio_for_RLOF</span> + + <span class="c1"># binaries: mass ratio</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"q"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_2"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"Mass ratio"</span><span class="p">,</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"options['Mmin']/M_1"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"qmax"</span><span class="p">,</span> + <span class="p">],</span> + <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dq"</span><span class="p">,</span> + <span class="n">precode</span><span class="o">=</span><span class="s2">"""</span> +<span class="s2">M_2 = q * M_1</span> +<span class="s2">sep = calc_sep_from_period(M_1, M_2, orbital_period)</span> +<span class="s2"> """</span><span class="p">,</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> + <span class="ow">or</span> <span class="s2">"self.const_linear(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span> + <span class="k">else</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">/M_1"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"Mmin"</span><span class="p">]),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">])[</span><span class="mi">1</span><span class="p">]</span> + <span class="k">else</span> <span class="s2">"qmax"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># (optional) binaries: eccentricity</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"ecc"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"eccentricity"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"Eccentricity"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"decc"</span><span class="p">,</span> + <span class="n">precode</span><span class="o">=</span><span class="s2">"eccentricity=ecc"</span><span class="p">,</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> + <span class="mi">0</span> + <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="p">],</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span> + <span class="s2">"ecc"</span> + <span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="ow">or</span> <span class="s2">"self.const_linear(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> + <span class="mi">0</span> + <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> + <span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># Now for triples and quadruples</span> + <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">>=</span> <span class="mi">3</span><span class="p">:</span> + <span class="c1"># Triple: period</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"log10per2"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"orbital_period_triple"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"log10(Orbital_Period2)"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> + <span class="n">condition</span><span class="o">=</span><span class="s1">'(self.grid_options["multiplicity"] >= 3)'</span><span class="p">,</span> + <span class="n">branchpoint</span><span class="o">=</span><span class="mi">2</span> + <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">></span> <span class="mi">2</span> + <span class="k">else</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Signal here to put a branchpoint if we have a max multiplicity higher than 1.</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"(</span><span class="si">{}</span><span class="s2"> * dlog10per2)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">LOG_LN_CONVERTER</span><span class="p">),</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="p">],</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span> + <span class="s2">"logP"</span> + <span class="p">][</span><span class="mi">1</span><span class="p">]</span> + <span class="ow">or</span> <span class="s2">"self.const_linear(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="p">),</span> + <span class="n">precode</span><span class="o">=</span><span class="s2">"""orbital_period_triple = 10.0**log10per2</span> +<span class="s2">q2min=</span><span class="si">{}</span><span class="s2">/(M_1+M_2)</span> +<span class="s2">q2max=maximum_mass_ratio_for_RLOF(M_1+M_2, orbital_period_triple)</span> +<span class="s2"> """</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"Mmin"</span><span class="p">]</span> + <span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># Triples: mass ratio</span> + <span class="c1"># Note, the mass ratio is M_outer/M_inner</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"q2"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_3"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"Mass ratio outer/inner"</span><span class="p">,</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"options['Mmin']/(M_1+M_2)"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"q2max"</span><span class="p">,</span> + <span class="p">],</span> + <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dq2"</span><span class="p">,</span> + <span class="n">precode</span><span class="o">=</span><span class="s2">"""</span> +<span class="s2">M_3 = q2 * (M_1 + M_2)</span> +<span class="s2">sep2 = calc_sep_from_period((M_1+M_2), M_3, orbital_period_triple)</span> +<span class="s2">eccentricity2=0</span> +<span class="s2">"""</span><span class="p">,</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"samplerfuncs"</span><span class="p">][</span> + <span class="s2">"M"</span> + <span class="p">][</span><span class="mi">2</span><span class="p">]</span> + <span class="ow">or</span> <span class="s2">"self.const_linear(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"options['Mmin']/(M_1+M_2)"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"q2max"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">2</span><span class="p">],</span> + <span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># (optional) triples: eccentricity</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"ecc2"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"eccentricity2"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"Eccentricity of the triple"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"decc2"</span><span class="p">,</span> + <span class="n">precode</span><span class="o">=</span><span class="s2">"eccentricity2=ecc2"</span><span class="p">,</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> + <span class="mi">0</span> + <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="p">],</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span> + <span class="s2">"samplerfuncs"</span> + <span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> + <span class="ow">or</span> <span class="s2">"self.const_linear(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> + <span class="mi">0</span> + <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> + <span class="mi">1</span> + <span class="p">],</span> + <span class="p">),</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span> + <span class="c1"># Quadruple: period</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"log10per3"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"orbital_period_quadruple"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"log10(Orbital_Period3)"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> + <span class="n">condition</span><span class="o">=</span><span class="s1">'(self.grid_options["multiplicity"] >= 4)'</span><span class="p">,</span> + <span class="n">branchpoint</span><span class="o">=</span><span class="mi">3</span> + <span class="k">if</span> <span class="n">max_multiplicity</span> <span class="o">></span> <span class="mi">3</span> + <span class="k">else</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Signal here to put a branchpoint if we have a max multiplicity higher than 1.</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"(</span><span class="si">{}</span><span class="s2"> * dlog10per3)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">LOG_LN_CONVERTER</span><span class="p">),</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="p">],</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span> + <span class="s2">"samplerfuncs"</span> + <span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> + <span class="ow">or</span> <span class="s2">"self.const_linear(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"logP"</span><span class="p">][</span> + <span class="mi">2</span> + <span class="p">],</span> + <span class="p">),</span> + <span class="n">precode</span><span class="o">=</span><span class="s2">"""orbital_period_quadruple = 10.0**log10per3</span> +<span class="s2">q3min=</span><span class="si">{}</span><span class="s2">/(M_3)</span> +<span class="s2">q3max=maximum_mass_ratio_for_RLOF(M_3, orbital_period_quadruple)</span> +<span class="s2"> """</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"Mmin"</span><span class="p">]</span> + <span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># Quadruple: mass ratio : M_outer / M_inner</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"q3"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_4"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"Mass ratio outer low/outer high"</span><span class="p">,</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"options['Mmin']/(M_3)"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"q3max"</span><span class="p">,</span> + <span class="p">],</span> + <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dq3"</span><span class="p">,</span> + <span class="n">precode</span><span class="o">=</span><span class="s2">"""</span> +<span class="s2">M_4 = q3 * M_3</span> +<span class="s2">sep3 = calc_sep_from_period((M_3), M_4, orbital_period_quadruple)</span> +<span class="s2">eccentricity3=0</span> +<span class="s2">"""</span><span class="p">,</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span> + <span class="s2">"samplerfuncs"</span> + <span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">3</span><span class="p">]</span> + <span class="ow">or</span> <span class="s2">"self.const_linear(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"options['Mmin']/(M_3)"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"q"</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ranges"</span><span class="p">,</span> <span class="p">{})</span> + <span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"q3max"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"M"</span><span class="p">][</span><span class="mi">2</span><span class="p">],</span> + <span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># (optional) triples: eccentricity</span> + <span class="k">if</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> + <span class="o">></span> <span class="mi">0</span> + <span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"ecc3"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"eccentricity3"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"Eccentricity of the triple+quadruple/outer binary"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"centred"</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"decc3"</span><span class="p">,</span> + <span class="n">precode</span><span class="o">=</span><span class="s2">"eccentricity3=ecc3"</span><span class="p">,</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> + <span class="mi">0</span> + <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> + <span class="mi">1</span> + <span class="p">],</span> + <span class="p">],</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span> + <span class="s2">"samplerfuncs"</span> + <span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> + <span class="ow">or</span> <span class="s2">"self.const_linear(</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> + <span class="mi">0</span> + <span class="p">],</span> <span class="c1"># Just fail if not defined.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"ranges"</span><span class="p">][</span><span class="s2">"ecc"</span><span class="p">][</span> + <span class="mi">1</span> + <span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"resolutions"</span><span class="p">][</span> + <span class="s2">"ecc"</span> + <span class="p">][</span><span class="mi">2</span><span class="p">],</span> + <span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># Now we are at the last part.</span> + <span class="c1"># Here we should combine all the information that we calculate and update the options</span> + <span class="c1"># dictionary. This will then be passed to the Moe_di_Stefano_2017_pdf to calculate</span> + <span class="c1"># the real probability. The trick we use is to strip the options_dict as a string</span> + <span class="c1"># and add some keys to it:</span> + + <span class="n">updated_options</span> <span class="o">=</span> <span class="s2">"{{</span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">}}"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">str</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]))[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> + <span class="s1">'"multiplicity": multiplicity'</span><span class="p">,</span> + <span class="s1">'"M_1": M_1'</span><span class="p">,</span> + <span class="s1">'"M_2": M_2'</span><span class="p">,</span> + <span class="s1">'"M_3": M_3'</span><span class="p">,</span> + <span class="s1">'"M_4": M_4'</span><span class="p">,</span> + <span class="s1">'"P": orbital_period'</span><span class="p">,</span> + <span class="s1">'"P2": orbital_period_triple'</span><span class="p">,</span> + <span class="s1">'"P3": orbital_period_quadruple'</span><span class="p">,</span> + <span class="s1">'"ecc": eccentricity'</span><span class="p">,</span> + <span class="s1">'"ecc2": eccentricity2'</span><span class="p">,</span> + <span class="s1">'"ecc3": eccentricity3'</span><span class="p">,</span> + <span class="p">)</span> + + <span class="n">probdist_addition</span> <span class="o">=</span> <span class="s2">"self.Moe_di_Stefano_2017_pdf(</span><span class="si">{}</span><span class="s2">, verbosity=self.grid_options['verbosity'])['total_probdens']"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">updated_options</span> + <span class="p">)</span> + + <span class="c1"># and finally the probability calculator</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="bp">self</span><span class="o">.</span><span class="n">_last_grid_variable</span><span class="p">()][</span> + <span class="s2">"probdist"</span> + <span class="p">]</span> <span class="o">=</span> <span class="n">probdist_addition</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017: Added final call to the pdf function"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Signal that the MOE2017 grid has been set</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_set_Moe2017_grid"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="c1">################################################################################################</span> +<div class="viewcode-block" id="Moe_di_Stefano_2017.Moe_di_Stefano_2017"><a class="viewcode-back" href="../../../../population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.Moe_di_Stefano_2017">[docs]</a> <span class="k">def</span> <span class="nf">Moe_di_Stefano_2017</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to handle setting the user input settings,</span> +<span class="sd"> set up the data and load that into interpolators and</span> +<span class="sd"> then set the distribution functions</span> + +<span class="sd"> Takes a dictionary as its only argument</span> +<span class="sd"> """</span> + + <span class="n">default_options</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"apply settings"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> + <span class="s2">"setup grid"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> + <span class="s2">"load data"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> + <span class="s2">"clean cache"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> + <span class="s2">"clean load flag"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> + <span class="s2">"clean all"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> + <span class="p">}</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="p">:</span> + <span class="n">options</span> <span class="o">=</span> <span class="p">{}</span> + <span class="n">options</span> <span class="o">=</span> <span class="n">update_dicts</span><span class="p">(</span><span class="n">default_options</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span> + + <span class="c1"># clean cache?</span> + <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"clean all"</span><span class="p">]</span> <span class="ow">or</span> <span class="n">options</span><span class="p">[</span><span class="s2">"clean cache"</span><span class="p">]:</span> + <span class="n">Moecache</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span> + + <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"clean all"</span><span class="p">]</span> <span class="ow">or</span> <span class="n">options</span><span class="p">[</span><span class="s2">"clean load flag"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_loaded_Moe2017_data"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> + + <span class="c1"># Set the user input</span> + <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"apply settings"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">set_moe_di_stefano_settings</span><span class="p">(</span><span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> + + <span class="c1"># Load the data</span> + <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"load data"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_load_moe_di_stefano_data</span><span class="p">()</span> + + <span class="c1"># construct the grid here</span> + <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"setup grid"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_set_moe_di_stefano_distributions</span><span class="p">()</span></div> + + <span class="k">def</span> <span class="nf">_clean_interpolators</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to clean up the interpolators after a run</span> + +<span class="sd"> We look in the Moecache global variable for items that are interpolators.</span> +<span class="sd"> Should be called by the general cleanup function AND the thread cleanup function</span> +<span class="sd"> """</span> + + <span class="n">interpolator_keys</span> <span class="o">=</span> <span class="p">[]</span> + <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> + <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">):</span> + <span class="n">interpolator_keys</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">interpolator_keys</span><span class="p">:</span> + <span class="n">Moecache</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">destroy</span><span class="p">()</span> + <span class="k">del</span> <span class="n">Moecache</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="n">gc</span><span class="o">.</span><span class="n">collect</span><span class="p">()</span> + + <span class="k">def</span> <span class="nf">_calculate_multiplicity_fraction</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to calculate multiplicity fraction</span> + +<span class="sd"> Makes use of the self.bse_options['multiplicity'] value. If its not set, it will raise an error</span> + +<span class="sd"> grid_options['multiplicity_fraction_function'] will be checked for the choice</span> + +<span class="sd"> TODO: add option to put a manual binary fraction in here (solve via negative numbers being the functions)</span> +<span class="sd"> """</span> + + <span class="c1"># Just return 1 if no option has been chosen</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"multiplicity_fraction_function"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="s2">"None"</span><span class="p">]:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction."</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">return</span> <span class="mi">1</span> + + <span class="c1"># Raise an error if the multiplicity is not set</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">system_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"multiplicity"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Multiplicity value has not been set. When using a specific multiplicity fraction function please set the multiplicity"</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Go over the chosen options</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"multiplicity_fraction_function"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="s2">"Arenou2010"</span><span class="p">]:</span> + <span class="c1"># Arenou 2010 will be used</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"_calculate_multiplicity_fraction: Using Arenou 2010 to calculate multiplicity fractions"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> + + <span class="n">binary_fraction</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Arenou2010_binary_fraction</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">])</span> + <span class="n">multiplicity_fraction_dict</span> <span class="o">=</span> <span class="p">{</span> + <span class="mi">1</span><span class="p">:</span> <span class="mi">1</span> <span class="o">-</span> <span class="n">binary_fraction</span><span class="p">,</span> + <span class="mi">2</span><span class="p">:</span> <span class="n">binary_fraction</span><span class="p">,</span> + <span class="mi">3</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> + <span class="mi">4</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> + <span class="p">}</span> + + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"multiplicity_fraction_function"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="s2">"Raghavan2010"</span><span class="p">]:</span> + <span class="c1"># Raghavan 2010 will be used</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"_calculate_multiplicity_fraction: Using Raghavan (2010) to calculate multiplicity fractions"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> + + <span class="n">binary_fraction</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">raghavan2010_binary_fraction</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">])</span> + <span class="n">multiplicity_fraction_dict</span> <span class="o">=</span> <span class="p">{</span> + <span class="mi">1</span><span class="p">:</span> <span class="mi">1</span> <span class="o">-</span> <span class="n">binary_fraction</span><span class="p">,</span> + <span class="mi">2</span><span class="p">:</span> <span class="n">binary_fraction</span><span class="p">,</span> + <span class="mi">3</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> + <span class="mi">4</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> + <span class="p">}</span> + + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"multiplicity_fraction_function"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="s2">"Moe2017"</span><span class="p">]:</span> + <span class="c1"># We need to check several things now here:</span> + + <span class="c1"># First, are the options for the MOE2017 grid set? On start it is filled with the default settings</span> + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"The MOE2017 options do not seem to be set properly. The value is </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Second: is the Moecache filled.</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"_calculate_multiplicity_fraction: Moecache is empty. It needs to be filled with the data for the interpolators. Loading the data now"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Load the data</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_load_moe_di_stefano_data</span><span class="p">()</span> + + <span class="c1"># record the prev value</span> + <span class="n">prev_M1_value_ms</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_1"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + + <span class="c1"># Set value of M1 of the current system</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="o">=</span> <span class="n">system_dict</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> + + <span class="c1"># Calculate the multiplicity fraction</span> + <span class="n">multiplicity_fraction_list</span> <span class="o">=</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">Moe_di_Stefano_2017_multiplicity_fractions</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1"># Turn into dict</span> + <span class="n">multiplicity_fraction_dict</span> <span class="o">=</span> <span class="p">{</span> + <span class="n">el</span> <span class="o">+</span> <span class="mi">1</span><span class="p">:</span> <span class="n">multiplicity_fraction_list</span><span class="p">[</span><span class="n">el</span><span class="p">]</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">multiplicity_fraction_list</span><span class="p">))</span> + <span class="p">}</span> + + <span class="c1"># Set the prev value back</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"Moe2017_options"</span><span class="p">][</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="o">=</span> <span class="n">prev_M1_value_ms</span> + + <span class="c1"># we don't know what to do next</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Chosen value for the multiplicity fraction function is not known."</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># To make sure we normalize the dictionary</span> + <span class="n">multiplicity_fraction_dict</span> <span class="o">=</span> <span class="n">normalize_dict</span><span class="p">(</span> + <span class="n">multiplicity_fraction_dict</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> + <span class="p">)</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Multiplicity: </span><span class="si">{}</span><span class="s2"> multiplicity_fraction: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">system_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">],</span> + <span class="n">multiplicity_fraction_dict</span><span class="p">[</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">]],</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">3</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">return</span> <span class="n">multiplicity_fraction_dict</span><span class="p">[</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">]]</span> + +<div class="viewcode-block" id="Moe_di_Stefano_2017.get_moe_di_stefano_dataset"><a class="viewcode-back" href="../../../../population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_moe_di_stefano_dataset">[docs]</a> <span class="k">def</span> <span class="nf">get_moe_di_stefano_dataset</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to get the default Moe and di Stefano dataset or accept a user input.</span> + +<span class="sd"> Returns a dict containing the (JSON) data.</span> +<span class="sd"> """</span> + + <span class="n">json_data</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">if</span> <span class="s2">"JSON"</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> + <span class="c1"># use the JSON data passed in</span> + <span class="n">json_data</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"JSON"</span><span class="p">]</span> + + <span class="k">elif</span> <span class="s2">"file"</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> + <span class="c1"># use the file passed in, if provided</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"file"</span><span class="p">]):</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"The provided 'file' Moe and de Stefano JSON file does not seem to exist at </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"file"</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">raise</span> <span class="ne">ValueError</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="p">[</span><span class="s2">"file"</span><span class="p">]</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".json"</span><span class="p">):</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Provided filename is not a json file"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">else</span><span class="p">:</span> + <span class="c1"># Read input data and Clean up the data if there are white spaces around the keys</span> + <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"file"</span><span class="p">],</span> <span class="s2">"r"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">data_filehandle</span><span class="p">:</span> + <span class="n">datafile_data</span> <span class="o">=</span> <span class="n">data_filehandle</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> + <span class="n">datafile_data</span> <span class="o">=</span> <span class="n">datafile_data</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">'" '</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">)</span> + <span class="n">datafile_data</span> <span class="o">=</span> <span class="n">datafile_data</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">' "'</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">)</span> + <span class="n">datafile_data</span> <span class="o">=</span> <span class="n">datafile_data</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">' "'</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">)</span> + <span class="n">json_data</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">datafile_data</span><span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">json_data</span><span class="p">:</span> + <span class="c1"># no JSON data or filename given, use the default 2017 dataset</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Using the default Moe and de Stefano 2017 datafile"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="n">json_data</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">moe_di_stefano_2017_data</span><span class="o">.</span><span class="n">moe_di_stefano_2017_data</span><span class="p">)</span> + + <span class="k">return</span> <span class="n">json_data</span></div> + +<div class="viewcode-block" id="Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options"><a class="viewcode-back" href="../../../../population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options">[docs]</a> <span class="k">def</span> <span class="nf">get_Moe_di_Stefano_2017_default_options</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that returns the default options for the Moe & diStefano grid options</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="p">{</span> + <span class="c1"># place holder for the JSON data to be used if a file</span> + <span class="c1"># isn't specified</span> + <span class="s2">"JSON"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> + <span class="c1"># resolution data</span> + <span class="s2">"resolutions"</span><span class="p">:</span> <span class="p">{</span> + <span class="s2">"M"</span><span class="p">:</span> <span class="p">[</span> + <span class="mi">20</span><span class="p">,</span> <span class="c1"># M1</span> + <span class="mi">20</span><span class="p">,</span> <span class="c1"># M2 (i.e. q)</span> + <span class="mi">0</span><span class="p">,</span> <span class="c1"># M3 currently unused</span> + <span class="mi">0</span><span class="p">,</span> <span class="c1"># M4 currently unused</span> + <span class="p">],</span> + <span class="s2">"logP"</span><span class="p">:</span> <span class="p">[</span> + <span class="mi">20</span><span class="p">,</span> <span class="c1"># P2 (binary period)</span> + <span class="mi">0</span><span class="p">,</span> <span class="c1"># P3 (triple period) currently unused</span> + <span class="mi">0</span><span class="p">,</span> <span class="c1"># P4 (quadruple period) currently unused</span> + <span class="p">],</span> + <span class="s2">"ecc"</span><span class="p">:</span> <span class="p">[</span> + <span class="mi">10</span><span class="p">,</span> <span class="c1"># e (binary eccentricity)</span> + <span class="mi">0</span><span class="p">,</span> <span class="c1"># e2 (triple eccentricity) currently unused</span> + <span class="mi">0</span><span class="p">,</span> <span class="c1"># e3 (quadruple eccentricity) currently unused</span> + <span class="p">],</span> + <span class="p">},</span> + <span class="s2">"samplerfuncs"</span><span class="p">:</span> <span class="p">{</span> + <span class="s2">"M"</span><span class="p">:</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">],</span> + <span class="s2">"logP"</span><span class="p">:</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">],</span> + <span class="s2">"ecc"</span><span class="p">:</span> <span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">],</span> + <span class="p">},</span> + <span class="s2">"ranges"</span><span class="p">:</span> <span class="p">{</span> + <span class="c1"># stellar masses (Msun)</span> + <span class="s2">"M"</span><span class="p">:</span> <span class="p">[</span> + <span class="bp">self</span><span class="o">.</span><span class="n">minimum_stellar_mass</span><span class="p">()</span> + <span class="o">*</span> <span class="mf">1.05</span><span class="p">,</span> <span class="c1"># 0.08 is a tad bit above the minimum mass. Don't sample at 0.07, otherwise the first row of q values will have a phasevol of 0. Anything higher is fine.</span> + <span class="mf">80.0</span><span class="p">,</span> <span class="c1"># (rather arbitrary) upper mass cutoff</span> + <span class="p">],</span> + <span class="s2">"q"</span><span class="p">:</span> <span class="p">[</span> + <span class="kc">None</span><span class="p">,</span> <span class="c1"># artificial qmin : set to None to use default</span> + <span class="kc">None</span><span class="p">,</span> <span class="c1"># artificial qmax : set to None to use default</span> + <span class="p">],</span> + <span class="s2">"logP"</span><span class="p">:</span> <span class="p">[</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">8.0</span><span class="p">],</span> <span class="c1"># 0 = log10(1 day) # 8 = log10(10^8 days)</span> + <span class="s2">"ecc"</span><span class="p">:</span> <span class="p">[</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.99</span><span class="p">],</span> + <span class="p">},</span> + <span class="c1"># minimum stellar mass</span> + <span class="s2">"Mmin"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">minimum_stellar_mass</span><span class="p">(),</span> <span class="c1"># We take the value that binary_c has set as the default</span> + <span class="c1"># multiplicity model (as a function of log10M1)</span> + <span class="c1">#</span> + <span class="c1"># You can use 'Poisson' which uses the system multiplicity</span> + <span class="c1"># given by Moe and maps this to single/binary/triple/quad</span> + <span class="c1"># fractions.</span> + <span class="c1">#</span> + <span class="c1"># Alternatively, 'data' takes the fractions directly</span> + <span class="c1"># from the data, but then triples and quadruples are</span> + <span class="c1"># combined (and there are NO quadruples).</span> + <span class="s2">"multiplicity_model"</span><span class="p">:</span> <span class="s2">"Poisson"</span><span class="p">,</span> + <span class="c1"># multiplicity modulator:</span> + <span class="c1"># [single, binary, triple, quadruple]</span> + <span class="c1">#</span> + <span class="c1"># e.g. [1,0,0,0] for single stars only</span> + <span class="c1"># [0,1,0,0] for binary stars only</span> + <span class="c1">#</span> + <span class="c1"># defaults to [1,1,0,0] i.e. all types</span> + <span class="c1">#</span> + <span class="s2">"multiplicity_modulator"</span><span class="p">:</span> <span class="p">[</span> + <span class="mi">1</span><span class="p">,</span> <span class="c1"># single</span> + <span class="mi">1</span><span class="p">,</span> <span class="c1"># binary</span> + <span class="mi">0</span><span class="p">,</span> <span class="c1"># triple</span> + <span class="mi">0</span><span class="p">,</span> <span class="c1"># quadruple</span> + <span class="p">],</span> + <span class="c1"># given a mix of multiplicities, you can either (noting that</span> + <span class="c1"># here (S,B,T,Q) = appropriate modulator * model(S,B,T,Q) )</span> + <span class="c1">#</span> + <span class="c1"># 'norm' : normalise so the whole population is 1.0</span> + <span class="c1"># after implementing the appropriate fractions</span> + <span class="c1"># S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q)</span> + <span class="c1">#</span> + <span class="c1"># 'raw' : stick to what is predicted, i.e.</span> + <span class="c1"># S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q)</span> + <span class="c1"># without normalisation</span> + <span class="c1"># (in which case the total probability < 1.0 unless</span> + <span class="c1"># all you use single, binary, triple and quadruple)</span> + <span class="c1">#</span> + <span class="c1"># 'merge' : e.g. if you only have single and binary,</span> + <span class="c1"># add the triples and quadruples to the binaries, so</span> + <span class="c1"># binaries represent all multiple systems</span> + <span class="c1"># ...</span> + <span class="c1"># *** this is canonical binary population synthesis ***</span> + <span class="c1">#</span> + <span class="c1"># Note: if multiplicity_modulator == [1,1,1,1] this</span> + <span class="c1"># option does nothing (equivalent to 'raw').</span> + <span class="c1">#</span> + <span class="c1">#</span> + <span class="c1"># note: if you only set one multiplicity_modulator</span> + <span class="c1"># to 1, and all the others to 0, then normalising</span> + <span class="c1"># will mean that you effectively have the same number</span> + <span class="c1"># of stars as single, binary, triple or quad (whichever</span> + <span class="c1"># is non-zero) i.e. the multiplicity fraction is ignored.</span> + <span class="c1"># This is probably not useful except for</span> + <span class="c1"># testing purposes or comparing to old grids.</span> + <span class="s2">"normalize_multiplicities"</span><span class="p">:</span> <span class="s2">"merge"</span><span class="p">,</span> + <span class="c1"># q extrapolation (below 0.15 and above 0.9) method. We can choose from ['flat', 'linear', 'plaw2', 'nolowq']</span> + <span class="s2">"q_low_extrapolation_method"</span><span class="p">:</span> <span class="s2">"linear"</span><span class="p">,</span> + <span class="s2">"q_high_extrapolation_method"</span><span class="p">:</span> <span class="s2">"linear"</span><span class="p">,</span> + <span class="p">}</span></div> + +<div class="viewcode-block" id="Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options_description"><a class="viewcode-back" href="../../../../population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options_description">[docs]</a> <span class="k">def</span> <span class="nf">get_Moe_di_Stefano_2017_default_options_description</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the descriptions for all the Moe & diStefano grid options</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="p">{</span> + <span class="s2">"resolutions"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> + <span class="s2">"ranges"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> + <span class="s2">"Mmin"</span><span class="p">:</span> <span class="s2">"Minimum stellar mass"</span><span class="p">,</span> + <span class="s2">"multiplicity_model"</span><span class="p">:</span> <span class="s2">"""</span> +<span class="s2"> multiplicity model (as a function of log10M1)</span> + +<span class="s2"> You can use 'Poisson' which uses the system multiplicity</span> +<span class="s2"> given by Moe and maps this to single/binary/triple/quad</span> +<span class="s2"> fractions.</span> + +<span class="s2"> Alternatively, 'data' takes the fractions directly</span> +<span class="s2"> from the data, but then triples and quadruples are</span> +<span class="s2"> combined (and there are NO quadruples).</span> +<span class="s2"> """</span><span class="p">,</span> + <span class="s2">"multiplicity_modulator"</span><span class="p">:</span> <span class="s2">"""</span> +<span class="s2"> [single, binary, triple, quadruple]</span> + +<span class="s2"> e.g. [1,0,0,0] for single stars only</span> +<span class="s2"> [0,1,0,0] for binary stars only</span> + +<span class="s2"> defaults to [1,1,0,0] i.e. singles and binaries</span> +<span class="s2"> """</span><span class="p">,</span> + <span class="s2">"normalize_multiplicities"</span><span class="p">:</span> <span class="s2">"""</span> +<span class="s2"> 'norm': normalise so the whole population is 1.0</span> +<span class="s2"> after implementing the appropriate fractions</span> +<span class="s2"> S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q)</span> +<span class="s2"> given a mix of multiplicities, you can either (noting that</span> +<span class="s2"> here (S,B,T,Q) = appropriate modulator * model(S,B,T,Q) )</span> +<span class="s2"> note: if you only set one multiplicity_modulator</span> +<span class="s2"> to 1, and all the others to 0, then normalising</span> +<span class="s2"> will mean that you effectively have the same number</span> +<span class="s2"> of stars as single, binary, triple or quad (whichever</span> +<span class="s2"> is non-zero) i.e. the multiplicity fraction is ignored.</span> +<span class="s2"> This is probably not useful except for</span> +<span class="s2"> testing purposes or comparing to old grids.</span> + +<span class="s2"> 'raw' : stick to what is predicted, i.e.</span> +<span class="s2"> S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q)</span> +<span class="s2"> without normalisation</span> +<span class="s2"> (in which case the total probability < 1.0 unless</span> +<span class="s2"> all you use single, binary, triple and quadruple)</span> + +<span class="s2"> 'merge' : e.g. if you only have single and binary,</span> +<span class="s2"> add the triples and quadruples to the binaries, so</span> +<span class="s2"> binaries represent all multiple systems</span> +<span class="s2"> ...</span> +<span class="s2"> *** this is canonical binary population synthesis ***</span> + +<span class="s2"> It only takes the maximum multiplicity into account,</span> +<span class="s2"> i.e. it doesn't multiply the resulting array by the multiplicity modulator again.</span> +<span class="s2"> This prevents the resulting array to always be 1 if only 1 multiplicity modulator element is nonzero</span> + +<span class="s2"> Note: if multiplicity_modulator == [1,1,1,1]. this option does nothing (equivalent to 'raw').</span> +<span class="s2"> """</span><span class="p">,</span> + <span class="s2">"q_low_extrapolation_method"</span><span class="p">:</span> <span class="s2">"""</span> +<span class="s2"> q extrapolation (below 0.15) method</span> +<span class="s2"> none</span> +<span class="s2"> flat</span> +<span class="s2"> linear2</span> +<span class="s2"> plaw2</span> +<span class="s2"> nolowq</span> +<span class="s2"> """</span><span class="p">,</span> + <span class="s2">"q_high_extrapolation_method"</span><span class="p">:</span> <span class="s2">"Same as q_low_extrapolation_method"</span><span class="p">,</span> + <span class="p">}</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/analytics.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/analytics.html new file mode 100644 index 0000000000000000000000000000000000000000..4e45169a1da4d3a5b58c1771583ae32bba682020 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/analytics.html @@ -0,0 +1,229 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.analytics — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.analytics</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.analytics</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">The class extension for the population object that contains analytics functionality</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">time</span> + + +<div class="viewcode-block" id="analytics"><a class="viewcode-back" href="../../../../population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics">[docs]</a><span class="k">class</span> <span class="nc">analytics</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Extension for the Population class containing the functions for analytics</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the analytics class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + + <span class="c1">#######################</span> + <span class="c1"># time used functions</span> + <span class="c1">#######################</span> + +<div class="viewcode-block" id="analytics.make_analytics_dict"><a class="viewcode-back" href="../../../../population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics.make_analytics_dict">[docs]</a> <span class="k">def</span> <span class="nf">make_analytics_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to create the analytics dictionary</span> +<span class="sd"> """</span> + + <span class="nb">print</span><span class="p">(</span><span class="s2">"Do analytics"</span><span class="p">)</span> + + <span class="n">analytics_dict</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"do_analytics"</span><span class="p">]:</span> + <span class="c1"># Put all interesting stuff in a variable and output that afterwards, as analytics of the run.</span> + <span class="n">analytics_dict</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"population_id"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_population_id"</span><span class="p">],</span> + <span class="s2">"evolution_type"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">],</span> + <span class="s2">"failed_count"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_count"</span><span class="p">],</span> + <span class="s2">"failed_prob"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_prob"</span><span class="p">],</span> + <span class="s2">"failed_systems_error_codes"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"_failed_systems_error_codes"</span> + <span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> + <span class="s2">"errors_exceeded"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_exceeded"</span><span class="p">],</span> + <span class="s2">"errors_found"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_errors_found"</span><span class="p">],</span> + <span class="s2">"total_probability"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_probtot"</span><span class="p">],</span> + <span class="s2">"total_count"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">],</span> + <span class="s2">"start_timestamp"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_start_time_evolution"</span><span class="p">],</span> + <span class="s2">"end_timestamp"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_end_time_evolution"</span><span class="p">],</span> + <span class="s2">"time_elapsed"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">time_elapsed</span><span class="p">(),</span> + <span class="s2">"total_mass_run"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_mass_run"</span><span class="p">],</span> + <span class="s2">"total_probability_weighted_mass_run"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"_total_probability_weighted_mass_run"</span> + <span class="p">],</span> + <span class="s2">"zero_prob_stars_skipped"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"_zero_prob_stars_skipped"</span> + <span class="p">],</span> + <span class="p">}</span> + + <span class="k">if</span> <span class="s2">"metadata"</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">:</span> + <span class="c1"># Add analytics dict to the metadata too:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">analytics_dict</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Added analytics to metadata"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">add_system_metadata</span><span class="p">()</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># use existing analytics dict</span> + <span class="n">analytics_dict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"metadata"</span><span class="p">,</span> <span class="p">{})</span> + + <span class="k">return</span> <span class="n">analytics_dict</span></div> + +<div class="viewcode-block" id="analytics.set_time"><a class="viewcode-back" href="../../../../population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics.set_time">[docs]</a> <span class="k">def</span> <span class="nf">set_time</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">when</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to set the timestamp at when, where when is 'start' or 'end'.</span> + +<span class="sd"> If when == end, we also calculate the time elapsed.</span> +<span class="sd"> """</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_"</span> <span class="o">+</span> <span class="n">when</span> <span class="o">+</span> <span class="s2">"_time_evolution"</span><span class="p">]</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> + <span class="k">if</span> <span class="n">when</span> <span class="o">==</span> <span class="s2">"end"</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_time_elapsed"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">time_elapsed</span><span class="p">(</span><span class="n">force</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span></div> + +<div class="viewcode-block" id="analytics.time_elapsed"><a class="viewcode-back" href="../../../../population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics.time_elapsed">[docs]</a> <span class="k">def</span> <span class="nf">time_elapsed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">force</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return how long a population object has been running.</span> + +<span class="sd"> We return the cached value if it's available, and calculate</span> +<span class="sd"> the time elapsed if otherwise or if force is True</span> +<span class="sd"> """</span> + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"_start_time_evolution"</span><span class="p">,</span> <span class="s2">"_end_time_evolution"</span><span class="p">]:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">x</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> + <span class="c1"># print("{} missing : {}".format(x, self.grid_options[x]))</span> + + <span class="k">if</span> <span class="n">force</span> <span class="ow">or</span> <span class="s2">"_time_elapsed"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_time_elapsed"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_end_time_evolution"</span><span class="p">]</span> + <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_start_time_evolution"</span><span class="p">]</span> + <span class="p">)</span> + <span class="c1"># print(</span> + <span class="c1"># "set time elapsed = {} - {} = {}".format(</span> + <span class="c1"># self.grid_options["_end_time_evolution"],</span> + <span class="c1"># self.grid_options["_start_time_evolution"],</span> + <span class="c1"># self.grid_options["_time_elapsed"],</span> + <span class="c1"># )</span> + <span class="c1"># )</span> + + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_time_elapsed"</span><span class="p">]</span></div> + +<div class="viewcode-block" id="analytics.CPU_time"><a class="viewcode-back" href="../../../../population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics.CPU_time">[docs]</a> <span class="k">def</span> <span class="nf">CPU_time</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return how much CPU time we've used</span> +<span class="sd"> """</span> + <span class="n">dt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_time_elapsed"</span><span class="p">]</span> + + <span class="n">ncpus</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"num_processes"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> + + <span class="c1"># print("CPU time : dt={} n={} -> {}".format(dt, ncpus, dt * ncpus))</span> + + <span class="k">return</span> <span class="n">dt</span> <span class="o">*</span> <span class="n">ncpus</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/cache.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/cache.html new file mode 100644 index 0000000000000000000000000000000000000000..036049112664f3df2e777b94b5318a1c2c759e57 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/cache.html @@ -0,0 +1,475 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.cache — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.cache</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.cache</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">File containing the class extension for the population object that contains cache functionality</span> + +<span class="sd">Module containing (e.g. LRU) cache functionality for binary_c-python.</span> + +<span class="sd">We use cachetools when possible because this allows us to set up the</span> +<span class="sd">cache of the appropriate size for the task in the grid_options dict.</span> +<span class="sd">Please see the LRU_* options in there.</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">os</span> +<span class="kn">import</span> <span class="nn">time</span> +<span class="kn">import</span> <span class="nn">tempfile</span> +<span class="kn">import</span> <span class="nn">importlib</span> +<span class="kn">import</span> <span class="nn">getpass</span> +<span class="kn">import</span> <span class="nn">contextlib</span> + +<span class="kn">import</span> <span class="nn">cachetools</span> + + +<div class="viewcode-block" id="cache"><a class="viewcode-back" href="../../../../population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache">[docs]</a><span class="k">class</span> <span class="nc">cache</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Class extension for the population object that contains cache functionality</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the spacing_functions class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + +<div class="viewcode-block" id="cache.default_cache_dir"><a class="viewcode-back" href="../../../../population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.default_cache_dir">[docs]</a> <span class="k">def</span> <span class="nf">default_cache_dir</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Return a default cache directory path for binary_c-python, or None if we cannot find one. This is used in grid_options_defaults.py</span> +<span class="sd"> """</span> + + <span class="n">error_string</span> <span class="o">=</span> <span class="s2">"__*ERR*__"</span> <span class="c1"># string that cannot be a path</span> + <span class="k">for</span> <span class="n">path</span> <span class="ow">in</span> <span class="p">[</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"HOME"</span><span class="p">,</span> <span class="n">error_string</span><span class="p">),</span> <span class="s2">".cache"</span><span class="p">),</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"TMP"</span><span class="p">,</span> <span class="n">error_string</span><span class="p">),</span> <span class="s2">"cache"</span><span class="p">),</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s2">"var"</span><span class="p">,</span> <span class="s2">"tmp"</span><span class="p">,</span> <span class="n">getpass</span><span class="o">.</span><span class="n">getuser</span><span class="p">(),</span> <span class="s2">"cache"</span><span class="p">),</span> + <span class="p">]:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">error_string</span> <span class="ow">in</span> <span class="n">path</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">path</span><span class="p">):</span> + <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">"binary_c"</span><span class="p">)</span> + <span class="k">return</span> <span class="kc">None</span></div> + +<div class="viewcode-block" id="cache.NullCache"><a class="viewcode-back" href="../../../../population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.NullCache">[docs]</a> <span class="k">class</span> <span class="nc">NullCache</span><span class="p">(</span><span class="n">cachetools</span><span class="o">.</span><span class="n">Cache</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> A cachetools cache object that does as little as possible and never matches.</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the spacing_functions class</span> + +<span class="sd"> TODO: is this class necesarry to be defined *within* the cache class? can't it just be outside?</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="kc">None</span> + +<div class="viewcode-block" id="cache.NullCache.popitem"><a class="viewcode-back" href="../../../../population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.NullCache.popitem">[docs]</a> <span class="k">def</span> <span class="nf">popitem</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> pop function placeholder</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="c1"># do nothing</span></div> + +<div class="viewcode-block" id="cache.NullCache.__getitem__"><a class="viewcode-back" href="../../../../population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.NullCache.__getitem__">[docs]</a> <span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> getter function placeholder</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__missing__</span><span class="p">(</span><span class="n">key</span><span class="p">)</span></div> + +<div class="viewcode-block" id="cache.NullCache.__setitem__"><a class="viewcode-back" href="../../../../population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.NullCache.__setitem__">[docs]</a> <span class="k">def</span> <span class="fm">__setitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Setter function placeholder</span> +<span class="sd"> """</span> + + <span class="k">return</span></div> + +<div class="viewcode-block" id="cache.NullCache.__delitem__"><a class="viewcode-back" href="../../../../population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.NullCache.__delitem__">[docs]</a> <span class="k">def</span> <span class="fm">__delitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> deleter function placeholder</span> +<span class="sd"> """</span> + + <span class="k">return</span></div></div> + +<div class="viewcode-block" id="cache.setup_function_cache"><a class="viewcode-back" href="../../../../population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.setup_function_cache">[docs]</a> <span class="k">def</span> <span class="nf">setup_function_cache</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vb</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">cachetype</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to wrap binary_c-python's functions in function cache.</span> + +<span class="sd"> The functions listed in self.grid_options['function_cache_functions'] are</span> +<span class="sd"> given caches of size self.grid_options['function_cache_size'][func]</span> + +<span class="sd"> Args: None</span> +<span class="sd"> """</span> + + <span class="c1"># add our custom NullCache to the cachetools selection</span> + <span class="nb">setattr</span><span class="p">(</span><span class="n">cachetools</span><span class="p">,</span> <span class="s2">"NullCache"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">NullCache</span><span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"function_cache"</span><span class="p">]:</span> + <span class="c1"># no function cache: set all to NullCache</span> + <span class="c1"># TODO: This cachetype(Nullcache) is wrong.</span> + <span class="k">for</span> <span class="n">func</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"function_cache_functions"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> + <span class="bp">self</span><span class="o">.</span><span class="n">function_cache</span><span class="p">[</span><span class="n">func</span><span class="p">]</span> <span class="o">=</span> <span class="n">cachetype</span><span class="p">(</span><span class="n">NullCache</span><span class="p">)</span> + + <span class="k">for</span> <span class="n">func</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"function_cache_functions"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> + <span class="p">(</span><span class="n">maxsize</span><span class="p">,</span> <span class="n">cachetype</span><span class="p">,</span> <span class="n">testargs</span><span class="p">)</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"function_cache_functions"</span> + <span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">func</span><span class="p">)</span> + + <span class="c1"># which cache should we use?</span> + <span class="k">if</span> <span class="n">cachetype</span><span class="p">:</span> + <span class="c1"># use type passed in, if given</span> + <span class="n">usecachetype</span> <span class="o">=</span> <span class="n">cachetype</span> + <span class="k">elif</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"function_cache"</span><span class="p">]:</span> + <span class="c1"># function cache is disabled, use NoCache</span> + <span class="n">usecachetype</span> <span class="o">=</span> <span class="s2">"NoCache"</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">if</span> <span class="n">cachetype</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="c1"># use the default type</span> + <span class="n">usecachetype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"function_cache_default_type"</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># use type passed in</span> + <span class="n">usecachetype</span> <span class="o">=</span> <span class="n">cachetype</span> + + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Setup cache for func </span><span class="si">{func}</span><span class="s2"> : maxsize=</span><span class="si">{maxsize}</span><span class="s2">, cachetype=</span><span class="si">{cachetype}</span><span class="s2">, testargs=</span><span class="si">{testargs}</span><span class="s2">-> use </span><span class="si">{usecachetype}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">func</span><span class="o">=</span><span class="n">func</span><span class="p">,</span> + <span class="n">maxsize</span><span class="o">=</span><span class="n">maxsize</span><span class="p">,</span> + <span class="n">cachetype</span><span class="o">=</span><span class="n">cachetype</span><span class="p">,</span> + <span class="n">testargs</span><span class="o">=</span><span class="n">testargs</span><span class="p">,</span> + <span class="n">usecachetype</span><span class="o">=</span><span class="n">usecachetype</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">usecachetype</span> <span class="o">==</span> <span class="s2">"TTLCache"</span><span class="p">:</span> + <span class="n">extra_cacheargs</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"function_cache_TTL"</span><span class="p">]]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">extra_cacheargs</span> <span class="o">=</span> <span class="p">[]</span> + + <span class="c1"># detect if the function is already wrapped</span> + <span class="n">x</span> <span class="o">=</span> <span class="n">func</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"."</span><span class="p">)</span> + <span class="n">modulename</span> <span class="o">=</span> <span class="s2">"binarycpython.utils.population_extensions."</span> <span class="o">+</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">module</span> <span class="o">=</span> <span class="n">importlib</span><span class="o">.</span><span class="n">import_module</span><span class="p">(</span><span class="n">modulename</span><span class="p">)</span> + <span class="n">_method</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span> + <span class="s2">"module.</span><span class="si">{}</span><span class="s2">.</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> + <span class="p">)</span> <span class="c1"># TODO: we can do this differently with some .get call instead of eval</span> + <span class="n">_wrapped</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">_method</span><span class="p">,</span> <span class="s2">"__wrapped__"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> + + <span class="c1"># if function is wrapped...</span> + <span class="k">if</span> <span class="n">_wrapped</span> <span class="ow">and</span> <span class="nb">id</span><span class="p">(</span><span class="n">_method</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">id</span><span class="p">(</span><span class="n">_wrapped</span><span class="p">):</span> + <span class="c1"># save the wrapped function (this calls the cache)</span> + <span class="k">if</span> <span class="n">func</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">cached_function_cache</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">cached_function_cache</span><span class="p">[</span><span class="n">func</span><span class="p">]</span> <span class="o">=</span> <span class="n">_method</span> + <span class="bp">self</span><span class="o">.</span><span class="n">original_function_cache</span><span class="p">[</span><span class="n">func</span><span class="p">]</span> <span class="o">=</span> <span class="n">_wrapped</span> + + <span class="k">if</span> <span class="n">usecachetype</span> <span class="o">==</span> <span class="s2">"NoCache"</span><span class="p">:</span> + <span class="c1"># unwrap if we're after NoCache</span> + <span class="n">_code</span> <span class="o">=</span> <span class="s2">"module.</span><span class="si">{}</span><span class="s2">.</span><span class="si">{}</span><span class="s2"> = _wrapped"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> + <span class="n">exec</span><span class="p">(</span><span class="n">_code</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># function isn't wrapped, which means it was previously</span> + <span class="c1"># unwrapped, so rewrap it if not using NoCache</span> + <span class="k">if</span> <span class="n">usecachetype</span> <span class="o">!=</span> <span class="s2">"NoCache"</span> <span class="ow">and</span> <span class="n">func</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">cached_function_cache</span><span class="p">:</span> + <span class="n">_code</span> <span class="o">=</span> <span class="s1">'module.</span><span class="si">{}</span><span class="s1">.</span><span class="si">{}</span><span class="s1"> = self.cached_function_cache["</span><span class="si">{}</span><span class="s1">"]'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">func</span> + <span class="p">)</span> + <span class="n">exec</span><span class="p">(</span><span class="n">_code</span><span class="p">)</span> + + <span class="c1"># check we're not still wrapped</span> + <span class="n">_method</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="s2">"module"</span> <span class="o">+</span> <span class="s2">"."</span> <span class="o">+</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s2">"."</span> <span class="o">+</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> + <span class="n">_wrapped</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">_method</span><span class="p">,</span> <span class="s2">"__wrapped__"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> + + <span class="c1"># if NoCache (explicity use no cache), just use NullCache</span> + <span class="c1"># (it's never actually set)</span> + <span class="k">if</span> <span class="n">usecachetype</span> <span class="o">==</span> <span class="s2">"NoCache"</span><span class="p">:</span> + <span class="n">cachetools_func</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">cachetools</span><span class="p">,</span> <span class="s2">"NullCache"</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">cachetools_func</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">cachetools</span><span class="p">,</span> <span class="n">usecachetype</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">maxsize</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="n">maxsize</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"function_cache_default_maxsize"</span><span class="p">]</span> + + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Make function cache for func </span><span class="si">{func}</span><span class="s2">, maxsize </span><span class="si">{maxsize}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">func</span><span class="o">=</span><span class="n">func</span><span class="p">,</span> <span class="n">maxsize</span><span class="o">=</span><span class="n">maxsize</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1"># set up cache function args</span> + <span class="k">if</span> <span class="n">maxsize</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="mi">2</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="n">maxsize</span><span class="p">]</span> + <span class="n">args</span> <span class="o">+=</span> <span class="n">extra_cacheargs</span> + + <span class="c1"># clear any existing cache</span> + <span class="k">if</span> <span class="n">func</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">[</span><span class="n">func</span><span class="p">]</span><span class="o">.</span><span class="n">cache_clear</span><span class="p">()</span> + <span class="k">except</span><span class="p">:</span> + <span class="k">pass</span> + <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">[</span><span class="n">func</span><span class="p">]</span> + + <span class="c1"># set up new cache using the appropriate cachetools function</span> + <span class="k">if</span> <span class="n">usecachetype</span> <span class="o">!=</span> <span class="s2">"NoCache"</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">[</span><span class="n">func</span><span class="p">]</span> <span class="o">=</span> <span class="n">cachetools_func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span></div> + +<div class="viewcode-block" id="cache.test_caches"><a class="viewcode-back" href="../../../../population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.test_caches">[docs]</a> <span class="k">def</span> <span class="nf">test_caches</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dt</span><span class="o">=</span><span class="mf">5.0</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to test cache speeds of the functions that binary_c-python automatically caches.</span> + +<span class="sd"> Args:</span> +<span class="sd"> dt (default 5) in seconds the length of each test. Long is more accurate, but takes longer.</span> +<span class="sd"> """</span> + + <span class="c1"># loop lists</span> + <span class="n">cachetypes</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"NoCache"</span><span class="p">,</span> <span class="s2">"NullCache"</span><span class="p">,</span> <span class="s2">"FIFOCache"</span><span class="p">,</span> <span class="s2">"LRUCache"</span><span class="p">,</span> <span class="s2">"TTLCache"</span><span class="p">)</span> + <span class="n">functions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"function_cache_functions"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + <span class="n">maxsizes</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">16</span><span class="p">,</span> <span class="mi">32</span><span class="p">,</span> <span class="mi">64</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="mi">256</span><span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"function_cache"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + <span class="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="n">func</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">functions</span><span class="p">):</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Cache speed test of function </span><span class="si">{func}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">func</span><span class="o">=</span><span class="n">func</span><span class="p">))</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{:18s}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s2">""</span><span class="p">),</span> <span class="n">end</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> + <span class="k">for</span> <span class="n">x</span><span class="p">,</span> <span class="n">maxsize</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">maxsizes</span><span class="p">):</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{:>9s}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">maxsize</span><span class="p">)),</span> <span class="n">end</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span> + + <span class="n">best</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">best_type</span> <span class="o">=</span> <span class="kc">None</span> + <span class="n">best_maxsize</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">for</span> <span class="n">y</span><span class="p">,</span> <span class="nb">type</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">cachetypes</span><span class="p">):</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{:18s}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">type</span><span class="p">),</span> <span class="n">end</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"function_cache_default_type"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">type</span> + <span class="bp">self</span><span class="o">.</span><span class="n">setup_function_cache</span><span class="p">()</span> + <span class="p">(</span><span class="n">maxsize</span><span class="p">,</span> <span class="n">cachetype</span><span class="p">,</span> <span class="n">testargs</span><span class="p">)</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"function_cache_functions"</span> + <span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">func</span><span class="p">)</span> + + <span class="c1"># TODO: Make this part better: needs to be able to handle any depth</span> + <span class="n">x</span> <span class="o">=</span> <span class="n">func</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"."</span><span class="p">)</span> + <span class="n">modulename</span> <span class="o">=</span> <span class="s2">"binarycpython.utils.population_extensions."</span> <span class="o">+</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">module</span> <span class="o">=</span> <span class="n">importlib</span><span class="o">.</span><span class="n">import_module</span><span class="p">(</span><span class="n">modulename</span><span class="p">)</span> + <span class="n">_method</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="s2">"module.</span><span class="si">{}</span><span class="s2">.</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> + + <span class="k">if</span> <span class="n">testargs</span><span class="p">:</span> + + <span class="k">def</span> <span class="nf">_func_wrap</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> wrap to return args and kwargs</span> + +<span class="sd"> TODO: i think this function can be defined elsewhere</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span><span class="p">)</span> + + <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="s2">"_func_wrap(</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">testargs</span><span class="p">))</span> + <span class="k">for</span> <span class="n">x</span><span class="p">,</span> <span class="n">maxsize</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">maxsizes</span><span class="p">):</span> + <span class="k">if</span> <span class="nb">type</span> <span class="o">==</span> <span class="s2">"NoCache"</span> <span class="ow">and</span> <span class="n">maxsize</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="k">continue</span> + + <span class="c1"># redirect stdout to prevent lots of output</span> + <span class="k">with</span> <span class="n">contextlib</span><span class="o">.</span><span class="n">redirect_stdout</span><span class="p">(</span><span class="kc">None</span><span class="p">):</span> + + <span class="c1"># loop for dt seconds</span> + <span class="n">tfin</span> <span class="o">=</span> <span class="n">dt</span> <span class="o">+</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> + <span class="n">count</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">try</span><span class="p">:</span> + <span class="k">while</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o"><</span> <span class="n">tfin</span><span class="p">:</span> + <span class="n">_method</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> + <span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span> + <span class="c1"># TODO: specify the exception</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Cache call failed:"</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">count</span> <span class="o"><</span> <span class="mi">99999</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{:9d}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">count</span><span class="p">),</span> <span class="n">end</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{:9.2e}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">count</span><span class="p">)),</span> <span class="n">end</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">count</span> <span class="o">></span> <span class="n">best</span><span class="p">:</span> + <span class="n">best</span> <span class="o">=</span> <span class="n">count</span> + <span class="n">best_type</span> <span class="o">=</span> <span class="nb">type</span> + <span class="n">best_maxsize</span> <span class="o">=</span> <span class="n">maxsize</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span> + + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Best cache type </span><span class="si">{type}</span><span class="s2"> with maxsize </span><span class="si">{maxsize}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">type</span><span class="o">=</span><span class="n">best_type</span><span class="p">,</span> <span class="n">maxsize</span><span class="o">=</span><span class="n">best_maxsize</span> + <span class="p">)</span> + <span class="p">)</span></div> + + <span class="sd">"""</span> +<span class="sd">Cache speed test of function distribution_functions.powerlaw_constant</span> +<span class="sd"> 0 1 2 4 8 16 32 64 128 256</span> +<span class="sd">NoCache 6.28e+07</span> +<span class="sd">NullCache 6.39e+07 6.40e+07 6.41e+07 6.39e+07 6.44e+07 6.43e+07 6.37e+07 6.40e+07 6.38e+07 6.40e+07</span> +<span class="sd">FIFOCache 6.41e+07 6.37e+07 6.40e+07 6.39e+07 6.40e+07 6.37e+07 6.41e+07 6.40e+07 6.41e+07 6.40e+07</span> +<span class="sd">LRUCache 6.42e+07 6.41e+07 6.42e+07 6.41e+07 6.38e+07 6.43e+07 6.41e+07 6.43e+07 6.40e+07 6.41e+07</span> +<span class="sd">TTLCache 6.41e+07 6.35e+07 6.37e+07 6.39e+07 6.37e+07 6.42e+07 6.39e+07 6.38e+07 6.37e+07 6.38e+07</span> +<span class="sd">Best cache type NullCache with maxsize 8</span> + +<span class="sd">Cache speed test of function distribution_functions.calculate_constants_three_part_powerlaw</span> +<span class="sd"> 0 1 2 4 8 16 32 64 128 256</span> +<span class="sd">NoCache 1.44e+07</span> +<span class="sd">NullCache 9.13e+06 9.18e+06 9.20e+06 9.21e+06 9.20e+06 9.12e+06 9.18e+06 9.18e+06 9.15e+06 9.12e+06</span> +<span class="sd">FIFOCache 2.53e+07 2.52e+07 2.51e+07 2.50e+07 2.51e+07 2.52e+07 2.52e+07 2.52e+07 2.52e+07 2.51e+07</span> +<span class="sd">LRUCache 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07</span> +<span class="sd">TTLCache 1.43e+07 1.43e+07 1.43e+07 1.43e+07 1.43e+07 1.44e+07 1.42e+07 1.43e+07 1.43e+07 1.43e+07</span> +<span class="sd">Best cache type FIFOCache with maxsize 0</span> + +<span class="sd">Cache speed test of function distribution_functions.gaussian_normalizing_const</span> +<span class="sd"> 0 1 2 4 8 16 32 64 128 256</span> +<span class="sd">NoCache 64183</span> +<span class="sd">NullCache 64340 64339 64544 64260 64491 64382 64400 63974 63954 64338</span> +<span class="sd">FIFOCache 2.62e+07 2.62e+07 2.62e+07 2.61e+07 2.61e+07 2.59e+07 2.61e+07 2.59e+07 2.57e+07 2.59e+07</span> +<span class="sd">LRUCache 1.66e+07 1.66e+07 1.65e+07 1.66e+07 1.65e+07 1.65e+07 1.64e+07 1.65e+07 1.64e+07 1.65e+07</span> +<span class="sd">TTLCache 1.42e+07 1.44e+07 1.42e+07 1.44e+07 1.43e+07 1.43e+07 1.42e+07 1.44e+07 1.42e+07 1.44e+07</span> +<span class="sd">Best cache type FIFOCache with maxsize 1</span> + +<span class="sd">Cache speed test of function spacing_functions.const_linear</span> +<span class="sd"> 0 1 2 4 8 16 32 64 128 256</span> +<span class="sd">NoCache 1.22e+06</span> +<span class="sd">NullCache 1.05e+06 1.05e+06 1.06e+06 1.05e+06 1.05e+06 1.06e+06 1.05e+06 1.05e+06 1.05e+06 1.05e+06</span> +<span class="sd">FIFOCache 2.85e+07 2.85e+07 2.86e+07 2.85e+07 2.84e+07 2.85e+07 2.84e+07 2.84e+07 2.85e+07 2.81e+07</span> +<span class="sd">LRUCache 1.77e+07 1.79e+07 1.73e+07 1.73e+07 1.76e+07 1.79e+07 1.76e+07 1.74e+07 1.74e+07 1.72e+07</span> +<span class="sd">TTLCache 1.46e+07 1.49e+07 1.50e+07 1.53e+07 1.51e+07 1.53e+07 1.52e+07 1.51e+07 1.47e+07 1.50e+07</span> +<span class="sd">Best cache type FIFOCache with maxsize 2</span> + +<span class="sd">Cache speed test of function spacing_functions.const_int</span> +<span class="sd"> 0 1 2 4 8 16 32 64 128 256</span> +<span class="sd">NoCache 4.23e+07</span> +<span class="sd">NullCache 1.65e+07 1.66e+07 1.65e+07 1.64e+07 1.66e+07 1.65e+07 1.59e+07 1.59e+07 1.65e+07 1.64e+07</span> +<span class="sd">FIFOCache 2.86e+07 2.86e+07 2.87e+07 2.86e+07 2.84e+07 2.86e+07 2.81e+07 2.79e+07 2.78e+07 2.85e+07</span> +<span class="sd">LRUCache 1.78e+07 1.78e+07 1.77e+07 1.75e+07 1.77e+07 1.78e+07 1.78e+07 1.78e+07 1.74e+07 1.75e+07</span> +<span class="sd">TTLCache 1.55e+07 1.54e+07 1.55e+07 1.54e+07 1.55e+07 1.49e+07 1.52e+07 1.51e+07 1.52e+07 1.54e+07</span> +<span class="sd">Best cache type NoCache with maxsize 0</span> + +<span class="sd">Cache speed test of function spacing_functions.const_ranges</span> +<span class="sd"> 0 1 2 4 8 16 32 64 128 256</span> +<span class="sd">NoCache 2.54e+05</span> +<span class="sd">NullCache 2.25e+05 2.25e+05 2.24e+05 2.25e+05 2.25e+05 2.25e+05 2.25e+05 2.26e+05 2.25e+05 2.26e+05</span> +<span class="sd">FIFOCache 2.58e+07 2.55e+07 2.53e+07 2.54e+07 2.56e+07 2.57e+07 2.56e+07 2.57e+07 2.58e+07 2.58e+07</span> +<span class="sd">LRUCache 1.62e+07 1.63e+07 1.62e+07 1.62e+07 1.61e+07 1.62e+07 1.62e+07 1.62e+07 1.61e+07 1.63e+07</span> +<span class="sd">TTLCache 1.41e+07 1.43e+07 1.42e+07 1.42e+07 1.40e+07 1.42e+07 1.42e+07 1.43e+07 1.40e+07 1.43e+07</span> +<span class="sd">Best cache type FIFOCache with maxsize 128</span> + +<span class="sd">Cache speed test of function spacing_functions.gaussian_zoom</span> +<span class="sd"> 0 1 2 4 8 16 32 64 128 256</span> +<span class="sd">NoCache 24703</span> +<span class="sd">NullCache 24872 24935 24927 24896 24968 24964 24882 24840 24873 24913</span> +<span class="sd">FIFOCache 2.54e+07 2.54e+07 2.54e+07 2.54e+07 2.53e+07 2.52e+07 2.53e+07 2.51e+07 2.52e+07 2.52e+07</span> +<span class="sd">LRUCache 1.63e+07 1.63e+07 1.63e+07 1.64e+07 1.63e+07 1.64e+07 1.63e+07 1.63e+07 1.63e+07 1.63e+07</span> +<span class="sd">TTLCache 1.43e+07 1.43e+07 1.42e+07 1.42e+07 1.43e+07 1.42e+07 1.43e+07 1.43e+07 1.43e+07 1.43e+07</span> +<span class="sd">Best cache type FIFOCache with maxsize 0</span> +<span class="sd"> """</span></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/condor.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/condor.html new file mode 100644 index 0000000000000000000000000000000000000000..ad1ea2c28627c4ab15d164b163cf7e7dfe585035 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/condor.html @@ -0,0 +1,676 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.condor — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.condor</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.condor</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">The class extension for the population object that contains the Condor functionality</span> + +<span class="sd">TODO: there are many uses of $<variable name> in this file but this is not perl and we should replace them by actual format placeholders</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">os</span> +<span class="kn">import</span> <span class="nn">re</span> +<span class="kn">import</span> <span class="nn">sys</span> +<span class="kn">import</span> <span class="nn">stat</span> +<span class="kn">import</span> <span class="nn">time</span> +<span class="kn">import</span> <span class="nn">subprocess</span> + +<span class="kn">import</span> <span class="nn">pathlib</span> + +<span class="kn">import</span> <span class="nn">datasize</span> +<span class="kn">import</span> <span class="nn">lib_programname</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">command_string_from_list</span><span class="p">,</span> + <span class="n">now</span><span class="p">,</span> +<span class="p">)</span> + + +<div class="viewcode-block" id="condor"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor">[docs]</a><span class="k">class</span> <span class="nc">condor</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Extension for the Population class containing the code for Condor grid runs</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the condor class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + +<div class="viewcode-block" id="condor.condorID"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condorID">[docs]</a> <span class="k">def</span> <span class="nf">condorID</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ClusterID</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">Process</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return a Condor job ID as a string, [ClusterID].[Process]. The ClusterID and Process passed in are used if given, otherwise we default to the condor_ClusterID and condor_Process in grid_options.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="n">ClusterID</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">ClusterID</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_ClusterID"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">Process</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">Process</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_Process"</span><span class="p">]</span> + <span class="k">return</span> <span class="s2">"</span><span class="si">{ClusterID}</span><span class="s2">.</span><span class="si">{Process}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ClusterID</span><span class="o">=</span><span class="n">ClusterID</span><span class="p">,</span> <span class="n">Process</span><span class="o">=</span><span class="n">Process</span><span class="p">)</span></div> + +<div class="viewcode-block" id="condor.condorpath"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condorpath">[docs]</a> <span class="k">def</span> <span class="nf">condorpath</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the full condor directory path.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">condor_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">condor_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">]</span> + <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">condor_dir</span><span class="p">,</span> <span class="n">path</span><span class="p">))</span></div> + +<div class="viewcode-block" id="condor.condor_status_file"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_status_file">[docs]</a> <span class="k">def</span> <span class="nf">condor_status_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ClusterID</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">Process</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Return the condor status file corresponding to the ClusterID and Process, which default to grid_options condor_ClusterID and condor_Process, respectively.</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">condorpath</span><span class="p">(</span><span class="s2">"status"</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="n">condor_dir</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">condorID</span><span class="p">(</span><span class="n">ClusterID</span><span class="p">,</span> <span class="n">Process</span><span class="p">),</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="condor.condor_check_requirements"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_check_requirements">[docs]</a> <span class="k">def</span> <span class="nf">condor_check_requirements</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to check whether the condor parameters in grid_options have been set appropriately.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span> <span class="ow">and</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span> + <span class="ow">or</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">])</span> + <span class="p">):</span> + <span class="k">return</span> <span class="p">(</span> + <span class="kc">False</span><span class="p">,</span> + <span class="s2">"You have set condor=</span><span class="si">{condor}</span><span class="s2"> but not set condor_dir (</span><span class="si">{condor_dir}</span><span class="s2">) correctly. Please set it and try again."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">condor</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">],</span> + <span class="n">condor_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">],</span> + <span class="p">),</span> + <span class="p">)</span> + <span class="k">return</span> <span class="p">(</span><span class="kc">True</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span></div> + +<div class="viewcode-block" id="condor.condor_dirs"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_dirs">[docs]</a> <span class="k">def</span> <span class="nf">condor_dirs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Directories associated specifically with this condor job.</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">]</span></div> + +<div class="viewcode-block" id="condor.set_condor_status"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.set_condor_status">[docs]</a> <span class="k">def</span> <span class="nf">set_condor_status</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">string</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Set the condor status corresponing to the self object, which should have condor_ClusterID and condor_Process set.</span> + +<span class="sd"> Args:</span> +<span class="sd"> string : the status string to be set</span> +<span class="sd"> dir : the directory in which the status directory is held. If not set, this defaults to the HPC directory (e.g. slurm_dir or condor_dir).</span> +<span class="sd"> """</span> + <span class="c1"># save condor ClusterID to file</span> + + <span class="k">if</span> <span class="n">condor_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">condor_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">]</span> + + <span class="n">idfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">condor_dir</span><span class="p">,</span> <span class="s2">"ClusterID"</span><span class="p">)</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">idfile</span><span class="p">):</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">idfile</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">fClusterID</span><span class="p">:</span> + <span class="n">fClusterID</span><span class="o">.</span><span class="n">write</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{ClusterID}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">ClusterID</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_ClusterID"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="n">fClusterID</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">idfile</span><span class="p">)</span> + + <span class="c1"># save condor status</span> + <span class="n">file</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">condor_status_file</span><span class="p">(</span><span class="n">condor_dir</span><span class="o">=</span><span class="n">condor_dir</span><span class="p">)</span> + <span class="k">if</span> <span class="n">file</span><span class="p">:</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> + <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">string</span><span class="p">)</span> + <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">file</span><span class="p">)</span></div> + +<div class="viewcode-block" id="condor.get_condor_status"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.get_condor_status">[docs]</a> <span class="k">def</span> <span class="nf">get_condor_status</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ClusterID</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">Process</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Get and return the condor status corresponing to the self object, or ClusterID.Process if they are passed in. If no status is found, returns an empty string..</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="n">ClusterID</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">ClusterID</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_ClusterID"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">Process</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">Process</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_Process"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">ClusterID</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">Process</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="k">return</span> <span class="kc">None</span> + <span class="c1"># print("get_condor_status {}.{}".format(ClusterID,Process))</span> + + <span class="k">try</span><span class="p">:</span> + <span class="n">path</span> <span class="o">=</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">condor_status_file</span><span class="p">(</span> + <span class="n">condor_dir</span><span class="o">=</span><span class="n">condor_dir</span><span class="p">,</span> <span class="n">ClusterID</span><span class="o">=</span><span class="n">ClusterID</span><span class="p">,</span> <span class="n">Process</span><span class="o">=</span><span class="n">Process</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="c1"># print("path={}".format(path))</span> + <span class="c1"># print("size={}".format(path.stat().st_size))</span> + <span class="k">if</span> <span class="n">path</span><span class="p">:</span> + <span class="n">s</span> <span class="o">=</span> <span class="n">path</span><span class="o">.</span><span class="n">read_text</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="c1"># print("contains {}".format(s))</span> + <span class="k">return</span> <span class="n">s</span> + <span class="c1"># print("path empty")</span> + <span class="k">return</span> <span class="s2">""</span> + + <span class="c1"># NOTE: What is the actual exception that can occur here?</span> + <span class="c1"># TODO: We should specify that exception</span> + <span class="k">except</span><span class="p">:</span> + <span class="c1"># print("read failed")</span> + <span class="k">return</span> <span class="s2">""</span></div> + +<div class="viewcode-block" id="condor.condor_outfile"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_outfile">[docs]</a> <span class="k">def</span> <span class="nf">condor_outfile</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> return a standard filename for the condor chunk files</span> +<span class="sd"> """</span> + <span class="n">file</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{id}</span><span class="s2">.gz"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">condorID</span><span class="p">())</span> + <span class="k">if</span> <span class="n">condor_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">condor_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">]</span> + <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">condor_dir</span><span class="p">,</span> <span class="s2">"results"</span><span class="p">,</span> <span class="n">file</span><span class="p">))</span></div> + +<div class="viewcode-block" id="condor.make_condor_dirs"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.make_condor_dirs">[docs]</a> <span class="k">def</span> <span class="nf">make_condor_dirs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to make the condor directories</span> +<span class="sd"> """</span> + + <span class="c1"># make the condor directories</span> + <span class="k">if</span> <span class="n">condor_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">condor_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">]</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">condor_dir</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"You must set self.grid_options['condor_dir'] (or pass condor_dir=whatever to make_condor_dirs()) to a directory which we can use to set up binary_c-python's Condor files. This should be unique to your set of grids."</span> + <span class="p">)</span> + <span class="n">os</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span> + + <span class="c1"># make a list of directories, these contain the various condor</span> + <span class="c1"># output, status files, etc.</span> + <span class="n">dirs</span> <span class="o">=</span> <span class="p">[]</span> + <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"stdout"</span><span class="p">,</span> <span class="s2">"stderr"</span><span class="p">,</span> <span class="s2">"log"</span><span class="p">,</span> <span class="s2">"results"</span><span class="p">,</span> <span class="s2">"status"</span><span class="p">,</span> <span class="s2">"snapshots"</span><span class="p">]:</span> + <span class="n">dirs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">condorpath</span><span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="n">condor_dir</span><span class="p">))</span> + + <span class="c1"># make the directories: we do not allow these to already exist</span> + <span class="c1"># as the condor directory should be a fresh location for each set of jobs</span> + <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">dirs</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">condorpath</span><span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="n">condor_dir</span><span class="p">))</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span> + <span class="n">exist_ok</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">parents</span><span class="o">=</span><span class="kc">True</span> + <span class="p">)</span> + <span class="c1"># TODO: specify the actual exception</span> + <span class="c1"># TODO: is this try-except necessary? Especially having the code fail here, instead of earlier, if the directories exist already. Otherwise we can also just do exist_ok=True?</span> + <span class="k">except</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Tried to make the directory </span><span class="si">{d}</span><span class="s2"> but it already exists. When you launch a set of binary_c jobs on Condor, you need to set your condor_dir to be a fresh directory with no contents."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">d</span><span class="o">=</span><span class="n">d</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># check that they have been made and exist: we need this</span> + <span class="c1"># because on network mounts (NFS) there's often a delay between the mkdir</span> + <span class="c1"># above and the actual directory being made. This shouldn't be too long...</span> + <span class="n">fail</span> <span class="o">=</span> <span class="kc">True</span> + <span class="n">count</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">count_warn</span> <span class="o">=</span> <span class="mi">10</span> + <span class="k">while</span> <span class="n">fail</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> + <span class="n">fail</span> <span class="o">=</span> <span class="kc">False</span> + <span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span> + <span class="k">if</span> <span class="n">count</span> <span class="o">></span> <span class="n">count_warn</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Warning: Have been waiting about </span><span class="si">{}</span><span class="s2"> seconds for Condor directories to be made, there seems to be significant delay..."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">count</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">dirs</span><span class="p">:</span> + <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span> + <span class="n">fail</span> <span class="o">=</span> <span class="kc">True</span> + <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> + <span class="k">break</span></div> + +<div class="viewcode-block" id="condor.condor_grid"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_grid">[docs]</a> <span class="k">def</span> <span class="nf">condor_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="c1"># pragma: no cover</span> + <span class="sd">"""</span> +<span class="sd"> function to be called when running grids when grid_options['condor']>=1</span> + +<span class="sd"> if grid_options['condor']==1, we set up the condor script and launch the jobs, then return True to exit.</span> +<span class="sd"> if grid_options['condor']==2, we run the stars, which means we return False to continue.</span> +<span class="sd"> if grid_options['condor']==3, we are being called from the jobs to run the grids, return False to continue.</span> + +<span class="sd"> TODO: split this function into some parts</span> +<span class="sd"> TODO: Comment this function better</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span> + <span class="c1"># joining : set the evolution type to "join"</span> + <span class="c1">#</span> + <span class="c1"># return False to continue</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"join"</span> + <span class="k">return</span> <span class="kc">False</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> + <span class="c1"># run a grid of stars only, leaving the results</span> + <span class="c1"># in the appropriate outfile</span> + <span class="c1">#</span> + <span class="c1"># return False to actually run the stars</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"grid"</span> + <span class="k">return</span> <span class="kc">False</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="c1"># if condor=1, we should have no evolution type, we</span> + <span class="c1"># set up the Condor scripts and get them evolving</span> + <span class="c1"># in a Condor queue</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="c1"># make dirs</span> + <span class="bp">self</span><span class="o">.</span><span class="n">make_condor_dirs</span><span class="p">()</span> + + <span class="c1"># check we're not using too much RAM</span> + <span class="k">if</span> <span class="n">datasize</span><span class="o">.</span><span class="n">DataSize</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_memory"</span><span class="p">]</span> + <span class="p">)</span> <span class="o">></span> <span class="n">datasize</span><span class="o">.</span><span class="n">DataSize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_warn_max_memory"</span><span class="p">]):</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"WARNING: you want to use </span><span class="si">{}</span><span class="s2"> MB of RAM : this is unlikely to be correct. If you believe it is, set condor_warn_max_memory to something very large (it is currently </span><span class="si">{}</span><span class="s2"> MB)</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_memory"</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_warn_max_memory"</span><span class="p">],</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># get job id (might be passed in)</span> + <span class="n">ClusterID</span> <span class="o">=</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_ClusterID"</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_ClusterID"</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">""</span> + <span class="k">else</span> <span class="s2">"$ClusterID"</span> + <span class="p">)</span> + + <span class="c1"># get job array index</span> + <span class="n">Process</span> <span class="o">=</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_Process"</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_Process"</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">""</span> + <span class="k">else</span> <span class="s2">"$Process"</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_njobs"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"binary_c-python Condor : You must set grid_option condor_njobs to be non-zero"</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># find the path to the Python script that we are running</span> + <span class="n">pyscriptpath</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">lib_programname</span><span class="o">.</span><span class="n">get_path_executed_script</span><span class="p">())</span> + + <span class="c1"># set the condor initial dir to be our current working directory</span> + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_initial_dir"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_initial_dir"</span><span class="p">]</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getcwd</span><span class="p">()</span> + + <span class="c1"># build the grid command</span> + <span class="n">grid_command</span> <span class="o">=</span> <span class="p">(</span> + <span class="p">[</span> + <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_env"</span><span class="p">]),</span> + <span class="n">sys</span><span class="o">.</span><span class="n">executable</span><span class="p">,</span> + <span class="n">pyscriptpath</span><span class="p">,</span> + <span class="p">]</span> + <span class="o">+</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> + <span class="o">+</span> <span class="p">[</span> + <span class="s2">"start_at=$Process"</span><span class="p">,</span> <span class="c1"># Process is 0,1,2... which is what we want</span> + <span class="s2">"modulo="</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_njobs"</span><span class="p">]),</span> + <span class="s2">"condor_njobs="</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_njobs"</span><span class="p">]),</span> + <span class="s2">"condor_dir="</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">],</span> + <span class="s2">"verbosity="</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]),</span> + <span class="s2">"num_cores="</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]),</span> + <span class="p">]</span> + <span class="p">)</span> + + <span class="n">grid_command</span> <span class="o">=</span> <span class="n">command_string_from_list</span><span class="p">(</span><span class="n">grid_command</span><span class="p">)</span> + + <span class="c1"># make condor script paths</span> + <span class="n">submit_script_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">condorpath</span><span class="p">(</span><span class="s2">"condor_submit_script"</span><span class="p">)</span> + <span class="n">job_script_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">condorpath</span><span class="p">(</span><span class="s2">"condor_job_script"</span><span class="p">)</span> + + <span class="c1"># open the files</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">submit_script</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">submit_script_path</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">IOError</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Could not open Condor script at </span><span class="si">{path}</span><span class="s2"> for writing: please check you have set </span><span class="si">{condor_dir}</span><span class="s2"> correctly (it is currently </span><span class="si">{condor_dir}</span><span class="s2"> and can write to this directory."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">path</span><span class="o">=</span><span class="n">submit_script_path</span><span class="p">,</span> + <span class="n">condor_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">],</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">job_script</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">job_script_path</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">IOError</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Could not open Condor script at </span><span class="si">{path}</span><span class="s2"> for writing: please check you have set </span><span class="si">{condor_dir}</span><span class="s2"> correctly (it is currently </span><span class="si">{condor_dir}</span><span class="s2"> and can write to this directory."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">path</span><span class="o">=</span><span class="n">job_script_path</span><span class="p">,</span> <span class="n">condor_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># The condor job script calls your binary_c-pthyon script</span> + <span class="c1">############################################################</span> + <span class="n">condor_job_script</span> <span class="o">=</span> <span class="s2">"""#!</span><span class="si">{bash}</span><span class="s2"></span> +<span class="s2">echo "Condor Job Args: $@"</span> + +<span class="s2"># first two arguments are ClusterID and Process</span> +<span class="s2">export ClusterID="$1"</span> +<span class="s2">export Process="$2"</span> +<span class="s2">shift 2</span> + +<span class="s2">echo "Job ClusterID $ClusterID Process $Process"</span> + +<span class="s2"># Set binary_c startup conditions</span> +<span class="s2">export BINARY_C_PYTHON_ORIGINAL_CMD_LINE=</span><span class="si">{cmdline}</span><span class="s2"></span> +<span class="s2">export BINARY_C_PYTHON_ORIGINAL_WD=`</span><span class="si">{pwd}</span><span class="s2">`</span> +<span class="s2">export BINARY_C_PYTHON_ORIGINAL_SUBMISSION_TIME=`</span><span class="si">{date}</span><span class="s2">`</span> + +<span class="s2"># set status to </span><span class="se">\"</span><span class="s2">running</span><span class="se">\"</span><span class="s2"></span> +<span class="s2">echo </span><span class="se">\"</span><span class="s2">running</span><span class="se">\"</span><span class="s2"> > "</span><span class="si">{condor_dir}</span><span class="s2">/status/$ClusterID.$ProcessID"</span> + +<span class="s2"># make list of files which is checked for joining</span> +<span class="s2"># echo "</span><span class="si">{condor_dir}</span><span class="s2">/results/$ClusterID.$Process.gz" >> "</span><span class="si">{condor_dir}</span><span class="s2">/results/$ClusterID.all"</span> + +<span class="s2"># run grid of stars and, if this returns 0, set status to finished</span> +<span class="si">{grid_command}</span><span class="s2"> "condor=2" "evolution_type=grid" "condor_ClusterID=$ClusterID" "condor_Process=$Process" "save_population_object=</span><span class="si">{condor_dir}</span><span class="s2">/results/$ClusterID.$Process.gz" && echo -n </span><span class="se">\"</span><span class="s2">finished</span><span class="se">\"</span><span class="s2"> > "</span><span class="si">{condor_dir}</span><span class="s2">/status/$ClusterID.$ProcessID" && echo """</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">bash</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_bash"</span><span class="p">],</span> + <span class="n">date</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_date"</span><span class="p">],</span> + <span class="n">pwd</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_pwd"</span><span class="p">],</span> + <span class="n">cmdline</span><span class="o">=</span><span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"command_line"</span><span class="p">]),</span> + <span class="n">grid_command</span><span class="o">=</span><span class="n">grid_command</span><span class="p">,</span> + <span class="n">condor_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">],</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_postpone_join"</span><span class="p">]:</span> + <span class="n">joinfile</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{condor_dir}</span><span class="s2">/results/</span><span class="si">{ClusterID}</span><span class="s2">.all"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">condor_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">],</span> <span class="n">ClusterID</span><span class="o">=</span><span class="n">ClusterID</span> + <span class="p">)</span> + <span class="n">condor_job_script</span> <span class="o">+=</span> <span class="s2">"""&& echo </span><span class="se">\"</span><span class="s2">Checking if we can join...</span><span class="se">\"</span><span class="s2"> && echo && </span><span class="si">{grid_command}</span><span class="s2"> "condor=3" "evolution_type=join" "joinlist=</span><span class="si">{joinfile}</span><span class="s2">" "condor_ClusterID=$ClusterID" "condor_Process=$Process"</span> +<span class="s2"> """</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">bash</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_bash"</span><span class="p">],</span> + <span class="n">grid_command</span><span class="o">=</span><span class="n">grid_command</span><span class="p">,</span> + <span class="n">joinfile</span><span class="o">=</span><span class="n">joinfile</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># The Condor submit script is sent to condor_submit</span> + <span class="c1"># In here we know $(Cluster) and $(Process) which identify</span> + <span class="c1"># each job</span> + <span class="c1">############################################################</span> + <span class="n">extra_settings</span> <span class="o">=</span> <span class="s2">""</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_extra_settings"</span><span class="p">]:</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_extra_settings"</span><span class="p">]:</span> + <span class="n">extra_settings</span> <span class="o">+=</span> <span class="s2">"</span><span class="si">{key}</span><span class="s2"> = </span><span class="si">{value}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> + <span class="n">value</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_extra_settings"</span><span class="p">][</span><span class="n">key</span><span class="p">],</span> + <span class="p">)</span> + + <span class="n">jobid</span> <span class="o">=</span> <span class="s2">"$(Cluster).$(Process)"</span> + <span class="n">condor_submit_script</span> <span class="o">=</span> <span class="s2">"""</span> +<span class="s2">executable = </span><span class="si">{usr_bin_env}</span><span class="s2"></span> +<span class="s2">arguments = </span><span class="si">{bash}</span><span class="s2"> </span><span class="si">{job_script_path}</span><span class="s2"> $(Cluster) $(Process)</span> +<span class="s2">universe = </span><span class="si">{universe}</span><span class="s2"></span> +<span class="s2">getenv = </span><span class="si">{getenv}</span><span class="s2"></span> +<span class="s2">initial_dir = </span><span class="si">{initial_dir}</span><span class="s2"></span> +<span class="s2">output = </span><span class="si">{outfile}</span><span class="s2"></span> +<span class="s2">error = </span><span class="si">{errfile}</span><span class="s2"></span> +<span class="s2">log = </span><span class="si">{logfile}</span><span class="s2"></span> +<span class="s2">stream_output = </span><span class="si">{stream_output}</span><span class="s2"></span> +<span class="s2">stream_error = </span><span class="si">{stream_error}</span><span class="s2"></span> +<span class="s2">request_memory = </span><span class="si">{request_memory}</span><span class="s2"></span> +<span class="s2">request_cpus = </span><span class="si">{request_cpus}</span><span class="s2"></span> +<span class="s2">should_transfer_files = </span><span class="si">{should_transfer_files}</span><span class="s2"></span> +<span class="s2">when_to_transfer_output = </span><span class="si">{when_to_transfer_output}</span><span class="s2"></span> +<span class="s2">requirements = </span><span class="si">{requirements}</span><span class="s2"></span> +<span class="s2">JobBatchName = </span><span class="si">{batchname}</span><span class="s2"></span> +<span class="s2">kill_sig = </span><span class="si">{kill_sig}</span><span class="s2"></span> +<span class="si">{extra_settings}</span><span class="s2"></span> +<span class="s2">queue </span><span class="si">{njobs}</span><span class="s2"></span> +<span class="s2"> """</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">usr_bin_env</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_env"</span><span class="p">],</span> + <span class="n">bash</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_bash"</span><span class="p">],</span> + <span class="n">job_script_path</span><span class="o">=</span><span class="n">job_script_path</span><span class="p">,</span> + <span class="n">universe</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_universe"</span><span class="p">],</span> + <span class="n">getenv</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_getenv"</span><span class="p">],</span> + <span class="n">initial_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_initial_dir"</span><span class="p">],</span> + <span class="n">outfile</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">],</span> <span class="s2">"stdout"</span><span class="p">,</span> <span class="n">jobid</span><span class="p">)</span> + <span class="p">),</span> + <span class="n">errfile</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">],</span> <span class="s2">"stderr"</span><span class="p">,</span> <span class="n">jobid</span><span class="p">)</span> + <span class="p">),</span> + <span class="n">logfile</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_dir"</span><span class="p">],</span> <span class="s2">"log"</span><span class="p">,</span> <span class="n">jobid</span><span class="p">)</span> + <span class="p">),</span> + <span class="n">stream_output</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_stream_output"</span><span class="p">],</span> + <span class="n">stream_error</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_stream_error"</span><span class="p">],</span> + <span class="n">request_memory</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_memory"</span><span class="p">],</span> + <span class="n">request_cpus</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">],</span> + <span class="n">should_transfer_files</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"condor_should_transfer_files"</span> + <span class="p">],</span> + <span class="n">when_to_transfer_output</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"condor_when_to_transfer_output"</span> + <span class="p">],</span> + <span class="n">requirements</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_requirements"</span><span class="p">],</span> + <span class="n">batchname</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_batchname"</span><span class="p">],</span> + <span class="n">kill_sig</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_kill_sig"</span><span class="p">],</span> + <span class="n">extra_settings</span><span class="o">=</span><span class="n">extra_settings</span><span class="p">,</span> + <span class="n">njobs</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_njobs"</span><span class="p">],</span> + <span class="p">)</span> + + <span class="c1"># write the scripts, close them and make them executable by</span> + <span class="c1"># all (so the condor user can pick it up)</span> + <span class="k">for</span> <span class="n">file</span><span class="p">,</span> <span class="n">contents</span> <span class="ow">in</span> <span class="p">[</span> + <span class="p">(</span><span class="n">submit_script</span><span class="p">,</span> <span class="n">condor_submit_script</span><span class="p">),</span> + <span class="p">(</span><span class="n">job_script</span><span class="p">,</span> <span class="n">condor_job_script</span><span class="p">),</span> + <span class="p">]:</span> + <span class="n">path</span> <span class="o">=</span> <span class="n">file</span><span class="o">.</span><span class="n">name</span> + <span class="n">file</span><span class="o">.</span><span class="n">writelines</span><span class="p">(</span><span class="n">contents</span><span class="p">)</span> + <span class="n">file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="n">os</span><span class="o">.</span><span class="n">chmod</span><span class="p">(</span> + <span class="n">path</span><span class="p">,</span> + <span class="n">stat</span><span class="o">.</span><span class="n">S_IREAD</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IWRITE</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IEXEC</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IRGRP</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IXGRP</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IROTH</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IXOTH</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_postpone_submit"</span><span class="p">]:</span> + <span class="c1"># call sbatch to launch the condor jobs</span> + <span class="n">cmd</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_submit"</span><span class="p">],</span> <span class="n">submit_script_path</span><span class="p">]</span> + <span class="k">with</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span> + <span class="n">cmd</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stderr</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span> + <span class="p">)</span> <span class="k">as</span> <span class="n">pipes</span><span class="p">:</span> + <span class="n">std_out</span><span class="p">,</span> <span class="n">std_err</span> <span class="o">=</span> <span class="n">pipes</span><span class="o">.</span><span class="n">communicate</span><span class="p">()</span> + + <span class="k">if</span> <span class="n">pipes</span><span class="o">.</span><span class="n">returncode</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span> + <span class="c1"># an error happened!</span> + <span class="n">err_msg</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{red}{err}</span><span class="se">\n</span><span class="s2">Return Code: </span><span class="si">{code}{reset}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">err</span><span class="o">=</span><span class="n">std_err</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> + <span class="n">code</span><span class="o">=</span><span class="n">pipes</span><span class="o">.</span><span class="n">returncode</span><span class="p">,</span> + <span class="n">red</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"red"</span><span class="p">],</span> + <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">err_msg</span><span class="p">)</span> + + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">std_err</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{red}{err}{reset}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">red</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"red"</span><span class="p">],</span> + <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="n">err</span><span class="o">=</span><span class="n">std_err</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">),</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{yellow}{out}{reset}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">yellow</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"yellow"</span><span class="p">],</span> + <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="n">out</span><span class="o">=</span><span class="n">std_out</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">),</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># just say we would have (use this for testing)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Condor script is at </span><span class="si">{path}</span><span class="s2"> but has not been launched"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">path</span><span class="o">=</span><span class="n">submit_script_path</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1"># some messages to the user, then return</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_postpone_submit"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Condor script written, to </span><span class="si">{path}</span><span class="s2">, but launching the jobs with sbatch was postponed."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">path</span><span class="o">=</span><span class="n">submit_script_path</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Condor jobs launched."</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"All done in condor_grid()."</span><span class="p">)</span> + + <span class="c1"># return True so we exit immediately</span> + <span class="k">return</span> <span class="kc">True</span></div> + +<div class="viewcode-block" id="condor.condor_queue_stats"><a class="viewcode-back" href="../../../../population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_queue_stats">[docs]</a> <span class="k">def</span> <span class="nf">condor_queue_stats</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="c1"># pragma: no cover</span> + <span class="sd">"""</span> +<span class="sd"> Return condor queue statistics for this job</span> +<span class="sd"> """</span> + + <span class="n">_id</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"condor_ClusterID"</span><span class="p">]</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">_id</span><span class="p">:</span> + <span class="k">return</span> <span class="kc">None</span> + + <span class="n">cmd</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> 2>&1"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">"/usr/bin/condor_q"</span><span class="p">,</span> <span class="n">_id</span> <span class="c1"># self.grid_options["condor_q"],</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Q cmd"</span><span class="p">,</span> <span class="n">cmd</span><span class="p">)</span> + + <span class="k">with</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">)</span> <span class="k">as</span> <span class="n">subp</span><span class="p">:</span> + <span class="n">result</span> <span class="o">=</span> <span class="n">subp</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Q result "</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> + <span class="k">return</span> <span class="kc">None</span> + + <span class="n">d</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span> + <span class="s2">"jobs"</span><span class="p">,</span> + <span class="s2">"completed"</span><span class="p">,</span> + <span class="s2">"removed"</span><span class="p">,</span> + <span class="s2">"idle"</span><span class="p">,</span> + <span class="s2">"running"</span><span class="p">,</span> + <span class="s2">"held"</span><span class="p">,</span> + <span class="s2">"suspended"</span><span class="p">,</span> + <span class="p">]:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Q x "</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span> + <span class="n">m</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="s2">"(\d+)\s+</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">result</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Q m "</span><span class="p">,</span> <span class="n">m</span><span class="p">)</span> + <span class="k">if</span> <span class="n">m</span><span class="p">:</span> + <span class="n">d</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> + + <span class="nb">print</span><span class="p">(</span><span class="s2">"Q d "</span><span class="p">,</span> <span class="n">d</span><span class="p">)</span> + <span class="k">return</span> <span class="n">d</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/dataIO.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/dataIO.html new file mode 100644 index 0000000000000000000000000000000000000000..72ea210941e39d12df9104475343a011f43f08c1 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/dataIO.html @@ -0,0 +1,923 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.dataIO — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.dataIO</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.dataIO</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">File containing the class extension for the population object that contains data input-output (IO) functions</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">os</span> +<span class="kn">import</span> <span class="nn">bz2</span> +<span class="kn">import</span> <span class="nn">gzip</span> +<span class="kn">import</span> <span class="nn">copy</span> +<span class="kn">import</span> <span class="nn">json</span> +<span class="kn">import</span> <span class="nn">time</span> +<span class="kn">import</span> <span class="nn">datetime</span> +<span class="kn">import</span> <span class="nn">subprocess</span> +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span> + +<span class="kn">import</span> <span class="nn">msgpack</span> +<span class="kn">import</span> <span class="nn">flufl.lock</span> +<span class="kn">import</span> <span class="nn">compress_pickle</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.ensemble</span> <span class="kn">import</span> <span class="n">ensemble_file_type</span><span class="p">,</span> <span class="n">ensemble_compression</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.dicts</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">merge_dicts</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">verbose_print</span><span class="p">,</span> + <span class="n">now</span><span class="p">,</span> +<span class="p">)</span> + + +<div class="viewcode-block" id="dataIO"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO">[docs]</a><span class="k">class</span> <span class="nc">dataIO</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Class extension for the population object that contains data input-output (IO) functions</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the spacing_functions class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + +<div class="viewcode-block" id="dataIO.dir_ok"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.dir_ok">[docs]</a> <span class="k">def</span> <span class="nf">dir_ok</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">directory</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to test if we can read and write to a directory that must exist. Return True if all is ok, False otherwise.</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">access</span><span class="p">(</span><span class="n">directory</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">F_OK</span><span class="p">)</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">access</span><span class="p">(</span><span class="n">directory</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">R_OK</span> <span class="o">|</span> <span class="n">os</span><span class="o">.</span><span class="n">W_OK</span><span class="p">)</span></div> + +<div class="viewcode-block" id="dataIO.save_population_object"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.save_population_object">[docs]</a> <span class="k">def</span> <span class="nf">save_population_object</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">population_object</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">filename</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">confirmation</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="n">compression</span><span class="o">=</span><span class="s2">"gzip"</span><span class="p">,</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Save pickled Population object to file at filename or, if filename is None, whatever is set at self.grid_options['save_population_object']</span> + +<span class="sd"> Args:</span> +<span class="sd"> population_object : the object to be saved to the file. If population_object is None, use self.</span> +<span class="sd"> filename : the name of the file to be saved. If not set, use self.grid_options['save_population_object']</span> +<span class="sd"> confirmation : if True, a file "filename.saved" is touched just after the dump, so we know it is finished. TODO: fix this</span> +<span class="sd"> compression (optional, default = "gzip"): TODO: fix this</span> + +<span class="sd"> Compression is performed according to the filename, as stated in the</span> +<span class="sd"> compress_pickle documentation at</span> +<span class="sd"> https://lucianopaz.github.io/compress_pickle/html/</span> + +<span class="sd"> Shared memory, stored in the population_object.shared_memory dict, is not saved.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">population_object</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="c1"># default to using self</span> + <span class="n">population_object</span> <span class="o">=</span> <span class="bp">self</span> + + <span class="k">if</span> <span class="n">filename</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="c1"># get filename from self</span> + <span class="n">filename</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"save_population_object"</span><span class="p">]</span> + + <span class="k">if</span> <span class="n">filename</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Save population </span><span class="si">{id}</span><span class="s2">, probtot </span><span class="si">{probtot}</span><span class="s2"> to pickle in </span><span class="si">{filename}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_population_id"</span><span class="p">],</span> + <span class="n">probtot</span><span class="o">=</span><span class="n">population_object</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_probtot"</span><span class="p">],</span> + <span class="n">filename</span><span class="o">=</span><span class="n">filename</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1"># Some parts of the population_object cannot be pickled:</span> + <span class="c1"># remove them, and restore them after pickling</span> + + <span class="c1"># remove shared memory</span> + <span class="n">shared_memory</span> <span class="o">=</span> <span class="n">population_object</span><span class="o">.</span><span class="n">shared_memory</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">shared_memory</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="c1"># delete system generator</span> + <span class="n">system_generator</span> <span class="o">=</span> <span class="n">population_object</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="c1"># delete _store_memaddr</span> + <span class="n">_store_memaddr</span> <span class="o">=</span> <span class="n">population_object</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_store_memaddr"</span><span class="p">]</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_store_memaddr"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="c1"># delete persistent_data_memory_dict</span> + <span class="n">persistent_data_memory_dict</span> <span class="o">=</span> <span class="n">population_object</span><span class="o">.</span><span class="n">persistent_data_memory_dict</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">persistent_data_memory_dict</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="c1"># add metadata if it doesn't exist</span> + <span class="k">if</span> <span class="ow">not</span> <span class="s2">"metadata"</span> <span class="ow">in</span> <span class="n">population_object</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">:</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="c1"># add datestamp</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> + <span class="s2">"save_population_time"</span> + <span class="p">]</span> <span class="o">=</span> <span class="n">now</span><span class="p">()</span> + + <span class="c1"># add extra metadata</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">add_system_metadata</span><span class="p">()</span> + + <span class="c1"># add max memory use</span> + <span class="k">try</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> + <span class="s2">"max_memory_use"</span> + <span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="nb">sum</span><span class="p">(</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"max_memory_use_per_thread"</span><span class="p">]))</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"save_population_object : Error: "</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> + <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span> + + <span class="c1"># dump pickle file</span> + <span class="n">compress_pickle</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">population_object</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">pickler_method</span><span class="o">=</span><span class="s2">"dill"</span><span class="p">)</span> + + <span class="c1"># restore data</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">shared_memory</span> <span class="o">=</span> <span class="n">shared_memory</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> <span class="o">=</span> <span class="n">system_generator</span> + <span class="k">del</span> <span class="n">population_object</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> + <span class="s2">"save_population_time"</span> + <span class="p">]</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"store_memaddr"</span><span class="p">]</span> <span class="o">=</span> <span class="n">_store_memaddr</span> + <span class="n">population_object</span><span class="o">.</span><span class="n">persistent_data_memory_dict</span> <span class="o">=</span> <span class="n">persistent_data_memory_dict</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> + + <span class="c1"># touch 'saved' file</span> + <span class="n">saved</span> <span class="o">=</span> <span class="n">filename</span> <span class="o">+</span> <span class="s2">".saved"</span> + <span class="bp">self</span><span class="o">.</span><span class="n">HPC_touch</span><span class="p">(</span><span class="n">saved</span><span class="p">)</span></div> + +<div class="viewcode-block" id="dataIO.load_population_object"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.load_population_object">[docs]</a> <span class="k">def</span> <span class="nf">load_population_object</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> returns the Population object loaded from filename</span> +<span class="sd"> """</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> + <span class="k">if</span> <span class="n">filename</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">obj</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">obj</span> <span class="o">=</span> <span class="n">compress_pickle</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">pickler_method</span><span class="o">=</span><span class="s2">"dill"</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="n">obj</span> <span class="o">=</span> <span class="kc">None</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Loading of the compressed object went wrong: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">e</span><span class="p">))</span> + <span class="k">return</span> <span class="n">obj</span></div> + +<div class="viewcode-block" id="dataIO.merge_populations"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.merge_populations">[docs]</a> <span class="k">def</span> <span class="nf">merge_populations</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">refpop</span><span class="p">,</span> <span class="n">newpop</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> merge newpop's results data into refpop's results data</span> + +<span class="sd"> Args:</span> +<span class="sd"> refpop : the original "reference" Population object to be added to</span> +<span class="sd"> newpop : Population object containing the new data</span> + +<span class="sd"> Returns:</span> +<span class="sd"> nothing</span> + +<span class="sd"> Note:</span> +<span class="sd"> The file should be saved using save_population_object()</span> +<span class="sd"> """</span> + + <span class="c1"># combine data</span> + <span class="n">refpop</span><span class="o">.</span><span class="n">grid_results</span> <span class="o">=</span> <span class="n">merge_dicts</span><span class="p">(</span><span class="n">refpop</span><span class="o">.</span><span class="n">grid_results</span><span class="p">,</span> + <span class="n">newpop</span><span class="o">.</span><span class="n">grid_results</span><span class="p">)</span> + + <span class="c1"># special cases</span> + <span class="n">maxmem</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">if</span> <span class="s2">"max_memory_use"</span> <span class="ow">in</span> <span class="n">refpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> + <span class="s2">"metadata"</span><span class="p">,</span> <span class="p">{}</span> + <span class="p">)</span> <span class="ow">and</span> <span class="s2">"max_memory_use"</span> <span class="ow">in</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"metadata"</span><span class="p">,</span> <span class="p">{}):</span> + <span class="n">maxmem</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span> + <span class="n">refpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"max_memory_use"</span><span class="p">],</span> + <span class="n">newpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"max_memory_use"</span><span class="p">],</span> + <span class="p">)</span> + + <span class="k">try</span><span class="p">:</span> + <span class="c1"># special cases:</span> + <span class="c1"># copy the settings</span> + <span class="n">settings</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">if</span> <span class="s2">"settings"</span> <span class="ow">in</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"metadata"</span><span class="p">,</span> <span class="p">{}):</span> + <span class="n">settings</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span> + <span class="n">newpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"settings"</span><span class="p">]</span> + <span class="p">)</span> + <span class="k">if</span> <span class="n">settings</span><span class="p">:</span> + <span class="n">refpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"settings"</span><span class="p">]</span> <span class="o">=</span> <span class="n">settings</span> + + <span class="c1"># Copy the Xinit</span> + <span class="n">Xinit</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">if</span> <span class="s2">"Xinit"</span> <span class="ow">in</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble"</span><span class="p">,</span> <span class="p">{}):</span> + <span class="n">Xinit</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">newpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"ensemble"</span><span class="p">][</span><span class="s2">"Xinit"</span><span class="p">])</span> + <span class="k">if</span> <span class="n">Xinit</span><span class="p">:</span> + <span class="n">refpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"ensemble"</span><span class="p">][</span><span class="s2">"Xinit"</span><span class="p">]</span> <span class="o">=</span> <span class="n">Xinit</span> + + <span class="c1"># merge the ensemble dicts</span> + <span class="n">refpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span> <span class="o">=</span> <span class="n">merge_dicts</span><span class="p">(</span> + <span class="n">refpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">,</span> + <span class="n">newpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span> + <span class="p">)</span> + + <span class="c1"># set special cases</span> + <span class="n">refpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"max_memory_use"</span><span class="p">]</span> <span class="o">=</span> <span class="n">maxmem</span> + + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Error merging grid_ensemble_results:"</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> + <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"_probtot"</span><span class="p">]:</span> + <span class="n">refpop</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">+=</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + + <span class="n">refpop</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_killed"</span><span class="p">]</span> <span class="o">|=</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_killed"</span><span class="p">]</span></div> + +<div class="viewcode-block" id="dataIO.merge_populations_from_file"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.merge_populations_from_file">[docs]</a> <span class="k">def</span> <span class="nf">merge_populations_from_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">refpop</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Wrapper for merge_populations so it can be done directly</span> +<span class="sd"> from a file.</span> + +<span class="sd"> Args:</span> +<span class="sd"> refpop : the original "reference" Population object to be added to</span> +<span class="sd"> filename : file containing the Population object containing the new data</span> + +<span class="sd"> Note:</span> +<span class="sd"> The file should be saved using save_population_object()</span> +<span class="sd"> """</span> + + <span class="n">mtime</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">localtime</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">getmtime</span><span class="p">(</span><span class="n">filename</span><span class="p">))</span> + <span class="n">modtime</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">"</span><span class="si">%a</span><span class="s2">, </span><span class="si">%d</span><span class="s2"> %b %Y %H:%M:%S"</span><span class="p">,</span> <span class="n">mtime</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Load data from </span><span class="si">{filename}</span><span class="s2"> : size </span><span class="si">{size}</span><span class="s2">, modtime </span><span class="si">{modtime}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">filename</span><span class="o">=</span><span class="n">filename</span><span class="p">,</span> + <span class="n">size</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">getsize</span><span class="p">(</span><span class="n">filename</span><span class="p">),</span> + <span class="n">modtime</span><span class="o">=</span><span class="n">modtime</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="n">newpop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">load_population_object</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> + + <span class="k">if</span> <span class="s2">"total_count"</span> <span class="ow">in</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_options</span><span class="p">:</span> + <span class="n">n</span> <span class="o">=</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"total_count"</span><span class="p">]</span> + <span class="k">elif</span> <span class="s2">"_count"</span> <span class="ow">in</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_options</span><span class="p">:</span> + <span class="n">n</span> <span class="o">=</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">]</span> + <span class="k">elif</span> <span class="p">(</span> + <span class="s2">"metadata"</span> <span class="ow">in</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span> + <span class="ow">and</span> <span class="s2">"_count"</span> <span class="ow">in</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">]</span> + <span class="p">):</span> + <span class="n">n</span> <span class="o">=</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"_count"</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">n</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> + + <span class="nb">print</span><span class="p">(</span><span class="s2">"Loaded data from </span><span class="si">{n}</span><span class="s2"> stars"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="n">n</span><span class="p">))</span> + + <span class="c1"># merge with refpop</span> + <span class="bp">self</span><span class="o">.</span><span class="n">merge_populations</span><span class="p">(</span><span class="n">refpop</span><span class="p">,</span> <span class="n">newpop</span><span class="p">)</span></div> + +<div class="viewcode-block" id="dataIO.snapshot_filename"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.snapshot_filename">[docs]</a> <span class="k">def</span> <span class="nf">snapshot_filename</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Automatically choose the snapshot filename.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job</span><span class="p">():</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_snapshot_filename</span><span class="p">()</span> + + <span class="n">file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"snapshot.gz"</span><span class="p">)</span> + <span class="k">return</span> <span class="n">file</span></div> + +<div class="viewcode-block" id="dataIO.load_snapshot"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.load_snapshot">[docs]</a> <span class="k">def</span> <span class="nf">load_snapshot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">file</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Load a snapshot from file and set it in the preloaded_population placeholder.</span> +<span class="sd"> """</span> + <span class="n">newpop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">load_population_object</span><span class="p">(</span><span class="n">file</span><span class="p">)</span> + + <span class="c1"># unset the _killed flag, in case it was set</span> + <span class="n">newpop</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_killed"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> + + <span class="c1"># set in preloaded_population for later merge</span> + <span class="bp">self</span><span class="o">.</span><span class="n">preloaded_population</span> <span class="o">=</span> <span class="n">newpop</span> + + <span class="c1"># set the start position for new stars</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]</span> <span class="o">=</span> <span class="n">newpop</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">]</span> + + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Loaded from snapshot at </span><span class="si">{file}</span><span class="s2"> : </span><span class="si">{nstars}</span><span class="s2"> stars, start at star </span><span class="si">{nstart}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">file</span><span class="o">=</span><span class="n">file</span><span class="p">,</span> + <span class="n">nstars</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="c1"># self.grid_options[''],</span> + <span class="n">nstart</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"start_at"</span><span class="p">],</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">return</span></div> + +<div class="viewcode-block" id="dataIO.save_snapshot"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.save_snapshot">[docs]</a> <span class="k">def</span> <span class="nf">save_snapshot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Save the population object to a snapshot file, automatically choosing the filename if none is given.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="n">file</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">file</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">snapshot_filename</span><span class="p">()</span> + + <span class="k">if</span> <span class="s2">"_count"</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">:</span> + <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_count"</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">n</span> <span class="o">=</span> <span class="s2">"?"</span> + + <span class="nb">print</span><span class="p">(</span><span class="s2">"Saving snapshot containing </span><span class="si">{}</span><span class="s2"> stars to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">file</span><span class="p">))</span> + <span class="bp">self</span><span class="o">.</span><span class="n">save_population_object</span><span class="p">(</span><span class="nb">object</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="n">file</span><span class="p">)</span></div> + +<div class="viewcode-block" id="dataIO.write_ensemble"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.write_ensemble">[docs]</a> <span class="k">def</span> <span class="nf">write_ensemble</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">output_file</span><span class="p">,</span> + <span class="n">data</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">sort_keys</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> + <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> write_ensemble : Write ensemble results to a file.</span> + +<span class="sd"> Args:</span> +<span class="sd"> output_file : the output filename.</span> + +<span class="sd"> If the filename has an extension that we recognise,</span> +<span class="sd"> e.g. .gz or .bz2, we compress the output appropriately.</span> + +<span class="sd"> The filename should contain .json or .msgpack, the two</span> +<span class="sd"> currently-supported formats.</span> + +<span class="sd"> Usually you'll want to output to JSON, but we can</span> +<span class="sd"> also output to msgpack.</span> + +<span class="sd"> data : the data dictionary to be converted and written to the file.</span> +<span class="sd"> If not set, this defaults to self.grid_ensemble_results.</span> + +<span class="sd"> sort_keys : if True, and output is to JSON, the keys will be sorted.</span> +<span class="sd"> (default: True, passed to json.dumps)</span> + +<span class="sd"> indent : number of space characters used in the JSON indent. (Default: 4,</span> +<span class="sd"> passed to json.dumps)</span> + +<span class="sd"> encoding : file encoding method, usually defaults to 'utf-8'</span> + +<span class="sd"> ensure_ascii : the ensure_ascii flag passed to json.dump and/or json.dumps</span> +<span class="sd"> (Default: False)</span> +<span class="sd"> """</span> + + <span class="c1"># get the file type</span> + <span class="n">file_type</span> <span class="o">=</span> <span class="n">ensemble_file_type</span><span class="p">(</span><span class="n">output_file</span><span class="p">)</span> + + <span class="c1"># default to using grid_ensemble_results if no data is given</span> + <span class="k">if</span> <span class="n">data</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">file_type</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Unable to determine file type from ensemble filename </span><span class="si">{}</span><span class="s2"> : it should be .json or .msgpack."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">output_file</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">if</span> <span class="n">file_type</span> <span class="o">==</span> <span class="s2">"JSON"</span><span class="p">:</span> + <span class="n">f</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"wt"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">)</span> + <span class="c1"># JSON output</span> + <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span> + <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span> + <span class="n">data</span><span class="p">,</span> + <span class="n">sort_keys</span><span class="o">=</span><span class="n">sort_keys</span><span class="p">,</span> + <span class="n">indent</span><span class="o">=</span><span class="n">indent</span><span class="p">,</span> + <span class="n">ensure_ascii</span><span class="o">=</span><span class="n">ensure_ascii</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="n">file_type</span> <span class="o">==</span> <span class="s2">"msgpack"</span><span class="p">:</span> + <span class="n">f</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> + <span class="n">output_file</span><span class="p">,</span> <span class="s2">"w"</span> + <span class="p">)</span> <span class="c1"># TODO: i think something is going wrong here. not sure but doing msgpack and .gz e.g gives an error about str input rather than bytes. i think this is because the self.open does not take into account that the msgpack stream requires different properties.</span> + + <span class="c1"># msgpack output</span> + <span class="n">msgpack</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span> + + <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Thread </span><span class="si">{thread}</span><span class="s2">: Wrote ensemble results to file: </span><span class="si">{colour}{file}{reset}</span><span class="s2"> (file type </span><span class="si">{file_type}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">thread</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">,</span> + <span class="n">file</span><span class="o">=</span><span class="n">output_file</span><span class="p">,</span> + <span class="n">colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"green"</span><span class="p">],</span> + <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="n">file_type</span><span class="o">=</span><span class="n">file_type</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="dataIO.write_binary_c_calls_to_file"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.write_binary_c_calls_to_file">[docs]</a> <span class="k">def</span> <span class="nf">write_binary_c_calls_to_file</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">output_dir</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> + <span class="n">output_filename</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> + <span class="n">include_defaults</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> + <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function that loops over the grid code and writes the generated parameters to a file.</span> +<span class="sd"> In the form of a command line call</span> + +<span class="sd"> Only useful when you have a variable grid as system_generator. MC wouldn't be that useful</span> + +<span class="sd"> Also, make sure that in this export there are the basic parameters</span> +<span class="sd"> like m1,m2,sep, orb-per, ecc, probability etc.</span> + +<span class="sd"> On default this will write to the datadir, if it exists</span> + +<span class="sd"> Args:</span> +<span class="sd"> output_dir: (optional, default = None) directory where to write the file to. If custom_options['data_dir'] is present, then that one will be used first, and then the output_dir</span> +<span class="sd"> output_filename: (optional, default = None) filename of the output. If not set it will be called "binary_c_calls.txt"</span> +<span class="sd"> include_defaults: (optional, default = None) whether to include the defaults of binary_c in the lines that are written. Beware that this will result in very long lines, and it might be better to just export the binary_c defaults and keep them in a separate file.</span> + +<span class="sd"> Returns:</span> +<span class="sd"> filename: filename that was used to write the calls to</span> +<span class="sd"> """</span> + + <span class="c1"># Check if there is no compiled grid yet. If not, lets try to build it first.</span> + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]:</span> + + <span class="c1">## check the settings:</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">[</span><span class="s2">"ensemble"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ensemble_defer"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Error, if you want to run an ensemble in a population, the output needs to be deferred"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span> + + <span class="c1"># Put in check</span> + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Error: you haven't defined any grid variables! Aborting"</span><span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span> + + <span class="c1">#</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_generate_grid_code</span><span class="p">(</span><span class="n">dry_run</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> + + <span class="c1">#</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_load_grid_function</span><span class="p">()</span> + + <span class="c1"># then if the _system_generator is present, we go through it</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]:</span> + <span class="c1"># Check if there is an output dir configured</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"data_dir"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">binary_c_calls_output_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom_options</span><span class="p">[</span><span class="s2">"data_dir"</span><span class="p">]</span> + <span class="c1"># otherwise check if there's one passed to the function</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">output_dir</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Error. No data_dir configured and you gave no output_dir. Aborting"</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span> + <span class="n">binary_c_calls_output_dir</span> <span class="o">=</span> <span class="n">output_dir</span> + + <span class="c1"># check if there's a filename passed to the function</span> + <span class="k">if</span> <span class="n">output_filename</span><span class="p">:</span> + <span class="n">binary_c_calls_filename</span> <span class="o">=</span> <span class="n">output_filename</span> + <span class="c1"># otherwise use default value</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">binary_c_calls_filename</span> <span class="o">=</span> <span class="s2">"binary_c_calls.txt"</span> + + <span class="n">binary_c_calls_full_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="n">binary_c_calls_output_dir</span><span class="p">,</span> <span class="n">binary_c_calls_filename</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Writing binary_c calls to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">binary_c_calls_full_filename</span><span class="p">))</span> + + <span class="c1"># Write to file</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> + <span class="n">binary_c_calls_full_filename</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span> + <span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span> + <span class="c1"># Get defaults and clean them, then overwrite them with the set values.</span> + <span class="k">if</span> <span class="n">include_defaults</span><span class="p">:</span> + <span class="c1"># TODO: make sure that the defaults here are cleaned up properly</span> + <span class="n">cleaned_up_defaults</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cleaned_up_defaults</span> + <span class="n">full_system_dict</span> <span class="o">=</span> <span class="n">cleaned_up_defaults</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> + <span class="n">full_system_dict</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">copy</span><span class="p">())</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">full_system_dict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> + + <span class="k">for</span> <span class="n">system</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">](</span><span class="bp">self</span><span class="p">):</span> + <span class="c1"># update values with current system values</span> + <span class="n">full_system_dict</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">system</span><span class="p">)</span> + + <span class="n">binary_cmdline_string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_argline</span><span class="p">(</span><span class="n">full_system_dict</span><span class="p">)</span> + <span class="n">file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">binary_cmdline_string</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Error. No grid function found!"</span><span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span> + + <span class="k">return</span> <span class="n">binary_c_calls_full_filename</span></div> + +<div class="viewcode-block" id="dataIO.set_status"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.set_status">[docs]</a> <span class="k">def</span> <span class="nf">set_status</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">string</span><span class="p">,</span> <span class="n">format_statment</span><span class="o">=</span><span class="s2">"process_</span><span class="si">{}</span><span class="s2">.txt"</span><span class="p">,</span> <span class="n">ID</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to set the status string in its appropriate file</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">ID</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">ID</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"status_dir"</span><span class="p">]:</span> + <span class="n">path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"status_dir"</span><span class="p">],</span> + <span class="n">format_statment</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ID</span><span class="p">),</span> + <span class="p">)</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> + <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">string</span><span class="p">)</span> + <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> + + <span class="c1"># custom logging functions for HPC jobs</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job</span><span class="p">():</span> + <span class="bp">self</span><span class="o">.</span><span class="n">HPC_set_status</span><span class="p">(</span><span class="n">string</span><span class="p">)</span></div> + +<div class="viewcode-block" id="dataIO.locked_close"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.locked_close">[docs]</a> <span class="k">def</span> <span class="nf">locked_close</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">file</span><span class="p">,</span> <span class="n">lock</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Partner function to locked_open_for_write()</span> + +<span class="sd"> Closes and unlocks the file</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="n">file</span><span class="p">:</span> + <span class="n">file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="k">if</span> <span class="n">lock</span><span class="p">:</span> + <span class="n">lock</span><span class="o">.</span><span class="n">unlock</span><span class="p">()</span> + <span class="k">if</span> <span class="n">file</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">file</span><span class="o">.</span><span class="n">name</span><span class="p">)</span></div> + +<div class="viewcode-block" id="dataIO.wait_for_unlock"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.wait_for_unlock">[docs]</a> <span class="k">def</span> <span class="nf">wait_for_unlock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">lock_suffix</span><span class="o">=</span><span class="s2">".lock"</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Companion to locked_open_for_write that waits for a filename</span> +<span class="sd"> to a) exist and b) be unlocked.</span> + +<span class="sd"> This should work because the lock file is created before the file</span> +<span class="sd"> is created.</span> +<span class="sd"> """</span> + <span class="k">while</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span> + <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.25</span><span class="p">)</span> + <span class="k">while</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">filename</span> <span class="o">+</span> <span class="n">lock_suffix</span><span class="p">):</span> + <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.25</span><span class="p">)</span></div> + +<div class="viewcode-block" id="dataIO.locked_open_for_write"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.locked_open_for_write">[docs]</a> <span class="k">def</span> <span class="nf">locked_open_for_write</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">filename</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> + <span class="n">lock_suffix</span><span class="o">=</span><span class="s2">".lock"</span><span class="p">,</span> + <span class="n">lock_timeout</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> + <span class="n">lock_lifetime</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> + <span class="n">exists_ok</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">fatal_open_errors</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="n">vb</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="o">**</span><span class="n">kwargs</span><span class="p">,</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Wrapper for Python's open(filename) which opens a file at</span> +<span class="sd"> filename for writing (mode "w") and locks it.</span> + +<span class="sd"> We check whether the file's lockfile already exists, in which</span> +<span class="sd"> case just return (None,None), and if we cannot obtain a</span> +<span class="sd"> lock on the file we also return (None,None).</span> + +<span class="sd"> If the file does not exist, we keep trying to lock until it does.</span> + +<span class="sd"> To do the locking, we use flufl.lock which is NFS safe.</span> + +<span class="sd"> Args:</span> +<span class="sd"> lock_lifetime: (passed to flufl.lock.Lock()) default 60 seconds.</span> +<span class="sd"> It should take less than this time to write the file.</span> +<span class="sd"> lock_timeout: (passed to flufl.lock.Lock()) default 5 seconds.</span> +<span class="sd"> This should be non-zero.</span> +<span class="sd"> fatal_open_errors: if open() fails and fatal_open_errors is True, exit.</span> +<span class="sd"> exists_ok: if False and the file at filename exists, return (None,None) (default False)</span> +<span class="sd"> vb: verbose logging if True, defaults to False</span> + +<span class="sd"> Returns:</span> +<span class="sd"> (file_object, lock_object) tuple.</span> +<span class="sd"> If the file was not opened, returns (None,None).</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">exists_ok</span> <span class="ow">is</span> <span class="kc">False</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"File at </span><span class="si">{}</span><span class="s2"> already exists: cannot write to it"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">filename</span><span class="p">))</span> + <span class="k">return</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + + <span class="c1"># set the lockfile path: this should be the same</span> + <span class="c1"># for all processes, so it's just the original file</span> + <span class="c1"># plus the lock_suffix</span> + <span class="n">lockfilename</span> <span class="o">=</span> <span class="n">filename</span> <span class="o">+</span> <span class="n">lock_suffix</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"lockfile=</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lockfilename</span><span class="p">))</span> + + <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> + <span class="c1"># if the file exists, just return</span> + <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">lockfilename</span><span class="p">):</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"lockfile at </span><span class="si">{}</span><span class="s2"> already exists (corresponding to file at </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">lockfilename</span><span class="p">,</span> <span class="n">filename</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">return</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + + <span class="c1"># make the lock object by opening the lockfile</span> + <span class="n">lock</span> <span class="o">=</span> <span class="n">flufl</span><span class="o">.</span><span class="n">lock</span><span class="o">.</span><span class="n">Lock</span><span class="p">(</span><span class="n">lockfilename</span><span class="p">,</span> <span class="n">default_timeout</span><span class="o">=</span><span class="n">lock_timeout</span><span class="p">)</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"post-lock: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lock</span><span class="p">))</span> + + <span class="k">if</span> <span class="n">lock</span><span class="p">:</span> + <span class="c1"># we have the lockfile, so set the lifetime and try to lock it</span> + <span class="n">lock</span><span class="o">.</span><span class="n">lifetime</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">seconds</span><span class="o">=</span><span class="n">lock_lifetime</span><span class="p">)</span> + <span class="k">try</span><span class="p">:</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"try to lock </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lock</span><span class="p">))</span> + <span class="n">lock</span><span class="o">.</span><span class="n">lock</span><span class="p">()</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="k">if</span> <span class="n">lock</span><span class="o">.</span><span class="n">is_locked</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"locked </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lock</span><span class="p">))</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"failed to lock </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lock</span><span class="p">))</span> + <span class="k">except</span><span class="p">:</span> + <span class="k">pass</span> + + <span class="c1"># if we acquired the lock, try to open the file</span> + <span class="k">if</span> <span class="n">lock</span><span class="o">.</span><span class="n">is_locked</span><span class="p">:</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{}</span><span class="s2"> is locked by </span><span class="si">{}</span><span class="s2"> to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">filename</span><span class="p">,</span> <span class="n">lock</span><span class="p">,</span> <span class="n">lockfilename</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">exists_ok</span> <span class="ow">is</span> <span class="kc">False</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"File at </span><span class="si">{}</span><span class="s2"> already exists (2): cannot write to it, unlocking and returning (None,None)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">filename</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="n">lock</span><span class="o">.</span><span class="n">unlock</span><span class="p">()</span> + <span class="k">return</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + + <span class="c1"># All is apparently ok: file is locked</span> + <span class="k">try</span><span class="p">:</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Try to open file at </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">filename</span><span class="p">))</span> + <span class="n">f</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Return locked file </span><span class="si">{}</span><span class="s2">, </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">lock</span><span class="p">))</span> + <span class="k">return</span> <span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">lock</span><span class="p">)</span> + + <span class="c1"># error on open should be fatal</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Error in locked_open_for_write() : </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">e</span><span class="p">))</span> + <span class="k">if</span> <span class="n">fatal_open_errors</span><span class="p">:</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"fatal exit on open"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"unlock </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lock</span><span class="p">))</span> + <span class="n">lock</span><span class="o">.</span><span class="n">unlock</span><span class="p">()</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"unlocked </span><span class="si">{}</span><span class="s2"> return None,None"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lock</span><span class="p">))</span> + <span class="k">return</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + + <span class="c1"># failed to lock this time, keep trying</span> + <span class="c1"># (we shouldn't lock up the CPU because the timeout is non-zero)</span> + <span class="k">continue</span></div> + +<div class="viewcode-block" id="dataIO.NFS_flush_hack"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.NFS_flush_hack">[docs]</a> <span class="k">def</span> <span class="nf">NFS_flush_hack</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Use opendir()/closedir() to flush NFS access to a file.</span> + +<span class="sd"> NOTE: this may or may not work!</span> + +<span class="sd"> TODO: This function leads to a complaint about unclosed scandir operators. Check if that can be resolved.</span> +<span class="sd"> """</span> + <span class="n">os</span><span class="o">.</span><span class="n">sync</span><span class="p">()</span> + <span class="n">dirname</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> + + <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">scandir</span><span class="p">(</span><span class="n">dirname</span><span class="p">):</span> + <span class="k">pass</span></div> + +<div class="viewcode-block" id="dataIO.compression_type"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.compression_type">[docs]</a> <span class="k">def</span> <span class="nf">compression_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Return the compression type of the ensemble file, based on its filename extension.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">filename</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".bz2"</span><span class="p">):</span> + <span class="k">return</span> <span class="s2">"bzip2"</span> + <span class="k">if</span> <span class="n">filename</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".gz"</span><span class="p">):</span> + <span class="k">return</span> <span class="s2">"gzip"</span> + + <span class="k">return</span> <span class="kc">None</span></div> + +<div class="viewcode-block" id="dataIO.open"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.open">[docs]</a> <span class="k">def</span> <span class="nf">open</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">file</span><span class="p">,</span> + <span class="n">mode</span><span class="o">=</span><span class="s2">"r"</span><span class="p">,</span> + <span class="n">buffering</span><span class="o">=-</span><span class="mi">1</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">errors</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">newline</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">closefd</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="n">opener</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">compression</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">compresslevel</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">vb</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Wrapper for open() with automatic compression based on the file extension.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">compression</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">compression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">compression_type</span><span class="p">(</span><span class="n">file</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s1">'open() file at "</span><span class="si">{file}</span><span class="s1">" with mode = </span><span class="si">{mode}</span><span class="s1">, compression </span><span class="si">{compression}</span><span class="s1">, compresslevel </span><span class="si">{compresslevel}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">file</span><span class="o">=</span><span class="n">file</span><span class="p">,</span> + <span class="n">compression</span><span class="o">=</span><span class="n">compression</span><span class="p">,</span> + <span class="n">compresslevel</span><span class="o">=</span><span class="n">compresslevel</span><span class="p">,</span> + <span class="n">mode</span><span class="o">=</span><span class="n">mode</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">compression</span><span class="p">:</span> + <span class="k">if</span> <span class="n">compresslevel</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">compresslevel</span> <span class="o">=</span> <span class="mi">9</span> + <span class="k">if</span> <span class="s2">"b"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">mode</span><span class="p">:</span> + <span class="c1"># if we don't specify binary-mode, the gzip module</span> + <span class="c1"># defaults to binary, which isn't compatible with JSON,</span> + <span class="c1"># so default to text if not specified otherwise</span> + <span class="n">mode</span> <span class="o">+=</span> <span class="s2">"t"</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"open() adding text mode"</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">encoding</span> <span class="o">=</span> <span class="kc">None</span> + <span class="n">errors</span> <span class="o">=</span> <span class="kc">None</span> + <span class="n">newline</span> <span class="o">=</span> <span class="kc">None</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"open() setting encoding=errors=newline=None"</span><span class="p">)</span> + <span class="k">if</span> <span class="n">compression</span> <span class="o">==</span> <span class="s2">"bzip2"</span><span class="p">:</span> + <span class="n">file_object</span> <span class="o">=</span> <span class="n">bz2</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> + <span class="n">file</span><span class="p">,</span> + <span class="n">mode</span><span class="o">=</span><span class="n">mode</span><span class="p">,</span> + <span class="n">compresslevel</span><span class="o">=</span><span class="n">compresslevel</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">,</span> + <span class="n">errors</span><span class="o">=</span><span class="n">errors</span><span class="p">,</span> + <span class="n">newline</span><span class="o">=</span><span class="n">newline</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="n">compression</span> <span class="o">==</span> <span class="s2">"gzip"</span><span class="p">:</span> + <span class="n">file_object</span> <span class="o">=</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> + <span class="n">file</span><span class="p">,</span> + <span class="n">mode</span><span class="o">=</span><span class="n">mode</span><span class="p">,</span> + <span class="n">compresslevel</span><span class="o">=</span><span class="n">compresslevel</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">,</span> + <span class="n">errors</span><span class="o">=</span><span class="n">errors</span><span class="p">,</span> + <span class="n">newline</span><span class="o">=</span><span class="n">newline</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">file_object</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span> + <span class="n">file</span><span class="p">,</span> + <span class="n">mode</span><span class="o">=</span><span class="n">mode</span><span class="p">,</span> + <span class="n">buffering</span><span class="o">=</span><span class="n">buffering</span><span class="p">,</span> + <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">,</span> + <span class="n">errors</span><span class="o">=</span><span class="n">errors</span><span class="p">,</span> + <span class="n">newline</span><span class="o">=</span><span class="n">newline</span><span class="p">,</span> + <span class="n">closefd</span><span class="o">=</span><span class="n">closefd</span><span class="p">,</span> + <span class="n">opener</span><span class="o">=</span><span class="n">opener</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"open() return file_object ="</span><span class="p">,</span> <span class="n">file_object</span><span class="p">)</span> + <span class="k">return</span> <span class="n">file_object</span></div> + +<div class="viewcode-block" id="dataIO.NFSpath"><a class="viewcode-back" href="../../../../population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.NFSpath">[docs]</a> <span class="k">def</span> <span class="nf">NFSpath</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Test path to see if it's on an NFS mount.</span> + +<span class="sd"> Args:</span> +<span class="sd"> path : the path to be tested</span> + +<span class="sd"> Returns:</span> +<span class="sd"> True : if on an NFS mount point.</span> +<span class="sd"> False : if not.</span> +<span class="sd"> None : if the path does not exist.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">path</span><span class="p">):</span> + <span class="n">cmd</span> <span class="o">=</span> <span class="s1">'stat -f -L -c %T "'</span> <span class="o">+</span> <span class="n">path</span> <span class="o">+</span> <span class="s1">'"'</span> + <span class="k">return</span> <span class="p">(</span> + <span class="s2">"nfs"</span> + <span class="ow">in</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">)</span> + <span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> + <span class="o">.</span><span class="n">decode</span><span class="p">()</span> + <span class="p">)</span> + + <span class="k">return</span> <span class="kc">None</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/distribution_functions.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/distribution_functions.html new file mode 100644 index 0000000000000000000000000000000000000000..65258c1bd5552f469d45741a824762e1b0f4fc87 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/distribution_functions.html @@ -0,0 +1,2424 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.distribution_functions — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.distribution_functions</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.distribution_functions</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">Module containing the predefined distribution functions</span> + +<span class="sd">The user can use any of these distribution functions to</span> +<span class="sd">generate probability distributions for sampling populations</span> + +<span class="sd">To add custom functions you can take any function and add it to the class instance before running the code.</span> +<span class="sd">See https://stackoverflow.com/a/28060251 for some tips on how to do that</span> + +<span class="sd">There are distributions for the following parameters:</span> +<span class="sd"> - mass</span> +<span class="sd"> - period</span> +<span class="sd"> - mass ratio</span> +<span class="sd"> - binary fraction</span> + +<span class="sd">Tasks:</span> +<span class="sd"> - TODO: make some things globally present? rob does this in his module..i guess it saves</span> +<span class="sd"> calculations but not sure if I'm gonna do that now</span> +<span class="sd"> - TODO: add eccentricity distribution: thermal, Mathieu eccentricity</span> +<span class="sd"> - TODO: Add SFH distributions depending on redshift</span> +<span class="sd"> - TODO: Add metallicity distributions depending on redshift</span> +<span class="sd"> - TODO: Add initial rotational velocity distributions</span> +<span class="sd"> - TODO: make an n-part power law that's general enough to fix the three part and the 4 part</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101, R0201</span> + +<span class="kn">import</span> <span class="nn">math</span> +<span class="kn">import</span> <span class="nn">json</span> +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span> + +<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> +<span class="kn">import</span> <span class="nn">cachetools</span> + +<span class="kn">import</span> <span class="nn">py_rinterpolate</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.useful_funcs</span> <span class="kn">import</span> <span class="n">calc_period_from_sep</span><span class="p">,</span> <span class="n">calc_sep_from_period</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">verbose_print</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.grid_options_defaults</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.dicts</span> <span class="kn">import</span> <span class="n">prepare_dict</span> + +<span class="c1"># Global dictinary to store values in</span> +<span class="n">Moecache</span> <span class="o">=</span> <span class="p">{}</span> + +<span class="c1">###</span> +<span class="c1"># File containing probability distributions</span> +<span class="c1"># Mostly copied from the Perl modules</span> +<span class="n">LOG_LN_CONVERTER</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="mf">10.0</span><span class="p">)</span> +<span class="n">distribution_constants</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># To store the constants in</span> + + +<div class="viewcode-block" id="distribution_functions"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions">[docs]</a><span class="k">class</span> <span class="nc">distribution_functions</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Extension for the Population grid object that contains the distribution functions</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the distribution_functions class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + +<div class="viewcode-block" id="distribution_functions.flat"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.flat">[docs]</a> <span class="k">def</span> <span class="nf">flat</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">float</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Dummy distribution function that returns 1</span> + +<span class="sd"> Returns:</span> +<span class="sd"> a flat uniform distribution: 1</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="mf">1.0</span></div> + +<div class="viewcode-block" id="distribution_functions.number"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.number">[docs]</a> <span class="k">def</span> <span class="nf">number</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Dummy distribution function that returns the input</span> + +<span class="sd"> Args:</span> +<span class="sd"> value: the value that will be returned by this function.</span> + +<span class="sd"> Returns:</span> +<span class="sd"> the value that was provided</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="n">value</span></div> + +<div class="viewcode-block" id="distribution_functions.const_distribution"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.const_distribution">[docs]</a> <span class="k">def</span> <span class="nf">const_distribution</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">min_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">max_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">val</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> a constant distribution function between min=min_bound and max=max_bound.</span> + +<span class="sd"> Args:</span> +<span class="sd"> min_bound: lower bound of the range</span> +<span class="sd"> max_bound: upper bound of the range</span> + +<span class="sd"> Returns:</span> +<span class="sd"> returns the value of 1/(max_bound-min_bound). If val is provided, it will check whether min_bound < val <= max_bound. if not: returns 0</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">val</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">min_bound</span> <span class="o"><</span> <span class="n">val</span> <span class="o"><=</span> <span class="n">max_bound</span><span class="p">:</span> + <span class="n">prob</span> <span class="o">=</span> <span class="mf">0.0</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">prob</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="n">max_bound</span> <span class="o">-</span> <span class="n">min_bound</span><span class="p">)</span> + <span class="k">return</span> <span class="n">prob</span></div> + +<div class="viewcode-block" id="distribution_functions.powerlaw_constant_nocache"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_constant_nocache">[docs]</a> <span class="k">def</span> <span class="nf">powerlaw_constant_nocache</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">min_val</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">max_val</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">k</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Function that returns the constant to normalise a power law</span> + +<span class="sd"> TODO: what if k is -1?</span> + +<span class="sd"> Args:</span> +<span class="sd"> min_val: lower bound of the range</span> +<span class="sd"> max_val: upper bound of the range</span> +<span class="sd"> k: power law slope</span> + +<span class="sd"> Returns:</span> +<span class="sd"> constant to normalise the given power law between the min_val and max_val range</span> +<span class="sd"> """</span> + + <span class="n">k1</span> <span class="o">=</span> <span class="n">k</span> <span class="o">+</span> <span class="mf">1.0</span> + <span class="c1"># print(</span> + <span class="c1"># "Powerlaw consts from {} to {}, k={} where k1={}".format(</span> + <span class="c1"># min_val, max_val, k, k1</span> + <span class="c1"># )</span> + <span class="c1"># )</span> + + <span class="n">powerlaw_const</span> <span class="o">=</span> <span class="n">k1</span> <span class="o">/</span> <span class="p">(</span><span class="n">max_val</span> <span class="o">**</span> <span class="n">k1</span> <span class="o">-</span> <span class="n">min_val</span> <span class="o">**</span> <span class="n">k1</span><span class="p">)</span> + <span class="k">return</span> <span class="n">powerlaw_const</span></div> + +<div class="viewcode-block" id="distribution_functions.powerlaw_constant"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_constant">[docs]</a> <span class="nd">@cachetools</span><span class="o">.</span><span class="n">cachedmethod</span><span class="p">(</span> + <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">[</span> + <span class="s2">"population_extensions._distribution_functions.powerlaw_constant"</span> + <span class="p">]</span> + <span class="p">)</span> + <span class="k">def</span> <span class="nf">powerlaw_constant</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">min_val</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">max_val</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">k</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Function that returns the constant to normalise a power law</span> + +<span class="sd"> TODO: what if k is -1?</span> + +<span class="sd"> Args:</span> +<span class="sd"> min_val: lower bound of the range</span> +<span class="sd"> max_val: upper bound of the range</span> +<span class="sd"> k: power law slope</span> + +<span class="sd"> Returns:</span> +<span class="sd"> constant to normalise the given power law between the min_val and max_val range</span> +<span class="sd"> """</span> + + <span class="n">k1</span> <span class="o">=</span> <span class="n">k</span> <span class="o">+</span> <span class="mf">1.0</span> + <span class="c1"># print(</span> + <span class="c1"># "Powerlaw consts from {} to {}, k={} where k1={}".format(</span> + <span class="c1"># min_val, max_val, k, k1</span> + <span class="c1"># )</span> + <span class="c1"># )</span> + + <span class="n">powerlaw_const</span> <span class="o">=</span> <span class="n">k1</span> <span class="o">/</span> <span class="p">(</span><span class="n">max_val</span> <span class="o">**</span> <span class="n">k1</span> <span class="o">-</span> <span class="n">min_val</span> <span class="o">**</span> <span class="n">k1</span><span class="p">)</span> + <span class="k">return</span> <span class="n">powerlaw_const</span></div> + +<div class="viewcode-block" id="distribution_functions.powerlaw"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw">[docs]</a> <span class="k">def</span> <span class="nf">powerlaw</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">min_val</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">max_val</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">k</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">x</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Single power law with index k at x from min to max</span> + +<span class="sd"> Args:</span> +<span class="sd"> min_val: lower bound of the power law</span> +<span class="sd"> max_val: upper bound of the power law</span> +<span class="sd"> k: slope of the power law</span> +<span class="sd"> x: position at which we want to evaluate</span> + +<span class="sd"> Returns:</span> +<span class="sd"> `probability` at the given position(x)</span> +<span class="sd"> """</span> + + <span class="c1"># Handle faulty value</span> + <span class="k">if</span> <span class="n">k</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"wrong value for k"</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="k">if</span> <span class="p">(</span><span class="n">x</span> <span class="o"><</span> <span class="n">min_val</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">x</span> <span class="o">></span> <span class="n">max_val</span><span class="p">):</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"input value is out of bounds!"</span><span class="p">)</span> + <span class="k">return</span> <span class="mi">0</span> + + <span class="n">powerlaw_const</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">powerlaw_constant</span><span class="p">(</span><span class="n">min_val</span><span class="p">,</span> <span class="n">max_val</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span> + + <span class="c1"># power law</span> + <span class="n">prob</span> <span class="o">=</span> <span class="n">powerlaw_const</span> <span class="o">*</span> <span class="p">(</span><span class="n">x</span> <span class="o">**</span> <span class="n">k</span><span class="p">)</span> + <span class="k">return</span> <span class="n">prob</span></div> + +<div class="viewcode-block" id="distribution_functions.calculate_constants_three_part_powerlaw"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calculate_constants_three_part_powerlaw">[docs]</a> <span class="nd">@cachetools</span><span class="o">.</span><span class="n">cachedmethod</span><span class="p">(</span> + <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">[</span> + <span class="s2">"distribution_functions.calculate_constants_three_part_powerlaw"</span> + <span class="p">]</span> + <span class="p">)</span> + <span class="k">def</span> <span class="nf">calculate_constants_three_part_powerlaw</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">m0</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">m1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">m2</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">m_max</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">p1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">p2</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">p3</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Function to calculate the constants for a three-part power law</span> + +<span class="sd"> TODO: use the power law_constant function to calculate all these values</span> + +<span class="sd"> Args:</span> +<span class="sd"> m0: lower bound mass</span> +<span class="sd"> m1: second boundary, between the first slope and the second slope</span> +<span class="sd"> m2: third boundary, between the second slope and the third slope</span> +<span class="sd"> m_max: upper bound mass</span> +<span class="sd"> p1: first slope</span> +<span class="sd"> p2: second slope</span> +<span class="sd"> p3: third slope</span> + +<span class="sd"> Returns:</span> +<span class="sd"> array of normalisation constants</span> +<span class="sd"> """</span> + + <span class="n">array_constants_three_part_powerlaw</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span> + + <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> + <span class="p">((</span><span class="n">m1</span> <span class="o">**</span> <span class="n">p2</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">m1</span> <span class="o">**</span> <span class="p">(</span><span class="o">-</span><span class="n">p1</span><span class="p">)))</span> + <span class="o">*</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p1</span><span class="p">))</span> + <span class="o">*</span> <span class="p">(</span><span class="n">m1</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p1</span><span class="p">)</span> <span class="o">-</span> <span class="n">m0</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p1</span><span class="p">))</span> + <span class="p">)</span> + <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+=</span> <span class="p">(</span> + <span class="p">(</span><span class="n">m2</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p2</span><span class="p">)</span> <span class="o">-</span> <span class="n">m1</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p2</span><span class="p">))</span> + <span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p2</span><span class="p">))</span> + <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+=</span> <span class="p">(</span> + <span class="p">((</span><span class="n">m2</span> <span class="o">**</span> <span class="n">p2</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">m2</span> <span class="o">**</span> <span class="p">(</span><span class="o">-</span><span class="n">p3</span><span class="p">)))</span> + <span class="o">*</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p3</span><span class="p">))</span> + <span class="o">*</span> <span class="p">(</span><span class="n">m_max</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p3</span><span class="p">)</span> <span class="o">-</span> <span class="n">m2</span> <span class="o">**</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p3</span><span class="p">))</span> + <span class="p">)</span> + <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span> + <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mf">1e-50</span> + <span class="p">)</span> + + <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span> + <span class="mi">1</span> + <span class="p">]</span> <span class="o">*</span> <span class="p">((</span><span class="n">m1</span> <span class="o">**</span> <span class="n">p2</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">m1</span> <span class="o">**</span> <span class="p">(</span><span class="o">-</span><span class="n">p1</span><span class="p">)))</span> + <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">array_constants_three_part_powerlaw</span><span class="p">[</span> + <span class="mi">1</span> + <span class="p">]</span> <span class="o">*</span> <span class="p">((</span><span class="n">m2</span> <span class="o">**</span> <span class="n">p2</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">m2</span> <span class="o">**</span> <span class="p">(</span><span class="o">-</span><span class="n">p3</span><span class="p">)))</span> + + <span class="k">return</span> <span class="n">array_constants_three_part_powerlaw</span></div> + +<div class="viewcode-block" id="distribution_functions.three_part_powerlaw"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.three_part_powerlaw">[docs]</a> <span class="k">def</span> <span class="nf">three_part_powerlaw</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">m0</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">m1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">m2</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">m_max</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">p1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">p2</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">p3</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Generalised three-part power law, usually used for mass distributions</span> + +<span class="sd"> Args:</span> +<span class="sd"> m: mass at which we want to evaluate the distribution.</span> +<span class="sd"> m0: lower bound mass</span> +<span class="sd"> m1: second boundary, between the first slope and the second slope</span> +<span class="sd"> m2: third boundary, between the second slope and the third slope</span> +<span class="sd"> m_max: upper bound mass</span> +<span class="sd"> p1: first slope</span> +<span class="sd"> p2: second slope</span> +<span class="sd"> p3: third slope</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' at given mass m</span> +<span class="sd"> """</span> + + <span class="n">three_part_powerlaw_constants</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">calculate_constants_three_part_powerlaw</span><span class="p">(</span> + <span class="n">m0</span><span class="p">,</span> <span class="n">m1</span><span class="p">,</span> <span class="n">m2</span><span class="p">,</span> <span class="n">m_max</span><span class="p">,</span> <span class="n">p1</span><span class="p">,</span> <span class="n">p2</span><span class="p">,</span> <span class="n">p3</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">m</span> <span class="o"><</span> <span class="n">m0</span><span class="p">:</span> + <span class="n">prob</span> <span class="o">=</span> <span class="mf">0.0</span> <span class="c1"># Below lower bound</span> + <span class="k">elif</span> <span class="n">m</span> <span class="o"><=</span> <span class="n">m1</span><span class="p">:</span> + <span class="n">prob</span> <span class="o">=</span> <span class="n">three_part_powerlaw_constants</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="n">p1</span><span class="p">)</span> <span class="c1"># Between m0 and m1</span> + <span class="k">elif</span> <span class="n">m</span> <span class="o"><=</span> <span class="n">m2</span><span class="p">:</span> + <span class="n">prob</span> <span class="o">=</span> <span class="n">three_part_powerlaw_constants</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="n">p2</span><span class="p">)</span> <span class="c1"># Between m1 and m2</span> + <span class="k">elif</span> <span class="n">m</span> <span class="o"><=</span> <span class="n">m_max</span><span class="p">:</span> + <span class="n">prob</span> <span class="o">=</span> <span class="n">three_part_powerlaw_constants</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="n">p3</span><span class="p">)</span> <span class="c1"># Between m2 and m_max</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">prob</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># Above m_max</span> + + <span class="k">return</span> <span class="n">prob</span></div> + +<div class="viewcode-block" id="distribution_functions.gaussian_normalizing_const"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian_normalizing_const">[docs]</a> <span class="nd">@cachetools</span><span class="o">.</span><span class="n">cachedmethod</span><span class="p">(</span> + <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">[</span><span class="s2">"distribution_functions.gaussian_normalizing_const"</span><span class="p">]</span> + <span class="p">)</span> + <span class="k">def</span> <span class="nf">gaussian_normalizing_const</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">mean</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">sigma</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">gmin</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">gmax</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Function to calculate the normalisation constant for the Gaussian</span> + +<span class="sd"> Args:</span> +<span class="sd"> mean: mean of the Gaussian</span> +<span class="sd"> sigma: standard deviation of the Gaussian</span> +<span class="sd"> gmin: lower bound of the range to calculate the probabilities in</span> +<span class="sd"> gmax: upper bound of the range to calculate the probabilities in</span> + +<span class="sd"> Returns:</span> +<span class="sd"> normalisation constant for the Gaussian distribution(mean, sigma) between gmin and gmax</span> +<span class="sd"> """</span> + + <span class="c1"># First time; calculate multiplier for given mean and sigma</span> + <span class="n">ptot</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">resolution</span> <span class="o">=</span> <span class="mi">1000</span> + <span class="n">d</span> <span class="o">=</span> <span class="p">(</span><span class="n">gmax</span> <span class="o">-</span> <span class="n">gmin</span><span class="p">)</span> <span class="o">/</span> <span class="n">resolution</span> + + <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">resolution</span><span class="p">):</span> + <span class="n">y</span> <span class="o">=</span> <span class="n">gmin</span> <span class="o">+</span> <span class="n">i</span> <span class="o">*</span> <span class="n">d</span> + <span class="n">ptot</span> <span class="o">+=</span> <span class="n">d</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">gaussian_func</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">mean</span><span class="p">,</span> <span class="n">sigma</span><span class="p">)</span> + + <span class="k">return</span> <span class="n">ptot</span></div> + +<div class="viewcode-block" id="distribution_functions.gaussian_func"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian_func">[docs]</a> <span class="k">def</span> <span class="nf">gaussian_func</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">mean</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">sigma</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Function to evaluate a Gaussian at a given point, but this time without any boundaries.</span> + +<span class="sd"> Args:</span> +<span class="sd"> x: location at which to evaluate the distribution</span> +<span class="sd"> mean: mean of the Gaussian</span> +<span class="sd"> sigma: standard deviation of the Gaussian</span> + +<span class="sd"> Returns:</span> +<span class="sd"> value of the Gaussian at x</span> +<span class="sd"> """</span> + <span class="n">gaussian_prefactor</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="mf">2.0</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">pi</span><span class="p">)</span> + + <span class="n">r</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="n">sigma</span><span class="p">)</span> + <span class="n">y</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">mean</span><span class="p">)</span> <span class="o">*</span> <span class="n">r</span> + <span class="k">return</span> <span class="n">gaussian_prefactor</span> <span class="o">*</span> <span class="n">r</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span> <span class="o">*</span> <span class="n">y</span> <span class="o">**</span> <span class="mi">2</span><span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.gaussian"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian">[docs]</a> <span class="k">def</span> <span class="nf">gaussian</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">x</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">mean</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">sigma</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">gmin</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">gmax</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Gaussian distribution function. used for e.g. Duquennoy + Mayor 1991</span> + +<span class="sd"> Args:</span> +<span class="sd"> x: location at which to evaluate the distribution</span> +<span class="sd"> mean: mean of the Gaussian</span> +<span class="sd"> sigma: standard deviation of the Gaussian</span> +<span class="sd"> gmin: lower bound of the range to calculate the probabilities in</span> +<span class="sd"> gmax: upper bound of the range to calculate the probabilities in</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' of the Gaussian distribution between the boundaries, evaluated at x</span> +<span class="sd"> """</span> + + <span class="c1"># # location (X value), mean and sigma, min and max range</span> + <span class="c1"># my ($x,$mean,$sigma,$gmin,$gmax) = @_;</span> + + <span class="k">if</span> <span class="p">(</span><span class="n">x</span> <span class="o"><</span> <span class="n">gmin</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">x</span> <span class="o">></span> <span class="n">gmax</span><span class="p">):</span> + <span class="n">prob</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># normalise over given range</span> + <span class="n">normalisation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">gaussian_normalizing_const</span><span class="p">(</span><span class="n">mean</span><span class="p">,</span> <span class="n">sigma</span><span class="p">,</span> <span class="n">gmin</span><span class="p">,</span> <span class="n">gmax</span><span class="p">)</span> + <span class="n">prob</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">gaussian_func</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">mean</span><span class="p">,</span> <span class="n">sigma</span><span class="p">)</span> <span class="o">/</span> <span class="n">normalisation</span> + + <span class="k">return</span> <span class="n">prob</span></div> + + <span class="c1">#####</span> + <span class="c1"># Mass distributions</span> + <span class="c1">#####</span> + +<div class="viewcode-block" id="distribution_functions.Kroupa2001"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Kroupa2001">[docs]</a> <span class="k">def</span> <span class="nf">Kroupa2001</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">newopts</span><span class="p">:</span> <span class="nb">dict</span> <span class="o">=</span> <span class="kc">None</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Probability distribution function for Kroupa 2001 IMF.</span> + +<span class="sd"> The (default) values for this is::</span> + +<span class="sd"> default = {</span> +<span class="sd"> "m0": 0.1,</span> +<span class="sd"> "m1": 0.5,</span> +<span class="sd"> "m2": 1,</span> +<span class="sd"> "mmax": 100,</span> +<span class="sd"> "p1": -1.3,</span> +<span class="sd"> "p2": -2.3,</span> +<span class="sd"> "p3": -2.3</span> +<span class="sd"> }</span> + +<span class="sd"> Args:</span> +<span class="sd"> m: mass to evaluate the distribution at</span> +<span class="sd"> newopts: optional dict to override the default values.</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' of distribution function evaluated at m</span> +<span class="sd"> """</span> + + <span class="c1"># Default parameters and override them</span> + <span class="n">default</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"m0"</span><span class="p">:</span> <span class="mf">0.1</span><span class="p">,</span> + <span class="s2">"m1"</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">,</span> + <span class="s2">"m2"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> + <span class="s2">"mmax"</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span> + <span class="s2">"p1"</span><span class="p">:</span> <span class="o">-</span><span class="mf">1.3</span><span class="p">,</span> + <span class="s2">"p2"</span><span class="p">:</span> <span class="o">-</span><span class="mf">2.3</span><span class="p">,</span> + <span class="s2">"p3"</span><span class="p">:</span> <span class="o">-</span><span class="mf">2.3</span><span class="p">,</span> + <span class="p">}</span> + + <span class="n">value_dict</span> <span class="o">=</span> <span class="n">default</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> + + <span class="k">if</span> <span class="n">newopts</span><span class="p">:</span> + <span class="n">value_dict</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">newopts</span><span class="p">)</span> + + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">three_part_powerlaw</span><span class="p">(</span> + <span class="n">m</span><span class="p">,</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m0"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m1"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m2"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"mmax"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p1"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p2"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p3"</span><span class="p">],</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.ktg93"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.ktg93">[docs]</a> <span class="k">def</span> <span class="nf">ktg93</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">newopts</span><span class="p">:</span> <span class="nb">dict</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Probability distribution function for KTG93 IMF, where the default values to the three_part_powerlaw are: default = {"m0": 0.1, "m1": 0.5, "m2": 1, "mmax": 80, "p1": -1.3, "p2": -2.2,"p3": -2.7}</span> + +<span class="sd"> Args:</span> +<span class="sd"> m: mass to evaluate the distribution at</span> +<span class="sd"> newopts: optional dict to override the default values.</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' of distribution function evaluated at m</span> +<span class="sd"> """</span> + + <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"m0"</span><span class="p">:</span> <span class="mf">0.1</span><span class="p">,</span> + <span class="s2">"m1"</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">,</span> + <span class="s2">"m2"</span><span class="p">:</span> <span class="mf">1.0</span><span class="p">,</span> + <span class="s2">"mmax"</span><span class="p">:</span> <span class="mi">80</span><span class="p">,</span> + <span class="s2">"p1"</span><span class="p">:</span> <span class="o">-</span><span class="mf">1.3</span><span class="p">,</span> + <span class="s2">"p2"</span><span class="p">:</span> <span class="o">-</span><span class="mf">2.2</span><span class="p">,</span> + <span class="s2">"p3"</span><span class="p">:</span> <span class="o">-</span><span class="mf">2.7</span><span class="p">,</span> + <span class="p">}</span> + <span class="n">value_dict</span> <span class="o">=</span> <span class="n">defaults</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> + + <span class="k">if</span> <span class="n">newopts</span><span class="p">:</span> + <span class="n">value_dict</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">newopts</span><span class="p">)</span> + + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">three_part_powerlaw</span><span class="p">(</span> + <span class="n">m</span><span class="p">,</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m0"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m1"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"m2"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"mmax"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p1"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p2"</span><span class="p">],</span> + <span class="n">value_dict</span><span class="p">[</span><span class="s2">"p3"</span><span class="p">],</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.imf_tinsley1980"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_tinsley1980">[docs]</a> <span class="k">def</span> <span class="nf">imf_tinsley1980</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Probability distribution function for Tinsley 1980 IMF (defined up until 80Msol): self.three_part_powerlaw(m, 0.1, 2.0, 10.0, 80.0, -2.0, -2.3, -3.3)</span> + +<span class="sd"> Args:</span> +<span class="sd"> m: mass to evaluate the distribution at</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' of distribution function evaluated at m</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">three_part_powerlaw</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">,</span> <span class="mf">10.0</span><span class="p">,</span> <span class="mf">80.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.3</span><span class="p">,</span> <span class="o">-</span><span class="mf">3.3</span><span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.imf_scalo1986"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_scalo1986">[docs]</a> <span class="k">def</span> <span class="nf">imf_scalo1986</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Probability distribution function for Scalo 1986 IMF (defined up until 80Msol): self.three_part_powerlaw(m, 0.1, 1.0, 2.0, 80.0, -2.35, -2.35, -2.70)</span> + +<span class="sd"> Args:</span> +<span class="sd"> m: mass to evaluate the distribution at</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' of distribution function evaluated at m</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">three_part_powerlaw</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">,</span> <span class="mf">80.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.35</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.35</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.70</span><span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.imf_scalo1998"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_scalo1998">[docs]</a> <span class="k">def</span> <span class="nf">imf_scalo1998</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> From Scalo 1998</span> + +<span class="sd"> Probability distribution function for Scalo 1998 IMF (defined up until 80Msol): self.three_part_powerlaw(m, 0.1, 1.0, 10.0, 80.0, -1.2, -2.7, -2.3)</span> + +<span class="sd"> Args:</span> +<span class="sd"> m: mass to evaluate the distribution at</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' of distribution function evaluated at m</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">three_part_powerlaw</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">10.0</span><span class="p">,</span> <span class="mf">80.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.2</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.7</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.3</span><span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.imf_chabrier2003"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_chabrier2003">[docs]</a> <span class="k">def</span> <span class="nf">imf_chabrier2003</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Probability distribution function for IMF of Chabrier 2003 PASP 115:763-795</span> + +<span class="sd"> Args:</span> +<span class="sd"> m: mass to evaluate the distribution at</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' of distribution function evaluated at m</span> +<span class="sd"> """</span> + + <span class="n">chabrier_logmc</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="mf">0.079</span><span class="p">)</span> + <span class="n">chabrier_sigma2</span> <span class="o">=</span> <span class="mf">0.69</span> <span class="o">*</span> <span class="mf">0.69</span> + <span class="n">chabrier_a1</span> <span class="o">=</span> <span class="mf">0.158</span> + <span class="n">chabrier_a2</span> <span class="o">=</span> <span class="mf">4.43e-2</span> + <span class="n">chabrier_x</span> <span class="o">=</span> <span class="o">-</span><span class="mf">1.3</span> + + <span class="k">if</span> <span class="n">m</span> <span class="o"><=</span> <span class="mi">0</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"below bounds"</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="k">if</span> <span class="mi">0</span> <span class="o"><</span> <span class="n">m</span> <span class="o"><</span> <span class="mf">1.0</span><span class="p">:</span> + <span class="n">dm</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> <span class="o">-</span> <span class="n">chabrier_logmc</span> + <span class="n">prob</span> <span class="o">=</span> <span class="n">chabrier_a1</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="p">(</span><span class="n">dm</span> <span class="o">**</span> <span class="mi">2</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mf">2.0</span> <span class="o">*</span> <span class="n">chabrier_sigma2</span><span class="p">))</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">prob</span> <span class="o">=</span> <span class="n">chabrier_a2</span> <span class="o">*</span> <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="n">chabrier_x</span><span class="p">)</span> + + <span class="n">prob</span> <span class="o">=</span> <span class="n">prob</span> <span class="o">/</span> <span class="p">(</span><span class="mf">0.1202462</span> <span class="o">*</span> <span class="n">m</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="mi">10</span><span class="p">))</span> + <span class="k">return</span> <span class="n">prob</span></div> + + <span class="c1">########################################################################</span> + <span class="c1"># Binary fractions</span> + <span class="c1">########################################################################</span> + +<div class="viewcode-block" id="distribution_functions.Arenou2010_binary_fraction"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Arenou2010_binary_fraction">[docs]</a> <span class="k">def</span> <span class="nf">Arenou2010_binary_fraction</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Arenou 2010 function for the binary fraction as f(M1)</span> + +<span class="sd"> GAIA-C2-SP-OPM-FA-054</span> +<span class="sd"> www.rssd.esa.int/doc_fetch.php?id=2969346</span> + +<span class="sd"> Args:</span> +<span class="sd"> m: mass to evaluate the distribution at</span> + +<span class="sd"> Returns:</span> +<span class="sd"> binary fraction at m</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="mf">0.8388</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">tanh</span><span class="p">(</span><span class="mf">0.688</span> <span class="o">*</span> <span class="n">m</span> <span class="o">+</span> <span class="mf">0.079</span><span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.raghavan2010_binary_fraction"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.raghavan2010_binary_fraction">[docs]</a> <span class="k">def</span> <span class="nf">raghavan2010_binary_fraction</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Fit to the Raghavan 2010 binary fraction as a function of</span> +<span class="sd"> spectral type (Fig 12). Valid for local stars (Z=Zsolar).</span> + +<span class="sd"> The spectral type is converted mass by use of the ZAMS</span> +<span class="sd"> effective temperatures from binary_c/BSE (at Z=0.02)</span> +<span class="sd"> and the new "long_spectral_type" function of binary_c</span> +<span class="sd"> (based on Jaschek+Jaschek's Teff-spectral type table).</span> + +<span class="sd"> Rob then fitted the result</span> + +<span class="sd"> Args:</span> +<span class="sd"> m: mass to evaluate the distribution at</span> + +<span class="sd"> Returns:</span> +<span class="sd"> binary fraction at m</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="nb">min</span><span class="p">(</span> + <span class="mf">1.0</span><span class="p">,</span> + <span class="nb">max</span><span class="p">(</span> + <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="mf">0.1</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mf">5.12310e-01</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="o">-</span><span class="mf">1.02070e-01</span><span class="p">),</span> + <span class="p">(</span><span class="mf">1.10450e00</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">m</span> <span class="o">**</span> <span class="p">(</span><span class="mf">4.93670e-01</span><span class="p">))</span> <span class="o">+</span> <span class="p">(</span><span class="o">-</span><span class="mf">6.95630e-01</span><span class="p">),</span> + <span class="p">),</span> + <span class="p">)</span></div> + + <span class="c1">########################################################################</span> + <span class="c1"># Period distributions</span> + <span class="c1">########################################################################</span> + +<div class="viewcode-block" id="distribution_functions.duquennoy1991"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.duquennoy1991">[docs]</a> <span class="k">def</span> <span class="nf">duquennoy1991</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">logper</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Period distribution from Duquennoy + Mayor 1991. Evaluated the function self.gaussian(logper, 4.8, 2.3, -2, 12)</span> + +<span class="sd"> Args:</span> +<span class="sd"> logper: logarithm of period to evaluate the distribution at</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' at self.gaussian(logper, 4.8, 2.3, -2, 12)</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">gaussian</span><span class="p">(</span><span class="n">logper</span><span class="p">,</span> <span class="mf">4.8</span><span class="p">,</span> <span class="mf">2.3</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.sana12"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.sana12">[docs]</a> <span class="k">def</span> <span class="nf">sana12</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">M1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">M2</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">a</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">P</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">amin</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">amax</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">x0</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">x1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">p</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> distribution of initial orbital periods as found by Sana et al. (2012)</span> +<span class="sd"> which is a flat distribution in ln(a) and ln(P) respectively for stars</span> +<span class="sd"> * less massive than 15Msun (no O-stars)</span> +<span class="sd"> * mass ratio q=M2/M1<0.1</span> +<span class="sd"> * log(P)<0.15=x0 and log(P)>3.5=x1</span> +<span class="sd"> and is be given by dp/dlogP ~ (logP)^p for all other binary configurations (default p=-0.55)</span> + +<span class="sd"> arguments are M1, M2, a, Period P, amin, amax, x0=log P0, x1=log P1, p</span> + +<span class="sd"> example args: 10, 5, sep(M1, M2, P), sep, ?, -2, 12, -0.55</span> + +<span class="sd"> # TODO: Fix this function! Half of the input here can be taken out and calculated within the function itself.</span> + +<span class="sd"> Args:</span> +<span class="sd"> M1: Mass of primary</span> +<span class="sd"> M2: Mass of secondary</span> +<span class="sd"> a: separation of binary</span> +<span class="sd"> P: period of binary</span> +<span class="sd"> amin: minimum separation of the distribution (lower bound of the range)</span> +<span class="sd"> amax: maximum separation of the distribution (upper bound of the range)</span> +<span class="sd"> x0: log of minimum period of the distribution (lower bound of the range)</span> +<span class="sd"> x1: log of maximum period of the distribution (upper bound of the range)</span> +<span class="sd"> p: slope of the distribution</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' of orbital period P given the other parameters</span> +<span class="sd"> """</span> + + <span class="n">res</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">if</span> <span class="p">(</span><span class="n">M1</span> <span class="o"><</span> <span class="mf">15.0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">M2</span> <span class="o">/</span> <span class="n">M1</span> <span class="o"><</span> <span class="mf">0.1</span><span class="p">):</span> + <span class="n">res</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">amax</span><span class="p">)</span> <span class="o">-</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">amin</span><span class="p">))</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">p1</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">+</span> <span class="n">p</span> + + <span class="c1"># For more details see the LyX document of binary_c for this distribution</span> + <span class="c1"># where the variables and normalisations are given</span> + <span class="c1"># we use the notation x=log(P), xmin=log(Pmin), x0=log(P0), ... to determine the</span> + <span class="n">x</span> <span class="o">=</span> <span class="n">LOG_LN_CONVERTER</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">P</span><span class="p">)</span> + <span class="n">xmin</span> <span class="o">=</span> <span class="n">LOG_LN_CONVERTER</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">calc_period_from_sep</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="n">M2</span><span class="p">,</span> <span class="n">amin</span><span class="p">))</span> + <span class="n">xmax</span> <span class="o">=</span> <span class="n">LOG_LN_CONVERTER</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">calc_period_from_sep</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="n">M2</span><span class="p">,</span> <span class="n">amax</span><span class="p">))</span> + + <span class="n">A1</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span> + <span class="n">x0</span> <span class="o">**</span> <span class="n">p</span> <span class="o">*</span> <span class="p">(</span><span class="n">x0</span> <span class="o">-</span> <span class="n">xmin</span><span class="p">)</span> + <span class="o">+</span> <span class="p">(</span><span class="n">x1</span> <span class="o">**</span> <span class="n">p1</span> <span class="o">-</span> <span class="n">x0</span> <span class="o">**</span> <span class="n">p1</span><span class="p">)</span> <span class="o">/</span> <span class="n">p1</span> + <span class="o">+</span> <span class="n">x1</span> <span class="o">**</span> <span class="n">p</span> <span class="o">*</span> <span class="p">(</span><span class="n">xmax</span> <span class="o">-</span> <span class="n">x1</span><span class="p">)</span> + <span class="p">)</span> + <span class="n">A0</span> <span class="o">=</span> <span class="n">A1</span> <span class="o">*</span> <span class="n">x0</span> <span class="o">**</span> <span class="n">p</span> + <span class="n">A2</span> <span class="o">=</span> <span class="n">A1</span> <span class="o">*</span> <span class="n">x1</span> <span class="o">**</span> <span class="n">p</span> + + <span class="k">if</span> <span class="n">x</span> <span class="o"><</span> <span class="n">x0</span><span class="p">:</span> + <span class="n">res</span> <span class="o">=</span> <span class="n">A0</span> + <span class="k">elif</span> <span class="n">x</span> <span class="o">></span> <span class="n">x1</span><span class="p">:</span> + <span class="n">res</span> <span class="o">=</span> <span class="n">A2</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">res</span> <span class="o">=</span> <span class="n">A1</span> <span class="o">*</span> <span class="n">x</span> <span class="o">**</span> <span class="n">p</span> + <span class="n">res</span> <span class="o">*=</span> <span class="mf">3.0</span> <span class="o">/</span> <span class="mf">2.0</span> <span class="o">*</span> <span class="n">LOG_LN_CONVERTER</span> + <span class="k">return</span> <span class="n">res</span></div> + +<div class="viewcode-block" id="distribution_functions.interpolate_in_mass_izzard2012"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.interpolate_in_mass_izzard2012">[docs]</a> <span class="k">def</span> <span class="nf">interpolate_in_mass_izzard2012</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> <span class="n">M</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">high</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">low</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Function to interpolate in mass</span> + +<span class="sd"> TODO: fix this function.</span> +<span class="sd"> TODO: describe the args</span> +<span class="sd"> high: at M=16.3</span> +<span class="sd"> low: at 1.15</span> + +<span class="sd"> Args:</span> +<span class="sd"> M: mass</span> +<span class="sd"> high:</span> +<span class="sd"> low:</span> + +<span class="sd"> Returns:</span> + +<span class="sd"> """</span> + + <span class="n">log_interpolation</span> <span class="o">=</span> <span class="kc">False</span> + + <span class="k">if</span> <span class="n">log_interpolation</span><span class="p">:</span> + <span class="k">return</span> <span class="p">(</span><span class="n">high</span> <span class="o">-</span> <span class="n">low</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="mf">16.3</span><span class="p">)</span> <span class="o">-</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="mf">1.15</span><span class="p">))</span> <span class="o">*</span> <span class="p">(</span> + <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">M</span><span class="p">)</span> <span class="o">-</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="mf">1.15</span><span class="p">)</span> + <span class="p">)</span> <span class="o">+</span> <span class="n">low</span> + <span class="k">return</span> <span class="p">(</span><span class="n">high</span> <span class="o">-</span> <span class="n">low</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mf">16.3</span> <span class="o">-</span> <span class="mf">1.15</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">M</span> <span class="o">-</span> <span class="mf">1.15</span><span class="p">)</span> <span class="o">+</span> <span class="n">low</span></div> + +<div class="viewcode-block" id="distribution_functions.Izzard2012_period_distribution"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Izzard2012_period_distribution">[docs]</a> <span class="k">def</span> <span class="nf">Izzard2012_period_distribution</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">P</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">M1</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">log10Pmin</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> period distribution which interpolates between</span> +<span class="sd"> Duquennoy and Mayor 1991 at low mass (G/K spectral type <~1.15Msun)</span> +<span class="sd"> and Sana et al 2012 at high mass (O spectral type >~16.3Msun)</span> + +<span class="sd"> This gives dN/dlogP, i.e. DM/Raghavan's Gaussian in log10P at low mass</span> +<span class="sd"> and Sana's power law (as a function of logP) at high mass</span> + +<span class="sd"> TODO: fix this function</span> + +<span class="sd"> Args:</span> +<span class="sd"> P: period</span> +<span class="sd"> M1: Primary star mass</span> +<span class="sd"> log10Pmin: minimum period in base log10 (optional)</span> + +<span class="sd"> Returns:</span> +<span class="sd"> 'probability' of interpolated distribution function at P and M1</span> + +<span class="sd"> """</span> + + <span class="c1"># Check if there is input and force it to be at least 1</span> + <span class="n">log10Pmin</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">log10Pmin</span><span class="p">)</span> + + <span class="c1"># save mass input and limit mass used (M1 from now on) to fitted range</span> + <span class="n">Mwas</span> <span class="o">=</span> <span class="n">M1</span> + <span class="n">M1</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mf">1.15</span><span class="p">,</span> <span class="nb">min</span><span class="p">(</span><span class="mf">16.3</span><span class="p">,</span> <span class="n">M1</span><span class="p">))</span> + + <span class="c1"># Calculate the normalisations</span> + <span class="c1"># need to normalise the distribution for this mass</span> + <span class="c1"># (and perhaps secondary mass)</span> + <span class="n">prepare_dict</span><span class="p">(</span><span class="n">distribution_constants</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Izzard2012"</span><span class="p">,</span> <span class="n">M1</span><span class="p">])</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"Izzard2012"</span><span class="p">][</span><span class="n">M1</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">log10Pmin</span><span class="p">):</span> + <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"Izzard2012"</span><span class="p">][</span><span class="n">M1</span><span class="p">][</span> + <span class="n">log10Pmin</span> + <span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> <span class="c1"># To prevent this loop from going recursive</span> + <span class="n">N</span> <span class="o">=</span> <span class="mf">200.0</span> <span class="c1"># Resolution for normalisation. I hope 1000 is enough</span> + <span class="n">dlP</span> <span class="o">=</span> <span class="p">(</span><span class="mf">10.0</span> <span class="o">-</span> <span class="n">log10Pmin</span><span class="p">)</span> <span class="o">/</span> <span class="n">N</span> + <span class="n">C</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># normalisation constant.</span> + <span class="k">for</span> <span class="n">lP</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">log10Pmin</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">dlP</span><span class="p">):</span> + <span class="n">C</span> <span class="o">+=</span> <span class="n">dlP</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">Izzard2012_period_distribution</span><span class="p">(</span><span class="mi">10</span> <span class="o">**</span> <span class="n">lP</span><span class="p">,</span> <span class="n">M1</span><span class="p">,</span> <span class="n">log10Pmin</span><span class="p">)</span> + + <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"Izzard2012"</span><span class="p">][</span><span class="n">M1</span><span class="p">][</span><span class="n">log10Pmin</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">C</span> + + <span class="n">lP</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">P</span><span class="p">)</span> + <span class="c1"># log period</span> + + <span class="c1"># # fits</span> + <span class="n">mu</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">interpolate_in_mass_izzard2012</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="o">-</span><span class="mf">17.8</span><span class="p">,</span> <span class="mf">5.03</span><span class="p">)</span> + <span class="n">sigma</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">interpolate_in_mass_izzard2012</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="mf">9.18</span><span class="p">,</span> <span class="mf">2.28</span><span class="p">)</span> + <span class="n">K</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">interpolate_in_mass_izzard2012</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="mf">6.93e-2</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> + <span class="n">nu</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">interpolate_in_mass_izzard2012</span><span class="p">(</span><span class="n">M1</span><span class="p">,</span> <span class="mf">0.3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> + <span class="n">g</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">+</span> <span class="mf">1e-30</span> <span class="o">**</span> <span class="p">(</span><span class="n">lP</span> <span class="o">-</span> <span class="n">nu</span><span class="p">)</span> + <span class="n">lPmu</span> <span class="o">=</span> <span class="n">lP</span> <span class="o">-</span> <span class="n">mu</span> + + <span class="k">if</span> <span class="p">(</span><span class="n">lP</span> <span class="o"><</span> <span class="n">log10Pmin</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">lP</span> <span class="o">></span> <span class="mf">10.0</span><span class="p">):</span> + <span class="k">return</span> <span class="mi">0</span> + + <span class="k">return</span> <span class="p">(</span> + <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"Izzard2012"</span><span class="p">][</span><span class="n">M1</span><span class="p">][</span><span class="n">log10Pmin</span><span class="p">]</span> + <span class="o">*</span> <span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">lPmu</span> <span class="o">*</span> <span class="n">lPmu</span> <span class="o">/</span> <span class="p">(</span><span class="mf">2.0</span> <span class="o">*</span> <span class="n">sigma</span> <span class="o">*</span> <span class="n">sigma</span><span class="p">))</span> <span class="o">+</span> <span class="n">K</span> <span class="o">/</span> <span class="nb">max</span><span class="p">(</span><span class="mf">0.1</span><span class="p">,</span> <span class="n">lP</span><span class="p">))</span> + <span class="o">/</span> <span class="n">g</span> + <span class="p">)</span></div> + + <span class="c1">########################################################################</span> + <span class="c1"># Mass ratio distributions</span> + <span class="c1">########################################################################</span> +<div class="viewcode-block" id="distribution_functions.flatsections"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.flatsections">[docs]</a> <span class="k">def</span> <span class="nf">flatsections</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="n">opts</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Function to generate flat distributions, possibly in multiple sections</span> + +<span class="sd"> Args:</span> +<span class="sd"> x: mass ratio value</span> +<span class="sd"> opts: list containing the flat sections. Which are themselves dictionaries, with keys "max": upper bound, "min": lower bound and "height": value</span> + +<span class="sd"> Returns:</span> +<span class="sd"> probability of that mass ratio.</span> +<span class="sd"> """</span> + + <span class="n">c</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">y</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">for</span> <span class="n">opt</span> <span class="ow">in</span> <span class="n">opts</span><span class="p">:</span> + <span class="n">dc</span> <span class="o">=</span> <span class="p">(</span><span class="n">opt</span><span class="p">[</span><span class="s2">"max"</span><span class="p">]</span> <span class="o">-</span> <span class="n">opt</span><span class="p">[</span><span class="s2">"min"</span><span class="p">])</span> <span class="o">*</span> <span class="n">opt</span><span class="p">[</span><span class="s2">"height"</span><span class="p">]</span> + <span class="n">c</span> <span class="o">+=</span> <span class="n">dc</span> + <span class="k">if</span> <span class="n">opt</span><span class="p">[</span><span class="s2">"min"</span><span class="p">]</span> <span class="o"><=</span> <span class="n">x</span> <span class="o"><=</span> <span class="n">opt</span><span class="p">[</span><span class="s2">"max"</span><span class="p">]:</span> + <span class="n">y</span> <span class="o">=</span> <span class="n">opt</span><span class="p">[</span><span class="s2">"height"</span><span class="p">]</span> + <span class="n">y</span> <span class="o">/=</span> <span class="n">c</span> + <span class="k">return</span> <span class="n">y</span></div> + + <span class="c1">########################################################################</span> + <span class="c1"># Eccentricity distributions</span> + <span class="c1">########################################################################</span> + + <span class="c1">########################################################################</span> + <span class="c1"># Star formation histories</span> + <span class="c1">########################################################################</span> + +<div class="viewcode-block" id="distribution_functions.cosmic_SFH_madau_dickinson2014"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.cosmic_SFH_madau_dickinson2014">[docs]</a> <span class="k">def</span> <span class="nf">cosmic_SFH_madau_dickinson2014</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">z</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Cosmic star formation history distribution from Madau & Dickonson 2014 (https://arxiv.org/pdf/1403.0007.pdf)</span> + +<span class="sd"> Args:</span> +<span class="sd"> z: redshift</span> + +<span class="sd"> Returns:</span> +<span class="sd"> Cosmic star formation rate in Solar mass year^-1 mega parsec^-3</span> +<span class="sd"> """</span> + + <span class="n">CSFH</span> <span class="o">=</span> <span class="mf">0.015</span> <span class="o">*</span> <span class="p">((</span><span class="mi">1</span> <span class="o">+</span> <span class="n">z</span><span class="p">)</span> <span class="o">**</span> <span class="mf">2.7</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="p">(((</span><span class="mi">1</span> <span class="o">+</span> <span class="n">z</span><span class="p">)</span> <span class="o">/</span> <span class="mf">2.9</span><span class="p">)</span> <span class="o">**</span> <span class="mf">5.6</span><span class="p">))</span> + <span class="k">return</span> <span class="n">CSFH</span></div> + + <span class="c1">########################################################################</span> + <span class="c1"># Metallicity distributions</span> + <span class="c1">########################################################################</span> + + <span class="c1">########################################################################</span> + <span class="c1"># Moe & DiStefano 2017 functions</span> + <span class="c1">#</span> + <span class="c1"># The code below are functions that are used to set up and interpolate</span> + <span class="c1"># on the Moe & DiStefano 2017 data. The interpolators take the last</span> + <span class="c1"># known value if we try to interpolate outside of the tables.</span> + <span class="c1"># There are still some open tasks and improvements that can be made:</span> + <span class="c1">#</span> + <span class="c1"># TODO: Parallelize the setting up of the interpolators</span> + <span class="c1"># TODO: Generalise the code such that we can input other/newer tables.</span> + <span class="c1">########################################################################</span> + +<div class="viewcode-block" id="distribution_functions.poisson"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.poisson">[docs]</a> <span class="k">def</span> <span class="nf">poisson</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lambda_val</span><span class="p">,</span> <span class="n">n</span><span class="p">,</span> <span class="n">nmax</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that calculates the Poisson value and normalises</span> +<span class="sd"> TODO: improve the description</span> +<span class="sd"> """</span> + + <span class="n">cachekey</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lambda_val</span><span class="p">,</span> <span class="n">n</span><span class="p">,</span> <span class="n">nmax</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">distribution_constants</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"poisson_cache"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="k">if</span> <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"poisson_cache"</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cachekey</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">p_val</span> <span class="o">=</span> <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"poisson_cache"</span><span class="p">][</span><span class="n">cachekey</span><span class="p">]</span> + <span class="k">return</span> <span class="n">p_val</span> + + <span class="c1"># Poisson distribution : note, n can be zero</span> + <span class="c1">#</span> + <span class="c1"># nmax is the truncation : if set, we normalise</span> + <span class="c1"># correctly.</span> + <span class="n">p_val</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_poisson</span><span class="p">(</span><span class="n">lambda_val</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">nmax</span><span class="p">:</span> + <span class="n">I_poisson</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nmax</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span> + <span class="n">I_poisson</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_poisson</span><span class="p">(</span><span class="n">lambda_val</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> + <span class="n">p_val</span> <span class="o">/=</span> <span class="n">I_poisson</span> + + <span class="c1"># Add to cache</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">distribution_constants</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"poisson_cache"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"poisson_cache"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + <span class="n">distribution_constants</span><span class="p">[</span><span class="s2">"poisson_cache"</span><span class="p">][</span><span class="n">cachekey</span><span class="p">]</span> <span class="o">=</span> <span class="n">p_val</span> + + <span class="k">return</span> <span class="n">p_val</span></div> + + <span class="k">def</span> <span class="nf">_poisson</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lambda_val</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the Poisson value</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="p">(</span><span class="n">lambda_val</span> <span class="o">**</span> <span class="n">n</span><span class="p">)</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">lambda_val</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">factorial</span><span class="p">(</span><span class="n">n</span><span class="p">))</span> + +<div class="viewcode-block" id="distribution_functions.get_max_multiplicity"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.get_max_multiplicity">[docs]</a> <span class="k">def</span> <span class="nf">get_max_multiplicity</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">multiplicity_array</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to get the maximum multiplicity</span> +<span class="sd"> """</span> + <span class="n">max_multiplicity</span> <span class="o">=</span> <span class="mi">0</span> + <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span> + <span class="k">if</span> <span class="n">multiplicity_array</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">max_multiplicity</span> <span class="o">=</span> <span class="n">n</span> <span class="o">+</span> <span class="mi">1</span> + <span class="k">return</span> <span class="n">max_multiplicity</span></div> + +<div class="viewcode-block" id="distribution_functions.merge_multiplicities"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.merge_multiplicities">[docs]</a> <span class="k">def</span> <span class="nf">merge_multiplicities</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result_array</span><span class="p">,</span> <span class="n">max_multiplicity</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to fold the multiplicities higher than the max_multiplicity onto the max_multiplicity</span> + +<span class="sd"> if max_multiplicity == 1:</span> +<span class="sd"> All the multiplicities are folded onto multiplicity == 1. This will always total to 1</span> +<span class="sd"> if max_multiplicity == 2:</span> +<span class="sd"> The multiplicity fractions of the triple and quadruples are folded onto that of the binary multiplicity fraction</span> +<span class="sd"> if max_multiplicity == 3:</span> +<span class="sd"> The multiplicity fractions of the quadruples are folded onto that of the triples</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">max_multiplicity</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">5</span><span class="p">):</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: merge_multiplicities: max_multiplicity has to be between 1 and 4. It is </span><span class="si">{}</span><span class="s2"> now"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">max_multiplicity</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="n">msg</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Fold multiplicities:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: merge_multiplicities: Merging multiplicities with initial array </span><span class="si">{}</span><span class="s2"> and max multiplicity </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">result_array</span><span class="p">,</span> <span class="n">max_multiplicity</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">max_multiplicity</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">result_array</span><span class="p">))[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span> + <span class="n">result_array</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">+=</span> <span class="n">result_array</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> + <span class="n">result_array</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: merge_multiplicities: Merging multiplicities to new array </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">result_array</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">return</span> <span class="n">result_array</span></div> + +<div class="viewcode-block" id="distribution_functions.Moe_di_Stefano_2017_multiplicity_fractions"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Moe_di_Stefano_2017_multiplicity_fractions">[docs]</a> <span class="k">def</span> <span class="nf">Moe_di_Stefano_2017_multiplicity_fractions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that creates a list of probability fractions and</span> +<span class="sd"> normalises and merges them according to the users choice.</span> + +<span class="sd"> TODO: make an extrapolation functionality in this. log10(1.6e1)</span> +<span class="sd"> is quite low.</span> + +<span class="sd"> The default result that is returned when sampling the mass outside</span> +<span class="sd"> of the mass range is now the last known value</span> + +<span class="sd"> Returns a list of multiplicity fractions for a given input of mass</span> +<span class="sd"> """</span> + + <span class="c1"># Use the global Moecache</span> + <span class="k">global</span> <span class="n">Moecache</span> + + <span class="n">multiplicity_modulator_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"multiplicity_modulator"</span><span class="p">]</span> + <span class="p">)</span> <span class="c1"># Modulator array</span> + + <span class="c1"># Check for length</span> + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">multiplicity_modulator_array</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">4</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Multiplicity modulator has to have 4 elements. Now it is </span><span class="si">{}</span><span class="s2">, len: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">multiplicity_modulator_array</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">multiplicity_modulator_array</span><span class="p">)</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="n">msg</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Set up some arrays</span> + <span class="n">full_fractions_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="c1"># Meant to contain the real fractions</span> + <span class="n">weighted_fractions_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span> + <span class="mi">4</span> + <span class="p">)</span> <span class="c1"># Meant to contain the fractions multiplied by the multiplicity modulator</span> + + <span class="c1"># Get max multiplicity</span> + <span class="n">max_multiplicity</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_max_multiplicity</span><span class="p">(</span><span class="n">multiplicity_modulator_array</span><span class="p">)</span> + + <span class="c1"># ... it's better to interpolate the multiplicity and then</span> + <span class="c1"># use a Poisson distribution to calculate the fractions</span> + <span class="c1"># (this is more accurate)</span> + + <span class="c1"># Set up the multiplicity interpolator</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_multiplicity"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_multiplicity"</span><span class="p">]</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> + <span class="n">table</span><span class="o">=</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"multiplicity_table"</span><span class="p">],</span> <span class="c1"># Contains the table of data</span> + <span class="n">nparams</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># logM1</span> + <span class="n">ndata</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="c1"># The number of datapoints (the parameters that we want to interpolate)</span> + <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> <span class="o">-</span> <span class="p">(</span><span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"multiplicity_model"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"Poisson"</span><span class="p">:</span> + <span class="n">multiplicity</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_multiplicity"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">])]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + + <span class="c1"># Fill the multiplicity array</span> + <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span> + <span class="n">full_fractions_array</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">poisson</span><span class="p">(</span><span class="n">multiplicity</span><span class="p">,</span> <span class="n">n</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> + + <span class="c1"># Normalize it so it fills to one when taking all the multiplicities:</span> + <span class="n">full_fractions_array</span> <span class="o">=</span> <span class="n">full_fractions_array</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">full_fractions_array</span><span class="p">)</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: using model </span><span class="si">{}</span><span class="s2">: full_fractions_array: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">"Poisson"</span><span class="p">,</span> <span class="n">full_fractions_array</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">elif</span> <span class="n">options</span><span class="p">[</span><span class="s2">"multiplicity_model"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"data"</span><span class="p">:</span> + <span class="c1"># use the fractions calculated from Moe's data directly</span> + <span class="c1">#</span> + <span class="c1"># note that in this case, there are no quadruples: these</span> + <span class="c1"># are combined with triples</span> + + <span class="c1"># Fill with the raw values</span> + <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span> + <span class="n">full_fractions_array</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span> + <span class="s2">"rinterpolator_multiplicity"</span> + <span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">])])[</span><span class="n">n</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> + + <span class="c1"># Set last value</span> + <span class="n">full_fractions_array</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span> <span class="c1"># no quadruples</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: using model </span><span class="si">{}</span><span class="s2">: full_fractions_array: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">"data"</span><span class="p">,</span> <span class="n">full_fractions_array</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Normalisation:</span> + <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"normalize_multiplicities"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"raw"</span><span class="p">:</span> + <span class="c1"># Don't multiply by the multiplicity_array, but do give a fractions array</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Not normalising (using raw results): results: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">full_fractions_array</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="n">result</span> <span class="o">=</span> <span class="n">full_fractions_array</span> + + <span class="k">elif</span> <span class="n">options</span><span class="p">[</span><span class="s2">"normalize_multiplicities"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"norm"</span><span class="p">:</span> + <span class="c1"># Multiply the full_multiplicity_fraction array by the multiplicity_multiplier_array, creating a weighted fractions array</span> + <span class="n">weighted_fractions_array</span> <span class="o">=</span> <span class="p">(</span> + <span class="n">full_fractions_array</span> <span class="o">*</span> <span class="n">multiplicity_modulator_array</span> + <span class="p">)</span> + + <span class="c1"># Normalise this so it is in total 1:</span> + <span class="n">result</span> <span class="o">=</span> <span class="n">weighted_fractions_array</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">weighted_fractions_array</span><span class="p">)</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with </span><span class="si">{}</span><span class="s2">. result: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">"norm"</span><span class="p">,</span> <span class="n">result</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">elif</span> <span class="n">options</span><span class="p">[</span><span class="s2">"normalize_multiplicities"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"merge"</span><span class="p">:</span> + <span class="c1"># We first take the full multiplicity array</span> + <span class="c1"># (i.e. not multiplied by multiplier) and do the merging</span> + <span class="n">result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">merge_multiplicities</span><span class="p">(</span> + <span class="n">full_fractions_array</span><span class="p">,</span> <span class="n">max_multiplicity</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> + <span class="p">)</span> + + <span class="c1"># Then normalise to be sure</span> + <span class="n">result</span> <span class="o">=</span> <span class="n">result</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with </span><span class="si">{}</span><span class="s2">, max_multiplicity=</span><span class="si">{}</span><span class="s2"> result=</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">"merge"</span><span class="p">,</span> <span class="n">max_multiplicity</span><span class="p">,</span> <span class="n">result</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">str</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># return array reference</span> + <span class="k">return</span> <span class="n">result</span></div> + +<div class="viewcode-block" id="distribution_functions.build_q_table"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.build_q_table">[docs]</a> <span class="k">def</span> <span class="nf">build_q_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Build an interpolation table for q, given a mass and</span> +<span class="sd"> orbital period.</span> + +<span class="sd"> m and p are labels which determine which system(s)</span> +<span class="sd"> to look up from Moe's data:</span> + +<span class="sd"> m can be M1, M2, M3, M4, or if set M1+M2 etc.</span> +<span class="sd"> p can be P, P2, P3</span> + +<span class="sd"> The actual values are in $opts:</span> + +<span class="sd"> mass is in $opts->{m}</span> +<span class="sd"> period is $opts->{p}</span> + +<span class="sd"> Since the information from the table for Moe and di Stefano 2017 is independent of any choice we make,</span> +<span class="sd"> we need to take into account that for example our choice of minimum mass leads to</span> +<span class="sd"> a minimum q_min that is not the same as in the table</span> +<span class="sd"> We should ignore those parts of the table and renormalise.</span> +<span class="sd"> If we are below the lowest value of qmin in the table we need to extrapolate the data</span> + +<span class="sd"> Anyway, the goal of this function is to provide some extrapolated values for q when we should sample outside of the boundaries</span> +<span class="sd"> TODO: fix description to be correct for python</span> +<span class="sd"> """</span> + + <span class="c1"># We can check if we have a cached value for this already:</span> + <span class="c1"># TODO: fix this cache check.</span> + <span class="n">incache</span> <span class="o">=</span> <span class="kc">False</span> + <span class="k">if</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="k">if</span> <span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span> <span class="ow">and</span> <span class="p">(</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="p">):</span> + <span class="k">if</span> <span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">][</span><span class="n">m</span><span class="p">]</span> <span class="o">==</span> <span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">])</span> <span class="ow">and</span> <span class="p">(</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">][</span><span class="n">p</span><span class="p">]</span> <span class="o">==</span> <span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> + <span class="p">):</span> + <span class="n">incache</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Found cached values for m=</span><span class="si">{}</span><span class="s2"> p=</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Cached values for different m=</span><span class="si">{}</span><span class="s2"> p=</span><span class="si">{}</span><span class="s2">. Freeing current table and making new table"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1">#</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">incache</span><span class="p">:</span> + <span class="c1"># trim and/or expand the table to the range qmin to qmax.</span> + + <span class="c1"># qmin is set by the minimum stellar mass</span> + <span class="n">qmin</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"Mmin"</span><span class="p">]</span> <span class="o">/</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table qmin: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">qmin</span><span class="p">,</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># qmax = maximum_mass_ratio_for_RLOF(options[m], options[p])</span> + <span class="c1"># TODO: change this to the above</span> + <span class="n">qmax</span> <span class="o">=</span> <span class="mi">1</span> + + <span class="c1"># qdata contains the table that we modify: we get</span> + <span class="c1"># the original data by interpolating Moe's table</span> + <span class="n">qdata</span> <span class="o">=</span> <span class="p">{}</span> + <span class="n">can_renormalize</span> <span class="o">=</span> <span class="mi">1</span> + + <span class="n">qeps</span> <span class="o">=</span> <span class="mf">1e-8</span> <span class="c1"># small number but such that qeps+1 != 1</span> + <span class="k">if</span> <span class="n">qeps</span> <span class="o">+</span> <span class="mi">1</span> <span class="o">==</span> <span class="mf">1.0</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: qeps (= </span><span class="si">{}</span><span class="s2">) +1 == 1. Make qeps larger"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">qeps</span><span class="p">,</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">qmin</span> <span class="o">>=</span> <span class="n">qmax</span><span class="p">:</span> + <span class="c1"># there may be NO binaries in this part of the parameter space:</span> + <span class="c1"># in which case, set up a table with lots of zero in it</span> + + <span class="n">qdata</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">:</span> <span class="mi">0</span><span class="p">}</span> + <span class="n">can_renormalize</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="k">else</span><span class="p">:</span> + <span class="c1"># qmin and qmax mean we'll get something non-zero</span> + <span class="n">can_renormalize</span> <span class="o">=</span> <span class="mi">1</span> + + <span class="c1"># require extrapolation sets whether we need to extrapolate</span> + <span class="c1"># at the low and high ends</span> + <span class="n">require_extrapolation</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="k">if</span> <span class="n">qmin</span> <span class="o">>=</span> <span class="mf">0.15</span><span class="p">:</span> + <span class="c1"># qmin is inside Moe's table : this is easy,</span> + <span class="c1"># we just keep points from qmin at the low</span> + <span class="c1"># end to qmax at the high end.</span> + <span class="n">require_extrapolation</span><span class="p">[</span><span class="s2">"low"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">require_extrapolation</span><span class="p">[</span> + <span class="s2">"high"</span> + <span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> <span class="c1"># TODO: shouldn't the extrapolation need to happen if qmax > 0.95</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">qmin</span><span class="p">]</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]),</span> <span class="n">qmin</span><span class="p">]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + + <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">0.15</span><span class="p">,</span> <span class="mf">0.950001</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">):</span> + <span class="k">if</span> <span class="n">qmin</span> <span class="o"><=</span> <span class="n">q</span> <span class="o"><=</span> <span class="n">qmax</span><span class="p">:</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]),</span> <span class="n">q</span><span class="p">]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">require_extrapolation</span><span class="p">[</span><span class="s2">"low"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> + <span class="n">require_extrapolation</span><span class="p">[</span><span class="s2">"high"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> + <span class="k">if</span> <span class="n">qmax</span> <span class="o"><</span> <span class="mf">0.15</span><span class="p">:</span> + <span class="c1"># qmax < 0.15 which is off the edge</span> + <span class="c1"># of the table. In this case, choose</span> + <span class="c1"># two points at q=0.15 and 0.16 and interpolate</span> + <span class="c1"># at these in case we want to extrapolate.</span> + <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="p">[</span><span class="mf">0.15</span><span class="p">,</span> <span class="mf">0.16</span><span class="p">]:</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]),</span> <span class="n">q</span><span class="p">]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># qmin < 0.15 and qmax > 0.15, so we</span> + <span class="c1"># have to generate Moe's table for</span> + <span class="c1"># q = 0.15 (i.e. 0.1 to 0.2) to 0.95 (0.9 to 1)</span> + <span class="c1"># as a function of M1 and orbital period,</span> + <span class="c1"># to obtain the q distribution data.</span> + + <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span> + <span class="mf">0.15</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">([</span><span class="mf">0.950001</span><span class="p">,</span> <span class="n">qmax</span> <span class="o">+</span> <span class="mf">0.0001</span><span class="p">]),</span> <span class="mf">0.1</span> + <span class="p">):</span> + <span class="n">val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]),</span> <span class="n">q</span><span class="p">]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span> + + <span class="c1"># just below qmin, if qmin>qeps, we want nothing</span> + <span class="k">if</span> <span class="n">qmin</span> <span class="o">-</span> <span class="mf">0.15</span> <span class="o">></span> <span class="n">qeps</span><span class="p">:</span> + <span class="n">q</span> <span class="o">=</span> <span class="n">qmin</span> <span class="o">-</span> <span class="n">qeps</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">require_extrapolation</span><span class="p">[</span><span class="s2">"low"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="c1"># just above qmax, if qmax<1, we want nothing</span> + <span class="k">if</span> <span class="n">qmax</span> <span class="o"><</span> <span class="mf">0.95</span><span class="p">:</span> + <span class="n">q</span> <span class="o">=</span> <span class="n">qmax</span> <span class="o">+</span> <span class="n">qeps</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">require_extrapolation</span><span class="p">[</span><span class="s2">"high"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="c1"># sorted list of qs</span> + <span class="n">qs</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">qdata</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> + + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">qs</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"No qs found error"</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">qs</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="c1"># only one q value : pretend there are two</span> + <span class="c1"># with a flat distribution up to 1.0.</span> + <span class="k">if</span> <span class="n">qs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mf">1.0</span><span class="p">:</span> + <span class="n">qs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">-</span> <span class="mf">1e-6</span> + <span class="n">qs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="mi">1</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="mi">1</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">qs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">qs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> + + <span class="c1"># We actually should do the extrapolation now.</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># Loop over both the lower end and the upper end</span> + <span class="k">for</span> <span class="n">pre</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"low"</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">]:</span> + <span class="k">if</span> <span class="n">require_extrapolation</span><span class="p">[</span><span class="n">pre</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="k">continue</span> + + <span class="n">sign</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> <span class="k">if</span> <span class="n">pre</span> <span class="o">==</span> <span class="s2">"low"</span> <span class="k">else</span> <span class="mi">1</span> + <span class="n">end_index</span> <span class="o">=</span> <span class="mi">0</span> <span class="k">if</span> <span class="n">pre</span> <span class="o">==</span> <span class="s2">"low"</span> <span class="k">else</span> <span class="nb">len</span><span class="p">(</span><span class="n">qs</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span> + <span class="n">indices</span> <span class="o">=</span> <span class="p">(</span> + <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="n">pre</span> <span class="o">==</span> <span class="s2">"low"</span> <span class="k">else</span> <span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="n">qs</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">qs</span><span class="p">)</span> <span class="o">-</span> <span class="mi">2</span><span class="p">]</span> + <span class="p">)</span> <span class="c1"># Based on whether we do the high or low end we need to use two different indices</span> + <span class="n">method</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> + <span class="s2">"q_</span><span class="si">{}</span><span class="s2">_extrapolation_method"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">pre</span><span class="p">),</span> <span class="kc">None</span> + <span class="p">)</span> + <span class="n">qlimit</span> <span class="o">=</span> <span class="n">qmin</span> <span class="k">if</span> <span class="n">pre</span> <span class="o">==</span> <span class="s2">"low"</span> <span class="k">else</span> <span class="n">qmax</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Extrapolating: Q: </span><span class="si">{}</span><span class="s2"> method: </span><span class="si">{}</span><span class="s2">, indices: </span><span class="si">{}</span><span class="s2"> End index: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">pre</span><span class="p">,</span> <span class="n">method</span><span class="p">,</span> <span class="n">indices</span><span class="p">,</span> <span class="n">end_index</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># truncate the distribution</span> + <span class="n">qdata</span><span class="p">[</span><span class="nb">max</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="nb">min</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">qlimit</span> <span class="o">+</span> <span class="n">sign</span> <span class="o">*</span> <span class="n">qeps</span><span class="p">))]</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="k">if</span> <span class="n">method</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="c1"># no extrapolation : just interpolate between 0.10 and 0.95</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: using no extrapolations"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">continue</span> + <span class="k">if</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">"flat"</span><span class="p">:</span> + <span class="c1"># use the end value and extrapolate it</span> + <span class="c1"># with zero slope</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">qlimit</span><span class="p">]</span> <span class="o">=</span> <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">end_index</span><span class="p">]]</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: using constant extrapolation"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">"linear"</span><span class="p">:</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">qlimit</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">linear_extrapolation_q</span><span class="p">(</span> + <span class="n">qs</span><span class="o">=</span><span class="n">qs</span><span class="p">,</span> + <span class="n">indices</span><span class="o">=</span><span class="n">indices</span><span class="p">,</span> + <span class="n">qlimit</span><span class="o">=</span><span class="n">qlimit</span><span class="p">,</span> + <span class="n">qdata</span><span class="o">=</span><span class="n">qdata</span><span class="p">,</span> + <span class="n">end_index</span><span class="o">=</span><span class="n">end_index</span><span class="p">,</span> + <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span><span class="p">,</span> + <span class="p">)</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: using linear extrapolation"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">if</span> <span class="n">pre</span> <span class="o">==</span> <span class="s2">"low"</span><span class="p">:</span> + <span class="n">below_qlimit</span> <span class="o">=</span> <span class="n">qlimit</span> <span class="o">-</span> <span class="n">qeps</span> + <span class="k">if</span> <span class="n">below_qlimit</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">below_qlimit</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">qdata</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: using linear extrapolation and setting the points below the lower q bound (</span><span class="si">{}</span><span class="s2">) to 0 "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">qlimit</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">"plaw2"</span><span class="p">:</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">qlimit</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">powerlaw_extrapolation_q</span><span class="p">(</span> + <span class="n">qs</span><span class="o">=</span><span class="n">qs</span><span class="p">,</span> + <span class="n">indices</span><span class="o">=</span><span class="n">indices</span><span class="p">,</span> + <span class="n">qdata</span><span class="o">=</span><span class="n">qdata</span><span class="p">,</span> + <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span><span class="p">,</span> + <span class="p">)</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: using powerlaw extrapolation"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">"nolowq"</span><span class="p">:</span> + <span class="n">newq</span> <span class="o">=</span> <span class="mf">0.05</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">newq</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: setting lowq to 0"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">"poly"</span><span class="p">:</span> + <span class="c1"># TODO: consider implementing the poly method (see Perl version)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> + <span class="s2">"Moe and di Stefano 2017: build_q_table: Method 'poly' not implemented"</span> + <span class="p">)</span> + + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Error no other methods available. The chosen method (</span><span class="si">{}</span><span class="s2">) does not exist!"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">method</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="n">msg</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># regenerate qs in new table. This is now the updated list of qs where we have some extrapolated numbers</span> + <span class="n">tmp_table</span> <span class="o">=</span> <span class="p">[]</span> + <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">qdata</span><span class="o">.</span><span class="n">keys</span><span class="p">()):</span> + <span class="n">tmp_table</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">q</span><span class="p">,</span> <span class="n">qdata</span><span class="p">[</span><span class="n">q</span><span class="p">]])</span> + + <span class="c1"># Make an interpolation table to contain our modified data</span> + <span class="n">q_interpolator</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> + <span class="n">table</span><span class="o">=</span><span class="n">tmp_table</span><span class="p">,</span> + <span class="n">nparams</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">ndata</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># Contains the table of data # q #</span> + <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> <span class="o">-</span> <span class="p">(</span><span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Created a new Q table"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">can_renormalize</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Renormalising table"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># now we integrate and renormalise (if the table is not all zero)</span> + <span class="n">I</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_integration_constant_q</span><span class="p">(</span> + <span class="n">q_interpolator</span><span class="p">,</span> <span class="n">tmp_table</span><span class="p">,</span> <span class="n">qdata</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">I</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="c1"># normalise to 1.0 by dividing the data by 1.0/$I</span> + <span class="n">q_interpolator</span><span class="o">.</span><span class="n">multiply_table_column</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">I</span><span class="p">)</span> + + <span class="c1"># test this</span> + <span class="n">new_I</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_integration_constant_q</span><span class="p">(</span> + <span class="n">q_interpolator</span><span class="p">,</span> <span class="n">tmp_table</span><span class="p">,</span> <span class="n">qdata</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> + <span class="p">)</span> + + <span class="c1"># fail if error in integral > 1e-6 (should be ~ machine precision)</span> + <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="mf">1.0</span> <span class="o">-</span> <span class="n">new_I</span><span class="p">)</span> <span class="o">></span> <span class="mf">1e-6</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: Error: > 1e-6 in q probability integral: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">I</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># set this new table in the cache</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">p</span><span class="p">)]</span> <span class="o">=</span> <span class="n">q_interpolator</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: stored q_interpolater as </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Store the values for which this table was set up in the dict</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">][</span><span class="n">m</span><span class="p">]</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="n">m</span><span class="p">]</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q_metadata"</span><span class="p">][</span><span class="n">p</span><span class="p">]</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="n">p</span><span class="p">]</span></div> + +<div class="viewcode-block" id="distribution_functions.powerlaw_extrapolation_q"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_extrapolation_q">[docs]</a> <span class="k">def</span> <span class="nf">powerlaw_extrapolation_q</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">qdata</span><span class="p">,</span> <span class="n">qs</span><span class="p">,</span> <span class="n">indices</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to do the power-law extrapolation at the lower end of the q range</span> +<span class="sd"> """</span> + <span class="n">newq</span> <span class="o">=</span> <span class="mf">0.05</span> + + <span class="c1"># use a power-law extrapolation down to q=0.05, if possible</span> + <span class="k">if</span> <span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]]</span> <span class="o">==</span> <span class="mf">0.0</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">]]]</span> <span class="o">==</span> <span class="mf">0.0</span><span class="p">):</span> + <span class="c1"># not possible</span> + <span class="k">return</span> <span class="mi">0</span> + + <span class="k">else</span><span class="p">:</span> + <span class="n">slope</span> <span class="o">=</span> <span class="p">(</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">]]])</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]])</span> + <span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">]])</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]))</span> + <span class="n">intercept</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]])</span> <span class="o">-</span> <span class="n">slope</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span> + <span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> + <span class="p">)</span> + + <span class="k">return</span> <span class="n">slope</span> <span class="o">*</span> <span class="n">newq</span> <span class="o">+</span> <span class="n">intercept</span></div> + +<div class="viewcode-block" id="distribution_functions.linear_extrapolation_q"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.linear_extrapolation_q">[docs]</a> <span class="k">def</span> <span class="nf">linear_extrapolation_q</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> <span class="n">qs</span><span class="p">,</span> <span class="n">indices</span><span class="p">,</span> <span class="n">qlimit</span><span class="p">,</span> <span class="n">qdata</span><span class="p">,</span> <span class="n">end_index</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to do the linear extrapolation for q.</span> +<span class="sd"> """</span> + + <span class="c1"># linear extrapolation</span> + <span class="n">dq</span> <span class="o">=</span> <span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">-</span> <span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> + + <span class="k">if</span> <span class="n">dq</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: linear dq=0"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># No change</span> + <span class="k">return</span> <span class="n">qs</span><span class="p">[</span><span class="n">end_index</span><span class="p">]</span> + + <span class="n">slope</span> <span class="o">=</span> <span class="p">(</span><span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">]]]</span> <span class="o">-</span> <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]])</span> <span class="o">/</span> <span class="n">dq</span> + + <span class="n">intercept</span> <span class="o">=</span> <span class="n">qdata</span><span class="p">[</span><span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]]</span> <span class="o">-</span> <span class="n">slope</span> <span class="o">*</span> <span class="n">qs</span><span class="p">[</span><span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> + <span class="n">qdata</span><span class="p">[</span><span class="n">qlimit</span><span class="p">]</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">slope</span> <span class="o">*</span> <span class="n">qlimit</span> <span class="o">+</span> <span class="n">intercept</span><span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: build_q_table: linear Slope: </span><span class="si">{}</span><span class="s2"> intercept: </span><span class="si">{}</span><span class="s2"> dn/dq(</span><span class="si">{}</span><span class="s2">) = </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">slope</span><span class="p">,</span> <span class="n">intercept</span><span class="p">,</span> <span class="n">qlimit</span><span class="p">,</span> <span class="n">qdata</span><span class="p">[</span><span class="n">qlimit</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">return</span> <span class="nb">max</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">slope</span> <span class="o">*</span> <span class="n">qlimit</span> <span class="o">+</span> <span class="n">intercept</span><span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.get_integration_constant_q"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.get_integration_constant_q">[docs]</a> <span class="k">def</span> <span class="nf">get_integration_constant_q</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">q_interpolator</span><span class="p">,</span> <span class="n">tmp_table</span><span class="p">,</span> <span class="n">qdata</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to integrate the q interpolator and return the integration constant</span> +<span class="sd"> """</span> + + <span class="n">dq</span> <span class="o">=</span> <span class="mf">1e-3</span> <span class="c1"># resolution of the integration/renormalisation</span> + <span class="n">I</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="c1"># integrate: note that the value of the integral is</span> + <span class="c1"># meaningless to within a factor (which depends on $dq)</span> + <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span> <span class="o">+</span> <span class="mf">2e-6</span><span class="p">,</span> <span class="n">dq</span><span class="p">):</span> + <span class="n">x</span> <span class="o">=</span> <span class="n">q_interpolator</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">q</span><span class="p">])</span> + + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: get_integration_constant_q: Q interpolator table interpolation failed.</span><span class="se">\n\t\t</span><span class="s2">tmp_table = </span><span class="si">{}</span><span class="se">\n\t\t</span><span class="s2">q_data = </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">str</span><span class="p">(</span><span class="n">tmp_table</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">qdata</span><span class="p">)</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="n">msg</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="n">I</span> <span class="o">+=</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">dq</span> + <span class="k">return</span> <span class="n">I</span></div> + +<div class="viewcode-block" id="distribution_functions.fill_data"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.fill_data">[docs]</a> <span class="k">def</span> <span class="nf">fill_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sample_values</span><span class="p">,</span> <span class="n">data_dict</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that returns the normalised array of values for given logmass and logperiod</span> +<span class="sd"> used for the e and q values</span> + +<span class="sd"> TODO: make sure we do the correct thing with the dstep</span> +<span class="sd"> """</span> + + <span class="n">data</span> <span class="o">=</span> <span class="p">{}</span> + <span class="n">I</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="n">dstep</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">sample_values</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">-</span> <span class="nb">float</span><span class="p">(</span><span class="n">sample_values</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> + + <span class="c1"># Read out the data</span> + <span class="k">for</span> <span class="n">sample_value</span> <span class="ow">in</span> <span class="n">sample_values</span><span class="p">:</span> + <span class="n">val</span> <span class="o">=</span> <span class="n">data_dict</span><span class="p">[</span><span class="n">sample_value</span><span class="p">]</span> + <span class="n">data</span><span class="p">[</span><span class="n">sample_value</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span> + <span class="n">I</span> <span class="o">+=</span> <span class="n">val</span> + + <span class="c1"># Normalise the data</span> + <span class="k">for</span> <span class="n">sample_value</span> <span class="ow">in</span> <span class="n">sample_values</span><span class="p">:</span> + <span class="n">data</span><span class="p">[</span><span class="n">sample_value</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">sample_value</span><span class="p">]</span> <span class="o">/</span> <span class="n">I</span> + + <span class="k">return</span> <span class="n">data</span></div> + +<div class="viewcode-block" id="distribution_functions.calc_e_integral"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_e_integral">[docs]</a> <span class="k">def</span> <span class="nf">calc_e_integral</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">options</span><span class="p">,</span> + <span class="n">integrals_string</span><span class="p">,</span> + <span class="n">interpolator_name</span><span class="p">,</span> + <span class="n">mass_string</span><span class="p">,</span> + <span class="n">period_string</span><span class="p">,</span> + <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to calculate the e integral</span> + +<span class="sd"> We need to renormalise this because min_per > 0, and not all periods should be included</span> +<span class="sd"> """</span> + + <span class="k">global</span> <span class="n">Moecache</span> + <span class="n">min_ecc</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">max_ecc</span> <span class="o">=</span> <span class="mf">0.9999</span> + + <span class="n">mass_period_string</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">_</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="n">period_string</span><span class="p">]</span> + <span class="p">)</span> + + <span class="c1"># Check if the dict exists</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">integrals_string</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="c1"># Check for cached value. If it doesn't exist: calculate</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">mass_period_string</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">I</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">decc</span> <span class="o">=</span> <span class="mf">1e-3</span> + + <span class="k">for</span> <span class="n">ecc</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">min_ecc</span><span class="p">,</span> <span class="n">max_ecc</span><span class="p">,</span> <span class="n">decc</span><span class="p">):</span> + <span class="c1"># Loop over all the values in the table, between the min and max P</span> + <span class="n">dp_decc</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="n">interpolator_name</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">]),</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">period_string</span><span class="p">]),</span> + <span class="n">ecc</span><span class="p">,</span> + <span class="p">]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + + <span class="n">I</span> <span class="o">+=</span> <span class="n">dp_decc</span> <span class="o">*</span> <span class="n">decc</span> + + <span class="c1"># Set the integral value in the dict</span> + <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">][</span><span class="n">mass_period_string</span><span class="p">]</span> <span class="o">=</span> <span class="n">I</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: calc_ecc_integral: min_ecc: </span><span class="si">{}</span><span class="s2"> max ecc: </span><span class="si">{}</span><span class="s2"> integrals_string: </span><span class="si">{}</span><span class="s2"> interpolator_name: </span><span class="si">{}</span><span class="s2"> mass_string: </span><span class="si">{}</span><span class="s2"> period_string: </span><span class="si">{}</span><span class="s2"> mass: </span><span class="si">{}</span><span class="s2"> period: </span><span class="si">{}</span><span class="s2"> I: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">min_ecc</span><span class="p">,</span> + <span class="n">max_ecc</span><span class="p">,</span> + <span class="n">integrals_string</span><span class="p">,</span> + <span class="n">interpolator_name</span><span class="p">,</span> + <span class="n">mass_string</span><span class="p">,</span> + <span class="n">period_string</span><span class="p">,</span> + <span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="n">period_string</span><span class="p">],</span> + <span class="n">I</span><span class="p">,</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: calc_ecc_integral: Found cached value for min_ecc: </span><span class="si">{}</span><span class="s2"> max ecc: </span><span class="si">{}</span><span class="s2"> integrals_string: </span><span class="si">{}</span><span class="s2"> interpolator_name: </span><span class="si">{}</span><span class="s2"> mass_string: </span><span class="si">{}</span><span class="s2"> period_string: </span><span class="si">{}</span><span class="s2"> mass: </span><span class="si">{}</span><span class="s2"> period: </span><span class="si">{}</span><span class="s2"> I: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">min_ecc</span><span class="p">,</span> + <span class="n">max_ecc</span><span class="p">,</span> + <span class="n">integrals_string</span><span class="p">,</span> + <span class="n">interpolator_name</span><span class="p">,</span> + <span class="n">mass_string</span><span class="p">,</span> + <span class="n">period_string</span><span class="p">,</span> + <span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="n">period_string</span><span class="p">],</span> + <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">][</span><span class="n">mass_period_string</span><span class="p">],</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.calc_P_integral"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_P_integral">[docs]</a> <span class="k">def</span> <span class="nf">calc_P_integral</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">options</span><span class="p">,</span> + <span class="n">min_logP</span><span class="p">,</span> + <span class="n">max_logP</span><span class="p">,</span> + <span class="n">integrals_string</span><span class="p">,</span> + <span class="n">interpolator_name</span><span class="p">,</span> + <span class="n">mass_string</span><span class="p">,</span> + <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to calculate the P integral</span> + +<span class="sd"> We need to renormalise this because min_per > 0, and not all periods should be included</span> +<span class="sd"> """</span> + + <span class="k">global</span> <span class="n">Moecache</span> + + <span class="c1"># Check if the dict exists</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">integrals_string</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="c1"># Check for cached value. If it doesn't exist: calculate</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">I</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">dlogP</span> <span class="o">=</span> <span class="mf">1e-3</span> + + <span class="k">for</span> <span class="n">logP</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">min_logP</span><span class="p">,</span> <span class="n">max_logP</span><span class="p">,</span> <span class="n">dlogP</span><span class="p">):</span> + <span class="c1"># Loop over all the values in the table, between the min and max P</span> + <span class="n">dp_dlogP</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="n">interpolator_name</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">]),</span> <span class="n">logP</span><span class="p">]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + + <span class="n">I</span> <span class="o">+=</span> <span class="n">dp_dlogP</span> <span class="o">*</span> <span class="n">dlogP</span> + + <span class="c1"># Set the integral value in the dict</span> + <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">][</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">]]</span> <span class="o">=</span> <span class="n">I</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: calc_P_integral: min_logP: </span><span class="si">{}</span><span class="s2"> integrals_string: </span><span class="si">{}</span><span class="s2"> interpolator_name: </span><span class="si">{}</span><span class="s2"> mass_string: </span><span class="si">{}</span><span class="s2"> mass: </span><span class="si">{}</span><span class="s2"> I: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">min_logP</span><span class="p">,</span> + <span class="n">integrals_string</span><span class="p">,</span> + <span class="n">interpolator_name</span><span class="p">,</span> + <span class="n">mass_string</span><span class="p">,</span> + <span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> + <span class="n">I</span><span class="p">,</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe and di Stefano 2017: calc_P_integral: Found cached value for min_logP: </span><span class="si">{}</span><span class="s2"> integrals_string: </span><span class="si">{}</span><span class="s2"> interpolator_name: </span><span class="si">{}</span><span class="s2"> mass_string: </span><span class="si">{}</span><span class="s2"> mass: </span><span class="si">{}</span><span class="s2"> I: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">min_logP</span><span class="p">,</span> + <span class="n">integrals_string</span><span class="p">,</span> + <span class="n">interpolator_name</span><span class="p">,</span> + <span class="n">mass_string</span><span class="p">,</span> + <span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">],</span> + <span class="n">Moecache</span><span class="p">[</span><span class="n">integrals_string</span><span class="p">][</span><span class="n">options</span><span class="p">[</span><span class="n">mass_string</span><span class="p">]],</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="distribution_functions.calc_total_probdens"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_total_probdens">[docs]</a> <span class="k">def</span> <span class="nf">calc_total_probdens</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prob_dict</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to calculate the total probability density</span> +<span class="sd"> """</span> + + <span class="n">total_probdens</span> <span class="o">=</span> <span class="mi">1</span> + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">prob_dict</span><span class="p">:</span> + <span class="n">total_probdens</span> <span class="o">*=</span> <span class="n">prob_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"total_probdens"</span><span class="p">]</span> <span class="o">=</span> <span class="n">total_probdens</span> + + <span class="k">return</span> <span class="n">prob_dict</span></div> + +<div class="viewcode-block" id="distribution_functions.Moe_di_Stefano_2017_pdf"><a class="viewcode-back" href="../../../../population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Moe_di_Stefano_2017_pdf">[docs]</a> <span class="k">def</span> <span class="nf">Moe_di_Stefano_2017_pdf</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Moe & diStefano function to calculate the probability density.</span> + +<span class="sd"> takes a dictionary as input (in options) with options:</span> + +<span class="sd"> M1, M2, M3, M4 => masses (Msun) [M1 required, rest optional]</span> +<span class="sd"> P, P2, P3 => periods (days) [number: none=binary, 2=triple, 3=quadruple]</span> +<span class="sd"> ecc, ecc2, ecc3 => eccentricities [numbering as for P above]</span> + +<span class="sd"> mmin => minimum allowed stellar mass (default 0.07)</span> +<span class="sd"> mmax => maximum allowed stellar mass (default 80.0)</span> +<span class="sd"> """</span> + + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf with options:</span><span class="se">\n\t\t</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="n">prob_dict</span> <span class="o">=</span> <span class="p">(</span> + <span class="p">{}</span> + <span class="p">)</span> <span class="c1"># Dictionary containing all the pdf values for the different parameters</span> + + <span class="c1"># Get the multiplicity from the options, and if its not there, calculate it based on the</span> + <span class="c1"># TODO: the function below makes no sense. We NEED to pass the multiplicity in the</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"multiplicity"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Did not find a multiplicity value in the options dictionary"</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="n">msg</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="n">multiplicity</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">]</span> + + <span class="c1"># Immediately return 0 if the multiplicity modulator is 0</span> + <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"multiplicity_modulator"</span><span class="p">][</span><span class="nb">int</span><span class="p">(</span><span class="n">multiplicity</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: returning 0 because of the multiplicity modulator being 0"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">return</span> <span class="mi">0</span> + + <span class="c1">############################################################</span> + <span class="c1"># multiplicity fraction</span> + <span class="c1"># Calculate the probability, or rather, fraction, of stars that belong to this mass</span> + + <span class="n">multiplicity_probability</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Moe_di_Stefano_2017_multiplicity_fractions</span><span class="p">(</span> + <span class="n">options</span><span class="p">,</span> <span class="n">verbosity</span> + <span class="p">)[</span><span class="nb">int</span><span class="p">(</span><span class="n">multiplicity</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">]</span> <span class="o">=</span> <span class="n">multiplicity_probability</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended multiplicity (mass1 = </span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob dict (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">],</span> <span class="n">prob_dict</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1">############################################################</span> + <span class="c1"># always require an IMF for the primary star</span> + <span class="c1">#</span> + <span class="c1"># NB multiply by M1 to convert dN/dM to dN/dlnM</span> + <span class="c1"># (dlnM = dM/M, so 1/dlnM = M/dM)</span> + + <span class="c1"># TODO: Create an n-part-powerlaw method that can have breakpoints and slopes. I'm using a three-part power law now.</span> + <span class="c1"># TODO: is this actually the correct way? putting the M1 in there? Do we sample in log space?</span> + <span class="n">M1_probability</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Kroupa2001</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">])</span> <span class="o">*</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="o">=</span> <span class="n">M1_probability</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended Mass (m=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob dict (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">prob_dict</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># if M1_probability == 0: # If the probability is 0 then we don't have to calculate more</span> + <span class="c1"># calc_total_probdens(prob_dict)</span> + <span class="c1"># return prob_dict</span> + + <span class="sd">"""</span> +<span class="sd"> From here we go through the multiplicities.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="n">multiplicity</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> + <span class="c1"># If the multiplicity is higher than 1, we will need to construct the following tables:</span> + <span class="c1"># - period distribution table</span> + <span class="c1"># - q distribution table</span> + <span class="c1"># - eccentricity distribution table</span> + + <span class="c1"># Set up the interpolator for the periods</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_log10P"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_log10P"</span><span class="p">]</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> + <span class="n">table</span><span class="o">=</span><span class="n">Moecache</span><span class="p">[</span> + <span class="s2">"period_distributions"</span> + <span class="p">],</span> <span class="c1"># Contains the table of data</span> + <span class="n">nparams</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="c1"># log10M, log10P</span> + <span class="n">ndata</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="c1"># binary, triple</span> + <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> <span class="o">-</span> <span class="p">(</span><span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Created new period interpolator: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_log10P"</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Make a table storing Moe's data for q distributions</span> + <span class="k">if</span> <span class="p">(</span> + <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="ow">or</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_3"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="ow">or</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_4"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="p">):</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_q"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> + <span class="n">table</span><span class="o">=</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"q_distributions"</span><span class="p">],</span> <span class="c1"># Contains the table of data</span> + <span class="n">nparams</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="c1"># log10M, log10P, q</span> + <span class="n">ndata</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="c1">#</span> + <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> + <span class="o">-</span> <span class="p">(</span><span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Created new q interpolator: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_q"</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Make a table storing Moe's data for q distributions, but only if the ecc is actually sampled</span> + <span class="k">if</span> <span class="s2">"ecc"</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">Moecache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rinterpolator_e"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_e"</span><span class="p">]</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> + <span class="n">table</span><span class="o">=</span><span class="n">Moecache</span><span class="p">[</span> + <span class="s2">"ecc_distributions"</span> + <span class="p">],</span> <span class="c1"># Contains the table of data</span> + <span class="n">nparams</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="c1"># log10M, log10P, e</span> + <span class="n">ndata</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="c1">#</span> + <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> + <span class="o">-</span> <span class="p">(</span><span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Created new e interpolator: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_e"</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1">###############</span> + <span class="c1"># Calculation for period of the binary</span> + + <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="c1"># Separation of the inner binary</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"sep"</span><span class="p">]</span> <span class="o">=</span> <span class="n">calc_sep_from_period</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]</span> + <span class="p">)</span> + <span class="c1"># TODO: add check for min_logP with instant RLOF?</span> + <span class="c1"># TODO: Actually use the value above.</span> + <span class="c1"># Total mass inner binary:</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> <span class="o">+</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> + + <span class="c1"># Calculate P integral or use cached value</span> + + <span class="c1"># get the periods from the Moecahe</span> + <span class="n">min_logP</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"logperiods"</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span> + <span class="n">max_logP</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"logperiods"</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">calc_P_integral</span><span class="p">(</span> + <span class="n">options</span><span class="p">,</span> + <span class="n">min_logP</span><span class="p">,</span> + <span class="n">max_logP</span><span class="p">,</span> + <span class="s2">"P_integrals"</span><span class="p">,</span> + <span class="s2">"rinterpolator_log10P"</span><span class="p">,</span> + <span class="s2">"M_1"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Set probabilty for P1</span> + <span class="n">p_val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_log10P"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">])]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">p_val</span> <span class="o">=</span> <span class="n">p_val</span> <span class="o">/</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"P_integrals"</span><span class="p">][</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]]</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]</span> <span class="o">=</span> <span class="n">p_val</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended period (m=</span><span class="si">{}</span><span class="s2">, P=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> <span class="n">prob_dict</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># if prob_dict['P'] == 0: # If the probability is 0 then we don't have to calculate more</span> + <span class="c1"># calc_total_probdens(prob_dict)</span> + <span class="c1"># return prob_dict</span> + + <span class="c1">############################################################</span> + <span class="c1"># mass ratio (0 < q = M2/M1 < qmax)</span> + <span class="c1">#</span> + <span class="c1"># we need to construct the q table for the given M1</span> + <span class="c1"># subject to qmin = Mmin/M1</span> + + <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span> + <span class="c1"># Build the table for q</span> + <span class="n">primary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> + <span class="n">secondary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> + <span class="n">m_label</span> <span class="o">=</span> <span class="s2">"M_1"</span> + <span class="n">p_label</span> <span class="o">=</span> <span class="s2">"P"</span> + + <span class="c1"># Construct the q table</span> + <span class="bp">self</span><span class="o">.</span><span class="n">build_q_table</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span><span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Created q_table (</span><span class="si">{}</span><span class="s2">) for m=</span><span class="si">{}</span><span class="s2"> p=</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">Moecache</span><span class="p">[</span> + <span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">)</span> + <span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="n">m_label</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="n">p_label</span><span class="p">],</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Add probability for the mass ratio</span> + <span class="n">q_prob</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span> + <span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">)</span> + <span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">secondary_mass</span> <span class="o">/</span> <span class="n">primary_mass</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q"</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_prob</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: appended mass ratio (M=</span><span class="si">{}</span><span class="s2"> P=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">) "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> <span class="o">/</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q"</span><span class="p">],</span> + <span class="n">prob_dict</span><span class="p">,</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># if prob_dict['q'] == 0: # If the probability is 0 then we don't have to calculate more</span> + <span class="c1"># calc_total_probdens(prob_dict)</span> + <span class="c1"># return prob_dict</span> + + <span class="c1">############################################################</span> + <span class="c1"># Eccentricity</span> + <span class="c1"># TODO: ask rob if the eccentricity requires an extrapolation as well.</span> + + <span class="c1"># Only do this if the eccentricity is sampled</span> + <span class="k">if</span> <span class="s2">"ecc"</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="c1"># Calculate ecc integral or use cached value</span> + <span class="bp">self</span><span class="o">.</span><span class="n">calc_e_integral</span><span class="p">(</span> + <span class="n">options</span><span class="p">,</span> + <span class="s2">"ecc_integrals"</span><span class="p">,</span> + <span class="s2">"rinterpolator_e"</span><span class="p">,</span> + <span class="s2">"M_1"</span><span class="p">,</span> + <span class="s2">"P"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="p">)</span> + <span class="n">mass_period_string</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">_</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">])</span> + + <span class="c1"># Set probability for ecc</span> + <span class="n">ecc_val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_e"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]),</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">],</span> + <span class="p">]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">ecc_val</span> <span class="o">=</span> <span class="n">ecc_val</span> <span class="o">/</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"ecc_integrals"</span><span class="p">][</span><span class="n">mass_period_string</span><span class="p">]</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="o">=</span> <span class="n">ecc_val</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended eccentricity (m=</span><span class="si">{}</span><span class="s2">, P=</span><span class="si">{}</span><span class="s2">, ecc=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">],</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">],</span> + <span class="n">prob_dict</span><span class="p">,</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># if prob_dict['ecc'] == 0: # If the probability is 0 then we don't have to calculate more</span> + <span class="c1"># calc_total_probdens(prob_dict)</span> + <span class="c1"># return prob_dict</span> + + <span class="c1"># Calculations for when multiplicity is bigger than 3</span> + <span class="c1"># BEWARE: binary_c does not evolve these systems actually and the code below should be revised for when binary_c actually evolves triples.</span> + <span class="c1"># For that reason, I would not advise to use things with multiplicity > 3</span> + <span class="k">if</span> <span class="n">multiplicity</span> <span class="o">>=</span> <span class="mi">3</span><span class="p">:</span> + + <span class="c1">############################################################</span> + <span class="c1"># orbital period 2 =</span> + <span class="c1"># orbital period of star 3 (multiplicity==3) or</span> + <span class="c1"># the star3+star4 binary (multiplicity==4)</span> + <span class="c1">#</span> + <span class="c1"># we assume the same period distribution for star 3</span> + <span class="c1"># (or stars 3 and 4) but with a separation that is >10*a*(1+e)</span> + <span class="c1"># where 10*a*(1+e) is the maximum apastron separation of</span> + <span class="c1"># stars 1 and 2</span> + + <span class="c1"># TODO: Is this a correct assumption?</span> + <span class="n">max_sep</span> <span class="o">=</span> <span class="mf">10.0</span> <span class="o">*</span> <span class="n">options</span><span class="p">[</span><span class="s2">"sep"</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">])</span> + <span class="n">min_P2</span> <span class="o">=</span> <span class="n">calc_period_from_sep</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"mmin"</span><span class="p">],</span> <span class="n">max_sep</span> + <span class="p">)</span> + <span class="n">min_logP2</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">min_P2</span><span class="p">)</span> + <span class="c1"># max_logP2 = 10.0</span> + <span class="c1"># min_logP = Moecache['logperiods'][0]</span> + <span class="n">max_logP2</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">Moecache</span><span class="p">[</span><span class="s2">"logperiods"</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> + + <span class="k">if</span> <span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]</span> <span class="o"><</span> <span class="n">min_P2</span><span class="p">:</span> + <span class="c1"># period is too short : system is not hierarchical</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: period2 is too short: </span><span class="si">{}</span><span class="s2"> < </span><span class="si">{}</span><span class="s2">, system is not hierarchical. Added 0 to probability list"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"P1"</span><span class="p">],</span> <span class="n">min_P2</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># if prob_dict['P2'] == 0: # If the probability is 0 then we don't have to calculate more</span> + <span class="c1"># calc_total_probdens(prob_dict)</span> + <span class="c1"># return prob_dict</span> + + <span class="k">else</span><span class="p">:</span> + <span class="c1"># period is long enough that the system is hierarchical</span> + <span class="c1"># hence the separation between the outer star</span> + <span class="c1"># and inner binary</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"sep2"</span><span class="p">]</span> <span class="o">=</span> <span class="n">calc_sep_from_period</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]</span> + <span class="p">)</span> + + <span class="c1"># Check for cached value of P integral or calculate</span> + <span class="bp">self</span><span class="o">.</span><span class="n">calc_P_integral</span><span class="p">(</span> + <span class="n">options</span><span class="p">,</span> + <span class="n">min_logP2</span><span class="p">,</span> + <span class="n">max_logP2</span><span class="p">,</span> + <span class="s2">"P2_integrals"</span><span class="p">,</span> + <span class="s2">"rinterpolator_log10P"</span><span class="p">,</span> + <span class="s2">"M_1+M_2"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Add the probability</span> + <span class="n">p_val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_log10P"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">])]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">p_val</span> <span class="o">=</span> <span class="n">p_val</span> <span class="o">/</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"P2_integrals"</span><span class="p">][</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]]</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]</span> <span class="o">=</span> <span class="n">p_val</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended period2 (m1=</span><span class="si">{}</span><span class="s2"> m2=</span><span class="si">{}</span><span class="s2">, P2=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">],</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">],</span> + <span class="n">prob_dict</span><span class="p">,</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># if prob_dict['P2'] == 0: # If the probability is 0 then we don't have to calculate more</span> + <span class="c1"># calc_total_probdens(prob_dict)</span> + <span class="c1"># return prob_dict</span> + + <span class="c1">############################################################</span> + <span class="c1"># mass ratio 2 = q2 = M3 / (M1+M2)</span> + <span class="c1">#</span> + <span class="c1"># we need to construct the q table for the given M1</span> + <span class="c1"># subject to qmin = Mmin/(M1+M2)</span> + + <span class="c1"># Set the variables for the masses and their names</span> + <span class="n">primary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]</span> + <span class="n">secondary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">]</span> + <span class="n">m_label</span> <span class="o">=</span> <span class="s2">"M_1+M_2"</span> + <span class="n">p_label</span> <span class="o">=</span> <span class="s2">"P2"</span> + + <span class="c1"># Build q table</span> + <span class="bp">self</span><span class="o">.</span><span class="n">build_q_table</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span><span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Called build_q_table"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Add the probability</span> + <span class="n">q2_val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span> + <span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">)</span> + <span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">secondary_mass</span> <span class="o">/</span> <span class="n">primary_mass</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q2"</span><span class="p">]</span> <span class="o">=</span> <span class="n">q2_val</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: appended mass ratio (M_1+M_2=</span><span class="si">{}</span><span class="s2"> M_3=</span><span class="si">{}</span><span class="s2"> P=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">) "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> + <span class="n">secondary_mass</span> <span class="o">/</span> <span class="n">primary_mass</span><span class="p">,</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q2"</span><span class="p">],</span> + <span class="n">prob_dict</span><span class="p">,</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># if prob_dict['q2'] == 0: # If the probability is 0 then we don't have to calculate more</span> + <span class="c1"># calc_total_probdens(prob_dict)</span> + <span class="c1"># return prob_dict</span> + + <span class="c1"># TODO: Implement ecc2 calculation</span> + <span class="k">if</span> <span class="n">multiplicity</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span> + <span class="c1"># quadruple system.</span> + <span class="c1"># TODO: Ask Rob about the structure of the quadruple. Is this only double binary quadruples?</span> + + <span class="c1">############################################################</span> + <span class="c1"># orbital period 3</span> + <span class="c1">#</span> + <span class="c1"># we assume the same period distribution for star 4</span> + <span class="c1"># as for any other stars but Pmax must be such that</span> + <span class="c1"># sep3 < sep2 * 0.2</span> + + <span class="c1"># TODO: fix this here</span> + <span class="n">max_sep3</span> <span class="o">=</span> <span class="mf">0.2</span> <span class="o">*</span> <span class="n">options</span><span class="p">[</span><span class="s2">"sep2"</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">options</span><span class="p">[</span><span class="s2">"ecc2"</span><span class="p">])</span> + <span class="n">max_per3</span> <span class="o">=</span> <span class="n">calc_period_from_sep</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">],</span> <span class="n">options</span><span class="p">[</span><span class="s2">"mmin"</span><span class="p">],</span> <span class="n">max_sep3</span> + <span class="p">)</span> + + <span class="c1"># Calculate P integral or use the cached value</span> + <span class="c1"># TODO: Make sure we use the correct period idea here.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">calc_P_integral</span><span class="p">(</span> + <span class="n">options</span><span class="p">,</span> + <span class="n">min_logP2</span><span class="p">,</span> + <span class="n">max_logP2</span><span class="p">,</span> + <span class="s2">"P2_integrals"</span><span class="p">,</span> + <span class="s2">"rinterpolator_log10P"</span><span class="p">,</span> + <span class="s2">"M_1+M_2"</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Set probability</span> + <span class="n">p_val</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"rinterpolator_log10P"</span><span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">(</span> + <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">])]</span> + <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">p_val</span> <span class="o">=</span> <span class="n">p_val</span> <span class="o">/</span> <span class="n">Moecache</span><span class="p">[</span><span class="s2">"P2_integrals"</span><span class="p">][</span><span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]]</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P3"</span><span class="p">]</span> <span class="o">=</span> <span class="n">p_val</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Appended period2 (M=4) (M_1=</span><span class="si">{}</span><span class="s2"> M_2=</span><span class="si">{}</span><span class="s2">, P2=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">],</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"P3"</span><span class="p">],</span> + <span class="n">prob_dict</span><span class="p">,</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># if prob_dict['P3'] == 0: # If the probability is 0 then we don't have to calculate more</span> + <span class="c1"># calc_total_probdens(prob_dict)</span> + <span class="c1"># return prob_dict</span> + + <span class="c1">############################################################</span> + <span class="c1"># mass ratio 2</span> + <span class="c1">#</span> + <span class="c1"># we need to construct the q table for the given M1</span> + <span class="c1"># subject to qmin = Mmin/(M1+M2)</span> + <span class="c1"># Make a table storing Moe's data for q distributions</span> + + <span class="c1"># Build the table for q2</span> + <span class="n">primary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">]</span> + <span class="n">secondary_mass</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">]</span> + <span class="n">m_label</span> <span class="o">=</span> <span class="s2">"M_1+M_2"</span> + <span class="n">p_label</span> <span class="o">=</span> <span class="s2">"P2"</span> + + <span class="c1"># Calculate new q table</span> + <span class="bp">self</span><span class="o">.</span><span class="n">build_q_table</span><span class="p">(</span> + <span class="n">options</span><span class="p">,</span> <span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="n">verbosity</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Created q_table "</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Add the probability</span> + <span class="n">q3_prob</span> <span class="o">=</span> <span class="n">Moecache</span><span class="p">[</span> + <span class="s2">"rinterpolator_q_given_</span><span class="si">{}</span><span class="s2">_log10</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m_label</span><span class="p">,</span> <span class="n">p_label</span><span class="p">)</span> + <span class="p">]</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">secondary_mass</span> <span class="o">/</span> <span class="n">primary_mass</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q3"</span><span class="p">]</span> <span class="o">=</span> <span class="n">q3_prob</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: appended mass ratio (M_1+M_2=</span><span class="si">{}</span><span class="s2"> M_3=</span><span class="si">{}</span><span class="s2"> P=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2">) probability (</span><span class="si">{}</span><span class="s2">) to the prob list (</span><span class="si">{}</span><span class="s2">) "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1+M_2"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">],</span> + <span class="n">secondary_mass</span> <span class="o">/</span> <span class="n">primary_mass</span><span class="p">,</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"q3"</span><span class="p">],</span> + <span class="n">prob_dict</span><span class="p">,</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># if prob_dict['q3'] == 0: # If the probability is 0 then we don't have to calculate more</span> + <span class="c1"># calc_total_probdens(prob_dict)</span> + <span class="c1"># return prob_dict</span> + + <span class="c1"># TODO: ecc 3</span> + + <span class="c1"># check for input of multiplicity</span> + <span class="k">elif</span> <span class="n">multiplicity</span> <span class="ow">not</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">5</span><span class="p">):</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: Unknown multiplicity </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">multiplicity</span> + <span class="p">)</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="n">msg</span><span class="p">,</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Calculate total probdens:</span> + <span class="n">prob_dict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">calc_total_probdens</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">)</span> + + <span class="c1"># Some info</span> + <span class="k">if</span> <span class="n">multiplicity</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: M_1=</span><span class="si">{}</span><span class="s2"> q=N/A log10P=N/A (</span><span class="si">{}</span><span class="s2">): </span><span class="si">{}</span><span class="s2"> -> </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> + <span class="nb">len</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> + <span class="nb">str</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"total_probdens"</span><span class="p">],</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="n">multiplicity</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: M_1=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2"> log10P=</span><span class="si">{}</span><span class="s2"> ecc=</span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2">): </span><span class="si">{}</span><span class="s2"> -> </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> <span class="o">/</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]),</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> + <span class="nb">len</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> + <span class="nb">str</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"total_probdens"</span><span class="p">],</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="n">multiplicity</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\t</span><span class="s2">Moe_di_Stefano_2017_pdf: M_1=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2"> log10P=</span><span class="si">{}</span><span class="s2"> ecc=</span><span class="si">{}</span><span class="s2"> M_3=</span><span class="si">{}</span><span class="s2"> log10P2=</span><span class="si">{}</span><span class="s2"> ecc2=</span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2">): </span><span class="si">{}</span><span class="s2"> -> </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> <span class="o">/</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]),</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">],</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]),</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"ecc2"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> + <span class="nb">len</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> + <span class="nb">str</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"total_probdens"</span><span class="p">],</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="n">multiplicity</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span> + <span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Moe_di_Stefano_2017_pdf: M_1=</span><span class="si">{}</span><span class="s2"> q=</span><span class="si">{}</span><span class="s2"> log10P=</span><span class="si">{}</span><span class="s2"> ecc=</span><span class="si">{}</span><span class="s2"> M_3=</span><span class="si">{}</span><span class="s2"> log10P2=</span><span class="si">{}</span><span class="s2"> ecc2=</span><span class="si">{}</span><span class="s2"> M_4=</span><span class="si">{}</span><span class="s2"> log10P3=</span><span class="si">{}</span><span class="s2"> ecc3=</span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2">) : </span><span class="si">{}</span><span class="s2"> -> </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">],</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_2"</span><span class="p">]</span> <span class="o">/</span> <span class="n">options</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"M_2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> + <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P"</span><span class="p">]),</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"ecc"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_3"</span><span class="p">],</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P2"</span><span class="p">]),</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"ecc2"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc2"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"M_4"</span><span class="p">],</span> + <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="s2">"P3"</span><span class="p">]),</span> + <span class="n">options</span><span class="p">[</span><span class="s2">"ecc3"</span><span class="p">]</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ecc3"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"N/A"</span><span class="p">,</span> + <span class="nb">len</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> + <span class="nb">str</span><span class="p">(</span><span class="n">prob_dict</span><span class="p">),</span> + <span class="n">prob_dict</span><span class="p">[</span><span class="s2">"total_probdens"</span><span class="p">],</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="p">,</span> + <span class="n">_MOE2017_VERBOSITY_LEVEL</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">return</span> <span class="n">prob_dict</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/grid_logging.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/grid_logging.html new file mode 100644 index 0000000000000000000000000000000000000000..b2633a6561a8b9e4cf6ac1458ba25fc736469613 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/grid_logging.html @@ -0,0 +1,576 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.grid_logging — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.grid_logging</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.grid_logging</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">The class extension for the population object that contains logging functionality</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">os</span> +<span class="kn">import</span> <span class="nn">sys</span> +<span class="kn">import</span> <span class="nn">time</span> +<span class="kn">import</span> <span class="nn">logging</span> +<span class="kn">import</span> <span class="nn">strip_ansi</span> + +<span class="kn">import</span> <span class="nn">binarycpython.utils.functions</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">format_number</span><span class="p">,</span> + <span class="n">trem</span><span class="p">,</span> + <span class="n">remove_file</span><span class="p">,</span> + <span class="n">verbose_print</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.population_extensions.grid_options_defaults</span> <span class="kn">import</span> <span class="n">secs_per_day</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">binary_c_log_code</span><span class="p">,</span> + <span class="n">create_and_load_logging_function</span><span class="p">,</span> + <span class="n">autogen_C_logging_code</span><span class="p">,</span> +<span class="p">)</span> + + +<div class="viewcode-block" id="grid_logging"><a class="viewcode-back" href="../../../../population_extensions/grid_logging.html#binarycpython.utils.population_extensions.grid_logging.grid_logging">[docs]</a><span class="k">class</span> <span class="nc">grid_logging</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> The class extension for the population object that contains logging functionality</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the grid_logging class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + + <span class="k">def</span> <span class="nf">_set_custom_logging</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function/routine to set all the custom logging so that the function memory pointer</span> +<span class="sd"> is known to the grid.</span> + +<span class="sd"> When the memory adress is loaded and the library file is set we'll skip rebuilding the library</span> +<span class="sd"> """</span> + + <span class="c1"># Only if the values are the 'default' unset values</span> + <span class="k">if</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"custom_logging_func_memaddr"</span><span class="p">]</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span> + <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span> + <span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Creating and loading custom logging functionality"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># C_logging_code gets priority of C_autogen_code</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"C_logging_code"</span><span class="p">]:</span> + <span class="c1"># Generate entire shared lib code around logging lines</span> + <span class="n">custom_logging_code</span> <span class="o">=</span> <span class="n">binary_c_log_code</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"C_logging_code"</span><span class="p">],</span> + <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> + <span class="o">-</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># Load memory address</span> + <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"custom_logging_func_memaddr"</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">],</span> + <span class="p">)</span> <span class="o">=</span> <span class="n">create_and_load_logging_function</span><span class="p">(</span> + <span class="n">custom_logging_code</span><span class="p">,</span> + <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> + <span class="o">-</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> + <span class="n">custom_tmp_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> + <span class="p">)</span> + + <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"C_auto_logging"</span><span class="p">]:</span> + <span class="c1"># Generate real logging code</span> + <span class="n">logging_line</span> <span class="o">=</span> <span class="n">autogen_C_logging_code</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"C_auto_logging"</span><span class="p">],</span> + <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> + <span class="o">-</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># Generate entire shared lib code around logging lines</span> + <span class="n">custom_logging_code</span> <span class="o">=</span> <span class="n">binary_c_log_code</span><span class="p">(</span> + <span class="n">logging_line</span><span class="p">,</span> + <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> + <span class="o">-</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># Load memory address</span> + <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"custom_logging_func_memaddr"</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">],</span> + <span class="p">)</span> <span class="o">=</span> <span class="n">create_and_load_logging_function</span><span class="p">(</span> + <span class="n">custom_logging_code</span><span class="p">,</span> + <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> + <span class="o">-</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_CUSTOM_LOGGING_VERBOSITY_LEVEL</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> + <span class="n">custom_tmp_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Custom logging library already loaded. Not setting them again."</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">def</span> <span class="nf">_print_info</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">run_number</span><span class="p">,</span> <span class="n">total_systems</span><span class="p">,</span> <span class="n">full_system_dict</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to print info about the current system and the progress of the grid.</span> + +<span class="sd"> # color info tricks from https://ozzmaker.com/add-colour-to-text-in-python/</span> +<span class="sd"> https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python</span> +<span class="sd"> """</span> + + <span class="c1"># Define frequency</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="n">print_freq</span> <span class="o">=</span> <span class="mi">1</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">print_freq</span> <span class="o">=</span> <span class="mi">10</span> + + <span class="k">if</span> <span class="n">run_number</span> <span class="o">%</span> <span class="n">print_freq</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="n">binary_cmdline_string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_argline</span><span class="p">(</span><span class="n">full_system_dict</span><span class="p">)</span> + <span class="n">info_string</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{color_part_1}</span><span class="s2"> </span><span class="se">\</span> +<span class="s2"> </span><span class="si">{text_part_1}{end_part_1}{color_part_2}</span><span class="s2"> </span><span class="se">\</span> +<span class="s2"> </span><span class="si">{text_part_2}{end_part_2}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">color_part_1</span><span class="o">=</span><span class="s2">"</span><span class="se">\033</span><span class="s2">[1;32;41m"</span><span class="p">,</span> + <span class="n">text_part_1</span><span class="o">=</span><span class="s2">"</span><span class="si">{}</span><span class="s2">/</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">run_number</span><span class="p">,</span> <span class="n">total_systems</span><span class="p">),</span> + <span class="n">end_part_1</span><span class="o">=</span><span class="s2">"</span><span class="se">\033</span><span class="s2">[0m"</span><span class="p">,</span> + <span class="n">color_part_2</span><span class="o">=</span><span class="s2">"</span><span class="se">\033</span><span class="s2">[1;32;42m"</span><span class="p">,</span> + <span class="n">text_part_2</span><span class="o">=</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">binary_cmdline_string</span><span class="p">),</span> + <span class="n">end_part_2</span><span class="o">=</span><span class="s2">"</span><span class="se">\033</span><span class="s2">[0m"</span><span class="p">,</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="n">info_string</span><span class="p">)</span> + + <span class="k">def</span> <span class="nf">_set_loggers</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to set the loggers for the execution of the grid</span> +<span class="sd"> """</span> + + <span class="c1"># Set log file</span> + <span class="n">binary_c_logfile</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_file"</span><span class="p">]</span> + + <span class="c1"># Create directory</span> + <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">binary_c_logfile</span><span class="p">),</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + + <span class="c1"># Set up logger</span> + <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"binary_c_python_logger"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">])</span> + + <span class="c1"># Reset handlers</span> + <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">handlers</span> <span class="o">=</span> <span class="p">[]</span> + + <span class="c1"># Set formatting of output</span> + <span class="n">log_formatter</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span> + <span class="s2">"</span><span class="si">%(asctime)s</span><span class="s2"> - </span><span class="si">%(name)s</span><span class="s2"> - </span><span class="si">%(levelname)s</span><span class="s2"> - </span><span class="si">%(message)s</span><span class="s2">"</span> + <span class="p">)</span> + + <span class="c1"># Make and add file handlers</span> + <span class="c1"># make handler for output to file</span> + <span class="n">handler_file</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">FileHandler</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">binary_c_logfile</span><span class="p">))</span> + <span class="n">handler_file</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">log_formatter</span><span class="p">)</span> + <span class="n">handler_file</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span> + + <span class="c1"># Make handler for output to stdout</span> + <span class="n">handler_stdout</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">)</span> + <span class="n">handler_stdout</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">log_formatter</span><span class="p">)</span> + <span class="n">handler_stdout</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span> + + <span class="c1"># Add the loggers</span> + <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">handler_file</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">handler_stdout</span><span class="p">)</span> + + <span class="c1">######################</span> + <span class="c1"># Status logging</span> + +<div class="viewcode-block" id="grid_logging.vb1print"><a class="viewcode-back" href="../../../../population_extensions/grid_logging.html#binarycpython.utils.population_extensions.grid_logging.grid_logging.vb1print">[docs]</a> <span class="k">def</span> <span class="nf">vb1print</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ID</span><span class="p">,</span> <span class="n">now</span><span class="p">,</span> <span class="n">system_number</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Verbosity-level 1 printing, to keep an eye on a grid.</span> + +<span class="sd"> Input:</span> +<span class="sd"> ID: thread ID for debugging (int): TODO fix this</span> +<span class="sd"> now: the time now as a UNIX-style epoch in seconds (float)</span> +<span class="sd"> system_number: the system number</span> +<span class="sd"> """</span> + + <span class="c1"># calculate estimated time of arrive (eta and eta_secs), time per run (tpr)</span> + <span class="n">localtime</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">localtime</span><span class="p">(</span><span class="n">now</span><span class="p">)</span> + + <span class="c1"># calculate stats</span> + <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"n_saved_log_stats"</span><span class="p">]</span><span class="o">.</span><span class="n">value</span> + <span class="k">if</span> <span class="n">n</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> + <span class="c1"># simple 1-system calculation: inaccurate</span> + <span class="c1"># but best for small n</span> + <span class="n">dt</span> <span class="o">=</span> <span class="n">now</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_time"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="n">dn</span> <span class="o">=</span> <span class="n">system_number</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_system_number"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># average over n_saved_log_stats</span> + <span class="n">dt</span> <span class="o">=</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_time"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_time"</span><span class="p">][</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> + <span class="p">)</span> + <span class="n">dn</span> <span class="o">=</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_system_number"</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> + <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"prev_log_system_number"</span><span class="p">][</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> + <span class="p">)</span> + + <span class="n">eta</span><span class="p">,</span> <span class="n">units</span><span class="p">,</span> <span class="n">tpr</span><span class="p">,</span> <span class="n">eta_secs</span> <span class="o">=</span> <span class="n">trem</span><span class="p">(</span> + <span class="n">dt</span><span class="p">,</span> <span class="n">system_number</span><span class="p">,</span> <span class="n">dn</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> + <span class="p">)</span> + + <span class="c1"># compensate for multithreading and modulo</span> + <span class="n">tpr</span> <span class="o">*=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"modulo"</span><span class="p">]</span> + + <span class="k">if</span> <span class="n">eta_secs</span> <span class="o"><</span> <span class="n">secs_per_day</span><span class="p">:</span> + <span class="n">fintime</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">localtime</span><span class="p">(</span><span class="n">now</span> <span class="o">+</span> <span class="n">eta_secs</span><span class="p">)</span> + <span class="n">etf</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{hours:02d}</span><span class="s2">:</span><span class="si">{minutes:02d}</span><span class="s2">:</span><span class="si">{seconds:02d}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">hours</span><span class="o">=</span><span class="n">fintime</span><span class="o">.</span><span class="n">tm_hour</span><span class="p">,</span> <span class="n">minutes</span><span class="o">=</span><span class="n">fintime</span><span class="o">.</span><span class="n">tm_min</span><span class="p">,</span> <span class="n">seconds</span><span class="o">=</span><span class="n">fintime</span><span class="o">.</span><span class="n">tm_sec</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">d</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">eta_secs</span> <span class="o">/</span> <span class="n">secs_per_day</span><span class="p">)</span> + <span class="k">if</span> <span class="n">d</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="n">etf</span> <span class="o">=</span> <span class="s2">"Tomorrow"</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">etf</span> <span class="o">=</span> <span class="s2">"In </span><span class="si">{}</span><span class="s2"> days"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> + + <span class="c1"># modulo information</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"modulo"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="n">modulo</span> <span class="o">=</span> <span class="s2">""</span> <span class="c1"># usual case</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">modulo</span> <span class="o">=</span> <span class="s2">"%"</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"modulo"</span><span class="p">])</span> + + <span class="c1"># add up memory use from each thread</span> + <span class="n">total_mem_use</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">shared_memory</span><span class="p">[</span><span class="s2">"memory_use_per_thread"</span><span class="p">])</span> + + <span class="c1"># make a string to describe the system e.g. M1, M2, etc.</span> + <span class="n">system_string</span> <span class="o">=</span> <span class="s2">""</span> + + <span class="c1"># use the multiplicity if given</span> + <span class="k">if</span> <span class="s2">"multiplicity"</span> <span class="ow">in</span> <span class="n">system_dict</span><span class="p">:</span> + <span class="n">nmult</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">])</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">nmult</span> <span class="o">=</span> <span class="mi">4</span> + + <span class="c1"># masses</span> + <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nmult</span><span class="p">):</span> + <span class="n">i1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> + <span class="k">if</span> <span class="s2">"M_"</span> <span class="o">+</span> <span class="n">i1</span> <span class="ow">in</span> <span class="n">system_dict</span><span class="p">:</span> + <span class="n">system_string</span> <span class="o">+=</span> <span class="p">(</span> + <span class="s2">"M</span><span class="si">{}</span><span class="s2">="</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i1</span><span class="p">)</span> <span class="o">+</span> <span class="n">format_number</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"M_"</span> <span class="o">+</span> <span class="n">i1</span><span class="p">])</span> <span class="o">+</span> <span class="s2">" "</span> + <span class="p">)</span> + + <span class="c1"># separation and orbital period</span> + <span class="k">if</span> <span class="s2">"separation"</span> <span class="ow">in</span> <span class="n">system_dict</span><span class="p">:</span> + <span class="n">system_string</span> <span class="o">+=</span> <span class="s2">"a="</span> <span class="o">+</span> <span class="n">format_number</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"separation"</span><span class="p">])</span> + <span class="k">if</span> <span class="s2">"orbital_period"</span> <span class="ow">in</span> <span class="n">system_dict</span><span class="p">:</span> + <span class="n">system_string</span> <span class="o">+=</span> <span class="s2">"P="</span> <span class="o">+</span> <span class="n">format_number</span><span class="p">(</span><span class="n">system_dict</span><span class="p">[</span><span class="s2">"orbital_period"</span><span class="p">])</span> + + <span class="c1"># do the print</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{opening_colour}{system_number}</span><span class="s2">/</span><span class="si">{total_starcount}{modulo}</span><span class="s2"> </span><span class="si">{pc_colour}{pc_complete:5.1f}% c</span><span class="s2">omplete </span><span class="si">{time_colour}{hours:02d}</span><span class="s2">:</span><span class="si">{minutes:02d}</span><span class="s2">:</span><span class="si">{seconds:02d}</span><span class="s2"> </span><span class="si">{ETA_colour}</span><span class="s2">ETA=</span><span class="si">{ETA:7.1f}{units}</span><span class="s2"> tpr=</span><span class="si">{tpr:2.2e}</span><span class="s2"> </span><span class="si">{ETF_colour}</span><span class="s2">ETF=</span><span class="si">{ETF}</span><span class="s2"> </span><span class="si">{mem_use_colour}</span><span class="s2">mem:</span><span class="si">{mem_use:.1f}</span><span class="s2">MB </span><span class="si">{system_string_colour}{system_string}{closing_colour}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">opening_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">]</span> + <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"yellow on black"</span><span class="p">],</span> + <span class="n">system_number</span><span class="o">=</span><span class="n">system_number</span><span class="p">,</span> + <span class="n">total_starcount</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">],</span> + <span class="n">modulo</span><span class="o">=</span><span class="n">modulo</span><span class="p">,</span> + <span class="n">pc_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"blue on black"</span><span class="p">],</span> + <span class="n">pc_complete</span><span class="o">=</span><span class="p">(</span><span class="mf">100.0</span> <span class="o">*</span> <span class="n">system_number</span><span class="p">)</span> + <span class="o">/</span> <span class="p">(</span><span class="mf">1.0</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">])</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_total_starcount"</span><span class="p">]</span> + <span class="k">else</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> + <span class="n">time_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"green on black"</span><span class="p">],</span> + <span class="n">hours</span><span class="o">=</span><span class="n">localtime</span><span class="o">.</span><span class="n">tm_hour</span><span class="p">,</span> + <span class="n">minutes</span><span class="o">=</span><span class="n">localtime</span><span class="o">.</span><span class="n">tm_min</span><span class="p">,</span> + <span class="n">seconds</span><span class="o">=</span><span class="n">localtime</span><span class="o">.</span><span class="n">tm_sec</span><span class="p">,</span> + <span class="n">ETA_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"red on black"</span><span class="p">],</span> + <span class="n">ETA</span><span class="o">=</span><span class="n">eta</span><span class="p">,</span> + <span class="n">units</span><span class="o">=</span><span class="n">units</span><span class="p">,</span> + <span class="n">tpr</span><span class="o">=</span><span class="n">tpr</span><span class="p">,</span> + <span class="n">ETF_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"blue"</span><span class="p">],</span> + <span class="n">ETF</span><span class="o">=</span><span class="n">etf</span><span class="p">,</span> + <span class="n">mem_use_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"magenta"</span><span class="p">],</span> + <span class="n">mem_use</span><span class="o">=</span><span class="n">total_mem_use</span><span class="p">,</span> + <span class="n">system_string_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"yellow"</span><span class="p">],</span> + <span class="n">system_string</span><span class="o">=</span><span class="n">system_string</span><span class="p">,</span> + <span class="n">closing_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{opening_colour}{system_number}{modulo}</span><span class="s2"> </span><span class="si">{time_colour}{hours:02d}</span><span class="s2">:</span><span class="si">{minutes:02d}</span><span class="s2">:</span><span class="si">{seconds:02d}</span><span class="s2"> tpr=</span><span class="si">{tpr:2.2e}</span><span class="s2"> </span><span class="si">{mem_use_colour}</span><span class="s2">mem:</span><span class="si">{mem_use:.1f}</span><span class="s2">MB </span><span class="si">{system_string_colour}{system_string}{closing_colour}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">opening_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">]</span> + <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"yellow on black"</span><span class="p">],</span> + <span class="n">system_number</span><span class="o">=</span><span class="n">system_number</span><span class="p">,</span> + <span class="n">modulo</span><span class="o">=</span><span class="n">modulo</span><span class="p">,</span> + <span class="n">time_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"green on black"</span><span class="p">],</span> + <span class="n">hours</span><span class="o">=</span><span class="n">localtime</span><span class="o">.</span><span class="n">tm_hour</span><span class="p">,</span> + <span class="n">minutes</span><span class="o">=</span><span class="n">localtime</span><span class="o">.</span><span class="n">tm_min</span><span class="p">,</span> + <span class="n">seconds</span><span class="o">=</span><span class="n">localtime</span><span class="o">.</span><span class="n">tm_sec</span><span class="p">,</span> + <span class="n">tpr</span><span class="o">=</span><span class="n">tpr</span><span class="p">,</span> + <span class="n">mem_use_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"magenta"</span><span class="p">],</span> + <span class="n">mem_use</span><span class="o">=</span><span class="n">total_mem_use</span><span class="p">,</span> + <span class="n">system_string_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"yellow"</span><span class="p">],</span> + <span class="n">system_string</span><span class="o">=</span><span class="n">system_string</span><span class="p">,</span> + <span class="n">closing_colour</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="grid_logging.vb2print"><a class="viewcode-back" href="../../../../population_extensions/grid_logging.html#binarycpython.utils.population_extensions.grid_logging.grid_logging.vb2print">[docs]</a> <span class="k">def</span> <span class="nf">vb2print</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">system_dict</span><span class="p">,</span> <span class="n">cmdline_string</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Extra function for verbose printing</span> +<span class="sd"> """</span> + + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Running this system now on thread </span><span class="si">{ID}</span><span class="se">\n</span><span class="si">{blue}{cmdline}{reset}</span><span class="s2">:</span><span class="se">\n\t</span><span class="si">{system_dict}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">ID</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">process_ID</span><span class="p">,</span> + <span class="n">blue</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"blue"</span><span class="p">],</span> + <span class="n">cmdline</span><span class="o">=</span><span class="n">cmdline_string</span><span class="p">,</span> + <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="n">system_dict</span><span class="o">=</span><span class="n">system_dict</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="grid_logging.verbose_print"><a class="viewcode-back" href="../../../../population_extensions/grid_logging.html#binarycpython.utils.population_extensions.grid_logging.grid_logging.verbose_print">[docs]</a> <span class="k">def</span> <span class="nf">verbose_print</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Wrapper method for the verbose print that calls the verbose print with the correct newline</span> + +<span class="sd"> TODO: consider merging the two</span> +<span class="sd"> """</span> + + <span class="c1"># wrapper for functions.verbose_print to use the correct newline</span> + <span class="n">newline</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newline"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"log_newline"</span><span class="p">])</span> + <span class="k">if</span> <span class="n">newline</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">newline</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="n">kwargs</span><span class="p">[</span><span class="s2">"newline"</span><span class="p">]</span> <span class="o">=</span> <span class="n">newline</span> + + <span class="c1"># Pass the rest to the original verbose print</span> + <span class="n">verbose_print</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div> + + <span class="k">def</span> <span class="nf">_boxed</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">stringlist</span><span class="p">,</span> <span class="n">colour</span><span class="o">=</span><span class="s2">"yellow on black"</span><span class="p">,</span> <span class="n">boxchar</span><span class="o">=</span><span class="s2">"*"</span><span class="p">,</span> <span class="n">separator</span><span class="o">=</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to output a list of strings in a single box.</span> + +<span class="sd"> Args:</span> +<span class="sd"> list = a list of strings to be output. If these contain the separator</span> +<span class="sd"> (see below) these strings are split by it.</span> +<span class="sd"> separator = strings are split on this, default "\n"</span> +<span class="sd"> colour = the colour to be used, usually this is 'yellow on black'</span> +<span class="sd"> as set in the ANSI_colours dict</span> +<span class="sd"> boxchar = the character used to make the box, '*' by default</span> + +<span class="sd"> Note: handles tabs (\t) badly, do not use them!</span> +<span class="sd"> """</span> + <span class="n">strlen</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">strings</span> <span class="o">=</span> <span class="p">[]</span> + <span class="n">lengths</span> <span class="o">=</span> <span class="p">[]</span> + + <span class="c1"># make a list of strings</span> + <span class="k">if</span> <span class="n">separator</span><span class="p">:</span> + <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">stringlist</span><span class="p">:</span> + <span class="n">strings</span> <span class="o">+=</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">sep</span><span class="o">=</span><span class="n">separator</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">strings</span> <span class="o">=</span> <span class="n">stringlist</span> + + <span class="c1"># get lengths without ANSI codes</span> + <span class="k">for</span> <span class="n">string</span> <span class="ow">in</span> <span class="n">strings</span><span class="p">:</span> + <span class="n">lengths</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">strip_ansi</span><span class="o">.</span><span class="n">strip_ansi</span><span class="p">(</span><span class="n">string</span><span class="p">)))</span> + + <span class="c1"># hence the max length</span> + <span class="n">strlen</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">lengths</span><span class="p">)</span> + <span class="n">strlen</span> <span class="o">+=</span> <span class="n">strlen</span> <span class="o">%</span> <span class="mi">2</span> + <span class="n">header</span> <span class="o">=</span> <span class="n">boxchar</span> <span class="o">*</span> <span class="p">(</span><span class="mi">4</span> <span class="o">+</span> <span class="n">strlen</span><span class="p">)</span> + + <span class="c1"># start output</span> + <span class="n">out</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="n">colour</span><span class="p">]</span> <span class="o">+</span> <span class="n">header</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + + <span class="c1"># loop over strings to output, padding as required</span> + <span class="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="n">string</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">strings</span><span class="p">):</span> + <span class="k">if</span> <span class="n">lengths</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="n">string</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">string</span> + <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="nb">int</span><span class="p">((</span><span class="n">strlen</span> <span class="o">-</span> <span class="n">lengths</span><span class="p">[</span><span class="n">n</span><span class="p">])</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span> + <span class="n">out</span> <span class="o">=</span> <span class="n">out</span> <span class="o">+</span> <span class="n">boxchar</span> <span class="o">+</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">pad</span> <span class="o">+</span> <span class="n">string</span> <span class="o">+</span> <span class="n">pad</span> <span class="o">+</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">boxchar</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + + <span class="c1"># close output and return</span> + <span class="n">out</span> <span class="o">=</span> <span class="n">out</span> <span class="o">+</span> <span class="n">header</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">]</span> + <span class="k">return</span> <span class="n">out</span> + + <span class="k">def</span> <span class="nf">_get_stream_logger</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to set up the streamlogger</span> +<span class="sd"> """</span> + + <span class="c1"># Format</span> + <span class="n">fmt</span> <span class="o">=</span> <span class="s2">"[</span><span class="si">%(asctime)s</span><span class="s2"> </span><span class="si">%(levelname)-8s</span><span class="s2"> </span><span class="si">%(processName)s</span><span class="s2">] --- </span><span class="si">%(message)s</span><span class="s2">"</span> + <span class="n">formatter</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span><span class="n">fmt</span><span class="p">)</span> + + <span class="c1"># Streamhandle</span> + <span class="n">sh</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">(</span><span class="n">stream</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">)</span> + <span class="n">sh</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">level</span><span class="p">)</span> + <span class="n">sh</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span> + + <span class="c1"># Logger itself</span> + <span class="n">stream_logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"stream_logger"</span><span class="p">)</span> + <span class="n">stream_logger</span><span class="o">.</span><span class="n">handlers</span> <span class="o">=</span> <span class="p">[]</span> + <span class="n">stream_logger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">level</span><span class="p">)</span> + <span class="n">stream_logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">sh</span><span class="p">)</span> + + <span class="k">return</span> <span class="n">stream_logger</span> + + <span class="k">def</span> <span class="nf">_clean_up_custom_logging</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">evol_type</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to clean up the custom logging.</span> +<span class="sd"> Has two types:</span> +<span class="sd"> 'single':</span> +<span class="sd"> - removes the compiled shared library</span> +<span class="sd"> (which name is stored in grid_options['_custom_logging_shared_library_file'])</span> +<span class="sd"> - TODO: unloads/frees the memory allocated to that shared library</span> +<span class="sd"> (which is stored in grid_options['custom_logging_func_memaddr'])</span> +<span class="sd"> - sets both to None</span> +<span class="sd"> 'multiple':</span> +<span class="sd"> - TODO: make this and design this</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">evol_type</span> <span class="o">==</span> <span class="s2">"single"</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Cleaning up the custom logging stuff. type: single"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># TODO: Explicitly unload the library</span> + + <span class="c1"># Reset the memory adress location</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"custom_logging_func_memaddr"</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> + + <span class="c1"># remove shared library files</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">]:</span> + <span class="n">remove_file</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">],</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_custom_logging_shared_library_file"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">if</span> <span class="n">evol_type</span> <span class="o">==</span> <span class="s2">"population"</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Cleaning up the custom logging stuffs. type: population"</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># TODO: make sure that these also work. not fully sure if necessary tho.</span> + <span class="c1"># whether its a single file, or a dict of files/mem addresses</span> + + <span class="k">if</span> <span class="n">evol_type</span> <span class="o">==</span> <span class="s2">"MC"</span><span class="p">:</span> + <span class="k">pass</span></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/grid_options_defaults.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/grid_options_defaults.html new file mode 100644 index 0000000000000000000000000000000000000000..5da25e0a656605a96740629af5e7e2fabff76b87 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/grid_options_defaults.html @@ -0,0 +1,738 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.grid_options_defaults — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.grid_options_defaults</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.grid_options_defaults</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">Module that contains the default options for the population grid code along with the description for these options, in the form of dictionaries:</span> +<span class="sd"> - grid_options_defaults_dict: dictionary containing the default values for all the options</span> +<span class="sd"> - grid_options_descriptions: dictionary containing the description for these options.</span> + +<span class="sd">There are several other functions in this module, mostly to generate help texts or documents:</span> +<span class="sd"> - grid_options_help: interactive function for the user to get descriptions for options</span> +<span class="sd"> - grid_options_description_checker: function that checks that checks which options have a description.</span> +<span class="sd"> - write_grid_options_to_rst_file: function to generate the .rst document for the docs</span> + +<span class="sd">With this its also possible to automatically generate a document containing all the setting names + descriptions.</span> + +<span class="sd">All the options starting with _ should not be changed by the user except when you really know what you're doing (which is probably hacking the code :P)</span> + +<span class="sd">TODO: reconsider having this all as class methods. It seems unnecessary to have all these functions as class methods.</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">os</span> +<span class="kn">import</span> <span class="nn">shutil</span> +<span class="kn">import</span> <span class="nn">sys</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="kn">import</span> <span class="n">temp_dir</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">command_string_from_list</span><span class="p">,</span> + <span class="n">now</span><span class="p">,</span> +<span class="p">)</span> + +<span class="n">_MOE2017_VERBOSITY_LEVEL</span> <span class="o">=</span> <span class="mi">5</span> +<span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL</span> <span class="o">=</span> <span class="mi">6</span> +<span class="n">_MOE2017_VERBOSITY_INTERPOLATOR_EXTRA_LEVEL</span> <span class="o">=</span> <span class="mi">7</span> + +<span class="n">secs_per_day</span> <span class="o">=</span> <span class="mi">86400</span> <span class="c1"># probably needs to go somewhere more sensible</span> + + +<div class="viewcode-block" id="grid_options_defaults"><a class="viewcode-back" href="../../../../population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults">[docs]</a><span class="k">class</span> <span class="nc">grid_options_defaults</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Class extension to Population grid containing all the functionality for the options and defaults</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the grid_options_defaults class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + +<div class="viewcode-block" id="grid_options_defaults.get_grid_options_defaults_dict"><a class="viewcode-back" href="../../../../population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.get_grid_options_defaults_dict">[docs]</a> <span class="k">def</span> <span class="nf">get_grid_options_defaults_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the default values for the grid options</span> +<span class="sd"> """</span> + + <span class="c1"># Options dict</span> + <span class="k">return</span> <span class="p">{</span> + <span class="c1">##########################</span> + <span class="c1"># general (or unordered..)</span> + <span class="c1">##########################</span> + <span class="s2">"num_cores"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="c1"># total number of cores used to evolve the population</span> + <span class="s2">"num_cores_available"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># set automatically, not by the user</span> + <span class="s2">"parse_function"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Function to parse the output with.</span> + <span class="s2">"multiplicity_fraction_function"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: Moe and di Stefano 2017</span> + <span class="s2">"tmp_dir"</span><span class="p">:</span> <span class="n">temp_dir</span><span class="p">(),</span> <span class="c1"># Setting the temp dir of the program</span> + <span class="s2">"cache_dir"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_cache_dir</span><span class="p">(),</span> <span class="c1"># Cache location, usually $HOME/.cache</span> + <span class="s2">"status_dir"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1">#</span> + <span class="s2">"_main_pid"</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># Placeholder for the main process id of the run.</span> + <span class="s2">"save_ensemble_chunks"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># Force the ensemble chunk to be saved even if we are joining a thread (just in case the joining fails)</span> + <span class="s2">"combine_ensemble_with_thread_joining"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># 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</span> + <span class="s2">"_commandline_input"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> + <span class="s2">"log_runtime_systems"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># whether to log the runtime of the systems (1 file per thread. stored in the tmp_dir)</span> + <span class="s2">"_actually_evolve_system"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># Whether to actually evolve the systems of just act as if. for testing. used in _process_run_population_grid</span> + <span class="s2">"max_queue_size"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Maximum size of the system call queue. Set to 0 for this to be calculated automatically</span> + <span class="s2">"run_zero_probability_system"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># Whether to run the zero probability systems</span> + <span class="s2">"_zero_prob_stars_skipped"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> + <span class="s2">"ensemble_factor_in_probability_weighted_mass"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Whether to multiply the ensemble results by 1/probability_weighted_mass</span> + <span class="s2">"do_dry_run"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># Whether to do a dry run to calculate the total probability for this run</span> + <span class="s2">"dry_run_num_cores"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="c1"># number of parallel processes for the dry run (outer loop)</span> + <span class="s2">"dry_run_hook"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Function hook for the dry run: this function is called, if not None, for every star in the dry run. Useful for checking initial distributions.</span> + <span class="s2">"custom_generator"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Place for the custom system generator</span> + <span class="s2">"return_after_dry_run"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Return immediately after a dry run?</span> + <span class="s2">"exit_after_dry_run"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Exit after dry run?</span> + <span class="s2">"print_stack_on_exit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># print the stack trace on exit calls?</span> + <span class="c1">#####################</span> + <span class="c1"># System information</span> + <span class="c1">#####################</span> + <span class="s2">"command_line"</span><span class="p">:</span> <span class="n">command_string_from_list</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">),</span> + <span class="s2">"original_command_line"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">"BINARY_C_PYTHON_ORIGINAL_CMD_LINE"</span><span class="p">),</span> + <span class="s2">"working_diretory"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">getcwd</span><span class="p">(),</span> + <span class="s2">"original_working_diretory"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">"BINARY_C_PYTHON_ORIGINAL_WD"</span><span class="p">),</span> + <span class="s2">"start_time"</span><span class="p">:</span> <span class="n">now</span><span class="p">(),</span> + <span class="s2">"original_submission_time"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span> + <span class="s2">"BINARY_C_PYTHON_ORIGINAL_SUBMISSION_TIME"</span> + <span class="p">),</span> + <span class="c1">##########################</span> + <span class="c1"># Execution log:</span> + <span class="c1">##########################</span> + <span class="s2">"verbosity"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Level of verbosity of the simulation</span> + <span class="s2">"log_file"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> <span class="c1"># not used (yet?)</span> + <span class="n">temp_dir</span><span class="p">(),</span> <span class="s2">"binary_c_python.log"</span> + <span class="p">),</span> <span class="c1"># Set to None to not log to file. The directory will be created</span> + <span class="s2">"log_dt"</span><span class="p">:</span> <span class="mi">5</span><span class="p">,</span> <span class="c1"># time between vb=1 logging outputs</span> + <span class="s2">"n_logging_stats"</span><span class="p">:</span> <span class="mi">50</span><span class="p">,</span> <span class="c1"># number of logging stats used to calculate time remaining (etc.) default = 50</span> + <span class="s2">"log_newline"</span><span class="p">:</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="c1"># newline character in logs ("\n" for newlines, "\x0d" for carriage return)</span> + <span class="c1">##########################</span> + <span class="c1"># binary_c files</span> + <span class="c1">##########################</span> + <span class="s2">"_binary_c_executable"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C"</span><span class="p">],</span> <span class="s2">"binary_c"</span><span class="p">),</span> + <span class="s2">"_binary_c_shared_library"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C"</span><span class="p">],</span> <span class="s2">"src"</span><span class="p">,</span> <span class="s2">"libbinary_c.so"</span> + <span class="p">),</span> + <span class="s2">"_binary_c_config_executable"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C"</span><span class="p">],</span> <span class="s2">"binary_c-config"</span> + <span class="p">),</span> + <span class="s2">"_binary_c_dir"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C"</span><span class="p">],</span> + <span class="c1">##########################</span> + <span class="c1"># Moe and di Stefano (2017) internal settings</span> + <span class="c1">##########################</span> + <span class="s2">"_loaded_Moe2017_data"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Holds flag whether the Moe and di Stefano (2017) data is loaded into memory</span> + <span class="s2">"_set_Moe2017_grid"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Whether the Moe and di Stefano (2017) grid has been loaded</span> + <span class="s2">"Moe2017_options"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Holds the Moe and di Stefano (2017) options.</span> + <span class="s2">"_Moe2017_JSON_data"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Stores the data</span> + <span class="c1">##########################</span> + <span class="c1"># Custom logging</span> + <span class="c1">##########################</span> + <span class="s2">"C_auto_logging"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Should contain a dictionary where the keys are they headers</span> + <span class="c1"># and the values are lists of parameters that should be logged.</span> + <span class="c1"># This will get parsed by autogen_C_logging_code in custom_logging_functions.py</span> + <span class="s2">"C_logging_code"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># Should contain a string which holds the logging code.</span> + <span class="s2">"custom_logging_func_memaddr"</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># Contains the custom_logging functions memory address</span> + <span class="s2">"_custom_logging_shared_library_file"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># file containing the .so file</span> + <span class="c1">##########################</span> + <span class="c1"># Store pre-loading:</span> + <span class="c1">##########################</span> + <span class="s2">"_store_memaddr"</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># Contains the store object memory address, useful for pre loading.</span> + <span class="c1"># defaults to -1 and isn't used if that's the default then.</span> + <span class="c1">##########################</span> + <span class="c1"># Log args: logging of arguments</span> + <span class="c1">##########################</span> + <span class="s2">"log_args"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># unused</span> + <span class="s2">"log_args_dir"</span><span class="p">:</span> <span class="s2">"/tmp/"</span><span class="p">,</span> <span class="c1"># unused</span> + <span class="c1">##########################</span> + <span class="c1"># Population evolution</span> + <span class="c1">##########################</span> + <span class="c1">## General</span> + <span class="s2">"evolution_type"</span><span class="p">:</span> <span class="s2">"grid"</span><span class="p">,</span> <span class="c1"># Flag for type of population evolution</span> + <span class="s2">"_evolution_type_options"</span><span class="p">:</span> <span class="p">[</span> + <span class="s2">"grid"</span><span class="p">,</span> + <span class="s2">"custom_generator"</span><span class="p">,</span> + <span class="p">],</span> <span class="c1"># available choices for type of population evolution. # TODO: fill later with Monte Carlo, source file</span> + <span class="s2">"_system_generator"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># value that holds the function that generates the system</span> + <span class="c1"># (result of building the grid script)</span> + <span class="s2">"source_file_filename"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># filename for the source</span> + <span class="s2">"_count"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># count of systems</span> + <span class="s2">"_total_starcount"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Total count of systems in this generator</span> + <span class="s2">"_probtot"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># total probability</span> + <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">1.0</span><span class="p">,</span> <span class="c1"># weighting for the probability</span> + <span class="s2">"repeat"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="c1"># number of times to repeat each system (probability is adjusted to be 1/repeat)</span> + <span class="s2">"_start_time_evolution"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Start time of the grid</span> + <span class="s2">"_end_time_evolution"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># end time of the grid</span> + <span class="s2">"_errors_found"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Flag whether there are any errors from binary_c</span> + <span class="s2">"_errors_exceeded"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># Flag whether the number of errors have exceeded the limit</span> + <span class="s2">"_failed_count"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># number of failed systems</span> + <span class="s2">"_failed_prob"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Summed probability of failed systems</span> + <span class="s2">"failed_systems_threshold"</span><span class="p">:</span> <span class="mi">20</span><span class="p">,</span> <span class="c1"># Maximum failed systems per process allowed to fail before the process stops logging the failing systems.</span> + <span class="s2">"_failed_systems_error_codes"</span><span class="p">:</span> <span class="p">[],</span> <span class="c1"># List to store the unique error codes</span> + <span class="s2">"_population_id"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># Random id of this grid/population run, Unique code for the population. Should be set only once by the controller process.</span> + <span class="s2">"_total_mass_run"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># To count the total mass that thread/process has ran</span> + <span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># To count the total mass * probability for each system that thread/process has ran</span> + <span class="s2">"modulo"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="c1"># run modulo n of the grid.</span> + <span class="s2">"start_at"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># start at the first model</span> + <span class="s2">"skip_before"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># skip models before this</span> + <span class="c1">## Grid type evolution</span> + <span class="s2">"_grid_variables"</span><span class="p">:</span> <span class="p">{},</span> <span class="c1"># grid variables</span> + <span class="s2">"gridcode_filename"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># filename of gridcode</span> + <span class="s2">"symlink_latest_gridcode"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># symlink to latest gridcode</span> + <span class="s2">"save_population_object"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># filename to which we should save a pickled grid object as the final thing we do</span> + <span class="s2">"joinlist"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> + <span class="s2">"do_analytics"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># if True, calculate analytics prior to return</span> + <span class="s2">"save_snapshots"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># if True, save snapshots on SIGINT</span> + <span class="s2">"restore_from_snapshot_file"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># file to restore from</span> + <span class="s2">"restore_from_snapshot_dir"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># dir to restore from</span> + <span class="s2">"exit_code"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># return code</span> + <span class="s2">"stop_queue"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> + <span class="s2">"_killed"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> + <span class="s2">"_queue_done"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> + <span class="c1">## Monte carlo type evolution</span> + <span class="c1"># TODO: make MC options</span> + <span class="c1">## Evolution from source file</span> + <span class="c1"># TODO: make run from sourcefile options.</span> + <span class="c1">########################################</span> + <span class="c1"># function caching options</span> + <span class="c1">########################################</span> + <span class="s2">"function_cache"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> + <span class="s2">"function_cache_default_maxsize"</span><span class="p">:</span> <span class="mi">256</span><span class="p">,</span> + <span class="s2">"function_cache_default_type"</span><span class="p">:</span> <span class="s2">"NullCache"</span><span class="p">,</span> <span class="c1"># one of LRUCache, LFUCache, FIFOCache, MRUCache, RRCache, TTLCache, NullCache, NoCache</span> + <span class="s2">"function_cache_TTL"</span><span class="p">:</span> <span class="mi">30</span><span class="p">,</span> + <span class="s2">"function_cache_functions"</span><span class="p">:</span> <span class="p">{</span> + <span class="c1"># key=function_name : value=(cache_size, cache_type, test_args (string))</span> + <span class="c1">#</span> + <span class="c1"># if cache_size is 0, use function_cache_default_maxsize</span> + <span class="c1"># set above</span> + <span class="c1">#</span> + <span class="c1"># if cache_type is None, use function_cache_default_type</span> + <span class="c1"># set above</span> + <span class="c1">#</span> + <span class="c1"># if n is None, no cache is set up</span> + <span class="s2">"distribution_functions.powerlaw_constant"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="s2">"NoCache"</span><span class="p">,</span> <span class="s2">"1,100,-2"</span><span class="p">),</span> + <span class="s2">"distribution_functions.calculate_constants_three_part_powerlaw"</span><span class="p">:</span> <span class="p">(</span> + <span class="mi">16</span><span class="p">,</span> + <span class="s2">"FIFOCache"</span><span class="p">,</span> + <span class="s2">"0.1,0.5,1,100,-1.3,-2.3,-2.3"</span><span class="p">,</span> + <span class="p">),</span> + <span class="s2">"distribution_functions.gaussian_normalizing_const"</span><span class="p">:</span> <span class="p">(</span> + <span class="mi">16</span><span class="p">,</span> + <span class="s2">"FIFOCache"</span><span class="p">,</span> + <span class="s2">"1.0,1.0,-10.0,+10.0"</span><span class="p">,</span> + <span class="p">),</span> + <span class="s2">"spacing_functions.const_linear"</span><span class="p">:</span> <span class="p">(</span><span class="mi">16</span><span class="p">,</span> <span class="s2">"FIFOCache"</span><span class="p">,</span> <span class="s2">"1,10,9"</span><span class="p">),</span> + <span class="s2">"spacing_functions.const_int"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="s2">"1,10,9"</span><span class="p">),</span> + <span class="s2">"spacing_functions.const_ranges"</span><span class="p">:</span> <span class="p">(</span> + <span class="mi">16</span><span class="p">,</span> + <span class="s2">"FIFOCache"</span><span class="p">,</span> + <span class="s2">"((0.1,0.65,10),(0.65,0.85,20),(0.85,10.0,10))"</span><span class="p">,</span> + <span class="p">),</span> + <span class="s2">"spacing_functions.gaussian_zoom"</span><span class="p">:</span> <span class="p">(</span> + <span class="mi">16</span><span class="p">,</span> + <span class="s2">"FIFOCache"</span><span class="p">,</span> + <span class="s2">"1.0,10.0,5.0,2.0,0.9,100"</span><span class="p">,</span> + <span class="p">),</span> + <span class="p">},</span> + <span class="c1">########################################</span> + <span class="c1"># HPC variables</span> + <span class="c1">########################################</span> + <span class="s2">"HPC_force_join"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># if True, and the HPC variable ("slurm" or "condor") is 3, skip checking our own job and force the join</span> + <span class="s2">"HPC_rebuild_joinlist"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># if True, ignore the joinlist we would usually use and rebuild it automatically</span> + <span class="c1">########################################</span> + <span class="c1"># Slurm stuff</span> + <span class="c1">########################################</span> + <span class="s2">"slurm"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># dont use the slurm by default, 0 = no slurm, 1 = launch slurm jobs, 2 = run slurm jobs</span> + <span class="s2">"slurm_ntasks"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="c1"># CPUs required per array job: usually only need this to be 1</span> + <span class="s2">"slurm_dir"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> <span class="c1"># working directory containing scripts output logs etc.</span> + <span class="s2">"slurm_njobs"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># number of scripts; set to 0 as default</span> + <span class="s2">"slurm_jobid"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> <span class="c1"># slurm job id (%A)</span> + <span class="s2">"slurm_memory"</span><span class="p">:</span> <span class="s2">"512MB"</span><span class="p">,</span> <span class="c1"># memory required for the job</span> + <span class="s2">"slurm_warn_max_memory"</span><span class="p">:</span> <span class="s2">"1024MB"</span><span class="p">,</span> <span class="c1"># warn if we set it to more than this (usually by accident)</span> + <span class="s2">"slurm_postpone_join"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># if 1 do not join on slurm, join elsewhere. want to do it off the slurm grid (e.g. with more RAM)</span> + <span class="s2">"slurm_jobarrayindex"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># slurm job array index (%a)</span> + <span class="s2">"slurm_jobname"</span><span class="p">:</span> <span class="s2">"binary_c-python"</span><span class="p">,</span> <span class="c1"># default</span> + <span class="s2">"slurm_partition"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> + <span class="s2">"slurm_time"</span><span class="p">:</span> <span class="s1">'0'</span><span class="p">,</span> <span class="c1"># total time. 0 = infinite time</span> + <span class="s2">"slurm_postpone_sbatch"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># if 1: don't submit, just make the script</span> + <span class="s2">"slurm_array"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># override for --array, useful for rerunning jobs</span> + <span class="s2">"slurm_array_max_jobs"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># override for the max number of concurrent array jobs</span> + <span class="s2">"slurm_extra_settings"</span><span class="p">:</span> <span class="p">{},</span> <span class="c1"># Dictionary of extra settings for Slurm to put in its launch script.</span> + <span class="s2">"slurm_sbatch"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"sbatch"</span><span class="p">),</span> <span class="c1"># sbatch command</span> + <span class="s2">"slurm_env"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"env"</span><span class="p">),</span> <span class="c1"># env location for Slurm</span> + <span class="s2">"slurm_bash"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"bash"</span><span class="p">),</span> <span class="c1"># bash location for Slurm</span> + <span class="s2">"slurm_pwd"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"pwd"</span><span class="p">),</span> <span class="c1"># pwd command location for Slurm</span> + <span class="s2">"slurm_date"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"date"</span><span class="p">),</span> <span class="c1"># bash location for Slurm</span> + <span class="c1">########################################</span> + <span class="c1"># Condor stuff</span> + <span class="c1">########################################</span> + <span class="s2">"condor"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># 1 to use condor, 0 otherwise</span> + <span class="s2">"condor_dir"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> <span class="c1"># working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all)</span> + <span class="s2">"condor_njobs"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># number of scripts/jobs that CONDOR will run in total</span> + <span class="s2">"condor_ClusterID"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># condor cluster id, equivalent to Slurm's jobid</span> + <span class="s2">"condor_Process"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># condor process, equivalent to Slurm's jobarrayindex</span> + <span class="s2">"condor_postpone_submit"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># if 1, the condor script is not submitted (useful for debugging). Default 0.</span> + <span class="s2">"condor_postpone_join"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># if 1, data is not joined, e.g. if you want to do it off the condor grid (e.g. with more RAM). Default 0.</span> + <span class="s2">"condor_memory"</span><span class="p">:</span> <span class="mi">512</span><span class="p">,</span> <span class="c1"># in MB, the memory use (ImageSize) of the job</span> + <span class="s2">"condor_warn_max_memory"</span><span class="p">:</span> <span class="mi">1024</span><span class="p">,</span> <span class="c1"># in MB, the memory use (ImageSize) of the job</span> + <span class="s2">"condor_universe"</span><span class="p">:</span> <span class="s2">"vanilla"</span><span class="p">,</span> <span class="c1"># usually vanilla universe</span> + <span class="s2">"condor_extra_settings"</span><span class="p">:</span> <span class="p">{},</span> <span class="c1"># Place to put extra configuration for the CONDOR submit file. The key and value of the dict will become the key and value of the line in te slurm batch file. Will be put in after all the other settings (and before the command). Take care not to overwrite something without really meaning to do so.</span> + <span class="c1"># snapshots and checkpoints</span> + <span class="s2">"condor_snapshot_on_kill"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1"># if 1 snapshot on SIGKILL before exit</span> + <span class="s2">"condor_stream_output"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># stream stdout</span> + <span class="s2">"condor_stream_error"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># stream stderr</span> + <span class="s2">"condor_should_transfer_files"</span><span class="p">:</span> <span class="s2">"YES"</span><span class="p">,</span> + <span class="s2">"condor_when_to_transfer_output"</span><span class="p">:</span> <span class="s2">"ON_EXIT_OR_EVICT"</span><span class="p">,</span> + <span class="c1"># (useful for debugging, otherwise a lot of work)</span> + <span class="s2">"condor_requirements"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> <span class="c1"># job requirements</span> + <span class="s2">"condor_env"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"env"</span><span class="p">),</span> <span class="c1"># /usr/bin/env location</span> + <span class="s2">"condor_bash"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"bash"</span><span class="p">),</span> <span class="c1"># bash executable location</span> + <span class="s2">"condor_pwd"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"pwd"</span><span class="p">),</span> <span class="c1"># pwd command location for Condor</span> + <span class="s2">"condor_date"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"date"</span><span class="p">),</span> <span class="c1"># bash location for Condor</span> + <span class="s2">"condor_initial_dir"</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="c1"># directory from which condor is run, if None is the directory in which your script is run</span> + <span class="s2">"condor_submit"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"condor_submit"</span><span class="p">),</span> <span class="c1"># the condor_submit command</span> + <span class="s2">"condor_q"</span><span class="p">:</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="s2">"condor_q"</span><span class="p">),</span> <span class="c1"># the condor_submit command</span> + <span class="s2">"condor_getenv"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># if True condor takes the environment at submission and copies it to the jobs. You almost certainly want this.</span> + <span class="s2">"condor_batchname"</span><span class="p">:</span> <span class="s2">"binary_c-condor"</span><span class="p">,</span> <span class="c1"># Condor batchname option</span> + <span class="s2">"condor_kill_sig"</span><span class="p">:</span> <span class="s2">"SIGINT"</span><span class="p">,</span> <span class="c1"># signal Condor should use to stop a process : note that grid.py expects this to be "SIGINT"</span> + <span class="c1"># ########################################</span> + <span class="c1"># # GRID</span> + <span class="c1"># ########################################</span> + <span class="c1"># control flow</span> + <span class="s2">"rungrid"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="c1"># usually run the grid, but can be 0 to skip it (e.g. for condor/slurm admin)</span> + <span class="p">}</span></div> + +<div class="viewcode-block" id="grid_options_defaults.get_grid_options_descriptions"><a class="viewcode-back" href="../../../../population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.get_grid_options_descriptions">[docs]</a> <span class="k">def</span> <span class="nf">get_grid_options_descriptions</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that returns the descriptions for all the grid options</span> + +<span class="sd"> TODO: consider putting input types for all of them</span> +<span class="sd"> """</span> + + <span class="c1"># Grid containing the descriptions of the options</span> + <span class="k">return</span> <span class="p">{</span> + <span class="s2">"tmp_dir"</span><span class="p">:</span> <span class="s2">"Directory where certain types of output are stored. The grid code is stored in that directory, as well as the custom logging libraries. Log files and other diagnostics will usually be written to this location, unless specified otherwise"</span><span class="p">,</span> <span class="c1"># TODO: improve this</span> + <span class="s2">"status_dir"</span><span class="p">:</span> <span class="s2">"Directory where grid status is stored"</span><span class="p">,</span> + <span class="s2">"_binary_c_dir"</span><span class="p">:</span> <span class="s2">"Director where binary_c is stored. This options are not really used"</span><span class="p">,</span> + <span class="s2">"_binary_c_config_executable"</span><span class="p">:</span> <span class="s2">"Full path of the binary_c-config executable. This options is not used in the population object."</span><span class="p">,</span> + <span class="s2">"_binary_c_executable"</span><span class="p">:</span> <span class="s2">"Full path to the binary_c executable. This options is not used in the population object."</span><span class="p">,</span> + <span class="s2">"_binary_c_shared_library"</span><span class="p">:</span> <span class="s2">"Full path to the libbinary_c file. This options is not used in the population object"</span><span class="p">,</span> + <span class="s2">"verbosity"</span><span class="p">:</span> <span class="s2">"Verbosity of the population code. Default is 0, by which only errors will be printed. Higher values will show more output, which is good for debugging."</span><span class="p">,</span> + <span class="s2">"log_dt"</span><span class="p">:</span> <span class="s2">"Time between verbose logging output."</span><span class="p">,</span> + <span class="s2">"log_newline"</span><span class="p">:</span> <span class="s2">"Newline character used at the end of verbose logging statements. This is </span><span class="se">\\</span><span class="s2">n (newline) by default, but </span><span class="se">\\</span><span class="s2">x0d (carriage return) might also be what you want."</span><span class="p">,</span> + <span class="s2">"n_logging_stats"</span><span class="p">:</span> <span class="s2">"Number of logging statistics used to calculate time remaining (etc.). E.g., if you set this to 10 the previous 10 calls to the verbose log will be used to construct an estimate of the time remaining."</span><span class="p">,</span> + <span class="s2">"num_cores"</span><span class="p">:</span> <span class="s2">"The number of cores that the population grid will use. You can set this manually by entering an integer great than 0. When 0 uses all logical cores. When -1 uses all physical cores. Input: int"</span><span class="p">,</span> + <span class="s2">"num_processes"</span><span class="p">:</span> <span class="s2">"Number of processes launched by multiprocessing. This should be set automatically by binary_c-python, not by the user."</span><span class="p">,</span> + <span class="s2">"_start_time_evolution"</span><span class="p">:</span> <span class="s2">"Variable storing the start timestamp of the population evolution. Set by the object itself."</span><span class="p">,</span> + <span class="s2">"_end_time_evolution"</span><span class="p">:</span> <span class="s2">"Variable storing the end timestamp of the population evolution. Set by the object itself"</span><span class="p">,</span> + <span class="s2">"_total_starcount"</span><span class="p">:</span> <span class="s2">"Variable storing the total number of systems in the generator. Used and set by the population object."</span><span class="p">,</span> + <span class="s2">"_custom_logging_shared_library_file"</span><span class="p">:</span> <span class="s2">"filename for the custom_logging shared library. Used and set by the population object"</span><span class="p">,</span> + <span class="s2">"_errors_found"</span><span class="p">:</span> <span class="s2">"Variable storing a Boolean flag whether errors by binary_c are encountered."</span><span class="p">,</span> + <span class="s2">"_errors_exceeded"</span><span class="p">:</span> <span class="s2">"Variable storing a Boolean flag whether the number of errors was higher than the set threshold (failed_systems_threshold). If True, then the command line arguments of the failing systems will not be stored in the failed_system_log files."</span><span class="p">,</span> + <span class="s2">"source_file_filename"</span><span class="p">:</span> <span class="s2">"Variable containing the source file containing lines of binary_c command line calls. These all have to start with binary_c."</span><span class="p">,</span> <span class="c1"># TODO: Expand</span> + <span class="s2">"C_auto_logging"</span><span class="p">:</span> <span class="s2">"Dictionary containing parameters to be logged by binary_c. The structure of this dictionary is as follows: the key is used as the headline which the user can then catch. The value at that key is a list of binary_c system parameters (like star[0].mass)"</span><span class="p">,</span> + <span class="s2">"C_logging_code"</span><span class="p">:</span> <span class="s2">"Variable to store the exact code that is used for the custom_logging. In this way the user can do more complex logging, as well as putting these logging strings in files."</span><span class="p">,</span> + <span class="s2">"_failed_count"</span><span class="p">:</span> <span class="s2">"Variable storing the number of failed systems."</span><span class="p">,</span> + <span class="s2">"_evolution_type_options"</span><span class="p">:</span> <span class="s2">"List containing the evolution type options."</span><span class="p">,</span> + <span class="s2">"_failed_prob"</span><span class="p">:</span> <span class="s2">"Variable storing the total probability of all the failed systems"</span><span class="p">,</span> + <span class="s2">"_failed_systems_error_codes"</span><span class="p">:</span> <span class="s2">"List storing the unique error codes raised by binary_c of the failed systems"</span><span class="p">,</span> + <span class="s2">"_grid_variables"</span><span class="p">:</span> <span class="s2">"Dictionary storing the grid_variables. These contain properties which are accessed by the _generate_grid_code function"</span><span class="p">,</span> + <span class="s2">"_population_id"</span><span class="p">:</span> <span class="s2">"Variable storing a unique 32-char hex string."</span><span class="p">,</span> + <span class="s2">"_commandline_input"</span><span class="p">:</span> <span class="s2">"String containing the arguments passed to the population object via the command line. Set and used by the population object."</span><span class="p">,</span> + <span class="s2">"_system_generator"</span><span class="p">:</span> <span class="s2">"Function object that contains the system generator function. This can be from a grid, or a source file, or a Monte Carlo grid."</span><span class="p">,</span> + <span class="s2">"gridcode_filename"</span><span class="p">:</span> <span class="s2">"Filename for the grid code. Set and used by the population object. TODO: allow the user to provide their own function, rather than only a generated function."</span><span class="p">,</span> + <span class="s2">"log_args"</span><span class="p">:</span> <span class="s2">"Boolean to log the arguments."</span><span class="p">,</span> + <span class="s2">"log_args_dir"</span><span class="p">:</span> <span class="s2">"Directory to log the arguments to."</span><span class="p">,</span> + <span class="s2">"log_file"</span><span class="p">:</span> <span class="s2">"Log file for the population object. Unused"</span><span class="p">,</span> + <span class="s2">"custom_logging_func_memaddr"</span><span class="p">:</span> <span class="s2">"Memory address where the custom_logging_function is stored. Input: int"</span><span class="p">,</span> + <span class="s2">"_count"</span><span class="p">:</span> <span class="s2">"Counter tracking which system the generator is on."</span><span class="p">,</span> + <span class="s2">"_probtot"</span><span class="p">:</span> <span class="s2">"Total probability of the population."</span><span class="p">,</span> + <span class="s2">"_main_pid"</span><span class="p">:</span> <span class="s2">"Main process ID of the master process. Used and set by the population object."</span><span class="p">,</span> + <span class="s2">"_store_memaddr"</span><span class="p">:</span> <span class="s2">"Memory address of the store object for binary_c."</span><span class="p">,</span> + <span class="s2">"failed_systems_threshold"</span><span class="p">:</span> <span class="s2">"Variable storing the maximum number of systems that are allowed to fail before logging their command line arguments to failed_systems log files"</span><span class="p">,</span> + <span class="s2">"parse_function"</span><span class="p">:</span> <span class="s2">"Function that the user can provide to handle the output the binary_c. This function has to take the arguments (self, output). Its best not to return anything in this function, and just store stuff in the self.grid_results dictionary, or just output results to a file"</span><span class="p">,</span> + <span class="c1">############################################################</span> + <span class="c1"># Condor</span> + <span class="s2">"condor"</span><span class="p">:</span> <span class="s2">"Integer flag used to control HTCondor (referred to as Condor here) jobs. Default is 0 which means no Condor. 1 means launch Condor jobs. Do not manually set this to 2 (run Condor jobs) or 3 (join Condor job data) unless you know what you are doing, this is usually done for you."</span><span class="p">,</span> + <span class="s2">"condor_dir"</span><span class="p">:</span> <span class="s2">"String. Working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all jobs). This directory should not exist when you launch the Condor jobs."</span><span class="p">,</span> + <span class="s2">"condor_njobs"</span><span class="p">:</span> <span class="s2">"Integer. Number of jobs that Condor will run"</span><span class="p">,</span> + <span class="s2">"condor_ClusterID"</span><span class="p">:</span> <span class="s2">"Integer. Condor ClusterID variable, equivalent to Slurm's jobid. Jobs are numbered <ClusterID>.<Process>"</span><span class="p">,</span> + <span class="s2">"condor_Process"</span><span class="p">:</span> <span class="s2">"Integer. Condor Process variable, equivalent to Slurm's jobarrayindex. Jobs are numbered <ClusterID>.<Process>"</span><span class="p">,</span> + <span class="s2">"condor_postpone_submit"</span><span class="p">:</span> <span class="s2">"Integer. Debugging tool. If 1, the condor script is not submitted (useful for debugging). Default 0."</span><span class="p">,</span> + <span class="s2">"condor_postpone_join"</span><span class="p">:</span> <span class="s2">"Integer. Use to delay the joining of Condor grid data. If 1, data is not joined, e.g. if you want to do it off the condor grid (e.g. with more RAM). Default 0."</span><span class="p">,</span> + <span class="s2">"condor_memory"</span><span class="p">:</span> <span class="s2">"Integer. In MB, the memory use (ImageSize) of the job."</span><span class="p">,</span> + <span class="s2">"condor_warn_max_memory"</span><span class="p">:</span> <span class="s2">"Integer. In MB, the memory use (ImageSize) of the job."</span><span class="p">,</span> + <span class="s2">"condor_universe"</span><span class="p">:</span> <span class="s1">'String. The HTCondor "universe": this is "vanilla" by default.'</span><span class="p">,</span> + <span class="s2">"condor_extra_settings"</span><span class="p">:</span> <span class="s2">"Dictionary. Place to put extra configuration for the CONDOR submit file. The key and value of the dict will become the key and value of the line in te slurm batch file. Will be put in after all the other settings (and before the command). Take care not to overwrite something without really meaning to do so."</span><span class="p">,</span> + <span class="s2">"condor_snapshot_on_kill"</span><span class="p">:</span> <span class="s2">"Integer. If 1 we save a snapshot on SIGKILL before exit."</span><span class="p">,</span> + <span class="s2">"condor_stream_output"</span><span class="p">:</span> <span class="s2">"Boolean. If True, we activate Condor's stdout stream. If False, this data is copied at the end of the job."</span><span class="p">,</span> + <span class="s2">"condor_stream_error"</span><span class="p">:</span> <span class="s2">"Boolean. If True, we activate Condor's stderr stream. If False, this data is copied at the end of the job."</span><span class="p">,</span> + <span class="s2">"condor_should_transfer_files"</span><span class="p">:</span> <span class="s1">'Integer. Condor</span><span class="se">\'</span><span class="s1">s option to transfer files at the end of the job. You should set this to "YES"'</span><span class="p">,</span> + <span class="s2">"condor_when_to_transfer_output"</span><span class="p">:</span> <span class="s1">'Integer. Condor</span><span class="se">\'</span><span class="s1">s option to decide when output files are transferred. You should usually set this to "ON_EXIT_OR_EVICT"'</span><span class="p">,</span> + <span class="s2">"condor_requirements"</span><span class="p">:</span> <span class="s2">"String. Condor job requirements. These are passed to Condor directly, you should read the HTCondor manual to learn about this. If no requirements exist, leave as an string."</span><span class="p">,</span> + <span class="s2">"condor_env"</span><span class="p">:</span> <span class="s1">'String. Points the location of the "env" command, e.g. /usr/bin/env or /bin/env, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.'</span><span class="p">,</span> + <span class="s2">"condor_bash"</span><span class="p">:</span> <span class="s1">'String. Points the location of the "bash" command, e.g. /bin/bash, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.'</span><span class="p">,</span> + <span class="s2">"condor_pwd"</span><span class="p">:</span> <span class="s1">'String. Points the location of the "pwd" command, e.g. /bin/pwd, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.'</span><span class="p">,</span> + <span class="s2">"condor_date"</span><span class="p">:</span> <span class="s1">'String. Points the location of the "date" command, e.g. /usr/bin/date, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.'</span><span class="p">,</span> + <span class="s2">"condor_initial_dir"</span><span class="p">:</span> <span class="s2">"String. Directory from which condor scripts are run. If set to the default, None, this is the directory from which your script is run."</span><span class="p">,</span> + <span class="s2">"condor_submit"</span><span class="p">:</span> <span class="s1">'String. The Condor_submit command, usually "/usr/bin/condor_submit" but will depend on your HTCondor installation.'</span><span class="p">,</span> + <span class="s2">"condor_q"</span><span class="p">:</span> <span class="s1">'String. The Condor_q command, usually "/usr/bin/condor_q" but will depend on your HTCondor installation.'</span><span class="p">,</span> + <span class="s2">"condor_getenv"</span><span class="p">:</span> <span class="s2">"Boolean. If True, the default, condor takes the environment at submission and copies it to the jobs. You almost certainly want this to be True."</span><span class="p">,</span> + <span class="s2">"condor_batchname"</span><span class="p">:</span> <span class="s1">'String. Condor batchname option: this is what appears in condor_q. Defaults to "binary_c-condor"'</span><span class="p">,</span> + <span class="s2">"condor_kill_sig"</span><span class="p">:</span> <span class="s1">'String. Signal Condor should use to stop a process. Note that grid.py expects this to be "SIGINT" which is the default.'</span><span class="p">,</span> + <span class="c1">############################################################</span> + <span class="c1"># Slurm options</span> + <span class="c1">############################################################</span> + <span class="s2">"slurm"</span><span class="p">:</span> <span class="s2">"Integer flag used to control Slurm jobs. Default is 0 which means no Slurm. 1 means launch Slurm jobs. Do not manually set this to 2 (run Slurm jobs) or 3 (join Slurm job data) unless you know what you are doing, this is usually done for you."</span><span class="p">,</span> + <span class="s2">"slurm_dir"</span><span class="p">:</span> <span class="s2">"String. Working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all jobs). This directory should not exist when you launch the Slurm jobs."</span><span class="p">,</span> + <span class="s2">"slurm_ntasks"</span><span class="p">:</span> <span class="s2">"Integer. Number of CPUs required per array job: usually only need this to be 1 (the default)."</span><span class="p">,</span> + <span class="s2">"slurm_njobs"</span><span class="p">:</span> <span class="s2">"Integer. Number of Slurm jobs to be launched."</span><span class="p">,</span> + <span class="s2">"slurm_jobid"</span><span class="p">:</span> <span class="s2">"Integer. Slurm job id. Each job is numbered <slurm_jobid>.<slurm_jobarrayindex>."</span><span class="p">,</span> + <span class="s2">"slurm_jobarrayindex"</span><span class="p">:</span> <span class="s2">"Integer. Slurm job array index. Each job is numbered <slurm_jobid>.<slurm_jobarrayindex>."</span><span class="p">,</span> + <span class="s2">"slurm_memory"</span><span class="p">:</span> <span class="s1">'String. Memory required for the job. Should be in megabytes in a format that Slurm understands, e.g. "512MB" (the default).'</span><span class="p">,</span> + <span class="s2">"slurm_warn_max_memory"</span><span class="p">:</span> <span class="s1">'String. If we set slurm_memory in excess of this, warn the user because this is usually a mistake. Default "1024MB".'</span><span class="p">,</span> + <span class="s2">"slurm_postpone_join"</span><span class="p">:</span> <span class="s2">"Integer, default 0. If 1 do not join job results with Slurm, instead you have to do it later manually."</span><span class="p">,</span> + <span class="s2">"slurm_jobname"</span><span class="p">:</span> <span class="s1">'String which names the Slurm jobs, default "binary_c-python".'</span><span class="p">,</span> + <span class="s2">"slurm_partition"</span><span class="p">:</span> <span class="s2">"String containing the Slurm partition name. You should check your local Slurm installation to find out partition information, e.g. using the sview command."</span><span class="p">,</span> + <span class="s2">"slurm_time"</span><span class="p">:</span> <span class="s2">"String. The time a Slurm job is allowed to take. Default is 0 which means no limit. Please check the Slurm documentation for required format of this option."</span><span class="p">,</span> + <span class="s2">"slurm_postpone_sbatch"</span><span class="p">:</span> <span class="s2">"Integer, default 0. If set to 1, do not launch Slurm jobs with sbatch, just make the scripts that would have."</span><span class="p">,</span> + <span class="s2">"slurm_array"</span><span class="p">:</span> <span class="s2">"String. Override for Slurm's --array option, useful for rerunning jobs manually. Default None."</span><span class="p">,</span> + <span class="s2">"slurm_array_max_jobs"</span><span class="p">:</span> <span class="s2">"Integer. Override for the max number of concurrent Slurm array jobs. Default None."</span><span class="p">,</span> + <span class="s2">"slurm_extra_settings"</span><span class="p">:</span> <span class="s2">"Dictionary of extra settings for Slurm to put in its launch script. Please see the Slurm documentation for the many options that are available to you."</span><span class="p">,</span> + <span class="s2">"slurm_sbatch"</span><span class="p">:</span> <span class="s1">'String. The Slurm "sbatch" submission command, usually "/usr/bin/sbatch" but will depend on your Slurm installation. By default is set automatically.'</span><span class="p">,</span> + <span class="s2">"slurm_env"</span><span class="p">:</span> <span class="s1">'String. Points the location of the "env" command, e.g. /usr/bin/env or /bin/env, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.'</span><span class="p">,</span> + <span class="s2">"slurm_bash"</span><span class="p">:</span> <span class="s1">'String. Points the location of the "bash" command, e.g. /bin/bash, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.'</span><span class="p">,</span> + <span class="s2">"slurm_pwd"</span><span class="p">:</span> <span class="s1">'String. Points the location of the "pwd" command, e.g. /bin/pwd, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.'</span><span class="p">,</span> + <span class="s2">"slurm_date"</span><span class="p">:</span> <span class="s1">'String. Points the location of the "date" command, e.g. /usr/bin/date, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.'</span><span class="p">,</span> + <span class="c1">############################################################</span> + <span class="c1"># High power computing (HPC) variables</span> + <span class="c1">############################################################</span> + <span class="s2">"HPC_force_join"</span><span class="p">:</span> <span class="s1">'Integer, default 0. If 1, and the HPC variable ("slurm" or "condor") is 3, skip checking our own job and force the join.'</span><span class="p">,</span> + <span class="s2">"HPC_rebuild_joinlist"</span><span class="p">:</span> <span class="s2">"Integer, default 0. If 1, ignore the joinlist we would usually use and rebuild it automatically"</span><span class="p">,</span> + <span class="c1">############################################################</span> + <span class="c1"># Cacheing</span> + <span class="c1">############################################################</span> + <span class="s2">"function_cache"</span><span class="p">:</span> <span class="s2">"Boolean, default True. If True, we use a cache for certain function calls."</span><span class="p">,</span> + <span class="s2">"function_cache_default_maxsize"</span><span class="p">:</span> <span class="s2">"Integer, default 256. The default maxsize of the cache. Should be a power of 2."</span><span class="p">,</span> + <span class="s2">"function_cache_default_type"</span><span class="p">:</span> <span class="s2">"String. One of the following types: LRUCache, LFUCache, FIFOCache, MRUCache, RRCache, TTLCache, NullCache, NoCache. You can find details of what these mean in the Python cachetools manual, except fo NoCache which means no cache is used at all, and NullCache is a dummy cache that never matches, used for testing overheads."</span><span class="p">,</span> + <span class="s2">"function_cache_functions."</span><span class="p">:</span> <span class="s2">"Dict. Keys are the function names that should be in the cache. The value is a tuple of (cache_size, cache_type, test_args) where cache_size used as the size of the cache, or if 0 the function_cache_default_maxsize is used. The cache_type is the function_cache_default_type if None, otherwise is the cache type (see the list defined at function_cache_default_type). The test_args are constant arguments used to call the function when testing the cache, see cache.cache_test() for details."</span><span class="p">,</span> + <span class="c1">############################################################</span> + <span class="s2">"weight"</span><span class="p">:</span> <span class="s2">"Weight factor for each system. The calculated probability is multiplied by this. If the user wants each system to be repeated several times, then this variable should not be changed, rather change the _repeat variable instead, as that handles the reduction in probability per system. This is useful for systems that have a process with some random element in it."</span><span class="p">,</span> <span class="c1"># TODO: add more info here, regarding the evolution splitting.</span> + <span class="s2">"repeat"</span><span class="p">:</span> <span class="s2">"Factor of how many times a system should be repeated. Consider the evolution splitting binary_c argument for supernovae kick repeating."</span><span class="p">,</span> + <span class="s2">"evolution_type"</span><span class="p">:</span> <span class="s2">"Variable containing the type of evolution used of the grid. Multiprocessing, linear processing or possibly something else (e.g. for Slurm or Condor)."</span><span class="p">,</span> + <span class="s2">"combine_ensemble_with_thread_joining"</span><span class="p">:</span> <span class="s2">"Boolean flag on whether to combine everything and return it to the user or if false: write it to data_dir/ensemble_output_</span><span class="si">{population_id}</span><span class="s2">_</span><span class="si">{thread_id}</span><span class="s2">.json"</span><span class="p">,</span> + <span class="s2">"log_runtime_systems"</span><span class="p">:</span> <span class="s2">"Whether to log the runtime of the systems . Each systems run by the thread is logged to a file and is stored in the tmp_dir. (1 file per thread). Don't use this if you are planning to run a lot of systems. This is mostly for debugging and finding systems that take long to run. Integer, default = 0. if value is 1 then the systems are logged"</span><span class="p">,</span> + <span class="s2">"_total_mass_run"</span><span class="p">:</span> <span class="s2">"To count the total mass that thread/process has ran"</span><span class="p">,</span> + <span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">:</span> <span class="s2">"To count the total mass * probability for each system that thread/process has ran"</span><span class="p">,</span> + <span class="s2">"_actually_evolve_system"</span><span class="p">:</span> <span class="s2">"Whether to actually evolve the systems of just act as if. for testing. used in _process_run_population_grid"</span><span class="p">,</span> + <span class="s2">"max_queue_size"</span><span class="p">:</span> <span class="s2">"Maximum size of the queue that is used to feed the processes. Don't make this too big! Default: 1000. Input: int"</span><span class="p">,</span> + <span class="s2">"_set_Moe2017_grid"</span><span class="p">:</span> <span class="s2">"Internal flag whether the Moe and di Stefano (2017) grid has been loaded"</span><span class="p">,</span> + <span class="s2">"run_zero_probability_system"</span><span class="p">:</span> <span class="s2">"Whether to run the zero probability systems. Default: True. Input: Boolean"</span><span class="p">,</span> + <span class="s2">"_zero_prob_stars_skipped"</span><span class="p">:</span> <span class="s2">"Internal counter to track how many systems are skipped because they have 0 probability"</span><span class="p">,</span> + <span class="s2">"ensemble_factor_in_probability_weighted_mass"</span><span class="p">:</span> <span class="s2">"Flag to multiply all the ensemble results with 1/probability_weighted_mass"</span><span class="p">,</span> + <span class="s2">"multiplicity_fraction_function"</span><span class="p">:</span> <span class="s2">"Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: Moe and di Stefano (2017) 2017"</span><span class="p">,</span> + <span class="s2">"m&s_options"</span><span class="p">:</span> <span class="s2">"Internal variable that holds the Moe and di Stefano (2017) options. Don't write to this your self"</span><span class="p">,</span> + <span class="s2">"_loaded_Moe2017_data"</span><span class="p">:</span> <span class="s2">"Internal variable storing whether the Moe and di Stefano (2017) data has been loaded into memory"</span><span class="p">,</span> + <span class="s2">"do_dry_run"</span><span class="p">:</span> <span class="s2">"Whether to do a dry run to calculate the total probability for this run"</span><span class="p">,</span> + <span class="s2">"dry_run_hook"</span><span class="p">:</span> <span class="s2">"Function hook to be called for every system in a dry run. The function is passed a dict of the system parameters. Does nothing if None (the default)."</span><span class="p">,</span> + <span class="s2">"return_after_dry_run"</span><span class="p">:</span> <span class="s2">"If True, return immediately after a dry run (and don't run actual stars). Default is False."</span><span class="p">,</span> + <span class="s2">"exit_after_dry_run"</span><span class="p">:</span> <span class="s2">"If True, exits after a dry run. Default is False."</span><span class="p">,</span> + <span class="s2">"print_stack_on_exit"</span><span class="p">:</span> <span class="s2">"If True, prints a stack trace when the population's exit method is called."</span><span class="p">,</span> + <span class="s2">"_Moe2017_JSON_data"</span><span class="p">:</span> <span class="s2">"Location to store the loaded Moe&diStefano2017 dataset"</span><span class="p">,</span> <span class="c1"># Stores the data</span> + <span class="p">}</span></div> + + <span class="c1">#################################</span> + <span class="c1"># Grid options functions</span> + + <span class="c1"># Utility functions</span> +<div class="viewcode-block" id="grid_options_defaults.grid_options_help"><a class="viewcode-back" href="../../../../population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.grid_options_help">[docs]</a> <span class="k">def</span> <span class="nf">grid_options_help</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">option</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function that prints out the description of a grid option. Useful function for the user.</span> + +<span class="sd"> Args:</span> +<span class="sd"> option: which option you want to have the description of</span> + +<span class="sd"> returns:</span> +<span class="sd"> dict containing the option, the description if its there, otherwise empty string. And if the key doesnt exist, the dict is empty</span> +<span class="sd"> """</span> + + <span class="c1">#</span> + <span class="n">grid_options_defaults_dict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_grid_options_defaults_dict</span><span class="p">()</span> + <span class="n">grid_options_descriptions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_grid_options_descriptions</span><span class="p">()</span> + + <span class="c1">#</span> + <span class="n">option_keys</span> <span class="o">=</span> <span class="n">grid_options_defaults_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + <span class="n">description_keys</span> <span class="o">=</span> <span class="n">grid_options_descriptions</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + + <span class="c1"># If the option is unknown</span> + <span class="k">if</span> <span class="n">option</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">option_keys</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Error: This is an invalid entry. Option does not exist, please choose from the following options:</span><span class="se">\n\t</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">option_keys</span><span class="p">)</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">return</span> <span class="p">{}</span> + + <span class="c1"># If its not described</span> + <span class="k">if</span> <span class="n">option</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">description_keys</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"This option has not been described properly yet. Please contact on of the authors"</span> + <span class="p">)</span> + <span class="k">return</span> <span class="p">{</span><span class="n">option</span><span class="p">:</span> <span class="s2">""</span><span class="p">}</span> + + <span class="c1"># If its known and described:</span> + <span class="nb">print</span><span class="p">(</span><span class="n">grid_options_descriptions</span><span class="p">[</span><span class="n">option</span><span class="p">])</span> + <span class="k">return</span> <span class="p">{</span><span class="n">option</span><span class="p">:</span> <span class="n">grid_options_descriptions</span><span class="p">[</span><span class="n">option</span><span class="p">]}</span></div> + +<div class="viewcode-block" id="grid_options_defaults.grid_options_description_checker"><a class="viewcode-back" href="../../../../population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.grid_options_description_checker">[docs]</a> <span class="k">def</span> <span class="nf">grid_options_description_checker</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">print_info</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function that checks which descriptions are missing</span> + +<span class="sd"> Args:</span> +<span class="sd"> print_info: whether to print out information about which options contain proper descriptions and which do not</span> + +<span class="sd"> Returns:</span> +<span class="sd"> the number of undescribed keys</span> +<span class="sd"> """</span> + + <span class="c1">#</span> + <span class="n">grid_options_defaults_dict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_grid_options_defaults_dict</span><span class="p">()</span> + <span class="n">grid_options_descriptions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_grid_options_descriptions</span><span class="p">()</span> + + <span class="c1">#</span> + <span class="n">option_keys</span> <span class="o">=</span> <span class="n">grid_options_defaults_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + <span class="n">description_keys</span> <span class="o">=</span> <span class="n">grid_options_descriptions</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + + <span class="c1">#</span> + <span class="n">undescribed_keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">option_keys</span><span class="p">)</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">description_keys</span><span class="p">))</span> + + <span class="k">if</span> <span class="n">undescribed_keys</span><span class="p">:</span> + <span class="k">if</span> <span class="n">print_info</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Warning: the following keys have no description yet:</span><span class="se">\n\t</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">undescribed_keys</span><span class="p">))</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Total description progress: </span><span class="si">{:.2f}%%</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="mi">100</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">description_keys</span><span class="p">)</span> <span class="o">/</span> <span class="nb">len</span><span class="p">(</span><span class="n">option_keys</span><span class="p">)</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="n">undescribed_keys</span><span class="p">)</span></div> + +<div class="viewcode-block" id="grid_options_defaults.write_grid_options_to_rst_file"><a class="viewcode-back" href="../../../../population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.write_grid_options_to_rst_file">[docs]</a> <span class="k">def</span> <span class="nf">write_grid_options_to_rst_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output_file</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function that writes the descriptions of the grid options to an rst file</span> + +<span class="sd"> Args:</span> +<span class="sd"> output_file: target file where the grid options descriptions are written to</span> +<span class="sd"> """</span> + + <span class="c1"># Get the options and the description</span> + <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_grid_options_defaults_dict</span><span class="p">()</span> + <span class="n">descriptions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_grid_options_descriptions</span><span class="p">()</span> + + <span class="c1"># Get those that do not have a description</span> + <span class="n">not_described_yet</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">options</span><span class="p">)</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">descriptions</span><span class="p">))</span> + + <span class="c1"># separate public and private options</span> + <span class="n">public_options</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">options</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"_"</span><span class="p">)]</span> + <span class="n">private_options</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">options</span> <span class="k">if</span> <span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"_"</span><span class="p">)]</span> + + <span class="c1"># Check input</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">output_file</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".rst"</span><span class="p">):</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Filename doesn't end with .rst, please provide a proper filename"</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># M&S options</span> + <span class="n">moe_di_stefano_default_options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_Moe_di_Stefano_2017_default_options</span><span class="p">()</span> + <span class="n">moe_di_stefano_default_options_description</span> <span class="o">=</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">get_Moe_di_Stefano_2017_default_options_description</span><span class="p">()</span> + <span class="p">)</span> + + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">output_file</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Population grid code options"</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s2">"="</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="s2">"Population grid code options"</span><span class="p">)),</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"The following chapter contains all grid code options, along with their descriptions"</span><span class="p">,</span> + <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"There are </span><span class="si">{}</span><span class="s2"> options that are not described yet."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">len</span><span class="p">(</span><span class="n">not_described_yet</span><span class="p">)</span> + <span class="p">),</span> + <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span> + + <span class="c1"># Start public options part</span> + <span class="bp">self</span><span class="o">.</span><span class="n">print_option_descriptions</span><span class="p">(</span> + <span class="n">f</span><span class="p">,</span> + <span class="n">public_options</span><span class="p">,</span> + <span class="n">descriptions</span><span class="p">,</span> + <span class="s2">"Public options"</span><span class="p">,</span> + <span class="s2">"The following options are meant to be changed by the user."</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Moe & di Stefano options:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">print_option_descriptions</span><span class="p">(</span> + <span class="n">f</span><span class="p">,</span> + <span class="n">moe_di_stefano_default_options</span><span class="p">,</span> + <span class="n">moe_di_stefano_default_options_description</span><span class="p">,</span> + <span class="s2">"Moe & di Stefano sampler options"</span><span class="p">,</span> + <span class="s2">"The following options are meant to be changed by the user."</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Start private options part</span> + <span class="bp">self</span><span class="o">.</span><span class="n">print_option_descriptions</span><span class="p">(</span> + <span class="n">f</span><span class="p">,</span> + <span class="n">private_options</span><span class="p">,</span> + <span class="n">descriptions</span><span class="p">,</span> + <span class="s2">"Private options"</span><span class="p">,</span> + <span class="s2">"The following options are not meant to be changed by the user, as these options are used and set internally by the object itself. The description still is provided, but just for documentation purposes."</span><span class="p">,</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="grid_options_defaults.print_option_descriptions"><a class="viewcode-back" href="../../../../population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.print_option_descriptions">[docs]</a> <span class="k">def</span> <span class="nf">print_option_descriptions</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> <span class="n">filehandle</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="n">descriptions</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">extra_text</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to print the description of an option</span> +<span class="sd"> """</span> + + <span class="c1"># Start public options part</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">title</span><span class="p">),</span> <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s2">"-"</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">title</span><span class="p">))),</span> <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">extra_text</span><span class="p">),</span> <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">)</span> + + <span class="k">for</span> <span class="n">option</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">options</span><span class="p">):</span> + <span class="k">if</span> <span class="n">option</span> <span class="ow">in</span> <span class="n">descriptions</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"| **</span><span class="si">{}</span><span class="s2">**: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">option</span><span class="p">,</span> <span class="n">descriptions</span><span class="p">[</span><span class="n">option</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n\t</span><span class="s2">"</span><span class="p">)</span> + <span class="p">),</span> + <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"| **</span><span class="si">{}</span><span class="s2">**: No description available yet"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">option</span><span class="p">),</span> + <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">,</span> + <span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">filehandle</span><span class="p">)</span></div> + +<div class="viewcode-block" id="grid_options_defaults.default_cache_dir"><a class="viewcode-back" href="../../../../population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.default_cache_dir">[docs]</a> <span class="k">def</span> <span class="nf">default_cache_dir</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Return a default cache directory path, or None if we cannot find one.</span> +<span class="sd"> """</span> + <span class="n">error_string</span> <span class="o">=</span> <span class="s2">"__*ERR*__"</span> <span class="c1"># string that cannot be a path</span> + <span class="k">for</span> <span class="n">path</span> <span class="ow">in</span> <span class="p">[</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"HOME"</span><span class="p">,</span> <span class="n">error_string</span><span class="p">),</span> <span class="s2">".cache"</span><span class="p">,</span> <span class="s2">"binary_c"</span><span class="p">),</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"TMP"</span><span class="p">,</span> <span class="n">error_string</span><span class="p">),</span> <span class="s2">"cache"</span><span class="p">),</span> + <span class="p">]:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">error_string</span> <span class="ow">in</span> <span class="n">path</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">path</span><span class="p">):</span> + <span class="k">return</span> <span class="n">path</span> + <span class="k">return</span> <span class="kc">None</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/gridcode.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/gridcode.html new file mode 100644 index 0000000000000000000000000000000000000000..c1ab4bc71801bc3ed44bbf5e30eea85c0fb91ce6 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/gridcode.html @@ -0,0 +1,1257 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.gridcode — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.gridcode</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.gridcode</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">Module containing the gridcode generation functions for the binarycpython package.</span> + +<span class="sd">This class object is an extension to the population grid object</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">datetime</span> +<span class="kn">import</span> <span class="nn">importlib</span> +<span class="kn">import</span> <span class="nn">json</span> +<span class="kn">import</span> <span class="nn">os</span> +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Any</span> + + +<span class="n">_count</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># used for file symlinking (for testing only)</span> +<span class="n">_numba</span> <span class="o">=</span> <span class="kc">False</span> <span class="c1"># activate experimental numba code?</span> + + +<div class="viewcode-block" id="gridcode"><a class="viewcode-back" href="../../../../population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode">[docs]</a><span class="k">class</span> <span class="nc">gridcode</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Extension to the population grid object that contains functionality to handle the metadata that will be put in the ensemble</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the gridcode class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + + <span class="c1">###################################################</span> + <span class="c1"># Grid code functions</span> + <span class="c1">#</span> + <span class="c1"># Function below are used to run populations with</span> + <span class="c1"># a variable grid</span> + <span class="c1">###################################################</span> + <span class="k">def</span> <span class="nf">_gridcode_filename</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Returns a filename for the gridcode.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job</span><span class="p">():</span> + <span class="n">filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> + <span class="s2">"binary_c_grid_</span><span class="si">{population_id}</span><span class="s2">.</span><span class="si">{jobid}</span><span class="s2">.py"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">population_id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_population_id"</span><span class="p">],</span> + <span class="n">jobid</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">jobID</span><span class="p">(),</span> + <span class="p">),</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> + <span class="s2">"binary_c_grid_</span><span class="si">{population_id}</span><span class="s2">.py"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">population_id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_population_id"</span><span class="p">]</span> + <span class="p">),</span> + <span class="p">)</span> + <span class="k">return</span> <span class="n">filename</span> + + <span class="k">def</span> <span class="nf">_add_code</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to add code to the grid code string</span> + +<span class="sd"> add code to the code_string</span> + +<span class="sd"> indent (=0) is added once at the beginning</span> +<span class="sd"> mindent (=0) is added for every line</span> + +<span class="sd"> don't use both!</span> +<span class="sd"> """</span> + + <span class="n">indent_block</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_indent_block</span><span class="p">(</span><span class="n">indent</span><span class="p">)</span> + <span class="k">for</span> <span class="n">thing</span> <span class="ow">in</span> <span class="n">args</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">code_string</span> <span class="o">+=</span> <span class="n">indent_block</span> <span class="o">+</span> <span class="n">thing</span> + + <span class="k">def</span> <span class="nf">_indent_block</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">n</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> return an indent block, with n extra blocks in it</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent_depth</span> <span class="o">+</span> <span class="n">n</span><span class="p">)</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent_string</span> + + <span class="k">def</span> <span class="nf">_increment_indent_depth</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">delta</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> increment the indent indent_depth by delta</span> +<span class="sd"> """</span> + <span class="bp">self</span><span class="o">.</span><span class="n">indent_depth</span> <span class="o">+=</span> <span class="n">delta</span> + + <span class="k">def</span> <span class="nf">_generate_grid_code</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dry_run</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that generates the code from which the population will be made.</span> + +<span class="sd"> dry_run: when True, it will return the starcount at the end so that we know</span> +<span class="sd"> what the total number of systems is.</span> + +<span class="sd"> The phasevol values are handled by generating a second array</span> + +<span class="sd"> Results in a generated file that contains a system_generator function.</span> + +<span class="sd"> # TODO: make sure running systems with multiplicity 3+ is also possible.</span> +<span class="sd"> # TODO: there is a lot of things going on in this function. Make sure to describe clearly what happens here.</span> +<span class="sd"> """</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span><span class="s2">"Generating grid code"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">)</span> + + <span class="n">total_grid_variables</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">])</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="c1"># Import packages</span> + <span class="s2">"import math</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"import numpy as np</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"from collections import OrderedDict</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"from binarycpython.utils.useful_funcs import *</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"import numba"</span> <span class="k">if</span> <span class="n">_numba</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> + <span class="s2">"</span><span class="se">\n\n</span><span class="s2">"</span><span class="p">,</span> + <span class="c1"># Make the function</span> + <span class="s2">"def grid_code(self, print_results=True):</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Increase indent_depth</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="c1"># Write some info in the function</span> + <span class="s2">"# Grid code generated on </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()),</span> + <span class="s2">"# This function generates the systems that will be evolved with binary_c</span><span class="se">\n\n</span><span class="s2">"</span> + <span class="c1"># Set some values in the generated code:</span> + <span class="s2">"# Set initial values</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"_total_starcount = 0</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"starcounts = [0 for i in range(</span><span class="si">{}</span><span class="s2">)]</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">total_grid_variables</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> + <span class="s2">"probabilities = </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"probabilities_list = [0 for i in range(</span><span class="si">{}</span><span class="s2">)]</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">total_grid_variables</span> <span class="o">+</span> <span class="mi">1</span> + <span class="p">),</span> + <span class="s2">"probabilities_sum = [0 for i in range(</span><span class="si">{}</span><span class="s2">)]</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">total_grid_variables</span> <span class="o">+</span> <span class="mi">1</span> + <span class="p">),</span> + <span class="s2">"parameter_dict = </span><span class="si">{}</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"phasevol = 1</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Set up the system parameters</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"M_1 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"M_2 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"M_3 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"M_4 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"orbital_period = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"orbital_period_triple = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"orbital_period_quadruple = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"eccentricity = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"eccentricity2 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"eccentricity3 = None</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="c1"># Prepare the probability</span> + <span class="s2">"# set probability lists</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">for</span> <span class="n">grid_variable_el</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span> + <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> + <span class="p">):</span> + <span class="c1"># Make probabilities dict</span> + <span class="n">grid_variable</span> <span class="o">=</span> <span class="n">grid_variable_el</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s1">'probabilities["</span><span class="si">{}</span><span class="s1">"] = 0</span><span class="se">\n</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]))</span> + + <span class="c1">#################################################################################</span> + <span class="c1"># Start of code generation</span> + <span class="c1">#################################################################################</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + + <span class="c1"># turn vb to True to have debugging output</span> + <span class="n">vb</span> <span class="o">=</span> <span class="kc">False</span> + + <span class="c1"># Generate code</span> + <span class="k">for</span> <span class="n">loopnr</span><span class="p">,</span> <span class="n">grid_variable_el</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span> + <span class="nb">sorted</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span> + <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> + <span class="p">)</span> + <span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Constructing/adding: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable_el</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">2</span><span class="p">,</span> + <span class="p">)</span> + <span class="n">grid_variable</span> <span class="o">=</span> <span class="n">grid_variable_el</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> + + <span class="c1">####################</span> + <span class="c1"># top code</span> + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"topcode"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"topcode"</span><span class="p">])</span> + + <span class="c1">#########################</span> + <span class="c1"># Set up the for loop</span> + <span class="c1"># Add comment for for loop</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"# for loop for variable </span><span class="si">{name}</span><span class="s2"> gridtype </span><span class="si">{gridtype}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="n">gridtype</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">],</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"sampled_values_</span><span class="si">{}</span><span class="s2"> = </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"samplerfunc"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"print('samples','</span><span class="si">{name}</span><span class="s2">',':',sampled_values_</span><span class="si">{name}</span><span class="s2">)</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"print('sample </span><span class="si">{name}</span><span class="s2"> from',sampled_values_</span><span class="si">{name}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + + <span class="c1"># calculate number of values and starting location</span> + <span class="c1">#</span> + <span class="c1"># if we're sampling a continuous variable, we</span> + <span class="c1"># have one fewer grid point than the length of the</span> + <span class="c1"># sampled_values list</span> + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span> + <span class="s2">"centred"</span><span class="p">,</span> + <span class="s2">"centre"</span><span class="p">,</span> + <span class="s2">"center"</span><span class="p">,</span> + <span class="s2">"edge"</span><span class="p">,</span> + <span class="s2">"left edge"</span><span class="p">,</span> + <span class="s2">"left"</span><span class="p">,</span> + <span class="s2">"right"</span><span class="p">,</span> + <span class="s2">"right edge"</span><span class="p">,</span> + <span class="p">]:</span> + <span class="n">offset</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> + <span class="k">elif</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"discrete"</span><span class="p">:</span> + <span class="c1"># discrete variables sample all the points</span> + <span class="n">offset</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="n">start</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="c1"># for loop over the variable</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s1">'print("var </span><span class="si">{name}</span><span class="s1"> values ",sampled_values_</span><span class="si">{name}</span><span class="s1">," len ",len(sampled_values_</span><span class="si">{name}</span><span class="s1">)+</span><span class="si">{offset}</span><span class="s1">," gridtype </span><span class="si">{gridtype}</span><span class="s1"> offset </span><span class="si">{offset}</span><span class="se">\\</span><span class="s1">n")</span><span class="se">\n</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="n">offset</span><span class="o">=</span><span class="n">offset</span><span class="p">,</span> + <span class="n">gridtype</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">],</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="n">stop</span> <span class="o">=</span> <span class="s2">"len(sampled_values_</span><span class="si">{name}</span><span class="s2">)+</span><span class="si">{offset}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">_numba</span> <span class="ow">and</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"dry_parallel"</span><span class="p">]:</span> + <span class="c1"># Parallel outer loop</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"@numba.jit(parallel=True)</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"def __parallel_func(phasevol,_total_starcount):</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"for </span><span class="si">{name}</span><span class="s2">_sample_number in numba.prange(</span><span class="si">{stop}</span><span class="s2">):</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="n">stop</span><span class="o">=</span><span class="n">stop</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> + <span class="k">if</span> <span class="n">start</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"if </span><span class="si">{name}</span><span class="s2">_sample_number < </span><span class="si">{start}</span><span class="s2">:</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="n">start</span><span class="o">=</span><span class="n">start</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"continue</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"for </span><span class="si">{name}</span><span class="s2">_sample_number in range(</span><span class="si">{start}</span><span class="s2">,</span><span class="si">{stop}</span><span class="s2">):</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="n">start</span><span class="o">=</span><span class="n">start</span><span class="p">,</span> + <span class="n">stop</span><span class="o">=</span><span class="n">stop</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># {}_this_index is this grid point's index</span> + <span class="c1"># {}_prev_index and {}_next_index are the previous and next grid points,</span> + <span class="c1"># (which can be None if there is no previous or next, or if</span> + <span class="c1"># previous and next should not be used: this is deliberate)</span> + <span class="c1">#</span> + + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"discrete"</span><span class="p">:</span> + <span class="c1"># discrete grids only care about this,</span> + <span class="c1"># both prev and next should be None to</span> + <span class="c1"># force errors where they are used</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2">_this_index = </span><span class="si">{name}</span><span class="s2">_sample_number "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="p">),</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2">_prev_index = None if </span><span class="si">{name}</span><span class="s2">_this_index == 0 else (</span><span class="si">{name}</span><span class="s2">_this_index - 1) "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="p">),</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2">_next_index = None if </span><span class="si">{name}</span><span class="s2">_this_index >= (len(sampled_values_</span><span class="si">{name}</span><span class="s2">)+</span><span class="si">{offset}</span><span class="s2"> - 1) else (</span><span class="si">{name}</span><span class="s2">_this_index + 1)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span> + <span class="p">),</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">elif</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span> + <span class="s2">"centred"</span><span class="p">,</span> + <span class="s2">"centre"</span><span class="p">,</span> + <span class="s2">"center"</span><span class="p">,</span> + <span class="s2">"edge"</span><span class="p">,</span> + <span class="s2">"left"</span><span class="p">,</span> + <span class="s2">"left edge"</span><span class="p">,</span> + <span class="p">]:</span> + + <span class="c1"># left and centred grids</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"if </span><span class="si">{}</span><span class="s2">_sample_number == 0:</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">])</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{}</span><span class="s2">_this_index = 0;</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]),</span> <span class="n">indent</span><span class="o">=</span><span class="mi">1</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"else:</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2">_this_index = </span><span class="si">{name}</span><span class="s2">_sample_number "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2">_prev_index = (</span><span class="si">{name}</span><span class="s2">_this_index - 1) if </span><span class="si">{name}</span><span class="s2">_this_index > 0 else None "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2">_next_index = </span><span class="si">{name}</span><span class="s2">_this_index + 1"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + + <span class="k">elif</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"right"</span><span class="p">,</span> <span class="s2">"right edge"</span><span class="p">]:</span> + + <span class="c1"># right edged grid</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"if </span><span class="si">{name}</span><span class="s2">_sample_number == 0:</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">])</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2">_this_index = 1;</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]),</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"else:</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2">_this_index = </span><span class="si">{name}</span><span class="s2">_sample_number + 1 "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="p">),</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2">_prev_index = </span><span class="si">{name}</span><span class="s2">_this_index - 1"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2">_next_index = (</span><span class="si">{name}</span><span class="s2">_this_index + 1) if </span><span class="si">{name}</span><span class="s2">_this_index < len(sampled_values_</span><span class="si">{name}</span><span class="s2">) else None"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + + <span class="c1"># calculate phase volume</span> + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"dphasevol"</span><span class="p">]</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span> + <span class="c1"># no phase volume required so set it to 1.0</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"dphasevol_</span><span class="si">{name}</span><span class="s2"> = 1.0 # 666</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">])</span> + <span class="p">)</span> + + <span class="k">elif</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"right"</span><span class="p">,</span> <span class="s2">"right edge"</span><span class="p">]:</span> + <span class="c1"># right edges always have this and prev defined</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"dphasevol_</span><span class="si">{name}</span><span class="s2"> = (sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_this_index] - sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_prev_index])"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"discrete"</span><span class="p">:</span> + <span class="c1"># discrete might have next defined, use it if we can,</span> + <span class="c1"># otherwise use prev</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"dphasevol_</span><span class="si">{name}</span><span class="s2"> = (sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_next_index] - sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_this_index]) if </span><span class="si">{name}</span><span class="s2">_next_index else (sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_this_index] - sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_prev_index])"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># left and centred always have this and next defined</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"dphasevol_</span><span class="si">{name}</span><span class="s2"> = (sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_next_index] - sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_this_index])"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + + <span class="c1">##############</span> + <span class="c1"># Add phasevol check:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"if dphasevol_</span><span class="si">{name}</span><span class="s2"> <= 0:</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">])</span> + <span class="p">)</span> + + <span class="c1"># n that case we need another local variable which will prevent it from being run but will track those parameters</span> + <span class="c1"># Add phasevol check action:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s1">'print("Grid generator: dphasevol_</span><span class="si">{name}</span><span class="s1"> <= 0! (this=",</span><span class="si">{name}</span><span class="s1">_this_index,"=",sampled_values_</span><span class="si">{name}</span><span class="s1">[</span><span class="si">{name}</span><span class="s1">_this_index],", next=",</span><span class="si">{name}</span><span class="s1">_next_index,"=",sampled_values_</span><span class="si">{name}</span><span class="s1">[</span><span class="si">{name}</span><span class="s1">_next_index],") Skipping current sample.")'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"continue</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"print('sample </span><span class="si">{name}</span><span class="s2"> from ',sampled_values_</span><span class="si">{name}</span><span class="s2">,' at this=',</span><span class="si">{name}</span><span class="s2">_this_index,', next=',</span><span class="si">{name}</span><span class="s2">_next_index)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + + <span class="c1"># select sampled point location based on gridtype (left, centre or right)</span> + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span> + <span class="s2">"edge"</span><span class="p">,</span> + <span class="s2">"left"</span><span class="p">,</span> + <span class="s2">"left edge"</span><span class="p">,</span> + <span class="s2">"right"</span><span class="p">,</span> + <span class="s2">"right edge"</span><span class="p">,</span> + <span class="s2">"discrete"</span><span class="p">,</span> + <span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2"> = sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_this_index]"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + <span class="k">elif</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"centred"</span><span class="p">,</span> <span class="s2">"centre"</span><span class="p">,</span> <span class="s2">"center"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{name}</span><span class="s2"> = 0.5 * (sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_next_index] + sampled_values_</span><span class="si">{name}</span><span class="s2">[</span><span class="si">{name}</span><span class="s2">_this_index])"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Unknown gridtype value </span><span class="si">{type}</span><span class="s2">."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">type</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"gridtype"</span><span class="p">]</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"print('hence </span><span class="si">{name}</span><span class="s2"> = ',</span><span class="si">{name}</span><span class="s2">)</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1">#################################################################################</span> + <span class="c1"># Check condition and generate for loop</span> + + <span class="c1"># If the grid variable has a condition, write the check and the action</span> + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"condition"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="c1"># Add comment</span> + <span class="s2">"# Condition for </span><span class="si">{name}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]),</span> + <span class="c1"># Add condition check</span> + <span class="s2">"if not </span><span class="si">{condition}</span><span class="s2">:</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">condition</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"condition"</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># Add condition failed action:</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]</span> <span class="o">>=</span> <span class="mi">4</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s1">'print("Grid generator: Condition for </span><span class="si">{name}</span><span class="s1"> not met!")'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"continue"</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"continue"</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="c1"># Add some whitespace</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + + <span class="c1"># Add some whitespace</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + + <span class="c1">#########################</span> + <span class="c1"># Set up pre-code and value in some cases</span> + <span class="c1"># Add pre-code</span> + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"precode"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{precode}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">precode</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"precode"</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_indent_block</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + + <span class="c1"># Set phasevol</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"phasevol *= dphasevol_</span><span class="si">{name}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1">#######################</span> + <span class="c1"># Probabilities</span> + <span class="c1"># Calculate probability</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"# Set probabilities</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"dprob_</span><span class="si">{name}</span><span class="s2"> = dphasevol_</span><span class="si">{name}</span><span class="s2"> * (</span><span class="si">{probdist}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="n">probdist</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"probdist"</span><span class="p">],</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="c1"># Save probability sum</span> + <span class="s2">"probabilities_sum[</span><span class="si">{n}</span><span class="s2">] += dprob_</span><span class="si">{name}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">n</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"probabilities_list[0] = dprob_</span><span class="si">{name}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"probabilities_list[</span><span class="si">{this}</span><span class="s2">] = probabilities_list[</span><span class="si">{prev}</span><span class="s2">] * dprob_</span><span class="si">{name}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">this</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> + <span class="n">prev</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">],</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + + <span class="c1">##############</span> + <span class="c1"># postcode</span> + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"postcode"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{postcode}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">postcode</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"postcode"</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_indent_block</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + + <span class="c1">#######################</span> + <span class="c1"># Increment starcount for this parameter</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"# Increment starcount for </span><span class="si">{name}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]),</span> + <span class="s2">"starcounts[</span><span class="si">{n}</span><span class="s2">] += 1"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">n</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="c1"># Add value to dict</span> + <span class="s1">'parameter_dict["</span><span class="si">{name}</span><span class="s1">"] = </span><span class="si">{name}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"parameter_name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># The final parts of the code, where things are returned, are within the deepest loop,</span> + <span class="c1"># but in some cases code from a higher loop needs to go under it again</span> + <span class="c1"># SO I think its better to put an if statement here that checks</span> + <span class="c1"># whether this is the last loop.</span> + <span class="k">if</span> <span class="n">loopnr</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_write_gridcode_system_call</span><span class="p">(</span> + <span class="n">grid_variable</span><span class="p">,</span> + <span class="n">dry_run</span><span class="p">,</span> + <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchpoint"</span><span class="p">],</span> + <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchcode"</span><span class="p">],</span> + <span class="p">)</span> + + <span class="c1"># increment indent_depth</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1">####################</span> + <span class="c1"># bottom code</span> + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"bottomcode"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"bottomcode"</span><span class="p">])</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + + <span class="c1"># Write parts to write below the part that yield the results.</span> + <span class="c1"># this has to go in a reverse order:</span> + <span class="c1"># Here comes the stuff that is put after the deepest nested part that calls returns stuff.</span> + <span class="c1"># Here we will have a</span> + <span class="n">reverse_sorted_grid_variables</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span> + <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s2">"grid_variable_number"</span><span class="p">],</span> + <span class="n">reverse</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">for</span> <span class="n">loopnr</span><span class="p">,</span> <span class="n">grid_variable_el</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">reverse_sorted_grid_variables</span><span class="p">):</span> + <span class="n">grid_variable</span> <span class="o">=</span> <span class="n">grid_variable_el</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"#"</span> <span class="o">*</span> <span class="mi">40</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"# Code below is for finalising the handling of this iteration of the parameter </span><span class="si">{name}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">),</span> + <span class="p">)</span> + + <span class="c1"># Set phasevol</span> + <span class="c1"># TODO: fix. this isn't supposed to be the value that we give it here. discuss</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"phasevol /= dphasevol_</span><span class="si">{name}</span><span class="se">\n\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">])</span> + <span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">_numba</span> <span class="ow">and</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"dry_parallel"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"__parallel_func(phasevol,_total_starcount)</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># Check the branchpoint part here. The branchpoint makes sure that we can construct</span> + <span class="c1"># a grid with several multiplicities and still can make the system calls for each</span> + <span class="c1"># multiplicity without reconstructing the grid each time</span> + <span class="k">if</span> <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchpoint"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="c1"># Add comment</span> + <span class="s2">"# Condition for branchpoint at </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">reverse_sorted_grid_variables</span><span class="p">[</span><span class="n">loopnr</span> <span class="o">+</span> <span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">][</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="c1"># # Add condition check</span> + <span class="c1"># "if not {}:".format(grid_variable["condition"])</span> + <span class="c1"># + "\n"</span> + <span class="c1"># Add branchpoint</span> + <span class="s2">"if multiplicity==</span><span class="si">{}</span><span class="s2">:"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchpoint"</span><span class="p">])</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_write_gridcode_system_call</span><span class="p">(</span> + <span class="n">reverse_sorted_grid_variables</span><span class="p">[</span><span class="n">loopnr</span> <span class="o">+</span> <span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span> + <span class="n">dry_run</span><span class="p">,</span> + <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchpoint"</span><span class="p">],</span> + <span class="n">grid_variable</span><span class="p">[</span><span class="s2">"branchcode"</span><span class="p">],</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + + <span class="c1">###############################</span> + <span class="c1"># Finalise print statements</span> + <span class="c1">#</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"#"</span> <span class="o">*</span> <span class="mi">40</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"if print_results:</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"print('Grid has handled </span><span class="si">{starcount}</span><span class="s2"> stars with a total probability of </span><span class="si">{probtot:g}</span><span class="s2">'.format(starcount=_total_starcount,probtot=self.grid_options['_probtot']))</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1">################</span> + <span class="c1"># Finalise return statement for dry run.</span> + <span class="c1">#</span> + <span class="k">if</span> <span class="n">dry_run</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"return _total_starcount</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> + <span class="c1">#################################################################################</span> + <span class="c1"># Stop of code generation. Here the code is saved and written</span> + + <span class="c1"># Save the grid code to the grid_options</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Save grid code to grid_options"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span> + <span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"code_string"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">code_string</span> + + <span class="c1"># Write to file</span> + <span class="n">gridcode_filename</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_gridcode_filename</span><span class="p">()</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"gridcode_filename"</span><span class="p">]</span> <span class="o">=</span> <span class="n">gridcode_filename</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{blue}</span><span class="s2">Write grid code to </span><span class="si">{file}</span><span class="s2"> [dry_run = </span><span class="si">{dry}</span><span class="s2">]</span><span class="si">{reset}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">blue</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"blue"</span><span class="p">],</span> + <span class="n">file</span><span class="o">=</span><span class="n">gridcode_filename</span><span class="p">,</span> + <span class="n">dry</span><span class="o">=</span><span class="n">dry_run</span><span class="p">,</span> + <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">gridcode_filename</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span> + <span class="n">file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">code_string</span><span class="p">)</span> + + <span class="c1"># perhaps create symlink</span> + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">HPC_job</span><span class="p">()</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"symlink_latest_gridcode"</span><span class="p">]:</span> + <span class="k">global</span> <span class="n">_count</span> + <span class="n">symlink</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"tmp_dir"</span><span class="p">],</span> <span class="s2">"binary_c_grid-latest"</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">_count</span><span class="p">)</span> + <span class="p">)</span> + <span class="n">_count</span> <span class="o">+=</span> <span class="mi">1</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">symlink</span><span class="p">)</span> + <span class="k">except</span><span class="p">:</span> + <span class="k">pass</span> + + <span class="k">try</span><span class="p">:</span> + <span class="n">os</span><span class="o">.</span><span class="n">symlink</span><span class="p">(</span><span class="n">gridcode_filename</span><span class="p">,</span> <span class="n">symlink</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{blue}</span><span class="s2">Symlinked grid code to </span><span class="si">{symlink}</span><span class="s2"> </span><span class="si">{reset}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">blue</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"blue"</span><span class="p">],</span> + <span class="n">symlink</span><span class="o">=</span><span class="n">symlink</span><span class="p">,</span> + <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"symlink failed"</span><span class="p">)</span> + + <span class="k">def</span> <span class="nf">_write_gridcode_system_call</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> <span class="n">grid_variable</span><span class="p">,</span> <span class="n">dry_run</span><span class="p">,</span> <span class="n">branchpoint</span><span class="p">,</span> <span class="n">branchcode</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to write the block of code (as string) that handles the setting the final probability, taking into account the weight and repeat settings, incrementing the total starcount and total probability.</span> + +<span class="sd"> Then if the run is a dry run we implement the dry_run_hook or pass depending on the settings. If it is not a dry run we yield the system dict</span> +<span class="sd"> """</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"#"</span> <span class="o">*</span> <span class="mi">40</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">branchcode</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"# Branch code</span><span class="se">\n</span><span class="s2">if </span><span class="si">{branchcode}</span><span class="s2">:</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">branchcode</span><span class="o">=</span><span class="n">branchcode</span><span class="p">)</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">branchpoint</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"# Code below will get evaluated for every system at this level of multiplicity (last one of that being </span><span class="si">{name}</span><span class="s2">)</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"# Code below will get evaluated for every generated system</span><span class="se">\n</span><span class="s2">"</span> + <span class="p">)</span> + + <span class="c1"># Factor in the custom weight input</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"# Weigh the probability by a custom weighting factor</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s1">'probability = self.grid_options["weight"] * probabilities_list[</span><span class="si">{n}</span><span class="s1">]'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">n</span><span class="o">=</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"grid_variable_number"</span><span class="p">]</span> + <span class="p">)</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="c1"># Take into account the multiplicity fraction:</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"# Factor the multiplicity fraction into the probability</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"probability *= self._calculate_multiplicity_fraction(parameter_dict)"</span> + <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="c1"># Divide by number of repeats</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"# Divide the probability by the number of repeats</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s1">'probability /= self.grid_options["repeat"]'</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="c1"># Now we yield the system self.grid_options["repeat"] times.</span> + <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s2">"# Loop over the repeats</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s1">'for _ in range(self.grid_options["repeat"]):'</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"_total_starcount += 1</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="c1"># set probability and phasevol values into the system dict</span> + <span class="s1">'parameter_dict["</span><span class="si">{p}</span><span class="s1">"] = </span><span class="si">{p}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">p</span><span class="o">=</span><span class="s2">"probability"</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="s1">'parameter_dict["</span><span class="si">{v}</span><span class="s1">"] = </span><span class="si">{v}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">v</span><span class="o">=</span><span class="s2">"phasevol"</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="c1"># Increment total probability</span> + <span class="s2">"self._increment_probtot(probability)</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">dry_run</span><span class="p">:</span> + <span class="c1"># Handle what is returned, or what is not.</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"yield(parameter_dict)</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># If its a dry run, dont do anything with it</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># run the hook function, only if given</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"dry_run_hook"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span> + <span class="s2">"self.grid_options['dry_run_hook'](self, parameter_dict)</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> + <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># or pass</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"pass</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_add_code</span><span class="p">(</span><span class="s2">"#"</span> <span class="o">*</span> <span class="mi">40</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">_increment_indent_depth</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> + + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">code_string</span> + + <span class="k">def</span> <span class="nf">_load_grid_function</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that loads the grid code from file</span> +<span class="sd"> """</span> + + <span class="c1"># Code to load the</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="n">message</span><span class="o">=</span><span class="s2">"Load grid code function from </span><span class="si">{file}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">file</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"gridcode_filename"</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">verbosity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="n">minimal_verbosity</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="n">spec</span> <span class="o">=</span> <span class="n">importlib</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">spec_from_file_location</span><span class="p">(</span> + <span class="s2">"binary_c_python_grid"</span><span class="p">,</span> + <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"gridcode_filename"</span><span class="p">]),</span> + <span class="p">)</span> + <span class="n">grid_file</span> <span class="o">=</span> <span class="n">importlib</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">module_from_spec</span><span class="p">(</span><span class="n">spec</span><span class="p">)</span> + <span class="n">spec</span><span class="o">.</span><span class="n">loader</span><span class="o">.</span><span class="n">exec_module</span><span class="p">(</span><span class="n">grid_file</span><span class="p">)</span> + <span class="n">generator</span> <span class="o">=</span> <span class="n">grid_file</span><span class="o">.</span><span class="n">grid_code</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_system_generator"</span><span class="p">]</span> <span class="o">=</span> <span class="n">generator</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span><span class="s2">"Grid code loaded"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> <span class="mi">1</span><span class="p">)</span> + + <span class="k">def</span> <span class="nf">_last_grid_variable</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that returns the last grid variable (i.e. the one with the highest grid_variable_number)</span> + +<span class="sd"> TODO: this function does not require this structure and can be simplified</span> +<span class="sd"> """</span> + + <span class="n">number</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">])</span> + <span class="k">for</span> <span class="n">grid_variable</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]:</span> + <span class="k">if</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">grid_variable</span><span class="p">][</span> + <span class="s2">"grid_variable_number"</span> + <span class="p">]</span> + <span class="o">==</span> <span class="n">number</span> <span class="o">-</span> <span class="mi">1</span> + <span class="p">):</span> + <span class="k">return</span> <span class="n">grid_variable</span> + +<div class="viewcode-block" id="gridcode.update_grid_variable"><a class="viewcode-back" href="../../../../population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode.update_grid_variable">[docs]</a> <span class="k">def</span> <span class="nf">update_grid_variable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to update the values of a grid variable.</span> + +<span class="sd"> Args:</span> +<span class="sd"> name:</span> +<span class="sd"> name of the grid variable to be changed.</span> +<span class="sd"> **kwargs:</span> +<span class="sd"> key-value pairs to override the existing grid variable data. See add_grid_variable for these names.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]:</span> + <span class="n">grid_variable</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">name</span><span class="p">]</span> + + <span class="c1"># Set the value and print</span> + <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> + <span class="n">grid_variable</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Updated grid variable: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Unknown grid variable </span><span class="si">{}</span><span class="s2"> - please create it with the add_grid_variable() method."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span></div> + +<div class="viewcode-block" id="gridcode.delete_grid_variable"><a class="viewcode-back" href="../../../../population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode.delete_grid_variable">[docs]</a> <span class="k">def</span> <span class="nf">delete_grid_variable</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> + <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to delete a grid variable with the given name.</span> + +<span class="sd"> Args:</span> +<span class="sd"> name:</span> +<span class="sd"> name of the grid variable to be deleted.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]:</span> + <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">name</span><span class="p">]</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Deleted grid variable: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Failed to remove grid variable </span><span class="si">{}</span><span class="s2">: please check it exists."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">name</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span></div> + +<div class="viewcode-block" id="gridcode.rename_grid_variable"><a class="viewcode-back" href="../../../../population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode.rename_grid_variable">[docs]</a> <span class="k">def</span> <span class="nf">rename_grid_variable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">oldname</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">newname</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to rename a grid variable.</span> + +<span class="sd"> note: this does NOT alter the order</span> +<span class="sd"> of the self.grid_options["_grid_variables"] dictionary.</span> + +<span class="sd"> The order in which the grid variables are loaded into the grid is based on their</span> +<span class="sd"> `grid_variable_number` property</span> + +<span class="sd"> Args:</span> +<span class="sd"> oldname:</span> +<span class="sd"> old name of the grid variable</span> +<span class="sd"> newname:</span> +<span class="sd"> new name of the grid variable</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">oldname</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">newname</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"_grid_variables"</span> + <span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">oldname</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">newname</span><span class="p">][</span><span class="s2">"name"</span><span class="p">]</span> <span class="o">=</span> <span class="n">newname</span> + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Rename grid variable: </span><span class="si">{}</span><span class="s2"> to </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">oldname</span><span class="p">,</span> <span class="n">newname</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Failed to rename grid variable </span><span class="si">{}</span><span class="s2"> to </span><span class="si">{}</span><span class="s2">."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">oldname</span><span class="p">,</span> <span class="n">newname</span><span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span></div> + +<div class="viewcode-block" id="gridcode.add_grid_variable"><a class="viewcode-back" href="../../../../population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode.add_grid_variable">[docs]</a> <span class="k">def</span> <span class="nf">add_grid_variable</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> + <span class="n">longname</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> + <span class="n">valuerange</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">list</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> + <span class="n">samplerfunc</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> + <span class="n">probdist</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> + <span class="n">dphasevol</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> + <span class="n">gridtype</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"centred"</span><span class="p">,</span> + <span class="n">branchpoint</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> + <span class="n">branchcode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> + <span class="n">precode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> + <span class="n">postcode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> + <span class="n">topcode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> + <span class="n">bottomcode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> + <span class="n">condition</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> + <span class="n">index</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> + <span class="n">dry_parallel</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> + <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function to add grid variables to the grid_options.</span> + +<span class="sd"> The execution of the grid generation will be through a nested for loop.</span> +<span class="sd"> Each of the grid variables will get create a deeper for loop.</span> + +<span class="sd"> The real function that generates the numbers will get written to a new file in the TMP_DIR,</span> +<span class="sd"> and then loaded imported and evaluated.</span> +<span class="sd"> beware that if you insert some destructive piece of code, it will be executed anyway.</span> +<span class="sd"> Use at own risk.</span> + +<span class="sd"> Args:</span> +<span class="sd"> name:</span> +<span class="sd"> name of parameter used in the grid Python code.</span> +<span class="sd"> This is evaluated as a parameter and you can use it throughout</span> +<span class="sd"> the rest of the function</span> + +<span class="sd"> Examples::</span> + +<span class="sd"> name = 'lnM_1'</span> + +<span class="sd"> parameter_name:</span> +<span class="sd"> name of the parameter in binary_c</span> + +<span class="sd"> This name must correspond to a Python variable of the same name,</span> +<span class="sd"> which is automatic if parameter_name == name.</span> + +<span class="sd"> Note: if parameter_name != name, you must set a</span> +<span class="sd"> variable in "precode" or "postcode" to define a Python variable</span> +<span class="sd"> called parameter_name</span> + +<span class="sd"> longname:</span> +<span class="sd"> Long name of parameter</span> + +<span class="sd"> Examples::</span> + +<span class="sd"> longname = 'Primary mass'</span> + +<span class="sd"> range:</span> +<span class="sd"> Range of values to take. Does not get used really, the samplerfunc is used to</span> +<span class="sd"> get the values from</span> + +<span class="sd"> Examples::</span> + +<span class="sd"> range = [math.log(m_min), math.log(m_max)]</span> + +<span class="sd"> samplerfunc:</span> +<span class="sd"> Function returning a list or numpy array of samples spaced appropriately.</span> +<span class="sd"> You can either use a real function, or a string representation of a function call.</span> + +<span class="sd"> Examples::</span> + +<span class="sd"> samplerfunc = "self.const_linear(math.log(m_min), math.log(m_max), {})".format(resolution['M_1'])</span> + +<span class="sd"> precode:</span> +<span class="sd"> Extra room for some code. This code will be evaluated within the loop of the</span> +<span class="sd"> sampling function (i.e. a value for lnM_1 is chosen already)</span> + +<span class="sd"> Examples::</span> + +<span class="sd"> precode = 'M_1=math.exp(lnM_1);'</span> + +<span class="sd"> postcode:</span> +<span class="sd"> Code executed after the probability is calculated.</span> + +<span class="sd"> probdist:</span> +<span class="sd"> Function determining the probability that gets assigned to the sampled parameter</span> + +<span class="sd"> Examples::</span> + +<span class="sd"> probdist = 'self.Kroupa2001(M_1)*M_1'</span> + +<span class="sd"> dphasevol:</span> +<span class="sd"> part of the parameter space that the total probability is calculated with. Put to -1</span> +<span class="sd"> if you want to ignore any dphasevol calculations and set the value to 1</span> + +<span class="sd"> Examples::</span> + +<span class="sd"> dphasevol = 'dlnM_1'</span> + +<span class="sd"> condition:</span> +<span class="sd"> condition that has to be met in order for the grid generation to continue</span> + +<span class="sd"> Examples::</span> + +<span class="sd"> condition = "self.grid_options['binary']==1"</span> + +<span class="sd"> gridtype:</span> +<span class="sd"> Method on how the value range is sampled. Can be either 'edge' (steps starting at</span> +<span class="sd"> the lower edge of the value range) or 'centred'</span> +<span class="sd"> (steps starting at ``lower edge + 0.5 * stepsize``).</span> + +<span class="sd"> dry_parallel:</span> +<span class="sd"> If True, try to parallelize this variable in dry runs.</span> + +<span class="sd"> topcode:</span> +<span class="sd"> Code added at the very top of the block.</span> + +<span class="sd"> bottomcode:</span> +<span class="sd"> Code added at the very bottom of the block.</span> +<span class="sd"> """</span> + + <span class="c1"># check parameters</span> + <span class="c1"># if False and dphasevol != -1.0 and gridtype == "discrete":</span> + <span class="k">if</span> <span class="n">dphasevol</span> <span class="o">!=</span> <span class="o">-</span><span class="mf">1.0</span> <span class="ow">and</span> <span class="n">gridtype</span> <span class="o">==</span> <span class="s2">"discrete"</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Error making grid: you have set the phasevol to be not -1 and gridtype to discrete, but a discrete grid has no phasevol calculation. You should only set the gridtype to discrete and not set the phasevol in this case."</span> + <span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># Add grid_variable</span> + <span class="n">grid_variable</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"name"</span><span class="p">:</span> <span class="n">name</span><span class="p">,</span> + <span class="s2">"parameter_name"</span><span class="p">:</span> <span class="n">parameter_name</span><span class="p">,</span> + <span class="s2">"longname"</span><span class="p">:</span> <span class="n">longname</span><span class="p">,</span> + <span class="s2">"valuerange"</span><span class="p">:</span> <span class="n">valuerange</span><span class="p">,</span> + <span class="s2">"samplerfunc"</span><span class="p">:</span> <span class="n">samplerfunc</span><span class="p">,</span> + <span class="s2">"precode"</span><span class="p">:</span> <span class="n">precode</span><span class="p">,</span> + <span class="s2">"postcode"</span><span class="p">:</span> <span class="n">postcode</span><span class="p">,</span> + <span class="s2">"probdist"</span><span class="p">:</span> <span class="n">probdist</span><span class="p">,</span> + <span class="s2">"dphasevol"</span><span class="p">:</span> <span class="n">dphasevol</span><span class="p">,</span> + <span class="s2">"condition"</span><span class="p">:</span> <span class="n">condition</span><span class="p">,</span> + <span class="s2">"gridtype"</span><span class="p">:</span> <span class="n">gridtype</span><span class="p">,</span> + <span class="s2">"branchpoint"</span><span class="p">:</span> <span class="n">branchpoint</span><span class="p">,</span> + <span class="s2">"branchcode"</span><span class="p">:</span> <span class="n">branchcode</span><span class="p">,</span> + <span class="s2">"topcode"</span><span class="p">:</span> <span class="n">topcode</span><span class="p">,</span> + <span class="s2">"bottomcode"</span><span class="p">:</span> <span class="n">bottomcode</span><span class="p">,</span> + <span class="s2">"grid_variable_number"</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">]),</span> + <span class="s2">"dry_parallel"</span><span class="p">:</span> <span class="n">dry_parallel</span><span class="p">,</span> + <span class="p">}</span> + + <span class="c1"># Check for gridtype input</span> + <span class="n">allowed_gridtypes</span> <span class="o">=</span> <span class="p">[</span> + <span class="s2">"edge"</span><span class="p">,</span> + <span class="s2">"right"</span><span class="p">,</span> + <span class="s2">"right edge"</span><span class="p">,</span> + <span class="s2">"left"</span><span class="p">,</span> + <span class="s2">"left edge"</span><span class="p">,</span> + <span class="s2">"centred"</span><span class="p">,</span> + <span class="s2">"centre"</span><span class="p">,</span> + <span class="s2">"center"</span><span class="p">,</span> + <span class="s2">"discrete"</span><span class="p">,</span> + <span class="p">]</span> + + <span class="k">if</span> <span class="n">gridtype</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">allowed_gridtypes</span><span class="p">:</span> + <span class="n">msg</span> <span class="o">=</span> <span class="s2">"Unknown gridtype </span><span class="si">{gridtype}</span><span class="s2">. Please choose one of: "</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">gridtype</span><span class="o">=</span><span class="n">gridtype</span> + <span class="p">)</span> <span class="o">+</span> <span class="s2">","</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">allowed_gridtypes</span><span class="p">)</span> + <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + + <span class="c1"># Load it into the grid_options</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_grid_variables"</span><span class="p">][</span><span class="n">grid_variable</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]]</span> <span class="o">=</span> <span class="n">grid_variable</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">verbose_print</span><span class="p">(</span> + <span class="s2">"Added grid variable: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">grid_variable</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> + <span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">],</span> + <span class="mi">2</span><span class="p">,</span> + <span class="p">)</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/metadata.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/metadata.html new file mode 100644 index 0000000000000000000000000000000000000000..cfa88591500d02ef960a4bb5a1404fc860a82ca3 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/metadata.html @@ -0,0 +1,250 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.metadata — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.metadata</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.metadata</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">Module containing the metadata functions for the binarycpython package.</span> + +<span class="sd">This class object is an extension to the population grid object</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">json</span> +<span class="kn">import</span> <span class="nn">platform</span> + +<span class="kn">from</span> <span class="nn">binarycpython.utils.dicts</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">multiply_values_dict</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.ensemble</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">binaryc_json_serializer</span><span class="p">,</span> +<span class="p">)</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">now</span><span class="p">,</span> +<span class="p">)</span> + + +<div class="viewcode-block" id="metadata"><a class="viewcode-back" href="../../../../population_extensions/metadata.html#binarycpython.utils.population_extensions.metadata.metadata">[docs]</a><span class="k">class</span> <span class="nc">metadata</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Extension to the population grid object that contains functionality to handle the metadata that will be put in the ensemble</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the metadata class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + +<div class="viewcode-block" id="metadata.add_system_metadata"><a class="viewcode-back" href="../../../../population_extensions/metadata.html#binarycpython.utils.population_extensions.metadata.metadata.add_system_metadata">[docs]</a> <span class="k">def</span> <span class="nf">add_system_metadata</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Add system's metadata to the grid_ensemble_results, and add some system information to metadata.</span> +<span class="sd"> """</span> + + <span class="c1"># add metadata if it doesn't exist</span> + <span class="k">if</span> <span class="ow">not</span> <span class="s2">"metadata"</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="c1"># add date</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"date"</span><span class="p">]</span> <span class="o">=</span> <span class="n">now</span><span class="p">()</span> + + <span class="c1"># add platform and build information</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"platform"</span><span class="p">]</span> <span class="o">=</span> <span class="n">platform</span><span class="o">.</span><span class="n">platform</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"platform_uname"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span> + <span class="n">platform</span><span class="o">.</span><span class="n">uname</span><span class="p">()</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"platform_machine"</span><span class="p">]</span> <span class="o">=</span> <span class="n">platform</span><span class="o">.</span><span class="n">machine</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"platform_node"</span><span class="p">]</span> <span class="o">=</span> <span class="n">platform</span><span class="o">.</span><span class="n">node</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"platform_release"</span><span class="p">]</span> <span class="o">=</span> <span class="n">platform</span><span class="o">.</span><span class="n">release</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"platform_version"</span><span class="p">]</span> <span class="o">=</span> <span class="n">platform</span><span class="o">.</span><span class="n">version</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> + <span class="s2">"platform_processor"</span> + <span class="p">]</span> <span class="o">=</span> <span class="n">platform</span><span class="o">.</span><span class="n">processor</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"platform_python_build"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="n">platform</span><span class="o">.</span><span class="n">python_build</span><span class="p">()</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> + <span class="s2">"platform_python_version"</span> + <span class="p">]</span> <span class="o">=</span> <span class="n">platform</span><span class="o">.</span><span class="n">python_version</span><span class="p">()</span> + + <span class="c1"># Get hostname</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"hostname"</span><span class="p">]</span> <span class="o">=</span> <span class="n">platform</span><span class="o">.</span><span class="n">uname</span><span class="p">()[</span><span class="mi">1</span><span class="p">]</span> + + <span class="c1"># Calculate time elapsed</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"duration"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">time_elapsed</span><span class="p">()</span> + + <span class="c1"># Calculate cpu time</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"CPU_time"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">CPU_time</span><span class="p">()</span></div> + +<div class="viewcode-block" id="metadata.add_ensemble_metadata"><a class="viewcode-back" href="../../../../population_extensions/metadata.html#binarycpython.utils.population_extensions.metadata.metadata.add_ensemble_metadata">[docs]</a> <span class="k">def</span> <span class="nf">add_ensemble_metadata</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">combined_output_dict</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to add metadata to the grid_ensemble_results and grid_options</span> +<span class="sd"> """</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"population_id"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"_population_id"</span> + <span class="p">]</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> + <span class="s2">"total_probability_weighted_mass"</span> + <span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">]</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> + <span class="s2">"factored_in_probability_weighted_mass"</span> + <span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"ensemble_factor_in_probability_weighted_mass"</span><span class="p">]:</span> + <span class="n">multiply_values_dict</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"ensemble"</span><span class="p">],</span> + <span class="mf">1.0</span> + <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> + <span class="s2">"total_probability_weighted_mass"</span> + <span class="p">],</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span> + <span class="s2">"factored_in_probability_weighted_mass"</span> + <span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"_killed"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_killed"</span><span class="p">]</span> + + <span class="c1"># Add settings of the populations</span> + <span class="n">all_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">return_all_info</span><span class="p">(</span> + <span class="n">include_population_settings</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="n">include_binary_c_defaults</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="n">include_binary_c_version_info</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="n">include_binary_c_help_all</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_ensemble_results</span><span class="p">[</span><span class="s2">"metadata"</span><span class="p">][</span><span class="s2">"settings"</span><span class="p">]</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span> + <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">all_info</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">binaryc_json_serializer</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> + <span class="p">)</span> + + <span class="c1">##############################</span> + <span class="c1"># Update grid options</span> + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_metadata_keylist</span><span class="p">():</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="n">combined_output_dict</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"_failed_systems_error_codes"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span> + <span class="nb">set</span><span class="p">(</span><span class="n">combined_output_dict</span><span class="p">[</span><span class="s2">"_failed_systems_error_codes"</span><span class="p">])</span> + <span class="p">)</span></div> + + <span class="k">def</span> <span class="nf">_metadata_keylist</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function that returns the list of metadata keys</span> + +<span class="sd"> TODO: Consider just setting this list as a property of the object in the init</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="p">[</span> + <span class="s2">"_failed_count"</span><span class="p">,</span> + <span class="s2">"_failed_prob"</span><span class="p">,</span> + <span class="s2">"_errors_exceeded"</span><span class="p">,</span> + <span class="s2">"_errors_found"</span><span class="p">,</span> + <span class="s2">"_probtot"</span><span class="p">,</span> + <span class="s2">"_count"</span><span class="p">,</span> + <span class="s2">"_total_mass_run"</span><span class="p">,</span> + <span class="s2">"_total_probability_weighted_mass_run"</span><span class="p">,</span> + <span class="s2">"_zero_prob_stars_skipped"</span><span class="p">,</span> + <span class="s2">"_killed"</span><span class="p">,</span> + <span class="p">]</span></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/slurm.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/slurm.html new file mode 100644 index 0000000000000000000000000000000000000000..45e6cc2f3196cb698852a6263a2dcca552c20837 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/slurm.html @@ -0,0 +1,574 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.slurm — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.slurm</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.slurm</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">Module containing the Slurm functions for the binarycpython package.</span> + +<span class="sd">This class object is an extension to the population grid object</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">os</span> +<span class="kn">import</span> <span class="nn">sys</span> +<span class="kn">import</span> <span class="nn">time</span> +<span class="kn">import</span> <span class="nn">stat</span> +<span class="kn">import</span> <span class="nn">pathlib</span> +<span class="kn">import</span> <span class="nn">subprocess</span> + +<span class="kn">import</span> <span class="nn">datasize</span> +<span class="kn">import</span> <span class="nn">lib_programname</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> + <span class="n">command_string_from_list</span><span class="p">,</span> + <span class="n">now</span><span class="p">,</span> +<span class="p">)</span> + + +<div class="viewcode-block" id="slurm"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm">[docs]</a><span class="k">class</span> <span class="nc">slurm</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Extension for the Population class containing the code for Slurm grid simulations</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the slurm class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + +<div class="viewcode-block" id="slurm.slurmID"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurmID">[docs]</a> <span class="k">def</span> <span class="nf">slurmID</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">jobid</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">jobarrayindex</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return a Slurm job ID as a string, [jobid].[jobarrayindex]. The jobid and jobarrayindex passed in are used if given, otherwise we default to the jobid and jobarrayindex in grid_options.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="n">jobid</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">jobid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_jobid"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">jobarrayindex</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">jobarrayindex</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_jobarrayindex"</span><span class="p">]</span> + <span class="k">return</span> <span class="s2">"</span><span class="si">{jobid}</span><span class="s2">.</span><span class="si">{jobarrayindex}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">jobid</span><span class="o">=</span><span class="n">jobid</span><span class="p">,</span> <span class="n">jobarrayindex</span><span class="o">=</span><span class="n">jobarrayindex</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="slurm.slurmpath"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurmpath">[docs]</a> <span class="k">def</span> <span class="nf">slurmpath</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">slurm_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the full slurm directory path.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="n">slurm_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">slurm_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">]</span> + + <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">slurm_dir</span><span class="p">,</span> <span class="n">path</span><span class="p">))</span></div> + +<div class="viewcode-block" id="slurm.slurm_status_file"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_status_file">[docs]</a> <span class="k">def</span> <span class="nf">slurm_status_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">jobid</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">jobarrayindex</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">slurm_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Return the slurm status file corresponding to the jobid and jobarrayindex, which default to grid_options slurm_jobid and slurm_jobarrayindex, respectively.</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">slurmpath</span><span class="p">(</span><span class="s2">"status"</span><span class="p">,</span> <span class="n">slurm_dir</span><span class="o">=</span><span class="n">slurm_dir</span><span class="p">),</span> + <span class="bp">self</span><span class="o">.</span><span class="n">slurmID</span><span class="p">(</span><span class="n">jobid</span><span class="o">=</span><span class="n">jobid</span><span class="p">,</span> <span class="n">jobarrayindex</span><span class="o">=</span><span class="n">jobarrayindex</span><span class="p">),</span> + <span class="p">)</span></div> + +<div class="viewcode-block" id="slurm.slurm_check_requirements"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_check_requirements">[docs]</a> <span class="k">def</span> <span class="nf">slurm_check_requirements</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to check whether the slurm parameters in grid_options have been set appropriately.</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span> <span class="ow">and</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span> + <span class="ow">or</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">])</span> + <span class="p">):</span> + <span class="k">return</span> <span class="p">(</span> + <span class="kc">False</span><span class="p">,</span> + <span class="s2">"You have set slurm=</span><span class="si">{slurm}</span><span class="s2"> but not set slurm_dir (</span><span class="si">{slurm_dir}</span><span class="s2">) correctly. Please set it and try again."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">slurm</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">],</span> + <span class="n">slurm_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">],</span> + <span class="p">),</span> + <span class="p">)</span> + <span class="k">return</span> <span class="p">(</span><span class="kc">True</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span></div> + +<div class="viewcode-block" id="slurm.slurm_dirs"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_dirs">[docs]</a> <span class="k">def</span> <span class="nf">slurm_dirs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Directories associated specifically with this slurm job.</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">]</span></div> + +<div class="viewcode-block" id="slurm.set_slurm_status"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.set_slurm_status">[docs]</a> <span class="k">def</span> <span class="nf">set_slurm_status</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">string</span><span class="p">,</span> <span class="n">slurm_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Set the slurm status corresponing to the self object, which should have slurm_jobid and slurm_jobarrayindex set.</span> + +<span class="sd"> Args:</span> +<span class="sd"> string : the status string to be set</span> +<span class="sd"> slurm_dir : the directory in which the status directory is held. If not set, this defaults to the HPC directory (e.g. slurm_dir or condor_dir).</span> +<span class="sd"> """</span> + <span class="c1"># save slurm jobid to file</span> + <span class="k">if</span> <span class="n">slurm_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">slurm_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">]</span> + + <span class="n">idfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">slurm_dir</span><span class="p">,</span> <span class="s2">"jobid"</span><span class="p">)</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">idfile</span><span class="p">):</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">idfile</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">fjobid</span><span class="p">:</span> + <span class="n">fjobid</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="si">{jobid}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">jobid</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_jobid"</span><span class="p">]))</span> + <span class="n">fjobid</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">idfile</span><span class="p">)</span> + + <span class="c1"># save slurm status</span> + <span class="n">status_file</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">slurm_status_file</span><span class="p">(</span><span class="n">slurm_dir</span><span class="o">=</span><span class="n">slurm_dir</span><span class="p">)</span> + <span class="k">if</span> <span class="n">status_file</span><span class="p">:</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">status_file</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> + <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">string</span><span class="p">)</span> + <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">status_file</span><span class="p">)</span> + + <span class="nb">print</span><span class="p">(</span><span class="s2">"Have set status in"</span><span class="p">,</span><span class="n">status_file</span><span class="p">,</span><span class="s2">"to"</span><span class="p">,</span><span class="n">string</span><span class="p">)</span> + <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">status_file</span><span class="p">,</span><span class="s2">"r"</span><span class="p">,</span><span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Contents"</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">readlines</span><span class="p">())</span> + <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div> + +<div class="viewcode-block" id="slurm.get_slurm_status"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.get_slurm_status">[docs]</a> <span class="k">def</span> <span class="nf">get_slurm_status</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">jobid</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">jobarrayindex</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">slurm_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Get and return the slurm status string corresponing to the self object, or jobid.jobarrayindex if they are passed in. If no status is found, returns an empty string.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="n">jobid</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">jobid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_jobid"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">jobarrayindex</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">jobarrayindex</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_jobarrayindex"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">jobid</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">jobarrayindex</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="k">return</span> <span class="kc">None</span> + <span class="k">try</span><span class="p">:</span> + + <span class="n">path</span> <span class="o">=</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">slurm_status_file</span><span class="p">(</span> + <span class="n">slurm_dir</span><span class="o">=</span><span class="n">slurm_dir</span><span class="p">,</span> <span class="n">jobid</span><span class="o">=</span><span class="n">jobid</span><span class="p">,</span> <span class="n">jobarrayindex</span><span class="o">=</span><span class="n">jobarrayindex</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">if</span> <span class="n">path</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">NFS_flush_hack</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> + <span class="k">return</span> <span class="n">path</span><span class="o">.</span><span class="n">read_text</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="k">return</span> <span class="s2">""</span> + <span class="c1"># TODO: Fix bare exception</span> + <span class="k">except</span><span class="p">:</span> + <span class="k">return</span> <span class="s2">""</span></div> + +<div class="viewcode-block" id="slurm.slurm_outfile"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_outfile">[docs]</a> <span class="k">def</span> <span class="nf">slurm_outfile</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">slurm_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> return a standard filename for the slurm chunk files</span> +<span class="sd"> """</span> + <span class="n">file</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{id}</span><span class="s2">.gz"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">slurmID</span><span class="p">(),</span> + <span class="p">)</span> + <span class="k">if</span> <span class="n">slurm_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">slurm_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">]</span> + <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">slurm_dir</span><span class="p">,</span> <span class="s2">"results"</span><span class="p">,</span> <span class="n">file</span><span class="p">))</span></div> + +<div class="viewcode-block" id="slurm.make_slurm_dirs"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.make_slurm_dirs">[docs]</a> <span class="k">def</span> <span class="nf">make_slurm_dirs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">slurm_dir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to create the necessary slurm directories</span> +<span class="sd"> """</span> + + <span class="c1"># TODO: replace the code block below with a function call to slurmpath</span> + <span class="c1"># make the slurm directories</span> + <span class="k">if</span> <span class="n">slurm_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">slurm_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">]</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">slurm_dir</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"You must set self.grid_options['slurm_dir'] (or pass slurm_dir=whatever to make_slurm_dirs()) to a directory which we can use to set up binary_c-python's Slurm files. This should be unique to your set of grids."</span> + <span class="p">)</span> + <span class="n">os</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span> + + <span class="c1"># make a list of directories, these contain the various slurm</span> + <span class="c1"># output, status files, etc.</span> + <span class="n">dirs</span> <span class="o">=</span> <span class="p">[]</span> + <span class="k">for</span> <span class="n">slurm_subdir</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"stdout"</span><span class="p">,</span> <span class="s2">"stderr"</span><span class="p">,</span> <span class="s2">"results"</span><span class="p">,</span> <span class="s2">"status"</span><span class="p">,</span> <span class="s2">"snapshots"</span><span class="p">]:</span> + <span class="n">dirs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">slurmpath</span><span class="p">(</span><span class="n">slurm_subdir</span><span class="p">))</span> + + <span class="c1"># make the directories: we do not allow these to already exist</span> + <span class="c1"># as the slurm directory should be a fresh location for each set of jobs</span> + <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">dirs</span><span class="p">:</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">slurmpath</span><span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="n">slurm_dir</span><span class="o">=</span><span class="n">slurm_dir</span><span class="p">))</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span> + <span class="n">exist_ok</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">parents</span><span class="o">=</span><span class="kc">True</span> + <span class="p">)</span> + <span class="c1"># TODO: fix this bare exception</span> + <span class="k">except</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Tried to make the directory </span><span class="si">{d}</span><span class="s2"> but it already exists. When you launch a set of binary_c jobs on Slurm, you need to set your slurm_dir to be a fresh directory with no contents."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">d</span><span class="o">=</span><span class="n">d</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># check that they have been made and exist: we need this</span> + <span class="c1"># because on network mounts (NFS) there's often a delay between the mkdir</span> + <span class="c1"># above and the actual directory being made. This shouldn't be too long...</span> + <span class="n">fail</span> <span class="o">=</span> <span class="kc">True</span> + <span class="n">count</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">count_warn</span> <span class="o">=</span> <span class="mi">10</span> + <span class="k">while</span> <span class="n">fail</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> + <span class="n">fail</span> <span class="o">=</span> <span class="kc">False</span> + <span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span> + <span class="k">if</span> <span class="n">count</span> <span class="o">></span> <span class="n">count_warn</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Warning: Have been waiting about </span><span class="si">{count}</span><span class="s2"> seconds for Slurm directories to be made, there seems to be significant delay..."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">count</span><span class="o">=</span><span class="n">count</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">dirs</span><span class="p">:</span> + <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span> + <span class="n">fail</span> <span class="o">=</span> <span class="kc">True</span> + <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> + <span class="k">break</span></div> + +<div class="viewcode-block" id="slurm.slurm_grid"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_grid">[docs]</a> <span class="k">def</span> <span class="nf">slurm_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="c1"># pragma: no cover</span> + <span class="sd">"""</span> +<span class="sd"> function to be called when running grids when grid_options['slurm']>=1</span> + +<span class="sd"> if grid_options['slurm']==1, we set up the slurm script and launch the jobs, then return True to exit.</span> +<span class="sd"> if grid_options['slurm']==2, we run the stars, which means we return False to continue.</span> +<span class="sd"> if grid_options['slurm']==3, we are being called from the jobs to run the grids, return False to continue.</span> + +<span class="sd"> TODO: split this function into some parts</span> +<span class="sd"> TODO: Comment this function better</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> + <span class="c1"># run a grid of stars only, leaving the results</span> + <span class="c1"># in the appropriate outfile</span> + <span class="k">return</span> <span class="kc">False</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span> + <span class="c1"># joining : set the evolution type to "join" and return</span> + <span class="c1"># False to continue</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"join"</span> + <span class="k">return</span> <span class="kc">False</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="c1"># if slurm=1, we should have no evolution type, we</span> + <span class="c1"># set up the Slurm scripts and get them evolving</span> + <span class="c1"># in a Slurm array</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"evolution_type"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="c1"># make dirs</span> + <span class="bp">self</span><span class="o">.</span><span class="n">make_slurm_dirs</span><span class="p">()</span> + + <span class="c1"># check we're not using too much RAM</span> + <span class="k">if</span> <span class="n">datasize</span><span class="o">.</span><span class="n">DataSize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_memory"</span><span class="p">])</span> <span class="o">></span> <span class="n">datasize</span><span class="o">.</span><span class="n">DataSize</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_warn_max_memory"</span><span class="p">]</span> + <span class="p">):</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"WARNING: you want to use </span><span class="si">{slurm_memory}</span><span class="s2"> MB of RAM : this is unlikely to be correct. If you believe it is, set slurm_warn_max_memory to something very large (it is currently </span><span class="si">{slurm_warn_max_memory}</span><span class="s2"> MB)</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">slurm_memory</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_memory"</span><span class="p">],</span> + <span class="n">slurm_warn_max_memory</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"slurm_warn_max_memory"</span> + <span class="p">],</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># set up slurm_array</span> + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_array_max_jobs"</span><span class="p">]:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_array_max_jobs"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"slurm_njobs"</span> + <span class="p">]</span> + <span class="n">slurm_array</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span> + <span class="s2">"slurm_array"</span> + <span class="p">]</span> <span class="ow">or</span> <span class="s2">"1-</span><span class="si">{njobs}</span><span class="s2">%</span><span class="si">{max_jobs}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">njobs</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_njobs"</span><span class="p">],</span> + <span class="n">max_jobs</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_array_max_jobs"</span><span class="p">],</span> + <span class="p">)</span> + + <span class="c1"># get job id (might be passed in)</span> + <span class="c1"># TODO: is this variable used?</span> + <span class="n">jobid</span> <span class="o">=</span> <span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_jobid"</span><span class="p">]</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_jobid"</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">""</span> + <span class="k">else</span> <span class="s2">"$SLURM_ARRAY_JOB_ID"</span> + <span class="p">)</span> + + <span class="c1"># get job array index</span> + <span class="n">jobarrayindex</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_jobarrayindex"</span><span class="p">]</span> + <span class="k">if</span> <span class="n">jobarrayindex</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">jobarrayindex</span> <span class="o">=</span> <span class="s2">"$SLURM_ARRAY_TASK_ID"</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_njobs"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"binary_c-python Slurm : You must set grid_option slurm_njobs to be non-zero"</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> + + <span class="c1"># build the grid command</span> + <span class="n">grid_command</span> <span class="o">=</span> <span class="p">(</span> + <span class="p">[</span> + <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_env"</span><span class="p">]),</span> + <span class="n">sys</span><span class="o">.</span><span class="n">executable</span><span class="p">,</span> + <span class="nb">str</span><span class="p">(</span><span class="n">lib_programname</span><span class="o">.</span><span class="n">get_path_executed_script</span><span class="p">()),</span> + <span class="p">]</span> + <span class="o">+</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> + <span class="o">+</span> <span class="p">[</span> + <span class="s2">"start_at=$(("</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">jobarrayindex</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"-1))"</span><span class="p">,</span> + <span class="s2">"modulo="</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_njobs"</span><span class="p">]),</span> + <span class="s2">"slurm_njobs="</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_njobs"</span><span class="p">]),</span> + <span class="s2">"slurm_dir="</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">],</span> + <span class="s2">"verbosity="</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"verbosity"</span><span class="p">]),</span> + <span class="s2">"num_cores="</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">]),</span> + <span class="p">]</span> + <span class="p">)</span> + + <span class="c1"># wrap command arguments in quotes</span> + <span class="n">grid_command</span> <span class="o">=</span> <span class="n">command_string_from_list</span><span class="p">(</span><span class="n">grid_command</span><span class="p">)</span> + + <span class="c1"># make slurm script</span> + <span class="n">scriptpath</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">slurmpath</span><span class="p">(</span><span class="s2">"slurm_script"</span><span class="p">)</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">script</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">scriptpath</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">IOError</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Could not open Slurm script at </span><span class="si">{path}</span><span class="s2"> for writing: please check you have set </span><span class="si">{slurm_dir}</span><span class="s2"> correctly (it is currently </span><span class="si">{slurm_dir}</span><span class="s2"> and can write to this directory."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">path</span><span class="o">=</span><span class="n">scriptpath</span><span class="p">,</span> <span class="n">slurm_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">]</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="n">slurmscript</span> <span class="o">=</span> <span class="s2">"""#!</span><span class="si">{bash}</span><span class="s2"></span> +<span class="s2"># Slurm launch script created by binary_c-python</span> + +<span class="s2"># Slurm options</span> +<span class="s2">#SBATCH --error=</span><span class="si">{slurm_dir}</span><span class="s2">/stderr/%A.</span><span class="si">%a</span><span class="s2"></span> +<span class="s2">#SBATCH --output=</span><span class="si">{slurm_dir}</span><span class="s2">/stdout/%A.</span><span class="si">%a</span><span class="s2"></span> +<span class="s2">#SBATCH --job-name=</span><span class="si">{slurm_jobname}</span><span class="s2"></span> +<span class="s2">#SBATCH --partition=</span><span class="si">{slurm_partition}</span><span class="s2"></span> +<span class="s2">#SBATCH --time=</span><span class="si">{slurm_time}</span><span class="s2"></span> +<span class="s2">#SBATCH --mem=</span><span class="si">{slurm_memory}</span><span class="s2"></span> +<span class="s2">#SBATCH --ntasks=</span><span class="si">{slurm_ntasks}</span><span class="s2"></span> +<span class="s2">#SBATCH --array=</span><span class="si">{slurm_array}</span><span class="s2"></span> +<span class="s2">#SBATCH --cpus-per-task=</span><span class="si">{ncpus}</span><span class="s2"></span> +<span class="s2">"""</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">bash</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_bash"</span><span class="p">],</span> + <span class="n">slurm_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">],</span> + <span class="n">slurm_jobname</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_jobname"</span><span class="p">],</span> + <span class="n">slurm_partition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_partition"</span><span class="p">],</span> + <span class="n">slurm_time</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_time"</span><span class="p">],</span> + <span class="n">slurm_ntasks</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_ntasks"</span><span class="p">],</span> + <span class="n">slurm_memory</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_memory"</span><span class="p">],</span> + <span class="n">slurm_array</span><span class="o">=</span><span class="n">slurm_array</span><span class="p">,</span> + <span class="n">ncpus</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_processes"</span><span class="p">],</span> + <span class="p">)</span> + + <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_extra_settings"</span><span class="p">]:</span> + <span class="n">slurmscript</span> <span class="o">+=</span> <span class="s2">"#SBATCH --</span><span class="si">{key}</span><span class="s2"> = </span><span class="si">{value}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">key</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_extra_settings"</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> + <span class="p">)</span> + + <span class="n">slurmscript</span> <span class="o">+=</span> <span class="s2">"""</span> + +<span class="s2">export BINARY_C_PYTHON_ORIGINAL_CMD_LINE=</span><span class="si">{cmdline}</span><span class="s2"></span> +<span class="s2">export BINARY_C_PYTHON_ORIGINAL_WD=`</span><span class="si">{pwd}</span><span class="s2">`</span> +<span class="s2">export BINARY_C_PYTHON_ORIGINAL_SUBMISSION_TIME=`</span><span class="si">{date}</span><span class="s2">`</span> + +<span class="s2"># set status to </span><span class="se">\"</span><span class="s2">running</span><span class="se">\"</span><span class="s2"></span> +<span class="s2">echo </span><span class="se">\"</span><span class="s2">running</span><span class="se">\"</span><span class="s2"> > "</span><span class="si">{slurm_dir}</span><span class="s2">/status/$SLURM_ARRAY_JOB_ID.$SLURM_ARRAY_TASK_ID"</span> + +<span class="s2"># make list of files which is checked for joining</span> +<span class="s2"># echo "</span><span class="si">{slurm_dir}</span><span class="s2">/results/$SLURM_ARRAY_JOB_ID.$SLURM_ARRAY_TASK_ID.gz" >> "</span><span class="si">{slurm_dir}</span><span class="s2">/results/$SLURM_ARRAY_JOB_ID.all"</span> + +<span class="s2"># run grid of stars and, if this returns 0, set status to finished</span> +<span class="si">{grid_command}</span><span class="s2"> "slurm=2" "evolution_type=grid" "slurm_jobid=$SLURM_ARRAY_JOB_ID" "slurm_jobarrayindex=$SLURM_ARRAY_TASK_ID" "save_population_object=</span><span class="si">{slurm_dir}</span><span class="s2">/results/$SLURM_ARRAY_JOB_ID.$SLURM_ARRAY_TASK_ID.gz" && echo -n </span><span class="se">\"</span><span class="s2">finished</span><span class="se">\"</span><span class="s2"> > "</span><span class="si">{slurm_dir}</span><span class="s2">/status/$SLURM_ARRAY_JOB_ID.$SLURM_ARRAY_TASK_ID" && echo """</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">slurm_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">],</span> + <span class="n">grid_command</span><span class="o">=</span><span class="n">grid_command</span><span class="p">,</span> + <span class="n">cmdline</span><span class="o">=</span><span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"command_line"</span><span class="p">]),</span> + <span class="n">date</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_date"</span><span class="p">],</span> + <span class="n">pwd</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_pwd"</span><span class="p">],</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_postpone_join"</span><span class="p">]:</span> + <span class="n">slurmscript</span> <span class="o">+=</span> <span class="s2">"""&& echo </span><span class="se">\"</span><span class="s2">Checking if we can join...</span><span class="se">\"</span><span class="s2"> && echo && </span><span class="si">{grid_command}</span><span class="s2"> "slurm=3" "evolution_type=join" "joinlist=</span><span class="si">{slurm_dir}</span><span class="s2">/results/$SLURM_ARRAY_JOB_ID.all" "slurm_jobid=$SLURM_ARRAY_JOB_ID" "slurm_jobarrayindex=$SLURM_ARRAY_TASK_ID"</span> +<span class="s2"> """</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">slurm_dir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_dir"</span><span class="p">],</span> + <span class="n">grid_command</span><span class="o">=</span><span class="n">grid_command</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">slurmscript</span> <span class="o">+=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> + + <span class="c1"># write to script, close it and make it executable by</span> + <span class="c1"># all (so the slurm user can pick it up)</span> + <span class="n">script</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">slurmscript</span><span class="p">)</span> + <span class="n">script</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <span class="n">os</span><span class="o">.</span><span class="n">chmod</span><span class="p">(</span> + <span class="n">scriptpath</span><span class="p">,</span> + <span class="n">stat</span><span class="o">.</span><span class="n">S_IREAD</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IWRITE</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IEXEC</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IRGRP</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IXGRP</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IROTH</span> + <span class="o">|</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IXOTH</span><span class="p">,</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_postpone_sbatch"</span><span class="p">]:</span> + <span class="c1"># call sbatch to launch the jobs</span> + <span class="n">cmd</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_sbatch"</span><span class="p">],</span> <span class="n">scriptpath</span><span class="p">]</span> + + <span class="k">with</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span> + <span class="n">cmd</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stderr</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span> + <span class="p">)</span> <span class="k">as</span> <span class="n">pipes</span><span class="p">:</span> + + <span class="n">std_out</span><span class="p">,</span> <span class="n">std_err</span> <span class="o">=</span> <span class="n">pipes</span><span class="o">.</span><span class="n">communicate</span><span class="p">()</span> + <span class="k">if</span> <span class="n">pipes</span><span class="o">.</span><span class="n">returncode</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span> + <span class="c1"># an error happened!</span> + <span class="n">err_msg</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{red}{err}</span><span class="se">\n</span><span class="s2">Return Code: </span><span class="si">{code}{reset}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">err</span><span class="o">=</span><span class="n">std_err</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> + <span class="n">code</span><span class="o">=</span><span class="n">pipes</span><span class="o">.</span><span class="n">returncode</span><span class="p">,</span> + <span class="n">red</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"red"</span><span class="p">],</span> + <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="p">)</span> + <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">err_msg</span><span class="p">)</span> + + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">std_err</span><span class="p">):</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{red}{err}{reset}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">red</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"red"</span><span class="p">],</span> + <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="n">err</span><span class="o">=</span><span class="n">std_err</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">),</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{yellow}{out}{reset}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">yellow</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"yellow"</span><span class="p">],</span> + <span class="n">reset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ANSI_colours</span><span class="p">[</span><span class="s2">"reset"</span><span class="p">],</span> + <span class="n">out</span><span class="o">=</span><span class="n">std_out</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">),</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># just say we would have (use this for testing)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Slurm script is at </span><span class="si">{path}</span><span class="s2"> but has not been launched"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">path</span><span class="o">=</span><span class="n">scriptpath</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="c1"># some messages to the user, then return</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"slurm_postpone_sbatch"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Slurm script written, but launching the jobs with sbatch was postponed."</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Slurm jobs launched"</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"All done in slurm_grid()."</span><span class="p">)</span> + + <span class="c1"># return True so we exit immediately</span> + <span class="k">return</span> <span class="kc">True</span></div> + +<div class="viewcode-block" id="slurm.slurm_queue_stats"><a class="viewcode-back" href="../../../../population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_queue_stats">[docs]</a> <span class="k">def</span> <span class="nf">slurm_queue_stats</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="c1"># pragma: no cover</span> + <span class="sd">"""</span> +<span class="sd"> Function to XXX</span> + +<span class="sd"> TODO</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="kc">None</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/spacing_functions.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/spacing_functions.html new file mode 100644 index 0000000000000000000000000000000000000000..e49fe3d0662fde1325c6f85222d8af9ac5c8c071 --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/spacing_functions.html @@ -0,0 +1,797 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.spacing_functions — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.spacing_functions</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.spacing_functions</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">Module containing the spacing functions for the binarycpython package. Very under-populated at the moment, but more are likely to come soon</span> + +<span class="sd">This class object is an extension to the population grid object</span> + +<span class="sd">Tasks:</span> +<span class="sd"> TODO: add more spacing functions to this module.</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E1101</span> + +<span class="kn">import</span> <span class="nn">sys</span> +<span class="kn">import</span> <span class="nn">math</span> +<span class="kn">import</span> <span class="nn">json</span> +<span class="kn">import</span> <span class="nn">functools</span> +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span> +<span class="kn">import</span> <span class="nn">traceback</span> + +<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> +<span class="kn">import</span> <span class="nn">cachetools</span> +<span class="kn">import</span> <span class="nn">diskcache</span> + + + +<span class="kn">import</span> <span class="nn">py_rinterpolate</span> + + +<div class="viewcode-block" id="spacing_functions"><a class="viewcode-back" href="../../../../population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions">[docs]</a><span class="k">class</span> <span class="nc">spacing_functions</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Extension for the Population class containing the code for spacing functions</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the spacing_functions class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + +<div class="viewcode-block" id="spacing_functions.const_linear"><a class="viewcode-back" href="../../../../population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_linear">[docs]</a> <span class="nd">@cachetools</span><span class="o">.</span><span class="n">cachedmethod</span><span class="p">(</span><span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">[</span><span class="s2">"spacing_functions.const_linear"</span><span class="p">])</span> + <span class="k">def</span> <span class="nf">const_linear</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> <span class="n">min_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">max_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">steps</span><span class="p">:</span> <span class="nb">int</span> + <span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Samples a range linearly. Uses numpy linspace, and returns an array of floats. Do NOT use this for integers.</span> + +<span class="sd"> Args:</span> +<span class="sd"> min_bound: lower bound of range</span> +<span class="sd"> max_bound: upper bound of range</span> +<span class="sd"> steps: number of segments between min_bound and max_bound</span> + +<span class="sd"> Returns:</span> +<span class="sd"> np.linspace(min_bound, max_bound, steps)</span> +<span class="sd"> """</span> + <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="n">min_bound</span><span class="p">,</span> <span class="n">max_bound</span><span class="p">,</span> <span class="n">steps</span><span class="p">)</span></div> + +<div class="viewcode-block" id="spacing_functions.const_int"><a class="viewcode-back" href="../../../../population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_int">[docs]</a> <span class="nd">@cachetools</span><span class="o">.</span><span class="n">cachedmethod</span><span class="p">(</span><span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">[</span><span class="s2">"spacing_functions.const_int"</span><span class="p">])</span> + <span class="k">def</span> <span class="nf">const_int</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> <span class="n">min_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">max_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">steps</span><span class="p">:</span> <span class="nb">int</span> + <span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Samples an integer range linearly. Returns a list of ints.</span> + +<span class="sd"> Args:</span> +<span class="sd"> min_bound: lower bound of range, must be an integer (is converted to int)</span> +<span class="sd"> max_bound: upper bound of range, must be an integer (is converted to int)</span> +<span class="sd"> steps: number of segments between min_bound and max_bound</span> + +<span class="sd"> Returns:</span> +<span class="sd"> range(min_bound,max_bound,step)</span> + +<span class="sd"> where step is int((int(max_bound)-int(min_bound))/steps)</span> +<span class="sd"> """</span> + + <span class="n">step</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="n">max_bound</span><span class="p">)</span> <span class="o">-</span> <span class="nb">int</span><span class="p">(</span><span class="n">min_bound</span><span class="p">))</span> <span class="o">/</span> <span class="nb">max</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">steps</span> <span class="o">-</span> <span class="mi">1</span><span class="p">))</span> + <span class="k">if</span> <span class="n">steps</span> <span class="o"><=</span> <span class="mi">1</span><span class="p">:</span> + <span class="k">return</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">min_bound</span><span class="p">)]</span> + <span class="k">return</span> <span class="nb">range</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">min_bound</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">max_bound</span> <span class="o">+</span> <span class="n">step</span><span class="p">),</span> <span class="n">step</span><span class="p">)</span></div> + + <span class="c1">############################################################</span> +<div class="viewcode-block" id="spacing_functions.const_ranges"><a class="viewcode-back" href="../../../../population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_ranges">[docs]</a> <span class="nd">@cachetools</span><span class="o">.</span><span class="n">cachedmethod</span><span class="p">(</span><span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">[</span><span class="s2">"spacing_functions.const_ranges"</span><span class="p">])</span> + <span class="k">def</span> <span class="nf">const_ranges</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ranges</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Samples a series of ranges linearly.</span> + +<span class="sd"> Args:</span> +<span class="sd"> ranges: a tuple of tuples passed to the self.const_linear() spacing function.</span> + +<span class="sd"> Returns:</span> +<span class="sd"> numpy array of masses</span> + +<span class="sd"> Example:</span> +<span class="sd"> The following allocates 10 stars between 0.1 and 0.65, 20 stars between 0.65</span> +<span class="sd"> and 0.85, and 10 stars between 0.85 and 10.0 Msun::</span> + +<span class="sd"> samplerfunc="const_ranges((({},{},{}),({},{},{}),({},{},{})))".format(</span> +<span class="sd"> 0.1, 0.65, 10,</span> +<span class="sd"> 0.65, 0.85, 20,</span> +<span class="sd"> 0.85, 10.0, 10</span> +<span class="sd"> )</span> + +<span class="sd"> """</span> + + <span class="n">masses</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> + <span class="k">for</span> <span class="n">valuerange</span> <span class="ow">in</span> <span class="n">ranges</span><span class="p">:</span> + <span class="n">masses</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">masses</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">const_linear</span><span class="p">(</span><span class="o">*</span><span class="n">valuerange</span><span class="p">))</span> + <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">unique</span><span class="p">(</span><span class="n">masses</span><span class="p">)</span></div> + + <span class="c1">############################################################</span> +<div class="viewcode-block" id="spacing_functions.peak_normalized_gaussian_func"><a class="viewcode-back" href="../../../../population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.peak_normalized_gaussian_func">[docs]</a> <span class="k">def</span> <span class="nf">peak_normalized_gaussian_func</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">mean</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">sigma</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]</span> + <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Function to evaluate a Gaussian at a given point, note</span> +<span class="sd"> that the normalization is such that the peak is always 1.0,</span> +<span class="sd"> not that the integral is 1.0</span> + +<span class="sd"> Args:</span> +<span class="sd"> x: location at which to evaluate the distribution</span> +<span class="sd"> mean: mean of the Gaussian</span> +<span class="sd"> sigma: standard deviation of the Gaussian</span> + +<span class="sd"> Returns:</span> +<span class="sd"> value of the Gaussian at x</span> +<span class="sd"> """</span> + + <span class="n">gaussian_prefactor</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="c1"># / math.sqrt(2.0 * math.pi)</span> + + <span class="n">r</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">sigma</span> + <span class="n">y</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">mean</span><span class="p">)</span> <span class="o">*</span> <span class="n">r</span> + <span class="k">return</span> <span class="n">gaussian_prefactor</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span> <span class="o">*</span> <span class="n">y</span> <span class="o">**</span> <span class="mi">2</span><span class="p">)</span></div> + + <span class="c1">############################################################</span> +<div class="viewcode-block" id="spacing_functions.gaussian_zoom"><a class="viewcode-back" href="../../../../population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.gaussian_zoom">[docs]</a> <span class="nd">@cachetools</span><span class="o">.</span><span class="n">cachedmethod</span><span class="p">(</span> + <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">caches</span><span class="p">[</span><span class="s2">"spacing_functions.gaussian_zoom"</span><span class="p">]</span> + <span class="p">)</span> + <span class="k">def</span> <span class="nf">gaussian_zoom</span><span class="p">(</span> + <span class="bp">self</span><span class="p">,</span> + <span class="n">min_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">max_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">zoom_mean</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">zoom_dispersion</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">zoom_magnitude</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> + <span class="n">steps</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> + <span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Samples such that a region is zoomed in according to a 1-Gaussian function</span> + +<span class="sd"> Args:</span> +<span class="sd"> min_bound: lower bound of range</span> +<span class="sd"> max_bound: upper bound of range</span> +<span class="sd"> zoom_mean: mean of the Gaussian zoom location</span> +<span class="sd"> zoom_dispersion: dispersion of the Gaussian</span> +<span class="sd"> zoom_magnitude: depth of the Gaussian (should be 0<= zoom_magntiude <1)</span> +<span class="sd"> steps: number of segments between min_bound and max_bound assuming a linear step</span> +<span class="sd"> this is what you'd normally call "resolution"</span> + +<span class="sd"> Returns:</span> +<span class="sd"> Numpy array of sample values</span> +<span class="sd"> """</span> + + <span class="c1"># linear spacing: this is what we'd have</span> + <span class="c1"># in the absence of a Gaussian zoom</span> + <span class="n">linear_spacing</span> <span class="o">=</span> <span class="p">(</span><span class="n">max_bound</span> <span class="o">-</span> <span class="n">min_bound</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">steps</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> + + <span class="c1"># make the list of values</span> + <span class="n">x</span> <span class="o">=</span> <span class="n">min_bound</span> + <span class="n">array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([])</span> + <span class="k">while</span> <span class="n">x</span> <span class="o"><=</span> <span class="n">max_bound</span><span class="p">:</span> + <span class="n">array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">array</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span> + <span class="n">g</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">peak_normalized_gaussian_func</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">zoom_mean</span><span class="p">,</span> <span class="n">zoom_dispersion</span><span class="p">)</span> + <span class="n">f</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">-</span> <span class="n">zoom_magnitude</span> <span class="o">*</span> <span class="n">g</span> + <span class="n">dx</span> <span class="o">=</span> <span class="n">linear_spacing</span> <span class="o">*</span> <span class="n">f</span> + <span class="n">x</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">dx</span> + + <span class="c1"># force the last array member to be max_bound if it's not</span> + <span class="k">if</span> <span class="n">array</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="n">max_bound</span><span class="p">:</span> + <span class="n">array</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">max_bound</span> + + <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">unique</span><span class="p">(</span><span class="n">array</span><span class="p">)</span></div> + +<div class="viewcode-block" id="spacing_functions.const_dt"><a class="viewcode-back" href="../../../../population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_dt">[docs]</a> <span class="k">def</span> <span class="nf">const_dt</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cachedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">usecache</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> const_dt returns a list of masses spaced at a constant age difference</span> + +<span class="sd"> Args:</span> +<span class="sd"> dt: the time difference between the masses (1000.0 Myr, used when logspacing==False)</span> +<span class="sd"> dlogt : the delta log10(time) difference between masses (0.1 dex, used when logspacing==True)</span> +<span class="sd"> mmin: the minimum mass to be considered in the stellar lifetime interpolation table (0.07 Msun)</span> +<span class="sd"> mmax: the maximum mass to be considered in the stellar lifetime interpolation table (100.0 Msun)</span> +<span class="sd"> nres: the resolution of the stellar lifetime interpolation table (100)</span> +<span class="sd"> logspacing: whether to use log-spaced time, in which case dt is actually d(log10(t))</span> +<span class="sd"> tmin: the minimum time to consider (Myr, default 3.0 Myr)</span> +<span class="sd"> tmax: the maximum time to consider (Myr, default None which means we use the grid option 'max_evolution_time')</span> +<span class="sd"> max_evolution_time: overrides bse_options['max_evolution_time'] if set</span> +<span class="sd"> mindm: a tuple of tuples containing a mass range and minimum mass spacing in that range. The default is ((0.07,1.0,0.1),(1.0,300.0,1.0)) allocated a minimum dm of 0.1Msun in the mass range 0.07 to 1.0 Msun and 1.0Msun in the range 1.0 to 300.0 Msun. Anything you set overrides this. Note, if you use only one tuple, you must set it with a trailing comma, thus, e.g. ((0.07,1.0,0.1),). (default None)</span> +<span class="sd"> maxdm: a list of tuples similar to mindm but specifying a maximum mass spacing. In the case of maxdm, if the third option in each tuple is negative it is treated as a log step (its absolute value is used as the step). (default None)</span> +<span class="sd"> fsample: a global sampling (Shannon-like) factor (<1) to improve resolution (default 1.0, set to smaller to improve resolution)</span> +<span class="sd"> factor: all masses generated are multiplied by this after generation</span> +<span class="sd"> showtable: if True, the mass list and times are shown to stdout after generation</span> +<span class="sd"> showlist: if True, show the mass list once generated</span> +<span class="sd"> logmasses: if True, the masses are logged with math.log()</span> +<span class="sd"> log10masses: if True, the masses are logged with math.log10()</span> +<span class="sd"> usecache: if True (the default) uses cached results if they are saved (in cachedir) and cachedir is not None</span> +<span class="sd"> cachedir: where the cache is stored. if None, defaults to grid_options['cache_dir']+'/const_dt_cache'</span> +<span class="sd"> vb : verbose logging flag (default False)</span> + +<span class="sd"> Returns:</span> +<span class="sd"> Array of masses.</span> + +<span class="sd"> Example:</span> +<span class="sd"> these are lines set as options to Population.add_grid_value(...)::</span> + +<span class="sd"> # linear time bins of 1Gyr</span> +<span class="sd"> samplerfunc="self.const_dt(self,dt=1000,nres=100,mmin=0.07,mmax=2.0,showtable=True)"</span> + +<span class="sd"> # logarithmic spacing in time, generally suitable for Galactic chemical evolution yield grids.</span> +<span class="sd"> samplerfunc="self.const_dt(self,dlogt=0.1,nres=100,mmin=0.07,mmax=80.0,maxdm=((0.07,1.0,0.1),(1.0,10.0,1.0),(10.0,80.0,2.0)),showtable=True,logspacing=True,fsample=1.0/4.0)"</span> + +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">usecache</span><span class="p">:</span> + <span class="k">if</span> <span class="n">cachedir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">cachedir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"cache_dir"</span><span class="p">]</span> + + <span class="k">if</span> <span class="n">cachedir</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">cachedir</span> <span class="o">+=</span> <span class="s2">"/const_dt_cache"</span> + <span class="n">cache</span> <span class="o">=</span> <span class="n">diskcache</span><span class="o">.</span><span class="n">Cache</span><span class="p">(</span><span class="n">cachedir</span><span class="p">)</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Use const_dt cache in </span><span class="si">{}</span><span class="s2"> [cache object </span><span class="si">{}</span><span class="s2">]"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">cachedir</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"const_dt uses no cache"</span><span class="p">)</span> + <span class="n">cache</span> <span class="o">=</span> <span class="kc">None</span> + + <span class="k">def</span> <span class="nf">_const_dt_wrapper</span><span class="p">(</span> + <span class="n">cachedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">num_cores</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">bse_options</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">dt</span><span class="o">=</span><span class="mf">1000.0</span><span class="p">,</span> + <span class="n">dlogt</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> + <span class="n">mmin</span><span class="o">=</span><span class="mf">0.07</span><span class="p">,</span> + <span class="n">mmax</span><span class="o">=</span><span class="mf">100.0</span><span class="p">,</span> + <span class="n">nres</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span> + <span class="n">logspacing</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">tmin</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span> <span class="c1"># start at 3Myr</span> + <span class="n">tmax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="c1"># use max_evolution_time by default</span> + <span class="n">max_evolution_time</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">mindm</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="c1"># tuple of tuples</span> + <span class="n">maxdm</span><span class="o">=</span><span class="p">((</span><span class="mf">0.07</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">),</span> <span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">300.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)),</span> <span class="c1"># tuple of tuples</span> + <span class="n">fsample</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> + <span class="n">factor</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> + <span class="n">logmasses</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">log10masses</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">showlist</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">showtable</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">usecache</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="n">vb</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Wrapper function for the const_dt funtion which handles verbose logging and filtering of arguments</span> +<span class="sd"> """</span> + + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"call _const_dt num_cores=</span><span class="si">{}</span><span class="s2"> dt=</span><span class="si">{}</span><span class="s2"> dlogt=</span><span class="si">{}</span><span class="s2"> mmin=</span><span class="si">{}</span><span class="s2"> mmax=</span><span class="si">{}</span><span class="s2"> nres=</span><span class="si">{}</span><span class="s2"> logspacing=</span><span class="si">{}</span><span class="s2"> tmin=</span><span class="si">{}</span><span class="s2"> mindm=</span><span class="si">{}</span><span class="s2"> maxdm=</span><span class="si">{}</span><span class="s2"> fsample=</span><span class="si">{}</span><span class="s2"> factor=</span><span class="si">{}</span><span class="s2"> logmasses=</span><span class="si">{}</span><span class="s2"> log10masses=</span><span class="si">{}</span><span class="s2"> showlist=</span><span class="si">{}</span><span class="s2"> usecache=</span><span class="si">{}</span><span class="s2"> [cache=</span><span class="si">{}</span><span class="s2"> vb=</span><span class="si">{}</span><span class="s2">]"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">num_cores</span><span class="p">,</span> + <span class="n">dt</span><span class="p">,</span> + <span class="n">dlogt</span><span class="p">,</span> + <span class="n">mmin</span><span class="p">,</span> + <span class="n">mmax</span><span class="p">,</span> + <span class="n">nres</span><span class="p">,</span> + <span class="n">logspacing</span><span class="p">,</span> + <span class="n">tmin</span><span class="p">,</span> + <span class="n">mindm</span><span class="p">,</span> + <span class="n">maxdm</span><span class="p">,</span> + <span class="n">fsample</span><span class="p">,</span> + <span class="n">factor</span><span class="p">,</span> + <span class="n">logmasses</span><span class="p">,</span> + <span class="n">log10masses</span><span class="p">,</span> + <span class="n">showlist</span><span class="p">,</span> + <span class="n">usecache</span><span class="p">,</span> + <span class="n">cache</span><span class="p">,</span> + <span class="n">vb</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="n">traceback</span><span class="o">.</span><span class="n">print_stack</span><span class="p">()</span> + + <span class="c1"># strip bse_options of options that will not affect</span> + <span class="c1"># _const_dt</span> + <span class="n">bse_stripped</span> <span class="o">=</span> <span class="n">bse_options</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> + + <span class="n">del_keys</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"multiplicity"</span><span class="p">]</span> + <span class="k">for</span> <span class="n">del_key</span> <span class="ow">in</span> <span class="n">del_keys</span><span class="p">:</span> + <span class="k">if</span> <span class="n">del_key</span> <span class="ow">in</span> <span class="n">bse_stripped</span><span class="p">:</span> + <span class="k">del</span> <span class="n">bse_stripped</span><span class="p">[</span><span class="n">del_key</span><span class="p">]</span> + + <span class="c1"># make a JSON string of the options (this can be</span> + <span class="c1"># used to check the cache)</span> + <span class="n">bse_options_json</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span> + <span class="n">bse_stripped</span><span class="p">,</span> <span class="n">sort_keys</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">ensure_ascii</span><span class="o">=</span><span class="kc">False</span> + <span class="p">)</span> + <span class="k">if</span> <span class="n">vb</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"BSE options JSON:"</span><span class="p">,</span> <span class="n">bse_options_json</span><span class="p">)</span> + + <span class="k">return</span> <span class="n">_const_dt</span><span class="p">(</span> + <span class="n">cachedir</span><span class="o">=</span><span class="n">cachedir</span><span class="p">,</span> + <span class="n">num_cores</span><span class="o">=</span><span class="n">num_cores</span><span class="p">,</span> + <span class="n">bse_options_json</span><span class="o">=</span><span class="n">bse_options_json</span><span class="p">,</span> + <span class="n">dt</span><span class="o">=</span><span class="n">dt</span><span class="p">,</span> + <span class="n">dlogt</span><span class="o">=</span><span class="n">dlogt</span><span class="p">,</span> + <span class="n">mmin</span><span class="o">=</span><span class="n">mmin</span><span class="p">,</span> + <span class="n">mmax</span><span class="o">=</span><span class="n">mmax</span><span class="p">,</span> + <span class="n">nres</span><span class="o">=</span><span class="n">nres</span><span class="p">,</span> + <span class="n">logspacing</span><span class="o">=</span><span class="n">logspacing</span><span class="p">,</span> + <span class="n">tmin</span><span class="o">=</span><span class="n">tmin</span><span class="p">,</span> + <span class="n">tmax</span><span class="o">=</span><span class="n">tmax</span><span class="p">,</span> + <span class="n">max_evolution_time</span><span class="o">=</span><span class="n">max_evolution_time</span><span class="p">,</span> + <span class="n">mindm</span><span class="o">=</span><span class="n">mindm</span><span class="p">,</span> + <span class="n">maxdm</span><span class="o">=</span><span class="n">maxdm</span><span class="p">,</span> + <span class="n">fsample</span><span class="o">=</span><span class="n">fsample</span><span class="p">,</span> + <span class="n">logmasses</span><span class="o">=</span><span class="n">logmasses</span><span class="p">,</span> + <span class="n">log10masses</span><span class="o">=</span><span class="n">log10masses</span><span class="p">,</span> + <span class="n">showlist</span><span class="o">=</span><span class="n">showlist</span><span class="p">,</span> + <span class="n">showtable</span><span class="o">=</span><span class="n">showtable</span><span class="p">,</span> + <span class="n">usecache</span><span class="o">=</span><span class="n">usecache</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># if we want to use the cache, set the __decorator</span> + <span class="c1"># to just be the cache.memoize function, otherwise</span> + <span class="c1"># make it a wrapped function that just returns the</span> + <span class="c1"># _const_dt function acting on its arguments</span> + <span class="k">def</span> <span class="nf">__dummy_decorator</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Placeholder decorator function</span> +<span class="sd"> """</span> + + <span class="nd">@functools</span><span class="o">.</span><span class="n">wraps</span><span class="p">(</span><span class="n">func</span><span class="p">)</span> + <span class="k">def</span> <span class="nf">wrapped</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Dummy wrapper function</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> + + <span class="k">return</span> <span class="n">wrapped</span> + + <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> + <span class="n">__decorator</span> <span class="o">=</span> <span class="n">cache</span><span class="o">.</span><span class="n">memoize</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">__decorator</span> <span class="o">=</span> <span class="n">__dummy_decorator</span> + + <span class="c1">#@cache.memoize() </span> + <span class="nd">@__decorator</span><span class="p">()</span> <span class="c1"># note: () works with python3.9+, maybe not for 3.8</span> + <span class="k">def</span> <span class="nf">_const_dt</span><span class="p">(</span> + <span class="n">cachedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">num_cores</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">bse_options_json</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="c1"># JSON string</span> + <span class="n">dt</span><span class="o">=</span><span class="mf">1000.0</span><span class="p">,</span> + <span class="n">dlogt</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> + <span class="n">mmin</span><span class="o">=</span><span class="mf">0.07</span><span class="p">,</span> + <span class="n">mmax</span><span class="o">=</span><span class="mf">100.0</span><span class="p">,</span> + <span class="n">nres</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span> + <span class="n">logspacing</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">tmin</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span> <span class="c1"># start at 3Myr</span> + <span class="n">tmax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="c1"># use max_evolution_time by default</span> + <span class="n">max_evolution_time</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">mindm</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="c1"># tuple of tuples</span> + <span class="n">maxdm</span><span class="o">=</span><span class="p">((</span><span class="mf">0.07</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">),</span> <span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">300.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)),</span> <span class="c1"># tuple of tuples</span> + <span class="n">fsample</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> + <span class="n">factor</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> + <span class="n">logmasses</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">log10masses</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">showlist</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">showtable</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">usecache</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> + <span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> first thing to do is make a stellar lifetime table</span> + +<span class="sd"> we should use the bse_options_json passed in</span> +<span class="sd"> so our lifetime_population uses the same physics</span> +<span class="sd"> as the main grid</span> + +<span class="sd"> TODO: Describe this function better with arguments and</span> +<span class="sd"> """</span> + + <span class="c1"># convert bse_options to dict</span> + <span class="n">bse_options</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">bse_options_json</span><span class="p">)</span> + + <span class="c1"># perhaps override max_evolution_time</span> + <span class="k">if</span> <span class="n">max_evolution_time</span><span class="p">:</span> + <span class="n">bse_options</span><span class="p">[</span><span class="s2">"max_evolution_time"</span><span class="p">]</span> <span class="o">=</span> <span class="n">max_evolution_time</span> + + <span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="kn">import</span> <span class="n">Population</span> + <span class="n">lifetime_population</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> + <span class="n">lifetime_population</span><span class="o">.</span><span class="n">bse_options</span> <span class="o">=</span> <span class="n">bse_options</span> + + <span class="c1"># we only want to evolve the star during nuclear burning,</span> + <span class="c1"># we don't want a dry run of the grid</span> + <span class="c1"># we want to use the right number of CPU cores</span> + <span class="n">lifetime_population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> + <span class="n">do_dry_run</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">num_cores</span><span class="o">=</span><span class="n">num_cores</span><span class="p">,</span> + <span class="n">max_stellar_type_1</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> + <span class="n">save_ensemble_chunks</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">symlink_latest_gridcode</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">modulo</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">start_at</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> + <span class="n">slurm</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> + <span class="n">condor</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> + <span class="n">multiplicity</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">ensemble</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> + <span class="n">ensemble_dt</span><span class="o">=</span><span class="mf">1e3</span><span class="p">,</span> + <span class="n">ensemble_logdt</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> + <span class="c1"># for debugging</span> + <span class="n">verbosity</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">log_dt</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># make a grid in M1</span> + <span class="n">lifetime_population</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> + <span class="n">name</span><span class="o">=</span><span class="s2">"lnM_1"</span><span class="p">,</span> + <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> + <span class="n">longname</span><span class="o">=</span><span class="s2">"log Primary mass"</span><span class="p">,</span> <span class="c1"># == single-star mass</span> + <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span><span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mmin</span><span class="p">),</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mmax</span><span class="p">)],</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_linear(math.log(</span><span class="si">{mmin}</span><span class="s2">),math.log(</span><span class="si">{mmax}</span><span class="s2">),</span><span class="si">{nres}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">mmin</span><span class="o">=</span><span class="n">mmin</span><span class="p">,</span> <span class="n">mmax</span><span class="o">=</span><span class="n">mmax</span><span class="p">,</span> <span class="n">nres</span><span class="o">=</span><span class="n">nres</span> + <span class="p">),</span> + <span class="n">probdist</span><span class="o">=</span><span class="s2">"1"</span><span class="p">,</span> <span class="c1"># dprob/dm1 : we don't care, so just set it to 1</span> + <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dlnM_1"</span><span class="p">,</span> + <span class="n">precode</span><span class="o">=</span><span class="s2">"M_1=math.exp(lnM_1)"</span><span class="p">,</span> + <span class="n">condition</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="c1"># Impose a condition on this grid variable. Mostly for a check for yourself</span> + <span class="n">gridtype</span><span class="o">=</span><span class="s2">"edge"</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># set up the parse function</span> + <span class="k">def</span> <span class="nf">_parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Parse function for the const_dt binary_c calls</span> +<span class="sd"> """</span> + + <span class="k">if</span> <span class="n">output</span><span class="p">:</span> + <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">():</span> + <span class="n">data</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> + <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"SINGLE_STAR_LIFETIME"</span><span class="p">:</span> + <span class="c1"># append (log10(mass), log10(lifetime)) tuples</span> + <span class="n">logm</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> + <span class="n">logt</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">2</span><span class="p">]))</span> + <span class="c1"># print(line)</span> + <span class="c1"># print("logM=",logm,"M=",10.0**logm," -> logt=",logt)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table m->t"</span><span class="p">][</span><span class="n">logm</span><span class="p">]</span> <span class="o">=</span> <span class="n">logt</span> + <span class="bp">self</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table t->m"</span><span class="p">][</span><span class="n">logt</span><span class="p">]</span> <span class="o">=</span> <span class="n">logm</span> + + <span class="n">lifetime_population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> + <span class="n">parse_function</span><span class="o">=</span><span class="n">_parse_function</span><span class="p">,</span> + <span class="p">)</span> + + <span class="c1"># run to build the interpolation table</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"Running population to make lifetime interpolation table, please wait"</span> + <span class="p">)</span> + <span class="n">lifetime_population</span><span class="o">.</span><span class="n">evolve</span><span class="p">()</span> + <span class="c1"># print("Data table",lifetime_population.grid_results['interpolation table t->m'])</span> + + <span class="k">if</span> <span class="p">(</span> + <span class="s2">"interpolation table t->m"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lifetime_population</span><span class="o">.</span><span class="n">grid_results</span> + <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span> + <span class="n">lifetime_population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table t->m"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + <span class="p">)</span> + <span class="o">==</span> <span class="mi">0</span> + <span class="p">):</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="se">\n\n\n</span><span class="s2">Error: The t->m lifetime table is empty. One usual cause for this is that the tmax or max_evolution_time option (currently passed in to const_dt as </span><span class="si">{tmax}</span><span class="s2">) is too short for there to be any entries in the table before the first timestep. Try increasing tmax and max_evolution_time, shorten the timestep or, if using log times, set tstart to be closer to 0.</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">tmax</span><span class="o">=</span><span class="n">tmax</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span> + + <span class="c1"># convert to nested lists for the interpolator</span> + <span class="c1">#</span> + <span class="c1"># make time -> mass table</span> + <span class="n">data_table_time_mass</span> <span class="o">=</span> <span class="p">[]</span> + <span class="n">times</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span> + <span class="n">lifetime_population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table t->m"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + <span class="p">)</span> + <span class="k">for</span> <span class="n">time</span> <span class="ow">in</span> <span class="n">times</span><span class="p">:</span> + <span class="n">mass</span> <span class="o">=</span> <span class="n">lifetime_population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table t->m"</span><span class="p">][</span> + <span class="n">time</span> + <span class="p">]</span> + <span class="c1"># we have to make sure the time is monotonic (not guaranteed at high mass)</span> + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data_table_time_mass</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> + <span class="n">data_table_time_mass</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">time</span><span class="p">,</span> <span class="n">mass</span><span class="p">])</span> + <span class="k">elif</span> <span class="n">mass</span> <span class="o"><</span> <span class="n">data_table_time_mass</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]:</span> + <span class="n">data_table_time_mass</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">time</span><span class="p">,</span> <span class="n">mass</span><span class="p">])</span> + + <span class="c1"># make mass -> time table</span> + <span class="n">data_table_mass_time</span> <span class="o">=</span> <span class="p">[]</span> + <span class="n">masses</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span> + <span class="n">lifetime_population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table m->t"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> + <span class="p">)</span> + <span class="k">for</span> <span class="n">mass</span> <span class="ow">in</span> <span class="n">masses</span><span class="p">:</span> + <span class="n">time</span> <span class="o">=</span> <span class="n">lifetime_population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table m->t"</span><span class="p">][</span> + <span class="n">mass</span> + <span class="p">]</span> + <span class="n">data_table_mass_time</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">mass</span><span class="p">,</span> <span class="n">time</span><span class="p">])</span> + + <span class="c1"># set up interpolators</span> + <span class="n">interpolator_time_mass</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> + <span class="n">table</span><span class="o">=</span><span class="n">data_table_time_mass</span><span class="p">,</span> + <span class="n">nparams</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">ndata</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="c1"># mass # lifetime</span> + <span class="p">)</span> + <span class="n">interpolator_mass_time</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> + <span class="n">table</span><span class="o">=</span><span class="n">data_table_mass_time</span><span class="p">,</span> + <span class="n">nparams</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">ndata</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> + <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="c1"># lifetime # mass</span> + <span class="p">)</span> + + <span class="k">def</span> <span class="nf">_mass_from_time</span><span class="p">(</span><span class="n">linear_time</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to get a mass given a time, calculated by using the interpolator_time_mass</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="p">(</span> + <span class="mf">10.0</span> + <span class="o">**</span> <span class="n">interpolator_time_mass</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">linear_time</span><span class="p">)])[</span><span class="mi">0</span><span class="p">]</span> + <span class="p">)</span> + + <span class="k">def</span> <span class="nf">_time_from_mass</span><span class="p">(</span><span class="n">mass</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to get a time given a mass, calculated by using the interpolator_time_mass</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="mf">10.0</span> <span class="o">**</span> <span class="n">interpolator_mass_time</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">mass</span><span class="p">)])[</span><span class="mi">0</span><span class="p">]</span> + + <span class="k">def</span> <span class="nf">_uniq</span><span class="p">(</span><span class="n">_list</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return a list containing only unique elements</span> + +<span class="sd"> TODO: move this to the functions file</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">_list</span><span class="p">)))</span> + + <span class="k">def</span> <span class="nf">_format</span><span class="p">(</span><span class="n">_list</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to format a list of numbers as %g strings</span> +<span class="sd"> """</span> + + <span class="k">return</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="s2">"</span><span class="si">{x:g}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">x</span><span class="p">))</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">_list</span><span class="p">]</span> + + <span class="c1"># construct mass list, always include the min and max</span> + <span class="n">mass_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">mmin</span><span class="p">,</span> <span class="n">mmax</span><span class="p">]</span> + + <span class="c1"># first, make sure the stars are separated by only</span> + <span class="c1"># maxdm</span> + <span class="k">if</span> <span class="n">maxdm</span><span class="p">:</span> + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">maxdm</span><span class="p">:</span> + <span class="n">range_min</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">range_max</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> + <span class="n">dm</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> + <span class="k">if</span> <span class="n">dm</span> <span class="o"><</span> <span class="mf">0.0</span><span class="p">:</span> + <span class="c1"># use log scale</span> + <span class="n">dlogm</span> <span class="o">=</span> <span class="o">-</span><span class="n">dm</span> + <span class="n">logm</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mmin</span><span class="p">)</span> + <span class="n">logmmax</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mmax</span><span class="p">)</span> + <span class="n">logrange_min</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">range_min</span><span class="p">)</span> + <span class="n">logrange_max</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">range_max</span><span class="p">)</span> + <span class="k">while</span> <span class="n">logm</span> <span class="o"><=</span> <span class="n">logmmax</span><span class="p">:</span> + <span class="k">if</span> <span class="n">logrange_min</span> <span class="o"><=</span> <span class="n">logm</span> <span class="o"><=</span> <span class="n">logrange_max</span><span class="p">:</span> + <span class="n">mass_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="n">logm</span><span class="p">))</span> + <span class="n">logm</span> <span class="o">+=</span> <span class="n">dlogm</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># use linear scale</span> + <span class="n">m</span> <span class="o">=</span> <span class="n">mmin</span> + <span class="k">while</span> <span class="n">m</span> <span class="o"><=</span> <span class="n">mmax</span><span class="p">:</span> + <span class="k">if</span> <span class="n">range_min</span> <span class="o"><=</span> <span class="n">m</span> <span class="o"><=</span> <span class="n">range_max</span><span class="p">:</span> + <span class="n">mass_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> + <span class="n">m</span> <span class="o">+=</span> <span class="n">dm</span> + + <span class="c1"># start time loop at tmax or max_evolution_time</span> + <span class="n">t</span> <span class="o">=</span> <span class="n">tmax</span> <span class="k">if</span> <span class="n">tmax</span> <span class="k">else</span> <span class="n">bse_options</span><span class="p">[</span><span class="s2">"max_evolution_time"</span><span class="p">]</span> + + <span class="c1"># set default mass list</span> + <span class="k">if</span> <span class="n">logspacing</span><span class="p">:</span> + <span class="n">logt</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> + <span class="n">logtmin</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">tmin</span><span class="p">)</span> + <span class="k">while</span> <span class="n">logt</span> <span class="o">></span> <span class="n">logtmin</span><span class="p">:</span> + <span class="n">m</span> <span class="o">=</span> <span class="n">_mass_from_time</span><span class="p">(</span><span class="mf">10.0</span> <span class="o">**</span> <span class="n">logt</span><span class="p">)</span> + <span class="n">mass_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> + <span class="n">logt</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">logtmin</span><span class="p">,</span> <span class="n">logt</span> <span class="o">-</span> <span class="n">dlogt</span> <span class="o">*</span> <span class="n">fsample</span><span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="k">while</span> <span class="n">t</span> <span class="o">></span> <span class="n">tmin</span><span class="p">:</span> + <span class="n">m</span> <span class="o">=</span> <span class="n">_mass_from_time</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> + <span class="n">mass_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> + <span class="n">t</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">tmin</span><span class="p">,</span> <span class="n">t</span> <span class="o">-</span> <span class="n">dt</span> <span class="o">*</span> <span class="n">fsample</span><span class="p">)</span> + + <span class="c1"># make mass list unique</span> + <span class="n">mass_list</span> <span class="o">=</span> <span class="n">_uniq</span><span class="p">(</span><span class="n">mass_list</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">mindm</span><span class="p">:</span> + <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">mindm</span><span class="p">:</span> + <span class="n">range_min</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> + <span class="n">range_max</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> + <span class="n">mindm</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> + <span class="c1"># impose a minimum dm: if two masses in the list</span> + <span class="c1"># are separated by < this, remove the second</span> + <span class="k">for</span> <span class="n">index</span><span class="p">,</span> <span class="n">mass</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mass_list</span><span class="p">):</span> + <span class="k">if</span> <span class="n">index</span> <span class="o">></span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">range_min</span> <span class="o"><=</span> <span class="n">mass</span> <span class="o"><=</span> <span class="n">range_max</span><span class="p">:</span> + <span class="n">dm</span> <span class="o">=</span> <span class="n">mass_list</span><span class="p">[</span><span class="n">index</span><span class="p">]</span> <span class="o">-</span> <span class="n">mass_list</span><span class="p">[</span><span class="n">index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> + <span class="k">if</span> <span class="n">dm</span> <span class="o"><</span> <span class="n">mindm</span><span class="p">:</span> + <span class="n">mass_list</span><span class="p">[</span><span class="n">index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span> + <span class="n">mass_list</span> <span class="o">=</span> <span class="n">_uniq</span><span class="p">(</span><span class="n">mass_list</span><span class="p">)</span> + <span class="k">if</span> <span class="n">mass_list</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mf">0.0</span><span class="p">:</span> + <span class="n">mass_list</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="mf">0.0</span><span class="p">)</span> + + <span class="c1"># apply multiplication factor if given</span> + <span class="k">if</span> <span class="n">factor</span> <span class="ow">and</span> <span class="n">factor</span> <span class="o">!=</span> <span class="mf">1.0</span><span class="p">:</span> + <span class="n">mass_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">m</span> <span class="o">*</span> <span class="n">factor</span> <span class="k">for</span> <span class="n">m</span> <span class="ow">in</span> <span class="n">mass_list</span><span class="p">]</span> + + <span class="c1"># reformat numbers</span> + <span class="n">mass_list</span> <span class="o">=</span> <span class="n">_format</span><span class="p">(</span><span class="n">mass_list</span><span class="p">)</span> + + <span class="c1"># show the mass<>time table?</span> + <span class="k">if</span> <span class="n">showtable</span><span class="p">:</span> + <span class="n">twas</span> <span class="o">=</span> <span class="mf">0.0</span> + <span class="n">logtwas</span> <span class="o">=</span> <span class="mf">0.0</span> + <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">m</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mass_list</span><span class="p">):</span> + <span class="n">t</span> <span class="o">=</span> <span class="n">_time_from_mass</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> + <span class="n">logt</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> + <span class="k">if</span> <span class="n">twas</span> <span class="o">></span> <span class="mf">0.0</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{i:4d}</span><span class="s2"> m=</span><span class="si">{m:13g}</span><span class="s2"> t=</span><span class="si">{t:13g}</span><span class="s2"> log10(t)=</span><span class="si">{logt:13g}</span><span class="s2"> dt=</span><span class="si">{dt:13g}</span><span class="s2"> dlog10(t)=</span><span class="si">{dlogt:13g}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">i</span><span class="o">=</span><span class="n">i</span><span class="p">,</span> + <span class="n">m</span><span class="o">=</span><span class="n">m</span><span class="p">,</span> + <span class="n">t</span><span class="o">=</span><span class="n">t</span><span class="p">,</span> + <span class="n">logt</span><span class="o">=</span><span class="n">logt</span><span class="p">,</span> + <span class="n">dt</span><span class="o">=</span><span class="n">twas</span> <span class="o">-</span> <span class="n">t</span><span class="p">,</span> + <span class="n">dlogt</span><span class="o">=</span><span class="n">logtwas</span> <span class="o">-</span> <span class="n">logt</span><span class="p">,</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span> + <span class="s2">"</span><span class="si">{i:4d}</span><span class="s2"> m=</span><span class="si">{m:13g}</span><span class="s2"> t=</span><span class="si">{t:13g}</span><span class="s2"> log10(t)=</span><span class="si">{logt:13g}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">i</span><span class="o">=</span><span class="n">i</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="n">m</span><span class="p">,</span> <span class="n">t</span><span class="o">=</span><span class="n">t</span><span class="p">,</span> <span class="n">logt</span><span class="o">=</span><span class="n">logt</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="n">twas</span> <span class="o">=</span> <span class="n">t</span> + <span class="n">logtwas</span> <span class="o">=</span> <span class="n">logt</span> + <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span> + + <span class="c1"># return the mass list as a numpy array</span> + <span class="n">mass_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">unique</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">mass_list</span><span class="p">))</span> + + <span class="c1"># perhaps log the masses</span> + <span class="k">if</span> <span class="n">logmasses</span><span class="p">:</span> + <span class="n">mass_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mass_array</span><span class="p">)</span> + <span class="k">if</span> <span class="n">log10masses</span><span class="p">:</span> + <span class="n">mass_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">mass_array</span><span class="p">)</span> + + <span class="k">return</span> <span class="n">mass_array</span> + + <span class="c1"># call _const_dt and return the mass_list</span> + <span class="c1">#</span> + <span class="c1"># Note: because _const_dt is cached to disk, calling it may</span> + <span class="c1"># use the cached result.</span> + <span class="c1">#</span> + <span class="c1"># Note: we send a sorted JSON string instead of the</span> + <span class="c1"># bse_options dict to make sure the order is preserved</span> + + <span class="n">mass_list</span> <span class="o">=</span> <span class="n">_const_dt_wrapper</span><span class="p">(</span> + <span class="n">cachedir</span><span class="o">=</span><span class="n">cachedir</span><span class="p">,</span> + <span class="n">num_cores</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">],</span> + <span class="n">bse_options</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">,</span> + <span class="o">**</span><span class="n">kwargs</span><span class="p">,</span> + <span class="p">)</span> + <span class="k">if</span> <span class="n">cache</span><span class="p">:</span> + <span class="n">cache</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + + <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"showlist"</span><span class="p">,</span> <span class="kc">True</span><span class="p">):</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"const_dt mass list (</span><span class="si">{}</span><span class="s2"> masses)</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">mass_list</span><span class="p">)),</span> <span class="n">mass_list</span><span class="p">)</span> + + <span class="k">return</span> <span class="n">mass_list</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/population_extensions/version_info.html b/docs/build/html/_modules/binarycpython/utils/population_extensions/version_info.html new file mode 100644 index 0000000000000000000000000000000000000000..855e7e2d53beacc5994d42b466fe9c0981b028be --- /dev/null +++ b/docs/build/html/_modules/binarycpython/utils/population_extensions/version_info.html @@ -0,0 +1,543 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>binarycpython.utils.population_extensions.version_info — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> + <script src="../../../../_static/jquery.js"></script> + <script src="../../../../_static/underscore.js"></script> + <script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../../../../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../../../../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../../../../genindex.html" /> + <link rel="search" title="Search" href="../../../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../../../../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../modules.html">Binarycpython code</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> + <li><a href="../../../index.html">Module code</a> »</li> + <li>binarycpython.utils.population_extensions.version_info</li> + <li class="wy-breadcrumbs-aside"> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for binarycpython.utils.population_extensions.version_info</h1><div class="highlight"><pre> +<span></span><span class="sd">"""</span> +<span class="sd">File containing the class object containing the functions to handle binary_c version info.</span> + +<span class="sd">This class will be used to extend the population object</span> + +<span class="sd">NOTE: could these functions not just be normal functions rather than class methods? I see hardly any use of the self</span> +<span class="sd">"""</span> + +<span class="c1"># pylint: disable=E0203</span> + +<span class="kn">import</span> <span class="nn">copy</span> +<span class="kn">import</span> <span class="nn">os</span> + +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span> + +<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">_binary_c_bindings</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">isfloat</span> + + +<div class="viewcode-block" id="version_info"><a class="viewcode-back" href="../../../../population_extensions/version_info.html#binarycpython.utils.population_extensions.version_info.version_info">[docs]</a><span class="k">class</span> <span class="nc">version_info</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Class object containing the functions to handle binary_c version info.</span> + +<span class="sd"> This class will be used to extend the population object</span> +<span class="sd"> """</span> + + <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Init function for the version_info class</span> +<span class="sd"> """</span> + + <span class="k">return</span> + + <span class="c1">########################################################</span> + <span class="c1"># version_info functions</span> + <span class="c1">########################################################</span> +<div class="viewcode-block" id="version_info.return_binary_c_version_info"><a class="viewcode-back" href="../../../../population_extensions/version_info.html#binarycpython.utils.population_extensions.version_info.version_info.return_binary_c_version_info">[docs]</a> <span class="k">def</span> <span class="nf">return_binary_c_version_info</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">dict</span><span class="p">]:</span> + <span class="sd">"""</span> +<span class="sd"> Function that returns the version information of binary_c. This function calls the function</span> +<span class="sd"> _binary_c_bindings.return_version_info()</span> + +<span class="sd"> Args:</span> +<span class="sd"> parsed: Boolean flag whether to parse the version_info output of binary_c. default = False</span> + +<span class="sd"> Returns:</span> +<span class="sd"> Either the raw string of binary_c or a parsed version of this in the form of a nested</span> +<span class="sd"> dictionary</span> +<span class="sd"> """</span> + + <span class="n">found_prev</span> <span class="o">=</span> <span class="kc">False</span> + <span class="k">if</span> <span class="s2">"BINARY_C_MACRO_HEADER"</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">:</span> + <span class="c1"># the env var is already present. lets save that and put that back later</span> + <span class="n">found_prev</span> <span class="o">=</span> <span class="kc">True</span> + <span class="n">prev_value</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C_MACRO_HEADER"</span><span class="p">]</span> + + <span class="c1">#</span> + <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C_MACRO_HEADER"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"macroxyz"</span> + + <span class="c1"># Get version_info</span> + <span class="n">raw_version_info</span> <span class="o">=</span> <span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">return_version_info</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + + <span class="c1"># delete value</span> + <span class="k">del</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C_MACRO_HEADER"</span><span class="p">]</span> + + <span class="c1"># put stuff back if we found a previous one</span> + <span class="k">if</span> <span class="n">found_prev</span><span class="p">:</span> + <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">"BINARY_C_MACRO_HEADER"</span><span class="p">]</span> <span class="o">=</span> <span class="n">prev_value</span> + + <span class="c1"># parse if wanted</span> + <span class="k">if</span> <span class="n">parsed</span><span class="p">:</span> + <span class="n">parsed_version_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">parse_binary_c_version_info</span><span class="p">(</span><span class="n">raw_version_info</span><span class="p">)</span> + <span class="k">return</span> <span class="n">parsed_version_info</span> + + <span class="k">return</span> <span class="n">raw_version_info</span></div> + +<div class="viewcode-block" id="version_info.parse_binary_c_version_info"><a class="viewcode-back" href="../../../../population_extensions/version_info.html#binarycpython.utils.population_extensions.version_info.version_info.parse_binary_c_version_info">[docs]</a> <span class="k">def</span> <span class="nf">parse_binary_c_version_info</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">version_info_string</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span> + <span class="sd">"""</span> +<span class="sd"> Function that parses the binary_c version info. Long function with a lot of branches</span> + +<span class="sd"> Args:</span> +<span class="sd"> version_info_string: raw output of version_info call to binary_c</span> + +<span class="sd"> Returns:</span> +<span class="sd"> Parsed version of the version info, which is a dictionary containing the keys: 'isotopes' for isotope info, 'argpairs' for argument pair info (TODO: explain), 'ensembles' for ensemble settings/info, 'macros' for macros, 'elements' for atomic element info, 'DTlimit' for (TODO: explain), 'nucleosynthesis_sources' for nucleosynthesis sources, and 'miscellaneous' for all those that were not caught by the previous groups. 'git_branch', 'git_build', 'revision' and 'email' are also keys, but its clear what those contain.</span> +<span class="sd"> """</span> + + <span class="n">version_info_dict</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="c1"># Clean data and put in correct shape</span> + <span class="n">splitted</span> <span class="o">=</span> <span class="n">version_info_string</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span> + <span class="n">cleaned</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">splitted</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">el</span> <span class="o">==</span> <span class="s2">""</span><span class="p">}</span> + + <span class="c1">##########################</span> + <span class="c1"># Network:</span> + <span class="c1"># Split off all the networks and parse the info.</span> + + <span class="n">networks</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Network "</span><span class="p">)}</span> + <span class="n">cleaned</span> <span class="o">=</span> <span class="n">cleaned</span> <span class="o">-</span> <span class="n">networks</span> + + <span class="n">networks_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">networks</span><span class="p">:</span> + <span class="n">network_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Network "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"=="</span><span class="p">)</span> + + <span class="n">network_number</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> + <span class="n">network_dict</span><span class="p">[</span><span class="s2">"network_number"</span><span class="p">]</span> <span class="o">=</span> <span class="n">network_number</span> + + <span class="n">network_info_split</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> + + <span class="n">shortname</span> <span class="o">=</span> <span class="n">network_info_split</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="n">network_dict</span><span class="p">[</span><span class="s2">"shortname"</span><span class="p">]</span> <span class="o">=</span> <span class="n">shortname</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">network_info_split</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">":"</span><span class="p">):</span> + <span class="n">network_split_info_extra</span> <span class="o">=</span> <span class="n">network_info_split</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)</span> + + <span class="n">longname</span> <span class="o">=</span> <span class="n">network_split_info_extra</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="n">network_dict</span><span class="p">[</span><span class="s2">"longname"</span><span class="p">]</span> <span class="o">=</span> <span class="n">longname</span> + + <span class="n">implementation</span> <span class="o">=</span> <span class="p">(</span> + <span class="n">network_split_info_extra</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"implemented in"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> + <span class="p">)</span> + <span class="k">if</span> <span class="n">implementation</span><span class="p">:</span> + <span class="n">network_dict</span><span class="p">[</span><span class="s2">"implemented_in"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span> + <span class="n">i</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">"()"</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">implementation</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> + <span class="p">]</span> + + <span class="n">networks_dict</span><span class="p">[</span><span class="n">network_number</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">network_dict</span><span class="p">)</span> + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"networks"</span><span class="p">]</span> <span class="o">=</span> <span class="n">networks_dict</span> <span class="k">if</span> <span class="n">networks_dict</span> <span class="k">else</span> <span class="kc">None</span> + + <span class="c1">##########################</span> + <span class="c1"># Isotopes:</span> + <span class="c1"># Split off</span> + <span class="n">isotopes</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Isotope "</span><span class="p">)}</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="n">isotopes</span> + + <span class="n">isotope_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">isotopes</span><span class="p">:</span> + <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Isotope "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> + + <span class="n">isotope_info</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> + <span class="n">name</span> <span class="o">=</span> <span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + + <span class="c1"># Get details</span> + <span class="n">mass_g</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span> + <span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"("</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">][:</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="p">)</span> + <span class="n">mass_amu</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span> + <span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"("</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="p">)</span> + <span class="n">mass_mev</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span> + <span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)[</span><span class="o">-</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">")"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="p">)</span> + <span class="n">A</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">")"</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span> + <span class="n">Z</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">isotope_info</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> + + <span class="c1">#</span> + <span class="n">isotope_dict</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])]</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"name"</span><span class="p">:</span> <span class="n">name</span><span class="p">,</span> + <span class="s2">"Z"</span><span class="p">:</span> <span class="n">Z</span><span class="p">,</span> + <span class="s2">"A"</span><span class="p">:</span> <span class="n">A</span><span class="p">,</span> + <span class="s2">"mass_mev"</span><span class="p">:</span> <span class="n">mass_mev</span><span class="p">,</span> + <span class="s2">"mass_g"</span><span class="p">:</span> <span class="n">mass_g</span><span class="p">,</span> + <span class="s2">"mass_amu"</span><span class="p">:</span> <span class="n">mass_amu</span><span class="p">,</span> + <span class="p">}</span> + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"isotopes"</span><span class="p">]</span> <span class="o">=</span> <span class="n">isotope_dict</span> <span class="k">if</span> <span class="n">isotope_dict</span> <span class="k">else</span> <span class="kc">None</span> + + <span class="c1">##########################</span> + <span class="c1"># Arg pairs:</span> + <span class="c1"># Split off</span> + <span class="n">argpairs</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"ArgPair"</span><span class="p">)}</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="n">argpairs</span> + + <span class="n">argpair_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">argpairs</span><span class="p">):</span> + <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"ArgPair "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="n">argpair_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="kc">None</span><span class="p">):</span> + <span class="n">argpair_dict</span><span class="p">[</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span><span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">2</span><span class="p">]}</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">argpair_dict</span><span class="p">[</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]][</span><span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> + + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"argpairs"</span><span class="p">]</span> <span class="o">=</span> <span class="n">argpair_dict</span> <span class="k">if</span> <span class="n">argpair_dict</span> <span class="k">else</span> <span class="kc">None</span> + + <span class="c1">##########################</span> + <span class="c1"># ensembles:</span> + <span class="c1"># Split off</span> + <span class="n">ensembles</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Ensemble"</span><span class="p">)}</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="n">ensembles</span> + + <span class="n">ensemble_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="n">ensemble_filter_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">ensembles</span><span class="p">:</span> + <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Ensemble "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> + + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">split_info</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"filter"</span><span class="p">):</span> + <span class="n">ensemble_dict</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])]</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">filter_no</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"filter "</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span> + <span class="n">ensemble_filter_dict</span><span class="p">[</span><span class="n">filter_no</span><span class="p">]</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> + + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"ensembles"</span><span class="p">]</span> <span class="o">=</span> <span class="n">ensemble_dict</span> <span class="k">if</span> <span class="n">ensemble_dict</span> <span class="k">else</span> <span class="kc">None</span> + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"ensemble_filters"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> + <span class="n">ensemble_filter_dict</span> <span class="k">if</span> <span class="n">ensemble_filter_dict</span> <span class="k">else</span> <span class="kc">None</span> + <span class="p">)</span> + + <span class="c1">##########################</span> + <span class="c1"># macros:</span> + <span class="c1"># Split off</span> + <span class="n">macros</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"macroxyz"</span><span class="p">)}</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="n">macros</span> + + <span class="n">param_type_dict</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"STRING"</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> + <span class="s2">"FLOAT"</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> + <span class="s2">"MACRO"</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> + <span class="s2">"INT"</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> + <span class="s2">"LONG_INT"</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> + <span class="s2">"UINT"</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> + <span class="p">}</span> + + <span class="n">macros_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">macros</span><span class="p">:</span> + <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"macroxyz "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" : "</span><span class="p">)</span> + <span class="n">param_type</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> + + <span class="n">new_split</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> + <span class="n">param_name</span> <span class="o">=</span> <span class="n">new_split</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="n">param_value</span> <span class="o">=</span> <span class="s2">" is "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">new_split</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span> + <span class="n">param_value</span> <span class="o">=</span> <span class="n">param_value</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + + <span class="c1"># print("macro ",param_name,"=",param_value," float?",isfloat(param_value)," int?",isint(param_value))</span> + + <span class="c1"># If we're trying to set the value to "on", check that</span> + <span class="c1"># it doesn't already exist. If it does, do nothing, as the</span> + <span class="c1"># extra information is better than just "on"</span> + <span class="k">if</span> <span class="n">param_name</span> <span class="ow">in</span> <span class="n">macros_dict</span><span class="p">:</span> + <span class="c1"># print("already exists (is ",macros_dict[param_name]," float? ",isfloat(macros_dict[param_name]),", int? ",isint(macros_dict[param_name]),") : check that we can improve it")</span> + <span class="k">if</span> <span class="n">macros_dict</span><span class="p">[</span><span class="n">param_name</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"on"</span><span class="p">:</span> + <span class="c1"># update with better value</span> + <span class="n">store</span> <span class="o">=</span> <span class="kc">True</span> + <span class="k">elif</span> <span class="p">(</span> + <span class="n">isfloat</span><span class="p">(</span><span class="n">macros_dict</span><span class="p">[</span><span class="n">param_name</span><span class="p">])</span> <span class="ow">is</span> <span class="kc">False</span> + <span class="ow">and</span> <span class="n">isfloat</span><span class="p">(</span><span class="n">param_value</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span> + <span class="p">):</span> + <span class="c1"># store the number we now have to replace the non-number we had</span> + <span class="n">store</span> <span class="o">=</span> <span class="kc">True</span> + <span class="k">else</span><span class="p">:</span> + <span class="c1"># don't override existing number</span> + <span class="n">store</span> <span class="o">=</span> <span class="kc">False</span> + + <span class="c1"># if store:</span> + <span class="c1"># print("Found improved macro value of param",param_name,", was ",macros_dict[param_name],", is",param_value)</span> + <span class="c1"># else:</span> + <span class="c1"># print("Cannot improve: use old value")</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">store</span> <span class="o">=</span> <span class="kc">True</span> + + <span class="k">if</span> <span class="n">store</span><span class="p">:</span> + <span class="c1"># Sometimes the macros have extra information behind it.</span> + <span class="c1"># Needs an update in outputting by binary_c (RGI: what does this mean David???)</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">macros_dict</span><span class="p">[</span><span class="n">param_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">param_type_dict</span><span class="p">[</span><span class="n">param_type</span><span class="p">](</span><span class="n">param_value</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> + <span class="n">macros_dict</span><span class="p">[</span><span class="n">param_name</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">param_value</span><span class="p">)</span> + + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"macros"</span><span class="p">]</span> <span class="o">=</span> <span class="n">macros_dict</span> <span class="k">if</span> <span class="n">macros_dict</span> <span class="k">else</span> <span class="kc">None</span> + + <span class="c1">##########################</span> + <span class="c1"># Elements:</span> + <span class="c1"># Split off:</span> + <span class="n">elements</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Element"</span><span class="p">)}</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="n">elements</span> + + <span class="c1"># Fill dict:</span> + <span class="n">elements_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">elements</span><span class="p">:</span> + <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Element "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" : "</span><span class="p">)</span> + <span class="n">name_info</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> + + <span class="c1"># get isotope info</span> + <span class="n">isotopes</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">if</span> <span class="ow">not</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"0"</span><span class="p">:</span> + <span class="n">isotope_string</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" = "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> + <span class="n">isotopes</span> <span class="o">=</span> <span class="p">{</span> + <span class="nb">int</span><span class="p">(</span><span class="n">split_isotope</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="mi">0</span><span class="p">]):</span> <span class="n">split_isotope</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"="</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span> + <span class="k">for</span> <span class="n">split_isotope</span> <span class="ow">in</span> <span class="n">isotope_string</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)</span> + <span class="p">}</span> + + <span class="n">elements_dict</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">name_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])]</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"name"</span><span class="p">:</span> <span class="n">name_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> + <span class="s2">"atomic_number"</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="n">name_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> + <span class="s2">"amt_isotopes"</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">isotopes</span><span class="p">),</span> + <span class="s2">"isotopes"</span><span class="p">:</span> <span class="n">isotopes</span><span class="p">,</span> + <span class="p">}</span> + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"elements"</span><span class="p">]</span> <span class="o">=</span> <span class="n">elements_dict</span> <span class="k">if</span> <span class="n">elements_dict</span> <span class="k">else</span> <span class="kc">None</span> + + <span class="c1">##########################</span> + <span class="c1"># dt_limits:</span> + <span class="c1"># split off</span> + <span class="n">dt_limits</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"DTlimit"</span><span class="p">)}</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="n">dt_limits</span> + + <span class="c1"># Fill dict</span> + <span class="n">dt_limits_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">dt_limits</span><span class="p">:</span> + <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"DTlimit "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" : "</span><span class="p">)</span> + <span class="n">dt_limits_dict</span><span class="p">[</span><span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()]</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"index"</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> + <span class="s2">"value"</span><span class="p">:</span> <span class="nb">float</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]),</span> + <span class="p">}</span> + + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"dt_limits"</span><span class="p">]</span> <span class="o">=</span> <span class="n">dt_limits_dict</span> <span class="k">if</span> <span class="n">dt_limits_dict</span> <span class="k">else</span> <span class="kc">None</span> + + <span class="c1">##############################</span> + <span class="c1"># Units</span> + + <span class="n">units</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Unit "</span><span class="p">)}</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="n">units</span> + <span class="n">units_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">units</span><span class="p">:</span> + <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Unit "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)</span> + <span class="n">s</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> + + <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> + <span class="n">long</span><span class="p">,</span> <span class="n">short</span> <span class="o">=</span> <span class="p">[</span><span class="n">i</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s1">'"'</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">s</span><span class="p">]</span> + <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> + <span class="n">long</span><span class="p">,</span> <span class="n">short</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">s</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> + <span class="k">else</span><span class="p">:</span> + <span class="nb">print</span><span class="p">(</span><span class="s2">"Warning: Failed to split unit string </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">el</span><span class="p">))</span> + + <span class="n">to_cgs</span> <span class="o">=</span> <span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">())[</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s1">'"'</span><span class="p">)</span> + <span class="n">code_units</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> + <span class="n">code_unit_type_num</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">code_units</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s1">'"'</span><span class="p">))</span> + <span class="n">code_unit_type</span> <span class="o">=</span> <span class="n">code_units</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s1">'"'</span><span class="p">)</span> + <span class="n">code_unit_cgs_value</span> <span class="o">=</span> <span class="n">code_units</span><span class="p">[</span><span class="mi">9</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s1">'"'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">")"</span><span class="p">)</span> + <span class="n">units_dict</span><span class="p">[</span><span class="n">long</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"long"</span><span class="p">:</span> <span class="n">long</span><span class="p">,</span> + <span class="s2">"short"</span><span class="p">:</span> <span class="n">short</span><span class="p">,</span> + <span class="s2">"to_cgs"</span><span class="p">:</span> <span class="n">to_cgs</span><span class="p">,</span> + <span class="s2">"code_unit_type_num"</span><span class="p">:</span> <span class="n">code_unit_type_num</span><span class="p">,</span> + <span class="s2">"code_unit_type"</span><span class="p">:</span> <span class="n">code_unit_type</span><span class="p">,</span> + <span class="s2">"code_unit_cgs_value"</span><span class="p">:</span> <span class="n">code_unit_cgs_value</span><span class="p">,</span> + <span class="p">}</span> + + <span class="c1"># Add the list of units</span> + <span class="n">units</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Units: "</span><span class="p">)}</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="n">units</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">units</span><span class="p">:</span> + <span class="n">el</span> <span class="o">=</span> <span class="n">el</span><span class="p">[</span><span class="mi">7</span><span class="p">:]</span> <span class="c1"># removes "Units: "</span> + <span class="n">units_dict</span><span class="p">[</span><span class="s2">"units list"</span><span class="p">]</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">"Units:"</span><span class="p">)</span> + + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"units"</span><span class="p">]</span> <span class="o">=</span> <span class="n">units_dict</span> + + <span class="c1">##########################</span> + <span class="c1"># Nucleosynthesis sources:</span> + <span class="c1"># Split off</span> + <span class="n">nucsyn_sources</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Nucleosynthesis"</span><span class="p">)}</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="n">nucsyn_sources</span> + + <span class="c1"># Fill dict</span> + <span class="n">nucsyn_sources_dict</span> <span class="o">=</span> <span class="p">{}</span> + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">nucsyn_sources</span><span class="p">:</span> + <span class="n">split_info</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Nucleosynthesis source"</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> + <span class="n">nucsyn_sources_dict</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">split_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])]</span> <span class="o">=</span> <span class="n">split_info</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> + + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"nucleosynthesis_sources"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> + <span class="n">nucsyn_sources_dict</span> <span class="k">if</span> <span class="n">nucsyn_sources_dict</span> <span class="k">else</span> <span class="kc">None</span> + <span class="p">)</span> + + <span class="c1">##########################</span> + <span class="c1"># miscellaneous:</span> + <span class="c1"># All those that I didn't catch with the above filters. Could try to get some more out though.</span> + + <span class="n">misc_dict</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="c1"># Filter out git revision</span> + <span class="n">git_revision</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"git revision"</span><span class="p">)]</span> + <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"git_revision"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> + <span class="n">git_revision</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"git revision "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">'"'</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> + <span class="p">)</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="nb">set</span><span class="p">(</span><span class="n">git_revision</span><span class="p">)</span> + + <span class="c1"># filter out git url</span> + <span class="n">git_url</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"git URL"</span><span class="p">)]</span> + <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"git_url"</span><span class="p">]</span> <span class="o">=</span> <span class="n">git_url</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"git URL "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">'"'</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="nb">set</span><span class="p">(</span><span class="n">git_url</span><span class="p">)</span> + + <span class="c1"># filter out version</span> + <span class="n">version</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Version"</span><span class="p">)]</span> + <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"version"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">version</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Version "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="nb">set</span><span class="p">(</span><span class="n">version</span><span class="p">)</span> + + <span class="n">git_branch</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"git branch"</span><span class="p">)]</span> + <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"git_branch"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> + <span class="n">git_branch</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"git branch "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">'"'</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> + <span class="p">)</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="nb">set</span><span class="p">(</span><span class="n">git_branch</span><span class="p">)</span> + + <span class="n">build</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Build"</span><span class="p">)]</span> + <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"build"</span><span class="p">]</span> <span class="o">=</span> <span class="n">build</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Build: "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">'"'</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="nb">set</span><span class="p">(</span><span class="n">build</span><span class="p">)</span> + + <span class="n">email</span> <span class="o">=</span> <span class="p">[</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Email"</span><span class="p">)]</span> + <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"email"</span><span class="p">]</span> <span class="o">=</span> <span class="n">email</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"Email "</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="nb">set</span><span class="p">(</span><span class="n">email</span><span class="p">)</span> + + <span class="n">other_items</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">cleaned</span> <span class="k">if</span> <span class="s2">" is "</span> <span class="ow">in</span> <span class="n">el</span><span class="p">}</span> + <span class="n">cleaned</span> <span class="o">-=</span> <span class="n">other_items</span> + + <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">other_items</span><span class="p">:</span> + <span class="n">split</span> <span class="o">=</span> <span class="n">el</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" is "</span><span class="p">)</span> + <span class="n">key</span> <span class="o">=</span> <span class="n">split</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="n">val</span> <span class="o">=</span> <span class="s2">" is "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">split</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">misc_dict</span><span class="p">:</span> + <span class="n">misc_dict</span><span class="p">[</span><span class="n">key</span> <span class="o">+</span> <span class="s2">" (alt)"</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">misc_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span> + + <span class="n">misc_dict</span><span class="p">[</span><span class="s2">"uncaught"</span><span class="p">]</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">cleaned</span><span class="p">)</span> + + <span class="n">version_info_dict</span><span class="p">[</span><span class="s2">"miscellaneous"</span><span class="p">]</span> <span class="o">=</span> <span class="n">misc_dict</span> <span class="k">if</span> <span class="n">misc_dict</span> <span class="k">else</span> <span class="kc">None</span> + <span class="k">return</span> <span class="n">version_info_dict</span></div> + +<div class="viewcode-block" id="version_info.minimum_stellar_mass"><a class="viewcode-back" href="../../../../population_extensions/version_info.html#binarycpython.utils.population_extensions.version_info.version_info.minimum_stellar_mass">[docs]</a> <span class="k">def</span> <span class="nf">minimum_stellar_mass</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Function to return the minimum stellar mass (in Msun) from binary_c.</span> +<span class="sd"> """</span> + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_minimum_stellar_mass</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_minimum_stellar_mass</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">return_binary_c_version_info</span><span class="p">(</span><span class="n">parsed</span><span class="o">=</span><span class="kc">True</span><span class="p">)[</span> + <span class="s2">"macros"</span> + <span class="p">][</span><span class="s2">"BINARY_C_MINIMUM_STELLAR_MASS"</span><span class="p">]</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_minimum_stellar_mass</span></div></div> +</pre></div> + + </div> + </div> + <footer> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/run_system_wrapper.html b/docs/build/html/_modules/binarycpython/utils/run_system_wrapper.html index 22dd9f1d89ceda1e3e30809db96f90e9eff323a4..2dfeafb0dd8013714dbebe84b49c63610027470f 100644 --- a/docs/build/html/_modules/binarycpython/utils/run_system_wrapper.html +++ b/docs/build/html/_modules/binarycpython/utils/run_system_wrapper.html @@ -1,68 +1,33 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>binarycpython.utils.run_system_wrapper — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - - - <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script> <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> <script src="../../../_static/jquery.js"></script> <script src="../../../_static/underscore.js"></script> + <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../../../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="../../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <script src="../../../_static/js/theme.js"></script> <link rel="index" title="Index" href="../../../genindex.html" /> <link rel="search" title="Search" href="../../../search.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../../../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -70,17 +35,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> @@ -92,83 +47,47 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../../../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../../../index.html">Docs</a> »</li> - + <li><a href="../../../index.html" class="icon icon-home"></a> »</li> <li><a href="../../index.html">Module code</a> »</li> - <li>binarycpython.utils.run_system_wrapper</li> - - <li class="wy-breadcrumbs-aside"> - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <h1>Source code for binarycpython.utils.run_system_wrapper</h1><div class="highlight"><pre> <span></span><span class="sd">"""</span> <span class="sd">Module containing the utility function run_system,</span> <span class="sd">which handles a lot of things by analysing the passed kwargs</span> <span class="sd">"""</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="p">(</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> <span class="n">create_arg_string</span><span class="p">,</span> <span class="n">get_arg_keys</span><span class="p">,</span> <span class="n">remove_file</span><span class="p">,</span> <span class="p">)</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="k">import</span> <span class="p">(</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="kn">import</span> <span class="p">(</span> <span class="n">create_and_load_logging_function</span><span class="p">,</span> <span class="p">)</span> -<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="k">import</span> <span class="n">_binary_c_bindings</span> +<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">_binary_c_bindings</span> <div class="viewcode-block" id="run_system"><a class="viewcode-back" href="../../../run_system_wrapper.html#binarycpython.utils.run_system_wrapper.run_system">[docs]</a><span class="k">def</span> <span class="nf">run_system</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> @@ -183,8 +102,8 @@ <span class="sd"> - run_system(M_1=10, parse_function=fancy_parsing_function)</span> <span class="sd"> Tasks:</span> -<span class="sd"> - TODO: Expand functionality.</span> <span class="sd"> - TODO: Notify user when an unknown keyword is passed.</span> +<span class="sd"> - TODO: Centralise the input checking routines here, abstract them and have the population object and this one use the same</span> <span class="sd"> All the arguments known to binary_c can be passed to this function as kwargs.</span> <span class="sd"> Several extra arguments can be passed through the kwargs:</span> @@ -220,19 +139,18 @@ <span class="n">binary_c_args</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># Check which binary_c arguments have been passed and put them into a dict</span> - <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span> + <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> <span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">available_binary_c_arg_keywords</span><span class="p">:</span> - <span class="n">binary_c_args</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="n">binary_c_args</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span> <span class="k">elif</span> <span class="nb">any</span><span class="p">(</span> - <span class="p">[</span> - <span class="kc">True</span> - <span class="k">if</span> <span class="p">(</span><span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">param</span><span class="p">[:</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">param</span><span class="p">[:</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="o"><</span> <span class="nb">len</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> - <span class="k">else</span> <span class="kc">False</span> - <span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">special_keywords</span> - <span class="p">]</span> + <span class="nb">bool</span><span class="p">((</span><span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">param</span><span class="p">[:</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">param</span><span class="p">[:</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span> <span class="o"><</span> <span class="nb">len</span><span class="p">(</span><span class="n">key</span><span class="p">)))</span> + <span class="c1"># True</span> + <span class="c1"># if (key.startswith(param[:-2]) and len(param[:-2]) < len(key))</span> + <span class="c1"># else False</span> + <span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">special_keywords</span> <span class="p">):</span> - <span class="n">binary_c_args</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> + <span class="n">binary_c_args</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span> <span class="c1"># Notify user when this key wont be used</span> <span class="k">else</span><span class="p">:</span> @@ -274,48 +192,36 @@ </pre></div> </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/spacing_functions.html b/docs/build/html/_modules/binarycpython/utils/spacing_functions.html deleted file mode 100644 index 4902f4dbb9d268e1916e63798f1d08a51a10ab84..0000000000000000000000000000000000000000 --- a/docs/build/html/_modules/binarycpython/utils/spacing_functions.html +++ /dev/null @@ -1,602 +0,0 @@ - - -<!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> -<head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>binarycpython.utils.spacing_functions — binary_c-python documentation</title> - - - - - - - - - <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script> - <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> - <script src="../../../_static/jquery.js"></script> - <script src="../../../_static/underscore.js"></script> - <script src="../../../_static/doctools.js"></script> - <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="../../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="index" title="Index" href="../../../genindex.html" /> - <link rel="search" title="Search" href="../../../search.html" /> -</head> - -<body class="wy-body-for-nav"> - - - <div class="wy-grid-for-nav"> - - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> - <div class="wy-side-scroll"> - <div class="wy-side-nav-search" > - - - - <a href="../../../index.html" class="icon icon-home"> binary_c-python - - - - </a> - - - - - - - -<div role="search"> - <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> - <input type="text" name="q" placeholder="Search docs" /> - <input type="hidden" name="check_keywords" value="yes" /> - <input type="hidden" name="area" value="default" /> - </form> -</div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - - <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> -<ul> -<li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../modules.html">Binarycpython code</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../example_notebooks.html">Example notebooks</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../binary_c_parameters.html">Binary_c parameters</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../grid_options_descriptions.html">Population grid code options</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> -</ul> - - - - </div> - </div> - </nav> - - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - - <i data-toggle="wy-nav-top" class="fa fa-bars"></i> - <a href="../../../index.html">binary_c-python</a> - - </nav> - - - <div class="wy-nav-content"> - - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - - <ul class="wy-breadcrumbs"> - - <li><a href="../../../index.html">Docs</a> »</li> - - <li><a href="../../index.html">Module code</a> »</li> - - <li>binarycpython.utils.spacing_functions</li> - - - <li class="wy-breadcrumbs-aside"> - - </li> - - </ul> - - - <hr/> -</div> - <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> - <div itemprop="articleBody"> - - <h1>Source code for binarycpython.utils.spacing_functions</h1><div class="highlight"><pre> -<span></span><span class="sd">"""</span> -<span class="sd">Module containing the spacing functions for the binarycpython package. Very under-populated at the moment, but more are likely to come soon</span> - -<span class="sd">Tasks:</span> -<span class="sd"> TODO: add more spacing functions to this module.</span> -<span class="sd">"""</span> - -<span class="kn">from</span> <span class="nn">typing</span> <span class="k">import</span> <span class="n">Union</span> -<span class="kn">import</span> <span class="nn">functools</span> -<span class="kn">import</span> <span class="nn">math</span> -<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> -<span class="kn">import</span> <span class="nn">py_rinterpolate</span> -<span class="kn">import</span> <span class="nn">sys</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="k">import</span> <span class="n">Population</span> - - -<div class="viewcode-block" id="const"><a class="viewcode-back" href="../../../spacing_functions.html#binarycpython.utils.spacing_functions.const">[docs]</a><span class="nd">@functools</span><span class="o">.</span><span class="n">lru_cache</span><span class="p">(</span><span class="n">maxsize</span><span class="o">=</span><span class="mi">16</span><span class="p">)</span> -<span class="k">def</span> <span class="nf">const</span><span class="p">(</span> - <span class="n">min_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">max_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">steps</span><span class="p">:</span> <span class="nb">int</span> -<span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Samples a range linearly. Uses numpy linspace.</span> - -<span class="sd"> Args:</span> -<span class="sd"> min_bound: lower bound of range</span> -<span class="sd"> max_bound: upper bound of range</span> -<span class="sd"> steps: number of segments between min_bound and max_bound</span> - -<span class="sd"> Returns:</span> -<span class="sd"> np.linspace(min_bound, max_bound, steps+1)</span> -<span class="sd"> """</span> - <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="n">min_bound</span><span class="p">,</span> <span class="n">max_bound</span><span class="p">,</span> <span class="n">steps</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span></div> - - -<span class="c1">############################################################</span> -<div class="viewcode-block" id="const_ranges"><a class="viewcode-back" href="../../../spacing_functions.html#binarycpython.utils.spacing_functions.const_ranges">[docs]</a><span class="nd">@functools</span><span class="o">.</span><span class="n">lru_cache</span><span class="p">(</span><span class="n">maxsize</span><span class="o">=</span><span class="mi">16</span><span class="p">)</span> -<span class="k">def</span> <span class="nf">const_ranges</span><span class="p">(</span><span class="n">ranges</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Samples a series of ranges linearly.</span> - -<span class="sd"> Args:</span> -<span class="sd"> ranges: a tuple of tuples passed to the const() spacing function.</span> - -<span class="sd"> Returns:</span> -<span class="sd"> numpy array of masses</span> - -<span class="sd"> Example:</span> -<span class="sd"> The following allocates 10 stars between 0.1 and 0.65, 20 stars between 0.65</span> -<span class="sd"> and 0.85, and 10 stars between 0.85 and 10.0 Msun.</span> - -<span class="sd"> samplerfunc="const_ranges((({},{},{}),({},{},{}),({},{},{})))".format(</span> -<span class="sd"> 0.1,0.65,10,</span> -<span class="sd"> 0.65,0.85,20,</span> -<span class="sd"> 0.85,10.0,10</span> -<span class="sd"> ),</span> - -<span class="sd"> """</span> - - <span class="n">masses</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> - <span class="k">for</span> <span class="nb">range</span> <span class="ow">in</span> <span class="n">ranges</span><span class="p">:</span> - <span class="n">masses</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">masses</span><span class="p">,</span> <span class="n">const</span><span class="p">(</span><span class="o">*</span><span class="nb">range</span><span class="p">))</span> - <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">unique</span><span class="p">(</span><span class="n">masses</span><span class="p">)</span></div> - - -<span class="c1">############################################################</span> -<div class="viewcode-block" id="peak_normalized_gaussian_func"><a class="viewcode-back" href="../../../spacing_functions.html#binarycpython.utils.spacing_functions.peak_normalized_gaussian_func">[docs]</a><span class="k">def</span> <span class="nf">peak_normalized_gaussian_func</span><span class="p">(</span> - <span class="n">x</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">mean</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">sigma</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]</span> -<span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> - <span class="sd">"""</span> -<span class="sd"> Function to evaluate a Gaussian at a given point, note</span> -<span class="sd"> that the normalization is such that the peak is always 1.0,</span> -<span class="sd"> not that the integral is 1.0</span> - -<span class="sd"> Args:</span> -<span class="sd"> x: location at which to evaluate the distribution</span> -<span class="sd"> mean: mean of the Gaussian</span> -<span class="sd"> sigma: standard deviation of the Gaussian</span> - -<span class="sd"> Returns:</span> -<span class="sd"> value of the Gaussian at x</span> -<span class="sd"> """</span> - <span class="n">gaussian_prefactor</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="c1"># / math.sqrt(2.0 * math.pi)</span> - - <span class="n">r</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">sigma</span> - <span class="n">y</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">mean</span><span class="p">)</span> <span class="o">*</span> <span class="n">r</span> - <span class="k">return</span> <span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span> <span class="o">*</span> <span class="n">y</span> <span class="o">**</span> <span class="mi">2</span><span class="p">)</span></div> - - -<span class="c1">############################################################</span> -<div class="viewcode-block" id="gaussian_zoom"><a class="viewcode-back" href="../../../spacing_functions.html#binarycpython.utils.spacing_functions.gaussian_zoom">[docs]</a><span class="nd">@functools</span><span class="o">.</span><span class="n">lru_cache</span><span class="p">(</span><span class="n">maxsize</span><span class="o">=</span><span class="mi">16</span><span class="p">)</span> -<span class="k">def</span> <span class="nf">gaussian_zoom</span><span class="p">(</span> - <span class="n">min_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">max_bound</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">zoom_mean</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">zoom_dispersion</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">zoom_magnitude</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> - <span class="n">steps</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> -<span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span> - <span class="sd">"""</span> -<span class="sd"> Samples such that a region is zoomed in according to a 1-Gaussian function</span> - -<span class="sd"> Args:</span> -<span class="sd"> min_bound: lower bound of range</span> -<span class="sd"> max_bound: upper bound of range</span> -<span class="sd"> zoom_mean: mean of the Gaussian zoom location</span> -<span class="sd"> zoom_dispersion: dispersion of the Gaussian</span> -<span class="sd"> zoom_magnitude: depth of the Gaussian (should be 0<= zoom_magntiude <1)</span> -<span class="sd"> steps: number of segments between min_bound and max_bound assuming a linear step</span> -<span class="sd"> this is what you'd normally call "resolution"</span> - -<span class="sd"> Returns:</span> -<span class="sd"> Numpy array of sample values</span> -<span class="sd"> """</span> - - <span class="c1"># linear spacing: this is what we'd have</span> - <span class="c1"># in the absence of a Gaussian zoom</span> - <span class="n">linear_spacing</span> <span class="o">=</span> <span class="p">(</span><span class="n">max_bound</span> <span class="o">-</span> <span class="n">min_bound</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">steps</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> - - <span class="c1"># make the list of values</span> - <span class="n">x</span> <span class="o">=</span> <span class="n">min_bound</span> - <span class="n">array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([])</span> - <span class="k">while</span> <span class="n">x</span> <span class="o"><=</span> <span class="n">max_bound</span><span class="p">:</span> - <span class="n">array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">array</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span> - <span class="n">g</span> <span class="o">=</span> <span class="n">peak_normalized_gaussian_func</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">zoom_mean</span><span class="p">,</span> <span class="n">zoom_dispersion</span><span class="p">)</span> - <span class="n">f</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">-</span> <span class="n">zoom_magnitude</span> <span class="o">*</span> <span class="n">g</span> - <span class="n">dx</span> <span class="o">=</span> <span class="n">linear_spacing</span> <span class="o">*</span> <span class="n">f</span> - <span class="n">x</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">dx</span> - - <span class="c1"># force the last array member to be max_bound if it's not</span> - <span class="k">if</span> <span class="n">array</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="n">max_bound</span><span class="p">:</span> - <span class="n">array</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">max_bound</span> - - <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">unique</span><span class="p">(</span><span class="n">array</span><span class="p">)</span></div> - - -<div class="viewcode-block" id="const_dt"><a class="viewcode-back" href="../../../spacing_functions.html#binarycpython.utils.spacing_functions.const_dt">[docs]</a><span class="nd">@functools</span><span class="o">.</span><span class="n">lru_cache</span><span class="p">(</span><span class="n">maxsize</span><span class="o">=</span><span class="mi">16</span><span class="p">)</span> -<span class="k">def</span> <span class="nf">const_dt</span><span class="p">(</span> - <span class="bp">self</span><span class="p">,</span> - <span class="n">dt</span><span class="o">=</span><span class="mf">1000.0</span><span class="p">,</span> - <span class="n">dlogt</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> - <span class="n">mmin</span><span class="o">=</span><span class="mf">0.07</span><span class="p">,</span> - <span class="n">mmax</span><span class="o">=</span><span class="mf">100.0</span><span class="p">,</span> - <span class="n">nres</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span> - <span class="n">logspacing</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> - <span class="n">tmin</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span> <span class="c1"># start at 3Myr</span> - <span class="n">tmax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="c1"># use max_evolution_time by default</span> - <span class="n">mindm</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="c1"># tuple of tuples</span> - <span class="n">maxdm</span><span class="o">=</span><span class="p">((</span><span class="mf">0.07</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">),</span> <span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">300.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)),</span> <span class="c1"># tuple of tuples</span> - <span class="n">fsample</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> - <span class="n">factor</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> - <span class="n">logmasses</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> - <span class="n">log10masses</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> - <span class="n">showlist</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> - <span class="n">showtable</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -<span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> const_dt returns a list of masses spaced at a constant age difference</span> - -<span class="sd"> Args:</span> -<span class="sd"> dt: the time difference between the masses (1000.0 Myr, used when logspacing==False)</span> -<span class="sd"> dlogt : the delta log10(time) difference between masses (0.1 dex, used when logspacing==True)</span> -<span class="sd"> mmin: the minimum mass to be considered in the stellar lifetime interpolation table (0.07 Msun)</span> -<span class="sd"> mmax: the maximum mass to be considered in the stellar lifetime interpolation table (100.0 Msun)</span> -<span class="sd"> nres: the resolution of the stellar lifetime interpolation table (100)</span> -<span class="sd"> logspacing: whether to use log-spaced time, in which case dt is actually d(log10(t))</span> -<span class="sd"> tmin: the minimum time to consider (Myr, default 3.0 Myr)</span> -<span class="sd"> tmax: the maximum time to consider (Myr, default None which means we use the grid option 'max_evolution_time')</span> -<span class="sd"> mindm: a tuple of tuples containing a mass range and minimum mass spacing in that range. The default is ((0.07,1.0,0.1),(1.0,300.0,1.0)) allocated a minimum dm of 0.1Msun in the mass range 0.07 to 1.0 Msun and 1.0Msun in the range 1.0 to 300.0 Msun. Anything you set overrides this. Note, if you use only one tuple, you must set it with a trailing comma, thus, e.g. ((0.07,1.0,0.1),). (default None)</span> -<span class="sd"> maxdm: a list of tuples similar to mindm but specifying a maximum mass spacing. In the case of maxdm, if the third option in each tuple is negative it is treated as a log step (its absolute value is used as the step). (default None)</span> -<span class="sd"> fsample: a global sampling (Shannon-like) factor (<1) to improve resolution (default 1.0, set to smaller to improve resolution)</span> -<span class="sd"> factor: all masses generated are multiplied by this after generation</span> -<span class="sd"> showtable: if True, the mass list and times are shown to stdout after generation</span> -<span class="sd"> showlist: if True, show the mass list once generated</span> -<span class="sd"> logmasses: if True, the masses are logged with math.log()</span> -<span class="sd"> log10masses: if True, the masses are logged with math.log10()</span> - -<span class="sd"> Returns:</span> -<span class="sd"> Array of masses.</span> - -<span class="sd"> Example:</span> -<span class="sd"> # these are lines set as options to Population.add_grid_value(...)</span> - -<span class="sd"> # linear time bins of 1Gyr</span> -<span class="sd"> samplerfunc="const_dt(self,dt=1000,nres=100,mmin=0.07,mmax=2.0,showtable=True)"</span> - -<span class="sd"> # logarithmic spacing in time, generally suitable for Galactic</span> -<span class="sd"> # chemical evolution yield grids.</span> -<span class="sd"> samplerfunc="const_dt(self,dlogt=0.1,nres=100,mmin=0.07,mmax=80.0,maxdm=((0.07,1.0,0.1),(1.0,10.0,1.0),(10.0,80.0,2.0)),showtable=True,logspacing=True,fsample=1.0/4.0)"</span> - -<span class="sd"> """</span> - - <span class="c1"># first, make a stellar lifetime table</span> - <span class="c1">#</span> - <span class="c1"># we should use the bse_options from self</span> - <span class="c1"># so our lifetime_population uses the same physics</span> - <span class="n">lifetime_population</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> - <span class="n">lifetime_population</span><span class="o">.</span><span class="n">bse_options</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">)</span> - - <span class="c1"># we only want to evolve the star during nuclear burning,</span> - <span class="c1"># we don't want a dry run of the grid</span> - <span class="c1"># we want to use the right number of CPU cores</span> - <span class="n">lifetime_population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> - <span class="n">do_dry_run</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> - <span class="n">num_cores</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">grid_options</span><span class="p">[</span><span class="s2">"num_cores"</span><span class="p">],</span> - <span class="n">max_stellar_type_1</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> - <span class="n">save_ensemble_chunks</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># make a grid in M1</span> - <span class="n">lifetime_population</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="s2">"lnM_1"</span><span class="p">,</span> - <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> - <span class="n">longname</span><span class="o">=</span><span class="s2">"log Primary mass"</span><span class="p">,</span> <span class="c1"># == single-star mass</span> - <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span><span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mmin</span><span class="p">),</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mmax</span><span class="p">)],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"const(math.log(</span><span class="si">{mmin}</span><span class="s2">),math.log(</span><span class="si">{mmax}</span><span class="s2">),</span><span class="si">{nres}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">mmin</span><span class="o">=</span><span class="n">mmin</span><span class="p">,</span> <span class="n">mmax</span><span class="o">=</span><span class="n">mmax</span><span class="p">,</span> <span class="n">nres</span><span class="o">=</span><span class="n">nres</span> - <span class="p">),</span> - <span class="n">probdist</span><span class="o">=</span><span class="s2">"1"</span><span class="p">,</span> <span class="c1"># dprob/dm1 : we don't care, so just set it to 1</span> - <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dlnM_1"</span><span class="p">,</span> - <span class="n">precode</span><span class="o">=</span><span class="s2">"M_1=math.exp(lnM_1)"</span><span class="p">,</span> - <span class="n">condition</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="c1"># Impose a condition on this grid variable. Mostly for a check for yourself</span> - <span class="n">gridtype</span><span class="o">=</span><span class="s2">"edge"</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># set up the parse function</span> - <span class="k">def</span> <span class="nf">_parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> - <span class="k">if</span> <span class="n">output</span><span class="p">:</span> - <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">():</span> - <span class="n">data</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> - <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"SINGLE_STAR_LIFETIME"</span><span class="p">:</span> - <span class="c1"># append (log10(mass), log10(lifetime)) tuples</span> - <span class="n">logm</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> - <span class="n">logt</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">2</span><span class="p">]))</span> - <span class="c1"># print(line)</span> - <span class="c1"># print("logM=",logm,"M=",10.0**logm," -> logt=",logt)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table m->t"</span><span class="p">][</span><span class="n">logm</span><span class="p">]</span> <span class="o">=</span> <span class="n">logt</span> - <span class="bp">self</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table t->m"</span><span class="p">][</span><span class="n">logt</span><span class="p">]</span> <span class="o">=</span> <span class="n">logm</span> - - <span class="n">lifetime_population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> - <span class="n">parse_function</span><span class="o">=</span><span class="n">_parse_function</span><span class="p">,</span> - <span class="p">)</span> - - <span class="c1"># run to build the interpolation table</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"Running population to make lifetime interpolation table, please wait"</span><span class="p">)</span> - <span class="n">lifetime_population</span><span class="o">.</span><span class="n">evolve</span><span class="p">()</span> - <span class="c1"># print("Data table",lifetime_population.grid_results['interpolation table t->m'])</span> - - <span class="c1"># convert to nested lists for the interpolator</span> - <span class="c1">#</span> - <span class="c1"># make time -> mass table</span> - <span class="n">data_table_time_mass</span> <span class="o">=</span> <span class="p">[]</span> - <span class="n">times</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">lifetime_population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table t->m"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> - <span class="k">for</span> <span class="n">time</span> <span class="ow">in</span> <span class="n">times</span><span class="p">:</span> - <span class="n">mass</span> <span class="o">=</span> <span class="n">lifetime_population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table t->m"</span><span class="p">][</span><span class="n">time</span><span class="p">]</span> - <span class="c1"># we have to make sure the time is monotonic (not guaranteed at high mass)</span> - <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data_table_time_mass</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> - <span class="n">data_table_time_mass</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">time</span><span class="p">,</span> <span class="n">mass</span><span class="p">])</span> - <span class="k">elif</span> <span class="n">mass</span> <span class="o"><</span> <span class="n">data_table_time_mass</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]:</span> - <span class="n">data_table_time_mass</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">time</span><span class="p">,</span> <span class="n">mass</span><span class="p">])</span> - - <span class="c1"># make mass -> time table</span> - <span class="n">data_table_mass_time</span> <span class="o">=</span> <span class="p">[]</span> - <span class="n">masses</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">lifetime_population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table m->t"</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> - <span class="k">for</span> <span class="n">mass</span> <span class="ow">in</span> <span class="n">masses</span><span class="p">:</span> - <span class="n">time</span> <span class="o">=</span> <span class="n">lifetime_population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s2">"interpolation table m->t"</span><span class="p">][</span><span class="n">mass</span><span class="p">]</span> - <span class="n">data_table_mass_time</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">mass</span><span class="p">,</span> <span class="n">time</span><span class="p">])</span> - - <span class="c1"># set up interpolators</span> - <span class="n">interpolator_time_mass</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> - <span class="n">table</span><span class="o">=</span><span class="n">data_table_time_mass</span><span class="p">,</span> <span class="n">nparams</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">ndata</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span> <span class="c1"># mass # lifetime</span> - <span class="p">)</span> - <span class="n">interpolator_mass_time</span> <span class="o">=</span> <span class="n">py_rinterpolate</span><span class="o">.</span><span class="n">Rinterpolate</span><span class="p">(</span> - <span class="n">table</span><span class="o">=</span><span class="n">data_table_mass_time</span><span class="p">,</span> <span class="n">nparams</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">ndata</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span> <span class="c1"># lifetime # mass</span> - <span class="p">)</span> - - <span class="c1"># function to get a mass given a time (Myr)</span> - <span class="k">def</span> <span class="nf">_mass_from_time</span><span class="p">(</span><span class="n">linear_time</span><span class="p">):</span> - <span class="k">return</span> <span class="mf">10.0</span> <span class="o">**</span> <span class="n">interpolator_time_mass</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">linear_time</span><span class="p">)])[</span><span class="mi">0</span><span class="p">]</span> - - <span class="c1"># function to get a time given a mass (Msun)</span> - <span class="k">def</span> <span class="nf">_time_from_mass</span><span class="p">(</span><span class="n">mass</span><span class="p">):</span> - <span class="k">return</span> <span class="mf">10.0</span> <span class="o">**</span> <span class="n">interpolator_mass_time</span><span class="o">.</span><span class="n">interpolate</span><span class="p">([</span><span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">mass</span><span class="p">)])[</span><span class="mi">0</span><span class="p">]</span> - - <span class="c1"># return a unique list</span> - <span class="k">def</span> <span class="nf">_uniq</span><span class="p">(</span><span class="n">_list</span><span class="p">):</span> - <span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">_list</span><span class="p">)))</span> - - <span class="c1"># format a whole list like %g</span> - <span class="k">def</span> <span class="nf">_format</span><span class="p">(</span><span class="n">_list</span><span class="p">):</span> - <span class="k">return</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="s2">"</span><span class="si">{x:g}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">x</span><span class="p">))</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">_list</span><span class="p">]</span> - - <span class="c1"># construct mass list, always include the min and max</span> - <span class="n">mass_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">mmin</span><span class="p">,</span> <span class="n">mmax</span><span class="p">]</span> - - <span class="c1"># first, make sure the stars are separated by only</span> - <span class="c1"># maxdm</span> - <span class="k">if</span> <span class="n">maxdm</span><span class="p">:</span> - <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">maxdm</span><span class="p">:</span> - <span class="n">range_min</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">range_max</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> - <span class="n">dm</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> - <span class="k">if</span> <span class="n">dm</span> <span class="o"><</span> <span class="mf">0.0</span><span class="p">:</span> - <span class="c1"># use log scale</span> - <span class="n">dlogm</span> <span class="o">=</span> <span class="o">-</span><span class="n">dm</span> - <span class="n">logm</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mmin</span><span class="p">)</span> - <span class="n">logmmax</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mmax</span><span class="p">)</span> - <span class="n">logrange_min</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">range_min</span><span class="p">)</span> - <span class="n">logrange_max</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">range_max</span><span class="p">)</span> - <span class="k">while</span> <span class="n">logm</span> <span class="o"><=</span> <span class="n">logmmax</span><span class="p">:</span> - <span class="k">if</span> <span class="n">logm</span> <span class="o">>=</span> <span class="n">logrange_min</span> <span class="ow">and</span> <span class="n">logm</span> <span class="o"><=</span> <span class="n">logrange_max</span><span class="p">:</span> - <span class="n">mass_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="n">logm</span><span class="p">))</span> - <span class="n">logm</span> <span class="o">+=</span> <span class="n">dlogm</span> - <span class="k">else</span><span class="p">:</span> - <span class="c1"># use linear scale</span> - <span class="n">m</span> <span class="o">=</span> <span class="n">mmin</span> - <span class="k">while</span> <span class="n">m</span> <span class="o"><=</span> <span class="n">mmax</span><span class="p">:</span> - <span class="k">if</span> <span class="n">m</span> <span class="o">>=</span> <span class="n">range_min</span> <span class="ow">and</span> <span class="n">m</span> <span class="o"><=</span> <span class="n">range_max</span><span class="p">:</span> - <span class="n">mass_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> - <span class="n">m</span> <span class="o">+=</span> <span class="n">dm</span> - - <span class="c1"># start time loop at tmax or max_evolution_time</span> - <span class="n">t</span> <span class="o">=</span> <span class="n">tmax</span> <span class="k">if</span> <span class="n">tmax</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">bse_options</span><span class="p">[</span><span class="s2">"max_evolution_time"</span><span class="p">]</span> - - <span class="c1"># set default mass list</span> - <span class="k">if</span> <span class="n">logspacing</span><span class="p">:</span> - <span class="n">logt</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> - <span class="n">logtmin</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">tmin</span><span class="p">)</span> - <span class="k">while</span> <span class="n">logt</span> <span class="o">></span> <span class="n">logtmin</span><span class="p">:</span> - <span class="n">m</span> <span class="o">=</span> <span class="n">_mass_from_time</span><span class="p">(</span><span class="mf">10.0</span> <span class="o">**</span> <span class="n">logt</span><span class="p">)</span> - <span class="n">mass_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> - <span class="n">logt</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">logtmin</span><span class="p">,</span> <span class="n">logt</span> <span class="o">-</span> <span class="n">dlogt</span> <span class="o">*</span> <span class="n">fsample</span><span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="k">while</span> <span class="n">t</span> <span class="o">></span> <span class="n">tmin</span><span class="p">:</span> - <span class="n">m</span> <span class="o">=</span> <span class="n">_mass_from_time</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> - <span class="n">mass_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> - <span class="n">t</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">tmin</span><span class="p">,</span> <span class="n">t</span> <span class="o">-</span> <span class="n">dt</span> <span class="o">*</span> <span class="n">fsample</span><span class="p">)</span> - - <span class="c1"># make mass list unique</span> - <span class="n">mass_list</span> <span class="o">=</span> <span class="n">_uniq</span><span class="p">(</span><span class="n">mass_list</span><span class="p">)</span> - - <span class="k">if</span> <span class="n">mindm</span><span class="p">:</span> - <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">mindm</span><span class="p">:</span> - <span class="n">range_min</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> - <span class="n">range_max</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> - <span class="n">mindm</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> - <span class="c1"># impose a minimum dm: if two masses in the list</span> - <span class="c1"># are separated by < this, remove the second</span> - <span class="k">for</span> <span class="n">index</span><span class="p">,</span> <span class="n">mass</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mass_list</span><span class="p">):</span> - <span class="k">if</span> <span class="n">index</span> <span class="o">></span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">mass</span> <span class="o">>=</span> <span class="n">range_min</span> <span class="ow">and</span> <span class="n">mass</span> <span class="o"><=</span> <span class="n">range_max</span><span class="p">:</span> - <span class="n">dm</span> <span class="o">=</span> <span class="n">mass_list</span><span class="p">[</span><span class="n">index</span><span class="p">]</span> <span class="o">-</span> <span class="n">mass_list</span><span class="p">[</span><span class="n">index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> - <span class="k">if</span> <span class="n">dm</span> <span class="o"><</span> <span class="n">mindm</span><span class="p">:</span> - <span class="n">mass_list</span><span class="p">[</span><span class="n">index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span> - <span class="n">mass_list</span> <span class="o">=</span> <span class="n">_uniq</span><span class="p">(</span><span class="n">mass_list</span><span class="p">)</span> - <span class="k">if</span> <span class="n">mass_list</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mf">0.0</span><span class="p">:</span> - <span class="n">mass_list</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="mf">0.0</span><span class="p">)</span> - - <span class="c1"># apply multiplication factor if given</span> - <span class="k">if</span> <span class="n">factor</span> <span class="ow">and</span> <span class="n">factor</span> <span class="o">!=</span> <span class="mf">1.0</span><span class="p">:</span> - <span class="n">mass_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">m</span> <span class="o">*</span> <span class="n">factor</span> <span class="k">for</span> <span class="n">m</span> <span class="ow">in</span> <span class="n">mass_list</span><span class="p">]</span> - - <span class="c1"># reformat numbers</span> - <span class="n">mass_list</span> <span class="o">=</span> <span class="n">_format</span><span class="p">(</span><span class="n">mass_list</span><span class="p">)</span> - - <span class="c1"># show the mass<>time table?</span> - <span class="k">if</span> <span class="n">showtable</span><span class="p">:</span> - <span class="n">twas</span> <span class="o">=</span> <span class="mf">0.0</span> - <span class="n">logtwas</span> <span class="o">=</span> <span class="mf">0.0</span> - <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">m</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mass_list</span><span class="p">):</span> - <span class="n">t</span> <span class="o">=</span> <span class="n">_time_from_mass</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> - <span class="n">logt</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> - <span class="k">if</span> <span class="n">twas</span> <span class="o">></span> <span class="mf">0.0</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{i:4d}</span><span class="s2"> m=</span><span class="si">{m:13g}</span><span class="s2"> t=</span><span class="si">{t:13g}</span><span class="s2"> log10(t)=</span><span class="si">{logt:13g}</span><span class="s2"> dt=</span><span class="si">{dt:13g}</span><span class="s2"> dlog10(t)=</span><span class="si">{dlogt:13g}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">i</span><span class="o">=</span><span class="n">i</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="n">m</span><span class="p">,</span> <span class="n">t</span><span class="o">=</span><span class="n">t</span><span class="p">,</span> <span class="n">logt</span><span class="o">=</span><span class="n">logt</span><span class="p">,</span> <span class="n">dt</span><span class="o">=</span><span class="n">twas</span> <span class="o">-</span> <span class="n">t</span><span class="p">,</span> <span class="n">dlogt</span><span class="o">=</span><span class="n">logtwas</span> <span class="o">-</span> <span class="n">logt</span> - <span class="p">)</span> - <span class="p">)</span> - <span class="k">else</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span> - <span class="s2">"</span><span class="si">{i:4d}</span><span class="s2"> m=</span><span class="si">{m:13g}</span><span class="s2"> t=</span><span class="si">{t:13g}</span><span class="s2"> log10(t)=</span><span class="si">{logt:13g}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">i</span><span class="o">=</span><span class="n">i</span><span class="p">,</span> <span class="n">m</span><span class="o">=</span><span class="n">m</span><span class="p">,</span> <span class="n">t</span><span class="o">=</span><span class="n">t</span><span class="p">,</span> <span class="n">logt</span><span class="o">=</span><span class="n">logt</span> - <span class="p">)</span> - <span class="p">)</span> - <span class="n">twas</span> <span class="o">=</span> <span class="n">t</span> - <span class="n">logtwas</span> <span class="o">=</span> <span class="n">logt</span> - <span class="n">exit</span><span class="p">()</span> - - <span class="c1"># return the mass list as a numpy array</span> - <span class="n">mass_list</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">unique</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">mass_list</span><span class="p">))</span> - - <span class="c1"># perhaps log the masses</span> - <span class="k">if</span> <span class="n">logmasses</span><span class="p">:</span> - <span class="n">mass_list</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">mass_list</span><span class="p">)</span> - <span class="k">if</span> <span class="n">log10masses</span><span class="p">:</span> - <span class="n">mass_list</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">mass_list</span><span class="p">)</span> - - <span class="k">if</span> <span class="n">showlist</span><span class="p">:</span> - <span class="nb">print</span><span class="p">(</span><span class="s2">"const_dt mass list (</span><span class="si">{}</span><span class="s2"> masses)</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">mass_list</span><span class="p">)),</span> <span class="n">mass_list</span><span class="p">)</span> - - <span class="k">return</span> <span class="n">mass_list</span></div> -</pre></div> - - </div> - - </div> - <footer> - - - <hr/> - - <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> - </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. -<br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. -<br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. - - - -</footer> - - </div> - </div> - - </section> - - </div> - - - - <script type="text/javascript"> - jQuery(function () { - SphinxRtdTheme.Navigation.enable(true); - }); - </script> - - - - - - -</body> -</html> \ No newline at end of file diff --git a/docs/build/html/_modules/binarycpython/utils/useful_funcs.html b/docs/build/html/_modules/binarycpython/utils/useful_funcs.html index 42f2932f355ba2e4c76fe88c28d05829687d1e80..d2e13b7ebff9780dbc9ddd8352a90eaf3e0ab51a 100644 --- a/docs/build/html/_modules/binarycpython/utils/useful_funcs.html +++ b/docs/build/html/_modules/binarycpython/utils/useful_funcs.html @@ -1,68 +1,33 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>binarycpython.utils.useful_funcs — binary_c-python documentation</title> + <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - - - <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script> <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> <script src="../../../_static/jquery.js"></script> <script src="../../../_static/underscore.js"></script> + <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../../../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="../../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + <script src="../../../_static/js/theme.js"></script> <link rel="index" title="Index" href="../../../genindex.html" /> <link rel="search" title="Search" href="../../../search.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../../../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -70,17 +35,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="../../../readme_link.html">Python module for binary_c</a></li> @@ -92,66 +47,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../../../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../../../index.html">Docs</a> »</li> - + <li><a href="../../../index.html" class="icon icon-home"></a> »</li> <li><a href="../../index.html">Module code</a> »</li> - <li>binarycpython.utils.useful_funcs</li> - - <li class="wy-breadcrumbs-aside"> - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <h1>Source code for binarycpython.utils.useful_funcs</h1><div class="highlight"><pre> <span></span><span class="sd">"""</span> <span class="sd">Collection of useful functions.</span> @@ -164,22 +83,21 @@ <span class="sd"> - rzams(m, z) gives you the ZAMS radius of a star</span> <span class="sd"> - ZAMS_collision(m1, m2, e, sep, z) returns 1 if stars collide on the ZAMS</span> <span class="sd"> - roche_lobe(q): returns roche lobe radius in units of separation</span> -<span class="sd"> - ragb(m, z): radius at first thermal pulse</span> +<span class="sd"> - ragb(m): radius at first thermal pulse</span> <span class="sd"> - minimum_period_for_RLOF(M1, M2, metallicity, store_memaddr=-1): function to calculate the minimum period that leads to RLOF on ZAMS</span> <span class="sd"> - minimum_separation_for_RLOF(M1, M2, metallicity, store_memaddr=-1): function to calculate the minimum period that leads to RLOF on ZAMS</span> <span class="sd"> - maximum_mass_ratio_for_RLOF(M1, orbital_period, store_memaddr=None): Function to calculate the maximum mass ratio that leads to RLOF on ZAMS</span> <span class="sd">Tasks:</span> <span class="sd"> - TODO: check whether these functions are correct</span> -<span class="sd"> - TODO: add unit test for maximum_mass_ratio_for_RLOF</span> <span class="sd">"""</span> <span class="kn">import</span> <span class="nn">math</span> <span class="kn">import</span> <span class="nn">re</span> -<span class="kn">from</span> <span class="nn">typing</span> <span class="k">import</span> <span class="n">Union</span> +<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span> -<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="k">import</span> <span class="n">_binary_c_bindings</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">create_arg_string</span> +<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">_binary_c_bindings</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">create_arg_string</span> <span class="n">AURSUN</span> <span class="o">=</span> <span class="mf">2.150445198804013386961742071435e02</span> <span class="n">YEARDY</span> <span class="o">=</span> <span class="mf">3.651995478818308811241877265275e02</span> @@ -359,11 +277,11 @@ <span class="k">return</span> <span class="mf">0.49</span> <span class="o">*</span> <span class="n">p</span> <span class="o">*</span> <span class="n">p</span> <span class="o">/</span> <span class="p">(</span><span class="mf">0.6</span> <span class="o">*</span> <span class="n">p</span> <span class="o">*</span> <span class="n">p</span> <span class="o">+</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="mf">1.0</span> <span class="o">+</span> <span class="n">p</span><span class="p">))</span></div> -<div class="viewcode-block" id="ragb"><a class="viewcode-back" href="../../../useful_funcs.html#binarycpython.utils.useful_funcs.ragb">[docs]</a><span class="k">def</span> <span class="nf">ragb</span><span class="p">(</span><span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span> <span class="n">z</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> +<div class="viewcode-block" id="ragb"><a class="viewcode-back" href="../../../useful_funcs.html#binarycpython.utils.useful_funcs.ragb">[docs]</a><span class="k">def</span> <span class="nf">ragb</span><span class="p">(</span><span class="n">m</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span> <span class="sd">"""</span> <span class="sd"> Function to calculate radius of a star in units of solar radii at first thermal pulse as a function of mass (Z=0.02 only, but also good for Z=0.0001)</span> -<span class="sd"> TODO: ask rob about this function</span> +<span class="sd"> TODO: ask rob about this function. Do we still need this? Can we make something better? (i.e. upon installation of the code run a grid of systems and get the data from there?)</span> <span class="sd"> Args:</span> <span class="sd"> m: mass of star in units of solar mass</span> @@ -540,48 +458,36 @@ </pre></div> </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/_modules/index.html b/docs/build/html/_modules/index.html index 5b831b47c10b6aa43a31e527508d2c94b4ab83d0..b31aab06c38de941d04e5cef259826286e962b7e 100644 --- a/docs/build/html/_modules/index.html +++ b/docs/build/html/_modules/index.html @@ -1,68 +1,33 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Overview: module code — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - - - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -70,17 +35,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -92,119 +47,85 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li>Overview: module code</li> - - <li class="wy-breadcrumbs-aside"> - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <h1>All modules for which code is available</h1> <ul><li><a href="binarycpython/utils/custom_logging_functions.html">binarycpython.utils.custom_logging_functions</a></li> -<li><a href="binarycpython/utils/distribution_functions.html">binarycpython.utils.distribution_functions</a></li> +<li><a href="binarycpython/utils/dicts.html">binarycpython.utils.dicts</a></li> +<li><a href="binarycpython/utils/ensemble.html">binarycpython.utils.ensemble</a></li> <li><a href="binarycpython/utils/functions.html">binarycpython.utils.functions</a></li> <li><a href="binarycpython/utils/grid.html">binarycpython.utils.grid</a></li> -<li><a href="binarycpython/utils/grid_options_defaults.html">binarycpython.utils.grid_options_defaults</a></li> <li><a href="binarycpython/utils/plot_functions.html">binarycpython.utils.plot_functions</a></li> +<li><a href="binarycpython/utils/population_extensions/HPC.html">binarycpython.utils.population_extensions.HPC</a></li> +<li><a href="binarycpython/utils/population_extensions/Moe_di_Stefano_2017.html">binarycpython.utils.population_extensions.Moe_di_Stefano_2017</a></li> +<li><a href="binarycpython/utils/population_extensions/analytics.html">binarycpython.utils.population_extensions.analytics</a></li> +<li><a href="binarycpython/utils/population_extensions/cache.html">binarycpython.utils.population_extensions.cache</a></li> +<li><a href="binarycpython/utils/population_extensions/condor.html">binarycpython.utils.population_extensions.condor</a></li> +<li><a href="binarycpython/utils/population_extensions/dataIO.html">binarycpython.utils.population_extensions.dataIO</a></li> +<li><a href="binarycpython/utils/population_extensions/distribution_functions.html">binarycpython.utils.population_extensions.distribution_functions</a></li> +<li><a href="binarycpython/utils/population_extensions/grid_logging.html">binarycpython.utils.population_extensions.grid_logging</a></li> +<li><a href="binarycpython/utils/population_extensions/grid_options_defaults.html">binarycpython.utils.population_extensions.grid_options_defaults</a></li> +<li><a href="binarycpython/utils/population_extensions/gridcode.html">binarycpython.utils.population_extensions.gridcode</a></li> +<li><a href="binarycpython/utils/population_extensions/metadata.html">binarycpython.utils.population_extensions.metadata</a></li> +<li><a href="binarycpython/utils/population_extensions/slurm.html">binarycpython.utils.population_extensions.slurm</a></li> +<li><a href="binarycpython/utils/population_extensions/spacing_functions.html">binarycpython.utils.population_extensions.spacing_functions</a></li> +<li><a href="binarycpython/utils/population_extensions/version_info.html">binarycpython.utils.population_extensions.version_info</a></li> <li><a href="binarycpython/utils/run_system_wrapper.html">binarycpython.utils.run_system_wrapper</a></li> -<li><a href="binarycpython/utils/spacing_functions.html">binarycpython.utils.spacing_functions</a></li> <li><a href="binarycpython/utils/useful_funcs.html">binarycpython.utils.useful_funcs</a></li> </ul> </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/_sources/binary_c_parameters.rst.txt b/docs/build/html/_sources/binary_c_parameters.rst.txt index b66bc0c57226dd2dcc729ece18ca996604c0dc16..9d00a7aca6f63646c1f16d38ad998fcbbe5c3874 100644 --- a/docs/build/html/_sources/binary_c_parameters.rst.txt +++ b/docs/build/html/_sources/binary_c_parameters.rst.txt @@ -4,7 +4,7 @@ The following chapter contains all the parameters that the current version of bi This information was obtained by the following binary_c build: - **binary_c git branch**: branch_david **binary_c git revision**: 5747:20211102:404ce27a0 **Built on**: Nov 2 2021 23:57:35 + **binary_c git branch**: branch_david **binary_c git revision**: 6118:20220617:8463fa650 **Built on**: Jun 17 2022 23:20:34 Section: stars @@ -250,6 +250,11 @@ Section: stars | **Parameter input type**: True|False | **Default value**: False +| **Parameter**: custom_timeout_time +| **Description**: Custom timeout time. Requires compilation with DAVID_CUSTOM_TIMEOUT +| **Parameter input type**: Float +| **Default value**: 100 + | **Parameter**: evolution_splitting | **Description**: If True, turn on splitting of an evolutionary run if splitpoint (e.g. supernova) occurs. | **Parameter input type**: True|False @@ -288,10 +293,10 @@ Section: stars | **Macros**: ['OPACITY_ALGORITHM_PACZYNSKI = 0', 'OPACITY_ALGORITHM_FERGUSON_OPAL = 1', 'OPACITY_ALGORITHM_STARS = 2'] | **Parameter**: wind_mass_loss -| **Description**: Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018). +| **Description**: Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018), 3 = Schneider + Sander and Wink (2020) for helium stars, 4 = Schneider + Hurley for LBV mass loss | **Parameter input type**: Unsigned integer | **Default value**: 3 -| **Macros**: ['WIND_ALGORITHM_NONE = 0', 'WIND_ALGORITHM_HURLEY2002 = 1', 'WIND_ALGORITHM_SCHNEIDER2018 = 2', 'WIND_ALGORITHM_BINARY_C_2020 = 3'] +| **Macros**: ['WIND_ALGORITHM_NONE = 0', 'WIND_ALGORITHM_HURLEY2002 = 1', 'WIND_ALGORITHM_SCHNEIDER2018 = 2', 'WIND_ALGORITHM_BINARY_C_2020 = 3', 'WIND_ALGORITHM_HENDRIKS_2022 = 4'] | **Extra**: 0 | **Parameter**: gbwind @@ -486,6 +491,18 @@ Section: stars | **Default value**: 0 | **Extra**: Ignore +| **Parameter**: PPISN_core_mass_range_shift +| **Description**: (Pulsational) Pair-Instability Supernova CO core mass range shift: Value by which we shift the range of CO core mass values that undergo PPISN. This is taken into account in the fit that calculates the mass removal. Negative number is shifting the range to lower masses, positive to higher masses. +| **Parameter input type**: Float +| **Default value**: 0 +| **Extra**: Ignore + +| **Parameter**: PPISN_massloss_multiplier +| **Description**: (Pulsational) Pair-Instability Supernova CO massloss multiplier: Value by which the (P)PISN massloss is multiplied. Currently only works with the new prescription. THe additional mass loss is not affected multiplied by this. +| **Parameter input type**: Float +| **Default value**: 1 +| **Extra**: Ignore + | **Parameter**: use_LWN_fallback | **Description**: Flag whether to use the Nazehdin-Lovegrove-Woosley hydrogen envelope ejection at failed supernova. | **Parameter input type**: Integer @@ -561,7 +578,7 @@ Section: stars | **Parameter**: sn_kick_distribution_PPISN | **Description**: Set the distribution of speeds applied to PPISN supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). | **Parameter input type**: Integer -| **Default value**: 1 +| **Default value**: 0 | **Macros**: ['KICK_VELOCITY_FIXED = 0', 'KICK_VELOCITY_MAXWELLIAN = 1', 'KICK_VELOCITY_CUSTOM = 2'] | **Parameter**: sn_kick_distribution_PISN @@ -634,7 +651,7 @@ Section: stars | **Parameter**: sn_kick_dispersion_PPISN | **Description**: Set the dispersion of speeds applied to the survivor of a PPISN supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). | **Parameter input type**: Float -| **Default value**: 190 +| **Default value**: 0 | **Parameter**: sn_kick_dispersion_PISN | **Description**: Set the dispersion of speeds applied to the survivor of a PISN supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). @@ -968,7 +985,7 @@ Section: stars | **Parameter**: MINT_metallicity | **Description**: This sets the metallicity for MINT. It is ignored if set to -1.0, the default, in which case the normal metallicity parameter is used. | **Parameter input type**: Float -| **Default value**: NULL +| **Default value**: -1 | **Parameter**: gaia_Teff_binwidth | **Description**: log10(Effective temperature) bin width used to make Gaia-like HRDs @@ -1153,6 +1170,21 @@ Section: stars | **Parameter input type**: True|False | **Default value**: False +| **Parameter**: degenerate_core_merger_nucsyn +| **Description**: If TRUE, assume that in a degnerate core merger, energy is generated from nucleosynthesis of the whole core, and that this can disrupt the core. The BSE algorithm (Hurley et al. 2002) assumes this to be TRUE, but binary_c assumes FALSE by default. (FALSE) +| **Parameter input type**: True|False +| **Default value**: False + +| **Parameter**: degenerate_core_helium_merger_ignition +| **Description**: If TRUE, assume that when there is a degenerate helium core merger, the star reignites helium. This is required to make R-type carbon stars. (TRUE) +| **Parameter input type**: True|False +| **Default value**: True + +| **Parameter**: degenerate_core_merger_dredgeup_fraction +| **Description**: If non-zero, mix this fraction of the degenerate core during a merger.(0.0). +| **Parameter input type**: Float +| **Default value**: NULL + Section: binary --------------- @@ -1325,7 +1357,7 @@ Section: binary | **Parameter**: post_ce_objects_have_envelopes | **Description**: If TRUE then post-common-envelope objects have thin envelopes. You need this if you are to have post-CE post-AGB stars. Note that this *may* be unstable, i.e. you may end up having many CEEs. The mass in the envelope is controlled by post_ce_adaptive_menv. TRUE by default. | **Parameter input type**: True|False -| **Default value**: True +| **Default value**: False | **Parameter**: PN_comenv_transition_time | **Description**: post-common envelope transition time in years (1e2). This is the time taken to move from CEE ejection to Teff > 30e4 K. Hall et al. (2013) suggest ~100 years. @@ -1794,7 +1826,7 @@ Section: binary | **Default value**: NULL | **Parameter**: lambda_ce -| **Description**: Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to -1 binary_c uses the Dewi and Tauris fits instead, -2 uses the formalism of Wang, Jia and Li (2016) and if -3 then a polytropic formalism is used (see also comenv_splitmass). +| **Description**: Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to LAMBDA_CE_DEWI_TAURIS == -1 binary_c uses the Dewi and Tauris fits instead, LAMBDA_CE_WANG_2016 == -2 uses the formalism of Wang, Jia and Li (2016), if LAMBDA_CE_POLYTROPE == -3 then a polytropic formalism is used (see also comenv_splitmass) and if LAMBDA_CE_KLENCKI_2020 == -4 use Klencki et al. (2020). | **Parameter input type**: Float | **Default value**: 0.5 | **Macros**: ['LAMBDA_CE_DEWI_TAURIS = -1', 'LAMBDA_CE_WANG_2016 = -2', 'LAMBDA_CE_POLYTROPE = -3', 'LAMBDA_CE_KLENCKI_2020 = -4'] @@ -1970,7 +2002,7 @@ Section: binary | **Default value**: 1e-06 | **Parameter**: cbdisc_minimum_fRing -| **Description**: Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = |Rout/Rin-1| < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS. +| **Description**: Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = abs(Rout/Rin-1) < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS. | **Parameter input type**: Float | **Default value**: 0.2 @@ -2357,6 +2389,36 @@ Section: output | **Parameter**: david_logging_function | **Description**: Function to choose which kind of information gets logged Requires DAVID. Choices are: 0= None, >0 for custom logging functions | **Parameter input type**: Integer +| **Default value**: -1 +| **Extra**: Ignore + +| **Parameter**: david_tzo_logging +| **Description**: Flag to enable logging for TZO project +| **Parameter input type**: Integer +| **Default value**: 0 +| **Extra**: Ignore + +| **Parameter**: david_ppisn_logging +| **Description**: Flag to enable logging for PPISN project +| **Parameter input type**: Integer +| **Default value**: 0 +| **Extra**: Ignore + +| **Parameter**: david_ppisn_single_logging +| **Description**: Flag to enable logging for PPISN project capturing single star systems that underwent SN +| **Parameter input type**: Integer +| **Default value**: 0 +| **Extra**: Ignore + +| **Parameter**: david_rlof_episode_logging +| **Description**: Flag to enable the RLOF episode logging +| **Parameter input type**: Integer +| **Default value**: 0 +| **Extra**: Ignore + +| **Parameter**: david_rlof_ensemble_logging +| **Description**: Flag to enable the RLOF ensemble logging +| **Parameter input type**: Integer | **Default value**: 0 | **Extra**: Ignore @@ -2593,105 +2655,111 @@ Section: output | **Default value**: NULL | **Extra**: Ignore +| **Parameter**: tides_diagnosis_log +| **Description**: Enable logging to test MINT tides. Requires MINT. Choices are: 0 disabled, 1 enable lambda test. +| **Parameter input type**: Integer +| **Default value**: 0 +| **Extra**: Ignore + Section: input -------------- | **Parameter**: MINT_dir | **Description**: Location of MINT algorithm data. | **Parameter input type**: String -| **Default value**: NULL +| **Default value**: | **Extra**: | **Parameter**: MINT_data_cleanup | **Description**: Activate checks on incoming data to try to account for problems. Will make data-loading slower, but may fix a few things. | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: False | **Extra**: | **Parameter**: MINT_MS_rejuvenation | **Description**: Turn on or off (hydrogen) main-sequence rejuvenation. | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: True | **Extra**: | **Parameter**: MINT_remesh | **Description**: Turn on or off MINT's remeshing. | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: True | **Extra**: | **Parameter**: MINT_use_ZAMS_profiles | **Description**: Use chemical profiles at the ZAMS if MINT_use_ZAMS_profiles is TRUE, otherwise set homogeneous abundances. (Default is TRUE, so we use the profiles if they are available.) | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: True | **Extra**: | **Parameter**: MINT_fallback_to_test_data | **Description**: If TRUE, use the MINT test_data directory as a fallback when data is unavailable. (FALSE) | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: False | **Extra**: | **Parameter**: MINT_disable_grid_load_warnings | **Description**: Use this to explicitly disable MINT's warnings when loading a grid with, e.g., missing or too much data. | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: False | **Extra**: | **Parameter**: MINT_Kippenhahn | **Description**: Turn on or off MINT's Kippenhahn diagrams. If 0, off, if 1, output star 1 (index 0), if 2 output star 2 (index 1). Default 0. | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: 0 | **Extra**: | **Parameter**: MINT_nshells | **Description**: Set the initial number of shells MINT uses in each star when doing nuclear burning. Note: remeshing can change this. If MINT_nshells is 0, shellular burning and other routines that require shells will not be available. (200) | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: 200 | **Extra**: | **Parameter**: MINT_maximum_nshells | **Description**: Set the maximum number of shells MINT uses in each star when doing nuclear burning. Note that this will be limited to MINT_HARD_MAX_NSHELLS. (1000) | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: 1000 | **Extra**: | **Parameter**: MINT_minimum_nshells | **Description**: Set the minimum number of shells MINT uses in each star when doing nuclear burning. Note that this will be greater than or equal to MINT_HARD_MIN_NSHELLS, which is 0 by default. (0) | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: 10 | **Extra**: | **Parameter**: MINT_Kippenhahn_stellar_type | **Description**: Stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for which Kippenhahn plot data should be output. | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: -1 | **Macros**: ['LOW_MASS_MS = 0', 'MS = 1', 'HG = 2', 'GIANT_BRANCH = 3', 'CHeB = 4', 'EAGB = 5', 'TPAGB = 6', 'HeMS = 7', 'HeHG = 8', 'HeGB = 9', 'HeWD = 10', 'COWD = 11', 'ONeWD = 12', 'NS = 13', 'BH = 14', 'MASSLESS_REMNANT = 15'] | **Extra**: | **Parameter**: MINT_Kippenhahn_companion_stellar_type | **Description**: Companion stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for the companion for which Kippenhahn plot data should be output. | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: -1 | **Macros**: ['LOW_MASS_MS = 0', 'MS = 1', 'HG = 2', 'GIANT_BRANCH = 3', 'CHeB = 4', 'EAGB = 5', 'TPAGB = 6', 'HeMS = 7', 'HeHG = 8', 'HeGB = 9', 'HeWD = 10', 'COWD = 11', 'ONeWD = 12', 'NS = 13', 'BH = 14', 'MASSLESS_REMNANT = 15'] | **Extra**: | **Parameter**: MINT_nuclear_burning | **Description**: Turn on or off MINT's nuclear burning algorithm. | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: False | **Extra**: | **Parameter**: MINT_minimum_shell_mass | **Description**: Minimum shell mass in MINT's nuclear burning routines. | **Parameter input type**: Float -| **Default value**: NULL +| **Default value**: 1e-06 | **Extra**: | **Parameter**: MINT_maximum_shell_mass | **Description**: Maximum shell mass in MINT's nuclear burning routines. : | **Parameter input type**: Float -| **Default value**: NULL +| **Default value**: 0.1 | **Extra**: Section: i/o diff --git a/docs/build/html/_sources/dicts.rst.txt b/docs/build/html/_sources/dicts.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..a2b4ae43db8ec6245001db353c6892239b7acad9 --- /dev/null +++ b/docs/build/html/_sources/dicts.rst.txt @@ -0,0 +1,7 @@ +dicts module +============ + +.. automodule:: binarycpython.utils.dicts + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/distribution_functions.rst.txt b/docs/build/html/_sources/distribution_functions.rst.txt deleted file mode 100644 index 5881ee38299d5af76771ac7312abd140886f99d1..0000000000000000000000000000000000000000 --- a/docs/build/html/_sources/distribution_functions.rst.txt +++ /dev/null @@ -1,7 +0,0 @@ -distribution_functions module -================================= - -.. automodule:: binarycpython.utils.distribution_functions - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/build/html/_sources/ensemble.rst.txt b/docs/build/html/_sources/ensemble.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..a213b22ad1c788fb273ee09fb5958794e298a97a --- /dev/null +++ b/docs/build/html/_sources/ensemble.rst.txt @@ -0,0 +1,7 @@ +ensemble module +=============== + +.. automodule:: binarycpython.utils.ensemble + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/example_notebooks.rst.txt b/docs/build/html/_sources/example_notebooks.rst.txt index c4e9e34c484b4484c61d959aa33e90cd8c9fe578..bb73b3d6fdca311d8d60ba5aa8159fb55b44bb0d 100644 --- a/docs/build/html/_sources/example_notebooks.rst.txt +++ b/docs/build/html/_sources/example_notebooks.rst.txt @@ -13,6 +13,7 @@ The order of the notebooks below is more or less the recommended order to read. examples/notebook_population.ipynb examples/notebook_extra_features.ipynb examples/notebook_api_functionality.ipynb + examples/notebook_ensembles.ipynb examples/notebook_luminosity_function_single.ipynb examples/notebook_luminosity_function_binaries.ipynb diff --git a/docs/build/html/_sources/examples/notebook_api_functionality.ipynb.txt b/docs/build/html/_sources/examples/notebook_api_functionality.ipynb.txt index 504ae4b16880946428716c496c81cbf82eea63a8..49d6f8d3db7beacc8770e2b86b21b4636bbf8e7a 100644 --- a/docs/build/html/_sources/examples/notebook_api_functionality.ipynb.txt +++ b/docs/build/html/_sources/examples/notebook_api_functionality.ipynb.txt @@ -105,7 +105,7 @@ " Function that contains random snippets. Do not expect this to remain available, or reliable. i.e. dont use it.\n", "\n", "FILE\n", - " /home/izzard/.local/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so\n", + " /home/david/.pyenv/versions/binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so\n", "\n", "\n" ] @@ -166,7 +166,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "<capsule object \"STORE\" at 0x146f912dbc60>\n", + "<capsule object \"STORE\" at 0x7fc1f0c3ff00>\n", "SINGLE_STAR_LIFETIME 10 28.4838\n", "\n" ] @@ -270,586 +270,13 @@ "M_2 : The initial mass of star two (in solar units, internally this is star index 1). : (null)\n", "M_3 : The initial mass of star three (in solar units, internally this is star index 2). : (null)\n", "M_4 : The initial mass of star four (in solar units, internally this is star index 3). : (null)\n", - "vrot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot2,3,4. : (null)\n", - "vrot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,3,4. : (null)\n", - "vrot3 : The initial equatorial rotational velocity of star three (in km/s, internally this is star index 2). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,4. : (null)\n", - "vrot4 : The initial equatorial rotational velocity of star four (in km/s, internally this is star index 3). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,3. : (null)\n", - "Prot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). See also Prot2,3,4. : (null)\n", - "Prot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). See also Prot1,3,4. : (null)\n", - "Prot3 : The initial equatorial rotational period of star three (in days, internally this is star index 2). See also Prot1,2,4. : (null)\n", - "Prot4 : The initial equatorial rotational period of star four (in days, internally this is star index 3). See also Prot1,2,3. : (null)\n", - "inclination1 : The initial inclination of star one (in degrees). : (null)\n", - "inclination2 : The initial inclination of star two (in degrees). : (null)\n", - "inclination3 : The initial inclination of star three (in degrees). : (null)\n", - "inclination4 : The initial inclination of star four (in degrees). : (null)\n", - "B_1 : The initial magnetic field of star one (in Gauss, internally this is star index 0). : (null)\n", - "B_2 : The initial magnetic field of star two (in Gauss, internally this is star index 1). : (null)\n", - "B_3 : The initial magnetic field of star three (in Gauss, internally this is star index 2). : (null)\n", - "B_4 : The initial magnetic field of star four (in Gauss, internally this is star index 3). : (null)\n", - "B_inclination1 : The initial inclination of the magnetic field of star one (in degrees). : (null)\n", - "B_inclination2 : The initial inclination of the magnetic field of star two (in degrees). : (null)\n", - "B_inclination3 : The initial inclination of the magnetic field of star three (in degrees). : (null)\n", - "B_inclination4 : The initial inclination of the magnetic field of star four (in degrees). : (null)\n", - "stellar_type_1 : Set the stellar type of star 1 (internal index 0), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_2 : Set the stellar type of star 2 (internal index 1), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_3 : Set the stellar type of star 3 (internal index 2), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_4 : Set the stellar type of star 4 (internal index 3), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "max_stellar_type_1 : The maximum stellar type of star 1 (internal index 0). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value. \n", - " : (null)\n", - "max_stellar_type_2 : The maximum stellar type of star 2 (internal index 1). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "max_stellar_type_3 : The maximum stellar type of star 3 (internal index 2). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "max_stellar_type_4 : The maximum stellar type of star 4 (internal index 3). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "probability : The probability is a weighting applied to the star based on, say, the initial mass function. When running a grid of stars to simulate *all* stars, the summed probability of all the stars should be 1.0. : (null)\n", - "phasevol : The system's phase volume, used by binary_grid. : (null)\n", - "stellar_structure_algorithm : Set the stellar structure algorithm. 0=modified BSE (default), 1=none, 2=external function (must be defined by the calling code), 3=binary_c (not yet implemented). : (null)\n", - "solver : The type of solver. Default is the Forward-Euler (0), but could be RK2 (1), RK4 (2) or a predictor-corretor (3). : (null)\n", - "max_evolution_time : Set the maximum age for the stars (Myr). : (null)\n", - "max_model_number : Set the maximum number of models, ignored if 0 (default is 0). : (null)\n", - "monte_carlo_kicks : Turn on Monte-Carlo SN kicks. On (True) by default, and indeed other algorithms are probably broken. : (null)\n", - "disable_debug : Disables debug output. Only has an effect when DEBUG is 1, which probably requires a rebuild. Default FALSE. : (null)\n", - "timestep_logging : Turn on timestep logging (default is False). : (null)\n", - "rejects_in_log : Show timestep rejections in the main log (default is False). : (null)\n", - "vandenHeuvel_logging : Turn on van den Heuvel logging (default is False). : (null)\n", - "evolution_splitting : If True, turn on splitting of an evolutionary run if splitpoint (e.g. supernova) occurs. : (null)\n", - "disable_events : Whether to disable the new events code (defaults to False, so we use events by default)\n", - " : (null)\n", - "evolution_splitting_sn_eccentricity_threshold : Threshold eccentricity above which evolution splitting happens in a system with no SN kick. (0.01) : (null)\n", - "evolution_splitting_sn_n : Number of runs to split into when a SN occurs. : (null)\n", - "evolution_splitting_maxdepth : Max number of splits in an evolutionary run. : (null)\n", - "equation_of_state_algorithm : Set the equation of state algorithm. 0 = Paczynski. : (null)\n", - "opacity_algorithm : Set the opacity algorithm. 0 = Paczynski, 1 = Ferguson/Opal. : (null)\n", - "wind_mass_loss : Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018). : 0\n", - "gbwind : Wind prescription for first red giant branch stars. 0=Reimers (Hurley et al 2000/2002; choose gb_reimers_eta=0.5 for their mass loss rate), 1=Schroeder+Cuntz 2005 (set gb_reimers_eta=1.0 for their mass loss rate). : (null)\n", - "postagbwind : Apply special post-(A)GB prescription. Default is POSTAGB_WIND_USE_GIANT which means we just use whatever is prescribed on the giant branch. Other options include: POSTAGB_WIND_NONE = 1 (no wind on the post (A)GB), POSTAGB_WIND_KRTICKA2020 = 2 which uses Krticka, Kubát and Krticková (2020, A&A 635, A173). : (null)\n", - "Teff_postAGB_min : The minimum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_max. (6000 K) : (null)\n", - "Teff_postAGB_max : The maximum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_min. (120000 K) : (null)\n", - "mattsson_Orich_tpagbwind : Experimental : turns on Mattsson's TPAGB wind when the star is oxygen rich. Requires MATTSSON_MASS_LOSS. : (null)\n", - "magnetic_braking_factor : Multiplier for the magnetic braking angular momentum loss rate. : (null)\n", - "magnetic_braking_gamma : gamma factor in Rappaport style magnetic braking expression. : (null)\n", - "magnetic_braking_algorithm : Algorithm for the magnetic braking angular momentum loss rate. 0 = Hurley et al. 2002, 1 = Andronov, Pinnsonneault and Sills 2003, 2 = Barnes and Kim 2010 : (null)\n", - "helium_flash_mass_loss : Mass to be lost at the helium flash. : (null)\n", - "gb_reimers_eta : First red giant branch wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) : (null)\n", - "gbwindfac : Multiplier for the giant branch wind mass loss rate : (null)\n", - "tpagbwindfac : Multiplier for the TPAGB wind mass loss rate : (null)\n", - "eagbwindfac : Multiplier for the EAGB wind mass loss rate : (null)\n", - "nieuwenhuijzen_windfac : Multiplier for the Nieuwenhuijzen & de Jager wind mass loss rate : (null)\n", - "tpagbwind : Wind prescription during the TPAGB. 0=Karakas 2002 (a modified Vassiliadis and Wood 1993), 1=Hurley et al 2000/2002 (Vassiliadis and Wood 1993), 2=Reimers, 3=Bloecker, 4=Van Loon, 5=Rob's C-wind (broken?), 6,7=Vassiliadis and Wood 1993 (Karakas,Hurley variants respectively) when C/O>1, 8=Mattsson, 9 = Goldman et al. (2017), 10 = Beasor et al. (2020). : (null)\n", - "eagbwind : Wind prescription during the EAGB. 0=BSE (Hurley+2002, based on VW93), 1 = Goldman et al. (2017), 2 = Beasor et al. (2020). : (null)\n", - "wind_gas_to_dust_ratio : Gas to dust ratio used in wind calculations (e.g. Goldman et al. 2017). Typically 200 (Milky Way)-500 (Magellanic Clouds). Default is 200, approximately as in MW stars. : (null)\n", - "vwind_multiplier : Multiplier for the stellar wind velocity. : (null)\n", - "vwind_beta : Beta for stellar wind speed calculations, where vwind=sqrt(beta) * escape velocity. Default 0.125 (from BSE, Hurley et al. 2002). : (null)\n", - "superwind_mira_switchon : In the Vassiliadis and Wood (1993) AGB wind prescription, the superwind is turned on at a given Mira period, usually 500 days. You can vary when this switch-on happens with this parameter. : (null)\n", - "vw93_mira_shift : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate depends on the Mira period plus this offset. Requires VW93_MIRA_SHIFT. : (null)\n", - "vw93_multiplier : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate is multiplied by this factor. Requires VW93_MULTIPLIER. : (null)\n", - "tpagb_reimers_eta : TPAGB Reimers wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) Note that Reimers is not the default TPAGB wind prescription. See also tpagbwind. : (null)\n", - "Tout_Pringle_1992_multiplier : Multiplier for the Tout & Pringle (1992) magnetic wind. (0.0) : (null)\n", - "artificial_mass_accretion_rate%d : Constant mass accretion rate for star <n>. : (null)\n", - "artificial_mass_accretion_rate_by_stellar_type%d : Constant mass accretion rate for stellar type <n>. : (null)\n", - "artificial_angular_momentum_accretion_rate%d : Constant angular momentum accretion for star <n>. : (null)\n", - "artificial_orbital_angular_momentum_accretion_rate : Constant angular momentum accretion rate on the orbit. : (null)\n", - "artificial_accretion_start_time : Time at which artificial accretion stars. Ignored if <0 (default is -1). : (null)\n", - "artificial_accretion_end_time : Time at which artificial accretion ends. Ignored if <0 (default is -1). : (null)\n", - "wr_wind : Massive-star (WR) wind prescription. 0 = Hurley et al 2000/2002, 1=Maeder and Meynet, 2=Nugis and Lamers, 3=John Eldridge's version of Vink's early-2000s wind (See Lynnette Dray's thesis, or John Eldridge's thesis) : (null)\n", - "wr_wind_fac : Massive-star (WR) wind multiplication factor. : (null)\n", - "wrwindfac : Massive-star (WR) wind multiplication factor. Synonymous with wr_wind_fac (which you should use instead). : (null)\n", - "BH_prescription : Black hole mass prescrition: relates the mass of a newly formed black hole to its progenitor's (CO) core mass. BH_HURLEY2002 = 0 = Hurley et al 2000/2002, BH_BELCZYNSKI = 1 = Belczynski (early 2000s), BH_SPERA2015 = Spera+ 2015, BH_FRYER12_DELAYED = 3 = Fryer et al. (2012) delayed prescription, BH_FRYER12_RAPID = 4 = Fryer et al. (2012) rapid prescription, BH_FRYER12_STARTRACK = 5 = Fryer et al. (2012) startrack prescription. : (null)\n", - "sn_kick_distribution_II : Set the distribution of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_ECAP : Set the distribution of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_NS_NS : Set the distribution of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IBC : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_GRB_COLLAPSAR : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_TZ : Set the distribution of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_AIC_BH : Set the distribution of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_BH_BH : Set the distribution of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_BH_NS : Set the distribution of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD : Set the distribution of speeds applied to any survivor of a hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD_subluminous : Set the distribution of speeds applied to any survivor of a subluminous hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_II : Set the dispersion of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_ECAP : Set the dispersion of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_NS_NS : Set the dispersion of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IBC : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_GRB_COLLAPSAR : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_TZ : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_AIC_BH : Set the dispersion of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_BH_BH : Set the dispersion of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_BH_NS : Set the dispersion of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD : Set the dispersion of speeds applied to the survivor of a SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD_subluminous : Set the dispersion of speeds applied to the survivor of a subluminous SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_companion_IA_He : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia He supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_ELD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia ELD (sub-Mch) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_CHAND : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_AIC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an accretion induced collapse (supernova) occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_ECAP : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an electron capture supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_He_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia helium merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_CHAND_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_NS_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron-star neutron-star merger. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_GRB_COLLAPSAR : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a GRB Collapsar (rapidly rotating SN Ibc) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_HeStarIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a He-star Ia supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IBC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type Ib/c supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_II : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type II supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type IIa supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_WDKICK : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a WD is kicked. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_TZ : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Thorne-Zytkow object is formed. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_AIC_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron star collapses to a black hole. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_BH_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when two black holes merge. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_BH_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a black hole merges with a neutron star. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_Hybrid_HeCOWD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_Hybrid_HeCOWD_subluminous : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a subluminous hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "wd_sigma : Set the speed at which white dwarfs are kicked when they form, in km/s. Default is zero (i.e. no kick). Requires WD_KICKS. : (null)\n", - "wd_kick_direction : Set the direction of white dwarf kicks. 0 = random, 1 = up, 2 = forward, 3 = backward, 4 = inward, 5 = outward. Requires WD_KICKS. : (null)\n", - "wd_kick_when : Decide when to kick a white dwarf. 0=at birth, 1=at first RLOF, 2=at given pulse number (see wd_kick_pulse_number), 3 at every pulse Requires WD_KICKS. : (null)\n", - "wd_kick_pulse_number : Apply a kick to a star at a desired pulse number on the TPAGB (i.e. pre-WD). Requires WD_KICKS. : (null)\n", - "minimum_helium_ignition_core_mass : Minimum helium core mass required to ignite helium in the case that the hydrogen envelope is stripped on the giant branch, e.g. to make an sdB or sdO star. Typically 0.4, if 0.0 then the BSE algorithm (based on the total mass) is used. : (null)\n", - "minimum_CO_core_mass_for_carbon_ignition : Minimum CO core mass for carbon ignition, assuming Mc,bagb>1.6Msun. Typically around 1.08Msun (Pols+1998). : (null)\n", - "minimum_CO_core_mass_for_neon_ignition : Minimum CO core mass for neon ignition. Typically around 1.42Msun. Stars that have cores that ignite carbon, but not neon explode in electon-capture supernovae. : (null)\n", - "minimum_mcbagb_for_nondegenerate_carbon_ignition : Minimum Mc,bagb (core mass at the base of the AGB) for non-degenerate carbon ignition. Typically around 2.25Msun (Pols+1998). : (null)\n", - "maximum_mcbagb_for_degenerate_carbon_ignition : Maximum Mc,bagb (core mass at the base of the AGB) for degenerate carbon ignition. Typically around 1.6Msun (Pols+1998). : (null)\n", - "max_neutron_star_mass : Maximum mass of a neutron star before it collapses to a black hole. Typically around 2Msun. : (null)\n", - "chandrasekhar_mass : The Chandrasekhar mass, usually 1.44Msun : (null)\n", - "delta_mcmin : A parameter to reduce the minimum core mass for third dredge up to occur on the TPAGB. As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null)\n", - "lambda_min : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. See also lambda_multiplier. : (null)\n", - "lambda_multiplier : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null)\n", - "minimum_envelope_mass_for_third_dredgeup : The minimum envelope mass for third dredge up on the TPAGB. Early, solar metallicity models by Straniero et al suggested 0.5Msun is typical. However, circumstantial evidence (Izzard et al 2009) as well as newer models by Stancliffe and Karakas suggest that at low metallicity a value nearer zero is more appropriate. : (null)\n", - "mass_of_pmz : The mass in the partial mixing zone of a TPAGB star, using the Karakas 2012 tables. Ask Carlo Abate for more details, or see the series of papers Abate et al 2012, 2013, 2014. Requires NUCSYN and USE_TABULAR_INTERSHELL_ABUNDANCES_KARAKAS_2012. : (null)\n", - "c13_eff : The \"efficiency\" of partial mixing in a TPAGB star intershell region, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null)\n", - "mc13_pocket_multiplier : Multiplies the mass in the partial mixing zone of a TPAGB star, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null)\n", - "tides_convective_damping : Tidal convective damping algorithm. 0=TIDES_HURLEY2002 Zahn 197x timescales + Hut, as in Hurley et al (2002), 1 = TIDES_ZAHN1989 : Zahn 1989 lambdas + Hut. : (null)\n", - "E2_prescription : Choose how to calculate the E2 structural parameter (used in tidal timescale calculations). 0=Hurley 1=Izzard (see Siess et al 2013). : (null)\n", - "dtfac : A parameter to decrease the timestep ONLY during the TPAGB phase. : (null)\n", - "hbbtfac : A parameter to modulate the temperature at the base of the hot-bottom burning zone in TPAGB stars. (Works only if NUCSYN is defined) : (null)\n", - "wind_multiplier_%d : Wind multiplier for the stellar type specified by the intger %d. By default these are all 1.0. : (null)\n", - "wind_type_multiplier_%d : Wind multiplier for different types of wind (MS, GB, AGB, WR, LBV, OTHER), given by the integer %d. By default these are all 1.0. : (null)\n", - "pre_main_sequence : Set to True to turn on pre-main sequence evolution. Currently this is not a special stellar type, rather the first (small) fraction of the main sequence has increased radii to match the Railton et al 2014 fits to Tout's pre-main sequence stars. Requires PRE_MAIN_SEQUENCE. See also pre_main_sequence_fit_lobes. : (null)\n", - "pre_main_sequence_fit_lobes : Set to True force a pre-main sequence star into its Roche lobe. This is done by artificially aging it. Requires PRE_MAIN_SEQUENCE : (null)\n", - "small_envelope_method : Choose the method used to determine the stellar radius when the envelope mass is very thin. 0 = Hurley et al. (2002), 1 = Miller Bertolami et al. (2016+) for GB and AGB stars only. : (null)\n", - "timestep_modulator : Multiplier applied to the global timestep. Requires TIMESTEP_MODULATION. : (null)\n", - "timestep_multiplier%d : Multiplier applied to timestep limit <n>. : (null)\n", - "maximum_timestep : The maximum timestep (MYr). : (null)\n", - "zoomfac_multiplier_decrease : When a timestep is rejected, decrease the timestep by this factor (0.5). : (null)\n", - "zoomfac_multiplier_increase : When a timestep is rejected, zooms, then succeeds, increase the timestep by this factor (1.2). : (null)\n", - "maximum_timestep_factor : The maximum factor between two subsequent timesteps (1.2). : (null)\n", - "maximum_nuclear_burning_timestep : The maximum timestep (MYr) in any nuclear burning phase. : (null)\n", - "nova_retention_method : Algorithm used to calculate the amount of mass retained during a nova explosion. 0=use nova_retention_fraction. (other methods pending) : (null)\n", - "MINT_metallicity : This sets the metallicity for MINT. It is ignored if set to -1.0, the default, in which case the normal metallicity parameter is used. : (null)\n", - "gaia_Teff_binwidth : log10(Effective temperature) bin width used to make Gaia-like HRDs\n", - " : (null)\n", - "gaia_L_binwidth : log10(luminosity) bin width used to make Gaia-like HRDs\n", - " : (null)\n", - "gaia_colour_transform_method : Use this to select the method used to transform to Gaia colours from other colour schemes. GAIA_CONVERSION_UBVRI_UNIVARIATE_JORDI2010 = 0 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_UBVRI_BIVARIATE_JORDI2010 = 1 Jordi et al.'s bivariate UBVRI fits, GAIA_CONVERSION_ugriz_UNIVARIATE_JORDI2010 = 2 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_ugriz_BIVARIATE_JORDI2010 = 3 Jordi et al.'s univariate ugriv fits, GAIA_CONVERSION_UBVRI_UNIVARIATE_EVANS2018 = 4 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_ugriz_UNIVARIATE_EVANS2018 = 5 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_UBVRI_RIELLO2020 = 6 Riello et al. (2020, DR3) fits, GAIA_CONVERSION_ugriz_RIELLO2020 = 7 Riello et al. (2020, DR3) fits. : (null)\n", - "rotationally_enhanced_mass_loss : Set to 1 to enable rotationally enhanced mass loss rate algorithms: 0= none, 1=formula cf. Langer models (=ROTATIONALLY_ENHANCED_MASSLOSS_LANGER_FORMULA), 2=limit accretion rate before wind loss is applied, 3 = both 1 and 2. See also rotationally_enhanced_exponent : (null)\n", - "AGB_core_algorithm : Algorithm to use for calculating AGB core masses. 0=Hurley et al. 2002 if no NUCSYN, Karakas 2002 if NUCSYN is defined; 1=Hurley et al. 2002 (overshooting models); 1=Karakas 2002 (non-overshooting models). : (null)\n", - "AGB_radius_algorithm : Algorithm to use for calculating radii on the TPAGB. : (null)\n", - "AGB_luminosity_algorithm : Algorithm to use for calculating luminosities on the TPAGB. : (null)\n", - "AGB_3dup_algorithm : Algorithm to use for calculating third dredge up efficiency on the TPAGB. : (null)\n", - "overspin_algorithm : Algorithm to determine what we do when a star is rotating at its breakup velocity. OVERSPIN_BSE (0) conservatively transfers the angular momentum back to the orbit. OVERSPIN_MASSLOSS uses the rotationally_enhanced_massloss parameter to lose mass which carries away the angular momentum. : (null)\n", - "rotationally_enhanced_exponent : The exponent (power) by which rotationally enhanced mass loss is raised. Requires ROTATIONALLY_ENHANCED_MASS_LOSS. See also rotationally_enhanced_mass_loss. : (null)\n", - "batchmode : Set the batchmode control variable. Use only if you know what you are doing! : (null)\n", - "speedtests : If True, turns on speedtests during version information (off by default). : (null)\n", - "use_fixed_timestep_%d : Set to True to use fixed timestep <n>, False to turn off. Fixed timesteps are on (this is True) by default. : (null)\n", - "task%d : Control tasks to be performed by binary_c. By default, these are all TRUE. For more information see binary_c_macros.h, particularly the BINARY_C_TASK_* macros. : (null)\n", - "orbiting_object : Usage: --orbiting_object mass,spinrate,central_object,period. : 1.0\n", - "orbiting_objects_log : If True, turn on orbiting-object log. : (null)\n", - "orbiting_objects_log : If True, turn on orbiting-object log. : (null)\n", - "orbiting_objects_wind_accretion_multiplier : Multiplier for wind accretion on orbiting objects. Hurley et al 2002 use 1.5, which is the default. : (null)\n", - "orbiting_objects_close_pc_threshold : How close are orbiting objects allowed to be? Set this to be the absolute percentage difference minimum. : (null)\n", - "orbiting_objects_tides_multiplier : Multiplier for tidal torques on orbiting objects. : (null)\n", - "evaporate_escaped_orbiting_objects : If True, evaporate orbiting objects that have escaped the system. : (null)\n", - "RLOF_transition_objects_escape : If True, objects that escape their Roche lobe are ejected from the system, otherwise they are placed just outside the minimum stable orbit. : (null)\n", - "PN_resolve : If True, the timestep will be shortened to resolve better the PN phase (FALSE). : (null)\n", - "PN_resolve_minimum_luminosity : The luminosity above which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_resolve_maximum_envelope_mass : The envelope mass below which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_resolve_minimum_effective_temperature : The minimum effective temperature above which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_fast_wind : If True, thin-envelope PNe will have fast winds (FALSE). : (null)\n", - "PN_fast_wind_dm_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null)\n", - "PN_fast_wind_mdot_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null)\n", - "PN_fast_wind_dm_AGB : The envelope mass below which fast wind used during the AGB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null)\n", - "PN_fast_wind_mdot_AGB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null)\n", - "HeWD_HeWD_ignition_mass : HeWD-HeWD mergers above this mass reignite helium. (0.3) : (null)\n", - "wind_Nieuwenhuijzen_luminosity_lower_limit : Above this luminosity we activate the Nieuwenhuijzen and de Jager wind (4e3 Lsun). : (null)\n", - "wind_LBV_luminosity_lower_limit : Above this luminosity we activate the LBV wind (6e5 Lsun). : (null)\n", - "colour%d : Sets colour %d (0 to NUM_ANSI_COLOURS-1) to the extended ANSI set colour you choose (1-255, 0 means ignore). The colour numbers are defined in src/logging/ansi_colours.h : (null)\n", - "apply_Darwin_Radau_correction : Apply Darwin-Radau correction to the moment of inertia to take rotation into account? : (null)\n", - "degenerate_core_merger_nucsyn : If TRUE, assume that in a degnerate core merger, energy is generated from nucleosynthesis of the whole core, and that this can disrupt the core. The BSE algorithm (Hurley et al. 2002) assumes this to be TRUE, but binary_c assumes FALSE by default. (FALSE) : (null)\n", - "degenerate_core_helium_merger_ignition : If TRUE, assume that when there is a degenerate helium core merger, the star reignites helium. This is required to make R-type carbon stars. (TRUE) : (null)\n", - "degenerate_core_merger_dredgeup_fraction : If non-zero, mix this fraction of the degenerate core during a merger.(0.0). : (null)\n", - "\n", - "############################################################\n", - "##### Section Binary\n", - "############################################################\n", - "separation : Set the orbital separation (actually the semi-major axis) of the binary (internal index 0, stellar indices 0 and 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "separation_triple : Set the orbital separation (actually the semi-major axis) of the triple (internal index 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "separation_quadruple : Set the orbital separation (actually the semi-major axis) of the quadruple (internal index 2) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "orbital_period : Set the initial orbital period of the binary, stars 1 and 2 (internal indices 0 and 1) in days. See also separation. : (null)\n", - "orbital_period_triple : Set the initial orbital period of the triple in days. See also separation. : (null)\n", - "orbital_period_quadruple : Set the orbital period of the outer binary in a quadrulple (stars 3 and 4, internal indices 2 and 3) in days. See also separation. : (null)\n", - "eccentricity : Set the initial eccentricity of the binary orbit (stars 1 and 2, internal indices 0 and 1). : (null)\n", - "eccentricity_triple : Set the initial eccentricity of the triple orbit. : (null)\n", - "eccentricity_quadruple : Set the initial eccentricity of the outer binary of a quadruple (stars 3 and 4, internal indices 2 and 3). : (null)\n", - "incliniation : Set the initial orbital_inclination of the binary relative to zero. : (null)\n", - "incliniation_triple : Set the initial orbital_inclination of the triple orbit relative to zero. : (null)\n", - "incliniation_quadruple : Set the initial orbital_inclinationy of the quadruple orbit relative to zero. : (null)\n", - "orbital_phase : Set the initial orbital phase of the binary orbit. : (null)\n", - "orbital_phase_triple : Set the initial orbital phase of the triple orbit. : (null)\n", - "orbital_phase_quadruple : Set the initial orbital phase of the quadruple orbit. : (null)\n", - "argument_of_periastron : Set the initial argument of periastron of the binary orbit. : (null)\n", - "argument_of_periastron_triple : Set the initial argument of periastron of the triple orbit. : (null)\n", - "argument_of_periastron_quadruple : Set the initial argument of periastron of the quadruple orbit. : (null)\n", - "disc_timestep_factor : Factor that multiplies the natural timestep of a disc. : (null)\n", - "white_dwarf_cooling_model : White dwarf cooling model, relates age to luminosity. WHITE_DWARF_COOLING_MESTEL = 0 is Mestel's model, WHITE_DWARF_COOLING_MESTEL_MODIFIED = 1 is Hurley's modified Mestel model, WHITE_DWARF_COOLING_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null)\n", - "white_dwarf_radius_model : White dwarf radius model, radius to mass (and perhaps age). WHITE_DWARF_RADIUS_NAUENBERG1972 = 0 Nauenberg (1972), WHITE_DWARF_RADIUS_MU = 1 mu-dependent variant, WHITE_DWARF_RADIUS_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null)\n", - "cbdisc_mass_loss_inner_viscous_accretion_method : Chooses where the mass that is accreted from the inner edge of a circumbinary disc goes, i.e. to which star. 0 = Young and Clarke 2015, 1 = Gerosa et al 2015, 2 = 50:50 (i.e. not dependence on mass). : (null)\n", - "cbdisc_inner_edge_stripping : If True, allow inner edge mass stripping. : (null)\n", - "cbdisc_end_evolution_after_disc : If True, stop evolution when a disc evaporates. : (null)\n", - "cbdisc_no_wind_if_cbdisc : If True, disable stellar winds when there is a circumbinary disc. : (null)\n", - "cbdisc_outer_edge_stripping : If True, allow outer edge mass stripping. : (null)\n", - "disc_n_monte_carlo_guesses : Number of monte carlo guesses to try in the disc solver if the normal list of guesses fails (0). : (null)\n", - "disc_log : If 1, turn on the disc log. Requires DISC_LOG to be defined on build. : (null)\n", - "disc_log2d : If 1, turn on the 2d disc log. Requires DISC_LOG to be defined on build. : (null)\n", - "disc_log_dt : If non-zero, only allows disc log output every disc_log_dt Myr. : (null)\n", - "disc_log_directory : Directory into which disc logging is sent (must exist!). : /tmp/\n", - "post_ce_adaptive_menv : If TRUE, and if post_ce_objects_have_envelopes is TRUE, then the envelope mass of a post-CE star is such that it sits just inside its Roche lobe. If FALSE then a fixed (thin) envelope mass is applied that depends on the stellar type (see macros POST_CE_ENVELOPE_DM_GB, POST_CE_ENVELOPE_DM_EAGB and POST_CE_ENVELOPE_DM_TPAGB). : (null)\n", - "post_ce_objects_have_envelopes : If TRUE then post-common-envelope objects have thin envelopes. You need this if you are to have post-CE post-AGB stars. Note that this *may* be unstable, i.e. you may end up having many CEEs. The mass in the envelope is controlled by post_ce_adaptive_menv. TRUE by default. : (null)\n", - "PN_comenv_transition_time : post-common envelope transition time in years (1e2). This is the time taken to move from CEE ejection to Teff > 30e4 K. Hall et al. (2013) suggest ~100 years. : (null)\n", - "minimum_time_between_PNe : The minimum time (Myr) between planetary nebula detections. This prevents multiple, fast common envelopes triggering two PNe (0.1). : (null)\n", - "PN_Hall_fading_time_algorithm : In stars with low mass (<0.45Msun) cores, you can choose to set the PN fading time to either the minimum (PN_HALL_FADING_TIME_ALGORITHM_MINIMUM) or maximum (PN_HALL_FADING_TIME_ALGORITHM_MAXIMUM) as shown in Fig. 6 of Hall et al. (2013). : (null)\n", - "PPN_envelope_mass : Desired pre-planetary nebula (post-AGB) envelope mass. : (null)\n", - "cbdisc_eccentricity_pumping_method : Select from various eccentricity-pumping methods when there is a circumbinary disc. Requires DISCS. 0 = off. : (null)\n", - "cbdisc_viscous_photoevaporative_coupling : Set to 1 to turn on viscous-photoevaporative coupling in circumbinary discs. Requires DISCS. 0 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_NONE = off, 1 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_INSTANT instant, 2 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_VISCOUS slow, viscous wind. : (null)\n", - "cbdisc_inner_edge_stripping_timescale : Defines the timescale for mass loss from by inner edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_in. : (null)\n", - "cbdisc_outer_edge_stripping_timescale : Defines the timescale for mass loss from by outer edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_out. : (null)\n", - "cbdisc_viscous_L2_coupling : Set to 1 to turn on viscous-L2-loss coupling in circumbinary discs. Requires DISCS. 0 = off. : (null)\n", - "gravitational_radiation_model : Model for gravitational radiation from the system. 0=Hurley et al 2002 (Landau and Lifshitz 1951). 1 = as 0 but only when there is no RLOF. 2 = none. : (null)\n", - "nova_irradiation_multiplier : Multiplier for nova-radiative induced mass loss. (Shara+1986) : (null)\n", - "gravitational_radiation_modulator_J : Modulator for gravitational wave radiation angular momentum loss rate (1.0). : (null)\n", - "gravitational_radiation_modulator_e : Modulator for gravitational wave radiation eccentricity pumping rate (1.0). : (null)\n", - "nova_faml_multiplier : Nova friction-induced angular momentum loss multiplier. (Shara+1986) : (null)\n", - "RLOF_angular_momentum_transfer_model : Choose angular momentum transfer model in RLOF. 0=BSE (with discs), 1=conservative : (null)\n", - "post_SN_orbit_method : Method by which the post-SN orbit is calculated. 0=BSE, 1=Tauris&Taken 1998. : (null)\n", - "multiplicity : Multiplicity: 1=single star, 2=binary, 3=triple, 4=quadruple. : (null)\n", - "accretion_limit_eddington_steady_multiplier : Steady accretion is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_steady_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_eddington_LMMS_multiplier : Accretion from a low-mass, convective, main_sequence star is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_LMMS_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_eddington_WD_to_remnant_multiplier : Accretion from a WD onto a remnant star (e.g. another white dwarf, neutron star or black hole) is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_WD_to_remnant_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_thermal_multiplier : Mass transfer onto a MS, HG or CHeB star is limited by the accretor's thermal rate times this multiplier. : (null)\n", - "accretion_limit_dynamical_multiplier : Mass transfer is limited by the accretor's dynamical rate times this multiplier. : (null)\n", - "donor_limit_envelope_multiplier : Mass transfer by RLOF is limited by this fraction of the donor's envelope mass per timestep : (null)\n", - "donor_limit_thermal_multiplier : Mass transfer by RLOF is limited by the accretor's thermal rate times this multiplier. : (null)\n", - "donor_limit_dynamical_multiplier : Mass transfer by RLOF is limited by the donor's dynamical rate times this multiplier. : (null)\n", - "Bondi_Hoyle_accretion_factor : Wind accretion rate, as calculated by the Bondi-Hoyle-Littleton formula, multiplcation factor. Hurley et al 2002 use 1.5, which is the default. : (null)\n", - "tidal_strength_factor : A modulator for the tidal strength. If this factor > 1 then tides are stronger, i.e. tidal timescales are reduced. : (null)\n", - "hachisu_qcrit : Critical q=Maccretor/Mdonor above which Hachisu's disk wind turns on. : (null)\n", - "hachisu_disk_wind : Set to True to turn on Hachisu's disk wind when material accretes too fast onto a white dwarf. This helps to make more SNeIa. See also hachisu_qcrit. : (null)\n", - "mass_accretion_for_eld : The mass that must be accreted onto a COWD for it to ignite as an edge-lit detonation SNIa. : (null)\n", - "WDWD_merger_algorithm : Algorithm to be used when merging two white dwarfs. 0 = Hurley et al. (2002), 1 = Perets+ (2019), 2 = Chen+ (2016, todo) : (null)\n", - "type_Ia_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from Chandrasekhar-mass exploders. 0 = DD7 (Iwamoto 1999), 1 = Seitenzahl 2013 3D hydro yields (you must also set Seitenzahl2013_model) : (null)\n", - "Seitenzahl2013_model : Which of Seitenzahl et al. 2013's models to use? One of N1,N3,N5,N10,N20,N40,N100L,N100,N100H,N150,N200,N300C,N1600,N1600C,N100_Z0.5,N100_Z0.1,N100_Z0.01 (defaults to N100). : N1\n", - "type_Ia_sub_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from sub-Chandrasekhar-mass exploders. (Currently unused.) : (null)\n", - "max_HeWD_mass : The maximum mass a HeWD can have before it ignites helium (0.7). : (null)\n", - "merger_mass_loss_fraction : Fraction of the total mass which is lost when stars merge. : (null)\n", - "merger_angular_momentum_factor : When two stars merge the resulting single star retains a fraction of the total system angular momentum (or the critical spin angular momentum, if it is smaller) multiplied by this factor. : (null)\n", - "wind_angular_momentum_loss : Prescription for losing angular momentum in a stellar wind. 0=Hurley et al 2002 ('Tout') prescription, 1=lw i.e. a factor multiplying the specific orbital angular momentum, 2=lw hybrid for fast winds. Set wind_djorb_fac to the desired factor.. : (null)\n", - "wind_djorb_fac : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=0 (the Tout/Hurley et al 2002 prescription). See wind_angular_momentum_loss. : (null)\n", - "lw : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=1,2 (the 'lw' prescription). See wind_angular_momentum_loss. : (null)\n", - "VW93_EAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null)\n", - "VW93_TPAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null)\n", - "use_periastron_Roche_radius : Set this to True to use the Roche lobe radius at periastron, rather than (the default to) assume a circular orbit. This will be useful one day when we treat RLOF in eccentric orbits properly, hopefully. : (null)\n", - "qcrit_LMMS : Apply critical q=Mdonor/Maccretor value for low-mass main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_LMMS : Apply critical q=Mdonor/Maccretor value for (low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "mass_for_Hestar_Ia_upper : Only helium stars below this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_lower. : (null)\n", - "mass_for_Hestar_Ia_lower : Only helium stars above this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_upper. : (null)\n", - "alphaCB : Circumbinary disk viscosity parameter, alpha. : (null)\n", - "minimum_donor_menv_for_comenv : Minimum donor envelope mass for common envelope evolution to be triggered (Msun). Default 0. : (null)\n", - "comenv_prescription : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null)\n", - "comenv_prescription%d : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null)\n", - "comenv_ejection_spin_method : When a common envelope is ejected, we need to decide how fast the stars are left spinning. COMENV_EJECTION_SPIN_METHOD_DO_NOTHING (0) is the default, this just leaves the stars/stellar cores spinning with the same spin rate (omega = angular velocity) with which they entered the common envelope phase. COMENV_EJECTION_SPIN_METHOD_SYCHRONIZE instead tidally synchronizes the stars with their new orbital angular velocity. : (null)\n", - "comenv_merger_spin_method : When a common envelope binary merges, we need to decide how fast the resulting single star is left spinning. COMENV_MERGER_SPIN_METHOD_SPECIFIC (0) is the default, this preserves angular momentum but limits the specific angular momentum of the merged star to the specific angular momentum of the system at the onset of common envelope evolution. COMENV_MERGER_SPIN_METHOD_CONSERVE_ANGMOM (1) sets the merger's angular momentum to be that of the system at the onset of common envelope evolution (which means the star may be rotating supercritically). COMENV_MERGER_SPIN_METHOD_CONSERVE_OMEGA (2) sets the spin rate (angular frequency = omega) of the merged star to be that of the orbit just at the onset of common envelope evolution. : (null)\n", - "comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null)\n", - "comenv_ms_accretion_fraction : Experimental. During common envelope evolution, a main sequence may accrete a fraction of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_mass. : (null)\n", - "comenv_ns_accretion_mass : Experimental. During common envelope evolution, a neutron star may accrete some of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_fraction. : (null)\n", - "comenv_ns_accretion_fraction : Experimental. During common envelope evolution, a neutron star may accrete a fraction of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_mass. : (null)\n", - "alpha_ce : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null)\n", - "alpha_ce%d : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null)\n", - "lambda_ce : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to LAMBDA_CE_DEWI_TAURIS == -1 binary_c uses the Dewi and Tauris fits instead, LAMBDA_CE_WANG_2016 == -2 uses the formalism of Wang, Jia and Li (2016), if LAMBDA_CE_POLYTROPE == -3 then a polytropic formalism is used (see also comenv_splitmass) and if LAMBDA_CE_KLENCKI_2020 == -4 use Klencki et al. (2020). : (null)\n", - "lambda_ce%d : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to -1 binary_c uses the Dewi and Tauris fits instead, -2 uses the formalism of Wang, Jia and Li (2016) and if -3 then a polytropic formalism is used (see also comenv_splitmass). : (null)\n", - "comenv_splitmass : When lambda_ce=-2, the envelope binding energy, lambda, is calculated using a polytropic formalism. The comenv_splitmass defines the point, in the units of the core mass, above which material is ejected. : (null)\n", - "nelemans_recalc_eccentricity : If True, recalculate the eccentricity after angular momentum is removed. : (null)\n", - "comenv_post_eccentricity : Eccentricity remaining after common envelope ejection. : (null)\n", - "nelemans_gamma : Set the fraction of the orbital specific angular momentum that is used to eject the common envelope according to the Nelemans and Tout prescription. See also nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null)\n", - "nelemans_minq : Only activate the Nelemans and Tout common envelope prescription for q>nelemans_minq. See also nelemans_gamma, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null)\n", - "nelemans_max_frac_j_change : Maximum fractional angular momentum change in the Nelemans and Tout common envelope prescription. See also nelemans_gamma, nelemans_minq, nelemans_n_comenvs. : (null)\n", - "nelemans_n_comenvs : Set the maximum number of common envelope ejections allowed to follow the Nelemans and Tout prescription, after which the standard alpha prescription is used. : (null)\n", - "lambda_ionisation : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null)\n", - "lambda_ionisation%d : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null)\n", - "lambda_enthalpy : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null)\n", - "lambda_enthalpy%d : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null)\n", - "cbdisc_albedo : Circumbinary-disc albedo. Requires DISCS. : (null)\n", - "cbdisc_gamma : Circumbinary disc gamma (equation of state) parameter. Requires DISCS. : (null)\n", - "cbdisc_alpha : Circumbinary disc alpha (viscosity) parameter. Requires DISCS. : (null)\n", - "cbdisc_kappa : Circumbinary disc kappa (opacity) parameter. Requires DISCS. : (null)\n", - "cbdisc_minimum_evaporation_timescale : Circumbinary disc minimum evaporation timescale (years). If (slow, not edge stripped) mass loss would evaporate the disc on a timescale less than this, simply evaporate the disc immediated. Usually set to 1y, ignore if zero. Requires DISCS. : (null)\n", - "cbdisc_torquef : Circumbinary disc binary torque multiplier. Requires DISCS. : (null)\n", - "cbdisc_max_lifetime : Circumbinary disc maximum lifetime (years, ignored if 0). Requires DISCS. : (null)\n", - "cbdisc_init_dM : On cbdisc start, reduce mass by a fraction dM if it won't converge. Requires DISCS. : (null)\n", - "cbdisc_init_dJdM : On cbdisc start, reduce angular momentum by a fraction dJ/dM*dM if it won't converge. Requires DISCS. : (null)\n", - "cbdisc_mass_loss_constant_rate : Circumbinary disc constant mass loss rate (Msun/year). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_FUV_multiplier : Circumbinary disc FUV mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_Xray_multiplier : Circumbinary disc X-ray mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_ISM_ram_pressure_multiplier : Circumbinary disc interstellar medium ram pressure stripping mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_ISM_pressure : Circumbinary disc interstellar medium ram pressure in units of Boltzmann constant per Kelvin (I think...). Requires DISCS. Typically 3000.0. See e.g. http://www.astronomy.ohio-state.edu/~pogge/Ast871/Notes/Intro.pdf page 15 or https://arxiv.org/pdf/0902.0820.pdf Fig. 1 (left panel). : (null)\n", - "cbdisc_mass_loss_inner_viscous_multiplier : Circumbinary disc inner edge viscous mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_inner_viscous_angular_momentum_multiplier : Circumbinary disc inner edge viscous angular momentum multiplier (no units). The inner edge angular momentum Requires DISCS. : (null)\n", - "cbdisc_resonance_multiplier : Circumbinary disc resonant interaction multiplier, affects eccentricity pumping and angular momentum rates. Requires DISCS. : (null)\n", - "cbdisc_resonance_damping : Circumbinary disc resonant interaction damping: should be on (True) to damp the l=1, m=2 resonance when the disc inner edge lies outside the resonance location. Requires DISCS. : (null)\n", - "cbdisc_fail_ring_inside_separation : If True, while converging on a structure, circumbinary discs with Rring < the binary separation are immediately failed. : (null)\n", - "cbdisc_mass_loss_inner_L2_cross_multiplier : Circumbinary disc inner edge L2-crossing mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_minimum_luminosity : Circumbinary disc minimum luminosity. If the disc becomes dimmer than this, the disc is evaporated instantly. Requires DISCS. : (null)\n", - "cbdisc_minimum_mass : Circumbinary disc minimum mass. If the disc becomes less massive than this, the disc is evaporated instantly. Requires DISCS. : (null)\n", - "cbdisc_minimum_fRing : Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = |Rout/Rin-1| < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS. : (null)\n", - "comenv_disc_angmom_fraction : If >0 Fraction of the common envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the moments of inertia to calculate (deprecated), if -2 use the common envelope's specific angular momentum, if -3 uses the L2 point at the end of the common envelope to set the angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null)\n", - "comenv_disc_mass_fraction : Fraction of the common envelope's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null)\n", - "wind_disc_angmom_fraction : If >0 Fraction of the wind envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the L2 point's specific angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null)\n", - "wind_disc_mass_fraction : Fraction of the stellar wind's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null)\n", - "WRLOF_method : Choose whether and how to apply wind-Roche-lobe-overflow. 0=none, 1=q-dependent, 2=quadratic See Abate et al 2013/14 for details. Requires WRLOF_MASS_TRANSFER. : (null)\n", - "minimum_timestep : The minimum timestep (Myr). : (null)\n", - "timestep_solver_factor : Factor applied in timestep_limits, e.g. to prevent X changing too fast by comparing to X/dX/dt, which is usually 1 but can be higher to lengthen timesteps when using an alternative solver. : (null)\n", - "RLOF_mdot_factor : Multiplier applied to the mass transfer rate during Roche-lobe overflow. Requires RLOF_MDOT_MODULATION. : (null)\n", - "RLOF_f : Factor to enlarge a Roche lobe, nominally because of radiation pressure (see Dermine et al paper). Requires RLOF_RADIATION_CORRECTION. : (null)\n", - "minimum_separation_for_instant_RLOF : If True, instead of evolving the system just report the minimum separation (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_orbital_period_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null)\n", - "minimum_orbital_period_for_instant_RLOF : If True, instead of evolving the system just report the minimum orbital period (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_separation_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null)\n", - "maximum_mass_ratio_for_instant_RLOF : If True, instead of evolving the system just report the maximum mass ratio (on the zero-age main sequence) that would lead to instant RLOF, given M1 and orbital period. Used by binary_grid. See also minimum_separation_for_instant_RLOF and minimum_orbital_period_for_instant_RLOF. : (null)\n", - "RLOF_method : Use RLOF_method to choose the algorithm you use for Roche-lobe overflow mass loss rate calculations. 0=Hurley et al 2002, 1=Adaptive (for radiative stars) R=RL method, 2=Ritter (probably broken), 3=Claeys etal 2014 variant on Hurley et al 2002. : (null)\n", - "RLOF_interpolation_method : When a star overflows its Roche lobe, it always has R>RL because of the limited time resolution of the simulation. Binary_c then uses an algorithm to get back to when R~RL (within a desired tolerance, set in RLOF_ENTRY_THRESHOLD which is usually 1.02, i.e. overflow of 2%). You can choose algorithm 0, the Hurley et al 2002 method which reverses time (i.e. uses a Newton-like scheme), or 1 to use the binary_c method which rejects a timestep (and hence does no logging on that timestep) and repeats with half the timestep until R~RL. The latter is now the default, because this means there are no negative timesteps which break various other algorithms (e.g. nucleosynthesis). : (null)\n", - "nova_retention_fraction : The mass accreted during a nova as fraction of mass transferred : (null)\n", - "beta_reverse_nova : The fraction of mass ejected in a nova explosion which is accreted back onto the companion star. Set to -1 to automatically calculate based on a geometric argument, or 0 or positive to set the value. : (null)\n", - "WD_accretion_rate_novae_upper_limit_hydrogen_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is hydrogen rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_novae_upper_limit_helium_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is helium rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_novae_upper_limit_other_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is neither hydrogen nor helium rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_hydrogen_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a hydrogen-rich donor. Below this mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_helium_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a helium-rich donor. Below this mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_other_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope when the donor is neither hydrogen nor helium rich. Below this mass transfer leads to stable burning. : (null)\n", - "CRAP_parameter : Tidally enhanced mass loss parameter. See Tout and Eggleton's paper on the subject. (Was the parameter bb). : (null)\n", - "individual_novae : If individual_novae is True, novae are resolved such that each explosion is performed separtaely. : (null)\n", - "nova_timestep_accelerator_num : The nova timestep is accelerated if the nova number exceeds nova_timestep_accelerator_num. If zero or negative, acceleration is off. See also nova_timestep_accelerator_index and nova_timestep_accelerator_max. Only used if individual_novae is on.\n", - " : (null)\n", - "nova_timestep_accelerator_index : The index at which the nova timestep is accelerated. A larger value gives longer timesteps. See also nova_timestep_accelerator_num and nova_timestep_accelerator_max. Only used if individual_novae is on.\n", - " : (null)\n", - "nova_timestep_accelerator_max : The nova timestep is accelerated by a factor that is capped at nova_timestep_accelerator_max. This parameter is ignored if it is zero or negative. See also nova_timestep_accelerator_num and nova_timestep_accelerator_index. Only used if individual_novae is on.\n", - " : (null)\n", - "nonconservative_angmom_gamma : Mass lost from the system (but NOT from a stellar wind) takes a fraction gamma of the orbital angular momentum with it. Set to -1 to take the specific angular momentum of the donor star. Set to -2 to take super-Eddington, nova and disk-wind angular momenta as if a wind from the accretor. : (null)\n", - "max_stellar_angmom_change : Maxmimum fractional change in stellar angular momentum allowed before a timestep is rejected (0.05). : (null)\n", - "comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null)\n", - "\n", - "############################################################\n", - "##### Section Nucsyn\n", - "############################################################\n", - "third_dup : If True, enables third dredge up. Requires NUCSYN and NUCSYN_THIRD_DREDGE_UP. : (null)\n", - "third_dup_multiplier : Usage: --third_dup_multiplier <i> <f>. Multiplies the abundance of element <i> by <f> during third dredge up. : 1.0\n", - "NeNaMgAl : Enables NeNaMgAl reaction network. Requires NUCSYN and NUCSYN_HBB. : Ignore\n", - "nucsyn_network%d : Usage: --nucsyn_network%d <boolean>. Turn a nuclear network on or off. : (null)\n", - "nucsyn_network_error%d : Usage: --nucsyn_network_error%d <f>. Threshold error in nuclear network solver for network %d. : (null)\n", - "nucreacmult%d : Usage: --nucreacmult%d <f>. Multiply nuclear reaction given by the integer %d (integer) by f (float). : (null)\n", - "nucsyn_metallicity : This sets the metallicity of the nucleosynthesis algorithms, i.e. the amount (by mass) of matter which is not hydrogen or helium. Usually you'd just set this with the metallicity parameter, but if you want the nucleosynthesis to be outside the range of the stellar evolution algorithm (e.g. Z=0 or Z=0.04) then you need to use nucsyn_metallicity. That said, it's also outside the range of some of the nucleosynthesis algorithms as well, so you have been warned! : (null)\n", - "nucsyn_solver : Choose the solver used in nuclear burning. 0 = KAPS_RENTROP is a Kaps-Rentrop scheme (fast, not great for stiff problems), 1 = LSODA (Adams/BSF switcher), 2 = CVODE library (https://computing.llnl.gov/projects/sundials. Default 0. : 0\n", - "initial_abundance_mix : initial abundance mixture: 0=AG89, 1=Karakas 2002, 2=Lodders 2003, 3=Asplund 2005 (not available?), 4=Garcia Berro, 5=Grevesse Noels 1993 : 0\n", - "init_abund : Usage: --init_abund <i> <X>. Sets the initial abundance of isotope number <i> to mass fraction <X>. : 0.02\n", - "init_abund_mult : Usage: --init_abund_mult <i> <f>. Multiplies the initial abundance of isotope number <i> by <f>. : 1.0\n", - "init_abund_dex : Usage: --init_abund_dex <i> <f>. Changes the initial abundance of isotope number <i> by <f> dex. : 0.0\n", - "init_abunds_only : If True, outputs only the initial abundances, then exits. : (null)\n", - "initial_abunds_only : If True, outputs only the initial abundances, then exits. : (null)\n", - "no_thermohaline_mixing : If True, disables thermohaline mixing. : (null)\n", - "lithium_GB_post_Heflash : Sets the lithium abundances after the helium flash. Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "lithium_GB_post_1DUP : Sets the lithium abundance after first dredge up. Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "lithium_hbb_multiplier : Multiplies the lithium abundances on the AGB during HBB (based on Karakas/Fishlock et al models).Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "angelou_lithium_decay_function : Functional form which describes Li7 decay. Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Choices are : 0 expoential (see angelou_lithium_decay_time). : (null)\n", - "angelou_lithium_LMMS_time : Time at which lithium manufacture is triggered in a low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_time : Time at which lithium manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_time : Time at which lithium manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_time : Time at which lithium manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_time : Time at which lithium manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_time : Time at which lithium manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_time : Time at which lithium manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_LMMS_decay_time : Decay time for surface lithium abundance during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_decay_time : Decay time for surface lithium abundance on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_decay_time : Decay time for surface lithium abundance on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_decay_time : Decay time for surface lithium abundance on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_decay_time : Decay time for surface lithium abundance during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_decay_time : Decay time for surface lithium abundance on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_decay_time : Decay time for surface lithium abundance on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_LMMS_massfrac : Lithium mass fraction when its manufacture is triggered during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_massfrac : Lithium mass fraction when its manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_massfrac : Lithium mass fraction when its manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_massfrac : Lithium mass fraction when its manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_massfrac : Lithium mass fraction when its manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_vrot_trigger : Equatorial rotational velocity at which lithium manufacture is triggered (km/s). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0.\n", - " : (null)\n", - "angelou_lithium_vrotfrac_trigger : Fraction of Keplerian (breakup) equatorial rotational velocity at which lithium manufacture is triggered (must be <1, ignored if 0). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0.\n", - " : (null)\n", - "\n", - "############################################################\n", - "##### Section Output\n", - "############################################################\n", - "cf_amanda_log : Enable logging to compare to Amanda's models. : (null)\n", - "float_overflow_checks : Turn on to enable floating-point overflow checks at the end of each timestep, if they are available. 0=off, 1=warn (stderr) on failure, 2=exit on failure (0) : (null)\n", - "save_pre_events_stardata : Enable this to save a copy of stardata to stardata->pre_events_stardata just before an event. : (null)\n", - "disable_end_logging : Disable the logging that happens at the end of the evolution. : (null)\n", - "ensemble : Turn on ensemble calculations and output. : (null)\n", - "ensemble_filters_off : Sets all ensemble filters to be off (FALSE) - these can then be enabled one-by-one with --ensemble_filter_[...] TRUE. : (null)\n", - "ensemble_filter_%d : Turn on or off ensemble filter <n>. For a list of filters, see ensemble_macros.h. : (null)\n", - "ensemble_legacy_ensemble : Turn on ensemble legacy population output. : (null)\n", - "legacy_yields : Turn on ensemble legacy yield output. : (null)\n", - "ensemble_defer : Defer ensemble output. : (null)\n", - "ensemble_dt : When doing ensemble calculations, data are stored and/or output every ensemble_dt Myr. See also ensemble, ensemble_logdt, ensemble_startlogtime. : (null)\n", - "ensemble_logdt : When doing ensemble calculations, and when logensembletimes is set, the ensemble is stored/output every ensemble_logdt Myr. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null)\n", - "ensemble_startlogtime : Start log ensemble data storage/calculations/output at ensemble_startlogtime. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null)\n", - "ensemble_logtimes : When doing ensemble calculations/output, set this to act at log times rather than linear times. : (null)\n", - "postagb_legacy_logging : Turn on post-AGB legacy logging. : (null)\n", - "disc_legacy_logging : Turn on disc legacy logging. : (null)\n", - "EMP_logg_maximum : Maximum logg that EMP stars are allowed to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_minimum_age. : (null)\n", - "EMP_minimum_age : Minimum age that EMP stars are required to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum. : (null)\n", - "EMP_feh_maximum : Maximum [Fe/H] that an EMP stars may have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default -2.0. : (null)\n", - "CEMP_cfe_minimum : Minimum [C/Fe] that CEMP stars are required to have. See Izzard et al 2009. See also NEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 0.7. : (null)\n", - "NEMP_cfe_minimum : Minimum [N/Fe] that NEMP stars are required to have. See Izzard et al 2009, Pols et al. 2012. See also CEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 1.0. : (null)\n", - "thick_disc_start_age : Lookback time for the start of the thick disc star formation, e.g. 13e3 Myr. Units = Myr. : (null)\n", - "thick_disc_end_age : Lookback time for the end of the thick disc star formation, e.g. 4e3 Myr. Units = Myr. : (null)\n", - "thick_disc_logg_min : Minimum logg for thick disc giants to be logged. : (null)\n", - "thick_disc_logg_max : Maximum logg for thick disc giants to be logged. : (null)\n", - "escape_velocity : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 1e9 km/s. See also escape_fraction. : (null)\n", - "escape_fraction : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 0.0. See also escape_velocity. : (null)\n", - "colour_log : If set to True, thelog is coloured with ANSI colour formatting. Requires FILE_LOG to be defined. : \n", - "log_filename : Location of the output logging filename. If set to \"/dev/null\" then there is no logging. : \n", - "log_arrows : Add arrows to the output log to show whether values are increasing or decreasing. : \n", - "stopfile : File which, when it exists, will stop the current binary_c repeat run. : \n", - "stardata_dump_filename : Location of the stardata dump file. : \n", - "stardata_load_filename : Location of the stardata file to load. : \n", - "api_log_filename_prefix : Location of the output logging filename prefix for the API. If set to \"/dev/null\" then there is no logging. : 0\n", - "hrdiag_output : Set to True to output high time-resolution Hertzstrpung-Russell diagram information. Requires HRDIAG. : (null)\n", - "internal_buffering : Experimental. Set to non-zero values to implement internal buffering prior to output. For use with binary_grid, you shouldn't really be playing with this. : (null)\n", - "eccentric_RLOF_model : Chooses which model is used to handle eccentric RLOF. Default is RLOF_ECCENTRIC_AS_CIRCULAR, i.e. ignore the eccentricity. Note: requires force_corotation_of_primary_and_orbit to be FALSE.\n", - " : (null)\n", - "force_circularization_on_RLOF : If True forces circularization of stars and orbit when RLOF starts, this is as in the BSE algorithm. (True) : (null)\n", - "wtts_log : If True, enables log file output for WTTS2. : (null)\n", - "fabian_imf_log_time : Time at which to output for Fabian Schneider's IMF project. Requires FABIAN_IMF_LOG : Ignore\n", - "fabian_imf_log_timestep : Timestep for Fabian Schneider's IMF project logging. Requires FABIAN_IMF_LOG : Ignore\n", - "version : Display binary_c version and build information. Also performs timing tests. : Ignore\n", - "dumpversion : Display binary_c version number (short format). : Ignore\n", - "version_only : Display binary_c version number and build information, but do not perform timing tests or anything that requires stardata to be non-NULL. : Ignore\n", - "tides_diagnosis_log : Enable logging to test MINT tides. Requires MINT. Choices are: 0 disabled, 1 enable lambda test. : Ignore\n", - "\n", - "############################################################\n", - "##### Section Input\n", - "############################################################\n", - "MINT_dir : Location of MINT algorithm data. : \n", - "MINT_data_cleanup : Activate checks on incoming data to try to account for problems. Will make data-loading slower, but may fix a few things. : \n", - "MINT_MS_rejuvenation : Turn on or off (hydrogen) main-sequence rejuvenation. : \n", - "MINT_remesh : Turn on or off MINT's remeshing. : \n", - "MINT_use_ZAMS_profiles : Use chemical profiles at the ZAMS if MINT_use_ZAMS_profiles is TRUE, otherwise set homogeneous abundances. (Default is TRUE, so we use the profiles if they are available.) : \n", - "MINT_fallback_to_test_data : If TRUE, use the MINT test_data directory as a fallback when data is unavailable. (FALSE) : \n", - "MINT_disable_grid_load_warnings : Use this to explicitly disable MINT's warnings when loading a grid with, e.g., missing or too much data. : \n", - "MINT_Kippenhahn : Turn on or off MINT's Kippenhahn diagrams. If 0, off, if 1, output star 1 (index 0), if 2 output star 2 (index 1). Default 0. : \n", - "MINT_nshells : Set the initial number of shells MINT uses in each star when doing nuclear burning. Note: remeshing can change this. If MINT_nshells is 0, shellular burning and other routines that require shells will not be available. (200) : \n", - "MINT_maximum_nshells : Set the maximum number of shells MINT uses in each star when doing nuclear burning. Note that this will be limited to MINT_HARD_MAX_NSHELLS. (1000) : \n", - "MINT_minimum_nshells : Set the minimum number of shells MINT uses in each star when doing nuclear burning. Note that this will be greater than or equal to MINT_HARD_MIN_NSHELLS, which is 0 by default. (0) : \n", - "MINT_Kippenhahn_stellar_type : Stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for which Kippenhahn plot data should be output. : \n", - "MINT_Kippenhahn_companion_stellar_type : Companion stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for the companion for which Kippenhahn plot data should be output. : \n", - "MINT_nuclear_burning : Turn on or off MINT's nuclear burning algorithm. : \n", - "MINT_minimum_shell_mass : Minimum shell mass in MINT's nuclear burning routines. : \n", - "MINT_maximum_shell_mass : Maximum shell mass in MINT's nuclear burning routines. : \n", - "\n", - "############################################################\n", - "##### Section I/O\n", - "############################################################\n", - "go : batchmode control command : Ignore\n", - "gogo : batchmode control command : Ignore\n", - "reset_stars : Reset the star structures. Used in batchmode : Ignore\n", - "reset_stars_defaults : Reset the star structures and set defaults. Used in batchmode : Ignore\n", - "defaults : Reset all defaults. Used in batchmode : Ignore\n", - "echo : Activate batchmode command echoing, i.e. when you enter a command, binary_c repeats the command then executes it. : Ignore\n", - "noecho : Deactivate batchmode command echoing. See 'echo'. : Ignore\n", - "noechonow : Deactivate batchmode command echoing. See 'echo'. : Ignore\n", - "bye : Quit binary_c. Used in batchmode. : Ignore\n", - "fin : batchmode control command : Ignore\n", - "reset_prefs : Reset preferences struct. Used in batchmode : Ignore\n", - "status : Output batchmode status information. : Ignore\n", - "\n", - "############################################################\n", - "##### Section Algorithms\n", - "############################################################\n", - "repeat : If > 1, repeats the system as many times as required. Handy if you're using Monte-Carlo kicks and want to sample the parameter space well. Also, if you are running speed tests this is good to give a statistically more reasonable result. (See e.g. 'tbse pgo'). : (null)\n", - "random_systems : Experimental. Use this to apply random initial system parameters (masses, separations, etc.). Useful for testing only. : (null)\n", - "\n", - "############################################################\n", - "##### Section Misc\n", - "############################################################\n", - "random_seed : Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null)\n", - "random_systems_seed : Random number seed for the generation of random systems. See random_systems and random_seed. : (null)\n", - "random_skip : Skip the first <random_seed> random numbers that are generated. Usually this is 0 so they are all used. : (null)\n", - "idum : [NB: deprecated, please use 'random_seed' instead.] Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null)\n", - "reverse_time : Make time go backwards. To be considered very experimental! : (null)\n", - "start_time : Start time for the simulation. : (null)\n", - "warmup_cpu : Uses the CPU at maximum power the given number of seconds, prior to running normal stellar evolution. : Ignore\n", - "help : Display help pages. Usage: --help <help topic>. : Ignore\n", - "argopts : Display argument options. Usage: --argopts <argument>. : Ignore\n", - "help_all : Display all help pages. : Ignore\n", - "list_args : Display list of arguments with their default values. Useful for batchmode. : Ignore\n", - "\n" + "(abridged)\n" ] } ], "source": [ - "print(_binary_c_bindings.return_help_all())" + "print('\\n'.join(_binary_c_bindings.return_help_all().splitlines()[:10]))\n", + "print(\"(abridged)\")" ] }, { @@ -873,12 +300,14 @@ "__ARG_BEGIN\n", "metallicity = 0.02\n", "effective_metallicity = -1\n", - "M_1 = 0\n" + "M_1 = 0\n", + "(abridged)\n" ] } ], "source": [ - "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))" + "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))\n", + "print(\"(abridged)\")" ] }, { @@ -966,7 +395,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -980,7 +409,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/_sources/examples/notebook_custom_logging.ipynb.txt b/docs/build/html/_sources/examples/notebook_custom_logging.ipynb.txt index 8dfb85034dd77e1b0ae790c475a1e52bd70d0227..8627ffb4751bfea37ebfc00c67e763a79463eba0 100644 --- a/docs/build/html/_sources/examples/notebook_custom_logging.ipynb.txt +++ b/docs/build/html/_sources/examples/notebook_custom_logging.ipynb.txt @@ -23,7 +23,7 @@ " create_and_load_logging_function,\n", ")\n", "from binarycpython.utils.run_system_wrapper import run_system\n", - "from binarycpython.utils.grid import Population" + "from binarycpython import Population" ] }, { @@ -461,11 +461,19 @@ "# print (abridged) output\n", "print(\"\\n\".join(output.splitlines()[-2:]))" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c708268f-0b0c-48ea-9155-ec632a0acc3a", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -479,7 +487,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/_sources/examples/notebook_ensembles.ipynb.txt b/docs/build/html/_sources/examples/notebook_ensembles.ipynb.txt new file mode 100644 index 0000000000000000000000000000000000000000..cc9a3ad9f4cfc1efc4c1327878f01b87bad9e8e5 --- /dev/null +++ b/docs/build/html/_sources/examples/notebook_ensembles.ipynb.txt @@ -0,0 +1,42 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d1d00572-29aa-4f27-a59c-f9f05889da7d", + "metadata": {}, + "source": [ + "# Tutorial: Generating and handling ensemble data\n", + "TODO: coming soon!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e8d9fca3-dd16-4c2c-a180-14d9a6b533ed", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docs/build/html/_sources/examples/notebook_extra_features.ipynb.txt b/docs/build/html/_sources/examples/notebook_extra_features.ipynb.txt index 44c19c11274fbd39732e34e03e7a14a371ff9d7c..a0f0fc0d9c66207de88d4c38672d257f9af522c2 100644 --- a/docs/build/html/_sources/examples/notebook_extra_features.ipynb.txt +++ b/docs/build/html/_sources/examples/notebook_extra_features.ipynb.txt @@ -18,11 +18,11 @@ "metadata": {}, "outputs": [], "source": [ + "from binarycpython import Population\n", "from binarycpython.utils.functions import (\n", " get_help,\n", " get_help_all,\n", " get_help_super,\n", - " return_binary_c_version_info,\n", " get_defaults\n", ")\n", "# help(binarycpython.utils.functions)" @@ -116,8 +116,7 @@ "metadata": {}, "source": [ "## Build information of binary_c\n", - "Sometimes we want to know with which settings binary_c has been built. We can use the function `return_binary_c_version_info` for this.\n", - "This function will parse the version info of binary_c and return a dictionary with all the settings." + "It can be useful to fetch the information with which the current version of binary_c has been configured with. We can do that through the Population object, by calling the instance method `return_binary_c_version_info`. This function will parse the version info of binary_c and return a dictionary with all the settings." ] }, { @@ -130,13 +129,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'nucleosynthesis_sources', 'miscellaneous'])\n" + "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'units', 'nucleosynthesis_sources', 'miscellaneous'])\n" ] } ], "source": [ - "version_info_dict = return_binary_c_version_info(parsed=True)\n", - "print(version_info_dict.keys())" + "version_info = Population().return_binary_c_version_info(parsed=True)\n", + "print(version_info.keys())" ] }, { @@ -168,27 +167,11 @@ "\n", "TODO:" ] - }, - { - "cell_type": "markdown", - "id": "b3c259ef-9f89-4b26-9ce3-45af625bc398", - "metadata": {}, - "source": [ - "## Getting help\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bf3c1e28-1662-47a7-abab-aa6fb0ef0882", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -202,7 +185,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/_sources/examples/notebook_individual_systems.ipynb.txt b/docs/build/html/_sources/examples/notebook_individual_systems.ipynb.txt index deb72fc55ba3785c9c829ab83ba0846cd9b86867..d752fc66ed4fdff229a1bab5d1f5e48921ea8e77 100644 --- a/docs/build/html/_sources/examples/notebook_individual_systems.ipynb.txt +++ b/docs/build/html/_sources/examples/notebook_individual_systems.ipynb.txt @@ -62,7 +62,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "SINGLE_STAR_LIFETIME 1 12461.2\n", + "SINGLE_STAR_LIFETIME 1 12461.1\n", "\n" ] } @@ -90,17 +90,17 @@ "name": "stdout", "output_type": "stream", "text": [ - " TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=62172 RANDOM_COUNT=0\n", + " TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=22065 RANDOM_COUNT=0\n", " 0.0000 1.000 0.000 1 15 -1 -1 -1.00 0.000 0.000 \"INITIAL \"\n", " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 \"OFF_MS\"\n", " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 11582.2424 1.000 0.000 3 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 12325.1085 0.817 0.000 4 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 12457.1301 0.783 0.000 5 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"shrinkAGB\"\n", - " 12461.1627 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 15000.0000 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", + " 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", + " 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"shrinkAGB\"\n", + " 12461.1490 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", + " 15000.0000 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", "\n" ] } @@ -236,13 +236,13 @@ "4 0.000002 1.0 1.0 1.0\n", "5 0.000003 1.0 1.0 1.0\n", "... ... ... ... ...\n", - "1345 12461.080763 0.71617 1.0 6.0\n", - "1346 12461.162734 0.644553 1.0 11.0\n", - "1347 13461.162734 0.644553 1.0 11.0\n", - "1348 14461.162734 0.644553 1.0 11.0\n", - "1349 15000.0 0.644553 1.0 11.0\n", + "1250 12461.061259 0.718593 1.0 6.0\n", + "1251 12461.149038 0.678026 1.0 11.0\n", + "1252 13461.149038 0.678026 1.0 11.0\n", + "1253 14461.149038 0.678026 1.0 11.0\n", + "1254 15000.0 0.678026 1.0 11.0\n", "\n", - "[1349 rows x 4 columns]\n" + "[1254 rows x 4 columns]\n" ] } ], @@ -299,10 +299,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options\n", - "adding: M_1=10 to BSE_options\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", "SINGLE_STAR_LIFETIME 10 28.4838\n", "\n" @@ -360,9 +358,9 @@ ");\n", " to grid_options\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", - "Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_dafa15d2b1e64e19972ac0e9eb5c9a55.so\n", + "Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_34a350b8f15c4d149deab88632948c99.so\n", "EXAMPLE_MASSLOSS 0.000000000000e+00 10 0 10 1\n", "EXAMPLE_MASSLOSS 0.000000000000e+00 10 10 10 1\n", "EXAMPLE_MASSLOSS 1.000000000000e-06 10 10 10 1\n", @@ -381,7 +379,7 @@ "\n", " stardata->star[0].stellar_type //5\n", ");\n", - "\"\"\" \n", + "\"\"\"\n", "\n", "example_pop.set(C_logging_code=custom_logging_print_statement)\n", "\n", @@ -397,7 +395,7 @@ "source": [ "Lastly we can add a parse_function to handle parsing the output again. \n", "\n", - "Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be (self, output). Returning the data is useful when running evolve_single(), but won't be used in a population evolution." + "Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be `(self, output)`. Returning the data is useful when running evolve_single(), but won't be used in a population evolution." ] }, { @@ -464,13 +462,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function object_parse_function at 0x149c2e81ec10> to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to custom_options >>>>\n", - "adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options\n", + "adding: parse_function=<function object_parse_function at 0x7f35b603e9d0> to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-david/notebooks/notebook_individual_systems to custom_options >>>>\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", - "Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_0639ee205c7d4782b4a27378f5d890bd.so\n", + "Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_446fe4cddfa94946bcafd55591ef3730.so\n", "[['time', 'mass', 'initial_mass', 'stellar_type'], [0.0, 10.0, 0.0, 10.0, 1.0], [0.0, 10.0, 10.0, 10.0, 1.0], [1e-06, 10.0, 10.0, 10.0, 1.0]]\n", "dict_keys(['time', 'mass', 'initial_mass', 'stellar_type'])\n" ] @@ -570,7 +567,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -584,7 +581,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/_sources/examples/notebook_luminosity_function_single.ipynb.txt b/docs/build/html/_sources/examples/notebook_luminosity_function_single.ipynb.txt index 93e041531422571b1a499b0089f9e4e465d4a0f3..0a19202d3d6b54cc27b089c742e1a194a226587a 100644 --- a/docs/build/html/_sources/examples/notebook_luminosity_function_single.ipynb.txt +++ b/docs/build/html/_sources/examples/notebook_luminosity_function_single.ipynb.txt @@ -54,8 +54,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: max_evolution_time=0.1 to BSE_options\n", - "adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_luminosity to grid_options\n", + "adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_luminosity to grid_options\n", "verbosity is 1\n" ] } @@ -104,28 +103,6 @@ "# help(population.add_grid_variable)" ] }, - { - "cell_type": "markdown", - "id": "bd75cebe-2152-4025-b680-dc020b80889b", - "metadata": {}, - "source": [ - "All the distribution functions that we can use are stored in the `binarycpython.utils.distribution_functions` or `binarycpython/utils/distribution_functions.py` on git. If you uncomment the help statement below you can see which functions are available now:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "048db541-3e92-4c5d-a25c-9c5a34b9c857", - "metadata": { - "scrolled": true, - "tags": [] - }, - "outputs": [], - "source": [ - "import binarycpython.utils.distribution_functions\n", - "# help(binarycpython.utils.distribution_functions)" - ] - }, { "cell_type": "markdown", "id": "2a9104fc-4136-4e53-8604-f24ad52fbe56", @@ -141,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "id": "aba3fe4e-18f2-4bb9-8e5c-4c6007ab038b", "metadata": {}, "outputs": [], @@ -165,22 +142,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "id": "47979841-2c26-4b26-8945-603d013dc93a", "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "add_grid_variable() got an unexpected keyword argument 'resolution'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/tmp/ipykernel_519112/518757914.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mtmp_dir\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mTMP_DIR\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m )\n\u001b[0;32m----> 6\u001b[0;31m population.add_grid_variable(\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"M_1\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mlongname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"Primary mass\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mTypeError\u001b[0m: add_grid_variable() got an unexpected keyword argument 'resolution'" - ] - } - ], + "outputs": [], "source": [ "# Mass\n", "population = Population()\n", @@ -191,8 +156,16 @@ " name=\"M_1\",\n", " longname=\"Primary mass\",\n", " valuerange=massrange,\n", - " samplerfunc=\"const({min}, {max}, {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", - " probdist=\"{probtot}/({max} - {min})\".format(probtot = total_probability, min = massrange[0], max = massrange[1]), # dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)\n", + " samplerfunc=\"self.const_linear({min}, {max}, {res})\".format(\n", + " min=massrange[0],\n", + " max=massrange[1],\n", + " res=resolution[\"M_1\"]\n", + " ),\n", + " probdist=\"{probtot}/({max} - {min})\".format(\n", + " probtot=total_probability,\n", + " min=massrange[0],\n", + " max=massrange[1]\n", + " ), # dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)\n", " dphasevol=\"dM_1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -214,7 +187,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "0c986215-93b1-4e30-ad79-f7c397e9ff7d", "metadata": {}, "outputs": [], @@ -258,10 +231,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "fd197154-a8ce-4865-8929-008d3483101a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "adding: parse_function=<function parse_function at 0x7f6920fd2430> to grid_options\n" + ] + } + ], "source": [ "# import the bin_data function so we can construct finite-resolution probability distributions\n", "# import the datalinedict to make a dictionary from each line of data from binary_c\n", @@ -279,18 +260,15 @@ " for line in output.splitlines():\n", " # obtain the line of data in dictionary form \n", " linedata = datalinedict(line,parameters)\n", - " \n", + "\n", " # Check the header and act accordingly\n", " if linedata['header'] == \"ZERO_AGE_MAIN_SEQUENCE_STAR\":\n", - " \n", + "\n", " # bin the log10(luminosity) to the nearest 0.1dex\n", " binned_log_luminosity = bin_data(math.log10(linedata['luminosity']),\n", " binwidth['luminosity'])\n", - " \n", " # append the data to the results_dictionary \n", " self.grid_results['luminosity distribution'][binned_log_luminosity] += linedata['probability'] \n", - " \n", - " #print (self.grid_results)\n", " \n", " # verbose reporting\n", " #print(\"parse out results_dictionary=\",self.grid_results)\n", @@ -316,12 +294,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "8ea376c1-1e92-45af-8cab-9d7fdca564eb", "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "adding: verbosity=0 to grid_options\n", + "Do dry run? True\n", + "Doing dry run to calculate total starcount and probability\n", + "Grid has handled 39 stars with a total probability of 1\n", + "**************************\n", + "* Dry run *\n", + "* Total starcount is 39 *\n", + "* Total probability is 1 *\n", + "**************************\n", + "\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", + "**********************************************************\n", + "* Population-f9b28e4ed6ec4a67b17cd86c5a43c41c finished! *\n", + "* The total probability is 1. *\n", + "* It took a total of 3.99s to run 39 systems on 2 cores *\n", + "* = 7.98s of CPU time. *\n", + "* Maximum memory use 343.570 MB *\n", + "**********************************************************\n", + "\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" + ] + } + ], "source": [ "# set number of threads\n", "population.set(\n", @@ -329,7 +337,7 @@ " verbosity=0,\n", " # set number of threads (i.e. number of CPU cores we use)\n", " num_cores=2,\n", - " )\n", + ")\n", "\n", "# Evolve the population - this is the slow, number-crunching step\n", "analytics = population.evolve() \n", @@ -348,20 +356,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "e1f0464b-0424-4022-b34b-5b744bc2c59d", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'population_id': 'f9b28e4ed6ec4a67b17cd86c5a43c41c', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.9999999999999999, 'total_count': 39, 'start_timestamp': 1655508316.7679594, 'end_timestamp': 1655508320.7581806, 'time_elapsed': 3.9902212619781494, 'total_mass_run': 1951.365, 'total_probability_weighted_mass_run': 50.035, 'zero_prob_stars_skipped': 0}\n" + ] + } + ], "source": [ "print(analytics)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "05c6d132-abee-423e-b1a8-2039c8996fbc", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[None]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaMAAAEdCAYAAAChVQjxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAA9vklEQVR4nO3dd3hUVfrA8e/MpJNAQu81cOhNihB6ExUVVMTeXcva19V1ddfuqj93bWtvgLoqKLZdBAKCoqEjHY4K0gMpJEAgdWZ+f9xJmCSTZCbM5M5M3s/z5Enm3jt33twk8+ace857LE6nEyGEEMJMVrMDEEIIISQZCSGEMJ0kIyGEEKaTZCSEEMJ0koyEEEKYLsLsAEJUNDAYSAfsJscihBChwga0AtYAhe47JBnVzmBgudlBCCFEiBoJ/Oi+QZJR7aQD5OScwOEI7DytJk3iyc7OC+hr1FdybQNHrm3ghPK1tVotJCU1ANd7qDtJRrVjB3A4nAFPRqWvIwJDrm3gyLUNnDC4tpVub8gABiGEEKaTZCSEEMJ0koyEEEKYTpKREEII00kyEkIIYToZTReC8vNPkJeXi91eYnYoIS0jw4rD4TA7jLAk19Z7hcUOrBaIjPCubRCM19ZmiyA+PpHY2Aa1PockoxCTn3+C48dzSExsRmRkFBaLxeyQQlZEhJWSkuD6ow4Xcm29c6KgmIKcfOwWC62aNSDCVnNCCrZr63Q6KS4uIjc3E6DWCUm66UJMXl4uiYnNiIqKlkQkRIg7frLY+MLpJL8wNHs6LBYLUVHRJCY2Iy8vt9bnkWQUYuz2EiIjo8wOQwhxmkrsDgrcElB+UWiXuYyMjDqtWweSjEKQtIiECH0n8ovLPS4oLMHpDN3KCqf7viTJSAgh6pjT6SSvQjJyOJwUB9G9oLomyUgIIepYUYmjLPE0iI0s2x7qXXWnQ5KREAFw8cXn8dRTj5ry2rff/gduv/0Pprx2qYMHDzJixCDmz//GlNdPT6/8+k899SgXX3yeaa89efKYssfuraKk+GhsrlF0BX4YxODp9UOBDO0WpkpPP8j06efXeNxf//oI55xT/o0kOzuLCy88F4fDwdy539CyZctKz7v99j+wYcN6OnXqzAcfzKm0/7vvFvP3v/8FgJdffoOBAweV7du4cQOzZ7/Hzp2/cuzYURITk0hO7saECWcxadJkX7/Vem/lyjS2bt3MDTfcbHYoXtuyZTOrVqVxySWXk5CQ4JdzOp3OsvtFMVERRERYiYmycSLfQUGRHafT6dX9l1C8ntWRZCRMlZiYxN/+9rjHfQ6Hg1deeYH8/JN07aoq7V+yZBExMTHYbBEsXryAK6+81uN5oqKi+P33Xfz2268kJ3ctty81dQFRUdEUFZVbdJLvvlvMI488SNeu3Zg+/VISEhqSnn6QDRvW8803XwR1MnrhhVfNDoFWrVqxZMlPRESceotZtWoFc+d+bNqb5wMPPOzzZNFt2zbz/vtvc84553mdjFq2rPy9u8svLClbAiI+1jgmNtrGifxinE4nhcV2YqJqfmuu6nrW9PrBKrSiFWEnNjaWs846x+O+d999k2PHjnL77XfTtWu3SvtTUxcwYsRooqKiSE1dWGUyat++IydPnmDx4oXlklFe3nFWrUpj2LAUvv9+abnnvPfeW3Tu3IU335xJZGRkuX05OUd8/C7rVsV4zWCxWIiOjjY7jHIC/eZst9ux2+1ERUVV+73n5RtdcRaLhbgY42flnnwKirxLRlUJxmvvDblnJILShg3rmT37PYYNS2HGjCsq7d+3by/bt29j/PhJjB8/iZ07f2XXrp1Vnm/8+EksWbKo3NDZpUuXYLFYGDlyTKXjDx7cT8+evT2+sSclNfb5+3n33TcZMWJQpe3z53/DiBGDSE8/WLbt4ovP48EH/8SaNSu5/vorGDcuheuvv4Jt27YA8O23/+XSSy9k3Ljh3H77Hzh48EC5c1a8Z7R+/VpGjBjE999/x8yZ7zB16tmMGzecu+66lf3791WKacmSRVx33eWMGzecKVMm8o9/PE5ubm65Y/bt28tDD/2Z888/i3HjhjNt2jk88siD5OUZK5BWvGf01FOPMnfuxwCMGDGo7OPkyZNMmDCCF198vlIc+/btZcSIQcybN7faa3v8+HGeeupRzjprNJMnj+HJJx8hL+94peM83TNavHgh119/JRMnjmLSpNFcffUM5swx4nz33Td5+eV/ATB9+vllMZf+rEaMGMRLL/2Tb7/9L5dffhHjxg1ny5ZN1d6z2bN3D39/6G5uuPIc7rxlBh9/PBuACJuVyAgr27ZuYMrkFNavX1vueRXPWdX19HRsqbVrV3PrrdczfnwKkyeP5eGHH6j0u1N6b+vw4UM88MA9TJw4kilTJvDvf7+I3R7YwRXSMhJB59ixozz++N9ISmrMQw895rH/PDV1AQkJDRky5EwsFguNGzchNXUBN9/8R4/nnDhxMh988D5btmyiT59+ACxatJDhw0cSF1e5fEmLFi1Zu3Y1mZkZNGvW3L/foBf27NnNk08+wtSpFzNpUiwffjiL+++/h1tu+SMffTSbCy64kJMnT/DRR7N49tkneeml12s856xZ72K12rj88qs5fvwYH3/8AY899jBvvz2r7Jj587/h6acfo1evPtx6651kZBzm888/Zfv2rbz99myio6MpLi7m3nvvwGazMmPG5TRq1IjDhw+TlvYjeXnHiY+Pr/TaF1xwIdnZ2axevaJct2xcXByjRo1l6dJU7rjjHmw2W9m+RYu+JSIigvHjJ1b5PTmdTh588E9s2rSBqVMvokOHjvzwwzKefPLRGq/HmjUrefTRhxg9eiznnz8Nu93O7t2/s3nzRi655DJGjx7HwYP7WbjwW+68814aNUoEjK5l93N8990ipk2bTkJCAk2bNq3y9UpKSrjvvjtJ7tabS6/8A9s2reb1118B4IorrinXGqppulFV17Pq73UV9913J+3adeDGG2/l5MkTzJ37MbfeegMzZ35MUtKp76mkpIR7772dPn368cc/3sWaNav45JMPadOmLdOmXVzja9WWJCMRdP7xjyfIysrkxRdfIzEx0eMxqakLGDVqTFnXy5gx41i8eCF/+MNtHpNX585d6NIlmdTUBfTp04/s7CzWr1/L448/4/H8V1xxDc888wQzZkylT59+9O3bn8GDh9K7d1+s1sB3KOzdu4e33ppJz569AWjWrAWPPPIgr776Mp98Mq/sjbGkpIQPPnifw4cP0aJF5QEc7kpKSnjvvVll16xhw0a89NLz7Nr1G507J1NSUsLrr79CcnI3XnnlTaKijEofSnXn0Ucf4ptvvuDiiy9l9+5dpKcf4O23Z9GjR6+y81d3L6h377506NCR1atXVOqWPeusc1i06FvWr1/D4MFnlm1PTV3A0KHDyr5XT3788Xs2bFjPHXfcU9aCnjr1Yu6885ZqrwVAWtpPdOrUmaee+j+P+5OTu6JUDxYu/JaRI8fQqlXrSsfs27eXDz6YQ/v2Hcq2ubdy3RUUFHDG4BQuvfIWbDYr1199BffeewczZ77LtGnTiYk+1QovLqm+FVLd9fTktddeIjExkddff7fs3tfQocO55Zbr+PDDmdxxxz3l4pw8+Vyuuuo6wLie119/Bf/971eSjET1dh08xjc//U6ByXMUYqJsnJfSic6tG9b6HJ9/Pofly5dx7bU3lhvZ5m7Hjm3s27eXe+65v2zb+PFnMW/eXDZv3kjfvv09Pm/ChLOYM+dj7rrrPr77bjGxsbEMG5bCypVplY6dMuUCmjVrzqeffsT69WtZt24N77//Nm3atOVvf3uC3r371Pp79EaXLl3LEhFAr17G1yNGjCr35tyzp5EM0tMP1piMzj33/HL3Tfr16w/AwYMH6Nw5mR07tpGTc4Sbbrq1LBEBjBs3kVdffYm0tJ+4+OJLadDAaPn89NNykpO7nfY9qkGDhtCkSVMWLVpQloy2bdvC/v37uOmm26p97ooVPxEZGckFF1xUts1ms3HRRTPYuPHnap8bHx9PRsZhtm7dUnZ9fTVw4KByiagm4yYaI0cbxEZgs9mYNu0i1q1bzaZNGxg85FQiLiz2399yVlYWv/76C1dddV25QRi9e/ehV68+rFjxY7lkBEbLy13fvgNYuHC+32LyRJJRGEhdu4+NO7PNDgOA2OgI/nB+r5oP9GDnzt949dWX6NdvANddd1OVxy1a9C1xcQ1o2bJl2T2Pxo0bk5iYyKJFC6pMRuPHT+LNN19l7drVpKYuYPToseXedCsaOnQYQ4cOo6CgAK23s2TJIr76ah733383H330WbmuDX+rmFhKE0Dz5i08bj9+/JjP50xIaOh6rnF/5dChdIBKb65Wq5W2bdtx+LCxv3XrNsyYcQUzZ77Dp5/+hwEDBjJ8+EgmTZrsscuzJjabjYkTJ/PNN19w330PEh0dzaJFC2jQoAEjRoys9rmHDh2iadPmxMTElNvuTYK48MLpLF26mJtvvpZWrdowePAQxo6dwODBQ72O3VNrqSo2m42mzYyfQbxr4ELbtu0BOHToIDarlUjXfKOiYv9VYqjq5wrQoUNHFi9eVG5bbGwcDRs2KrctISHBq9+x0yHJKAxMHNSOgsKSoGgZTRzcrlbPLSws4JFH/kpMTAyPPPJkuXsH7hwOB0uWpHLy5Akuv7xyl8GyZYu5++77PI6cat26Db169eGDD95n27Yt3HzzrV7FFhMTQ79+A+jXbwCNGiXy/vtvs3LlT5x99hSvv7+q5o04HJ5/ZrYqlhKoqovQm5JmVqvna1qbemh33HEP5557HsuXf8/q1Sv517+eZfbs93jzzfdrdY9t8uRz+eSTD0lLW86oUWP57rtURo8eR3R0TM1PrqWkpMa8//5/WL16JStXprFyZRpff/0F5557Pg8++HevzuFtfO7XOCrSRlSk559FdJSxvdjuwO5wYHP9vOty/aKqfvcCTZJRGOjcuiF3Te9ndhin5cUX/8nu3bt45pl/Vvrv3926dWvIzs7i5ptvp23btuX2ZWZm8PLL/2L16pUMHz7C4/MnTjyLF198nqSkxgwaNMSrN3F33bv3BIyuD1+4t0Lcu0oOHTrkWwAB1LJlK8C4X9W//8Cy7U6nk/3799GpU5dyx3funEznzslcc80NbN26hZtvvpYvv/ycm27ynOSrm8eZnNyVLl26smjRAuLiGnDkSDaTJp3tRcwt+fnntRQUFJRrHe3du6fG54IxDD4lZSQpKSNxOp288MJzzJs3l6uvvp42bdoC/ilK7HA4sdvtZGUeonvXzmXb9+/fC0CLFsa1b5KUCMDJE3kUFNppEGskhtLWjTtv65K6/1wr2rt3j8fJ4maQod3CdEuXLnbdHJ/BiBGjqz02NXUB8fHxXHbZlYwdO6Hcx/Tpl5GU1JjU1AVVPn/8+LO47rqbuOee+6tsfYExDNaTFSt+ArzrBnJnvLHBxo3ry7bl5+fz7bf/9ek8gdS9e0+Skhrz5ZefUVx8qlzN0qVLyMzMYPjwFABOnMijpKR82ZrOnbtgs9koKiqq8vwxMbHAqW7BiiZPPpdVq9L44ou5NG3arMp7hu6GDUuhuLiYr776vGyb3W7n888/rfG5R4/mlntssVjo0sWYh1ZYaEyCjo01YvY0VNwXxXajZZO68CsaxBhtAIfDwRdffE5sbCz9+g0AoF3btlitVnZs21Sup+OLLyoPb6/pepZq2rQpXbt2Y/78b8qG3oNxX27Llk0MG+b5H7e6Ji0jYaqsrEyeffYpYmPjSE7uWuVN0jZt2tK1q+KHH5YyePCZHrvhLBYLw4alsHTpYvLz88veSNwlJSV5VQHgwQf/RKtWrUlJGUWbNm3Izy9g7dpV/PTTcnr06ElKSvX3MioaMuRMWrRoyTPPPMFll+3GarXxv/99TWJiEocPB0frKCIigltvvYOnn36MO+64mQkTJpGRcZjPPvuUzp27cN550wBYt24tL7zwHGPGjKd9+w44HHYWLvwWi8XC6NHjqjy/Uj0AePHF/2Po0GFYrVYmTDirbP/EiZN5441X+PHHH7j00iu9GrWYkjKKPn368eqrL3HgwH46dOjEDz8sLfemW5VnnnmS48ePMXDgIJo3b87hw8b32rVrNzp27OSKuTsAb731GuPHTyIiIoKUlFEef7eq4nA4KbE7iY6O4ee1aTz77BMo1YO0tB9Zt241N998O3FxcQA0bJjAsJSxpC74ApvNikruRFracnJyciqdt6br6e622+7ivvvu5NZbr+fcc8/nxIkTzJ37CU2aNK1ysnhdk2QkTLV3756y/zqfeebJKo87++wppKSMJC8vr8ouOICUlJHMn/8Ny5d/f1olex544GGWL/+e775LJSsrE6fTuOd09dXXc+WV1/g8mz8iIoKnn36ef/7zGd555w0aN27CJZdcRkJCQ55++rFax+lv55xzHlFRUXz00SxeffUlGjRowMSJk7nlljvKZvUnJ3dlyJAzSUtbzldfzSMmJobk5K48//zL1Y4yHDlyNNOnX0Zq6gIWLfoWp9NZ7s2zadOmnHHGENdw5Zq76MC4h/bss//ipZf+ycKF87FYLKSkjOL22+/muusqT5Z2d9ZZZ/P111/wxRefkZd3nMaNmzBu3ASuv/4PZYmwW7fu3HzzH5k3by6rVq1w1UH82qdkdLKwBJzGAIann3mB1155niVLFpGQ0JCbb76dq666ttzxt91+L0VFxSxe+DU/LI1i3LgJ3HbbXVx99Yxyx9V0Pd0NHjyU559/mXfffZO33nqdqKhIBg0awm233RXQgTi+sITyYk4m6gj8np2dV1ZjKlCaNUsgM/NUM/zQoT20bOlbF5HwLCLCSkk9Xj8mkGp7be+//x7S0w94LGobqg4dOUlBYQlWq4V2zeNrLIJaUFTCoeyTADRtFEN8XPkRn8H8e1vT+5PVaqFJk3iATsDucvsCGpkQQngpI+Mwq1aleTWJM1S4Ly3eICbSq2rc0ZE2LFbjuPq0vpF00wkhTHXw4AE2b97IV1/NIyoqmilTppodkt+4Ly0eH+vd5GCLxUJMpI38whIKikq8XlIi1EnLSAhhqg0b1vPEE38nI+MwDz/8WJUloEKN+9LikRFWoiK9f7uNjTbaCXa7s2wkXriTlpEQwlTnnHNepYUTw0HFpcV9ad3ERJ2adlBQaCcqouppCOFCWkZCCBEAebXooisVGWHFVnbf6PSXIg8FkoyEEMLPyi0tHh1BhI8ldiwWCzGurrpC11Lk4U6SUQiqD7+YQoQyT0uL+6q0q87hcPq1cGqgnO77kiSjEGOzRVBcXHXJFSGE+Uq76CwWC3HRtVtiI9Ztsb1Q6KorLi7CZqv9MASvn6mUagI011pvd9vWCbgXaAzM1lovrHUkwivx8Ynk5maSmNiMyMioejHkU4hQYnc4jKoLQFxMBFZr7f5GIyKsZRNcza7IXx2n00lxcRG5uZkkJNS+moMvaewloBswBEApFQ8sB0oX9JihlBqntf6h1tGIGsXGGuvFHD2ahd0e/P8tBTOr1Vqnpfnrk/p8bfML7ZwoMFpGNnsUhwpq3wFVkF9MQZGdE4CzMAaLJTivrc0WQUJCUtn7U234koyGAR+4PZ6BkYjOATYAqcD9gCSjAIuNbXBaP3RhqFhqSfhPfb62T85ey66Dx2jSMJpnbx2O9TR6L9bsyOD1L7cA8OfLBtCjQ1LYXltfUnYLYJ/b47OBtVrrBVrrQ8BMYIAfYxNCiJCSnn2CXQeNFVGH9W55WokIoHv7xLKvt+85clrnCna+JKNiwL1U7Wjge7fHuUATP8QkhBAhacXWU8uBDOt1+ovWJcRF0b65sbT89t2Vl5EIJ74ko1+Ai5RSFqXU+RiDFpa47W8HhHfqFkKIKjicTlZsMZJR59YNadXEP13pPToagwJ+Tz/OyYLwvU/sSzJ6FaM1lAN8BuyifDIaCWz2X2hCCBE69N5cso8ZK8Sm9PbfUt49OjQGjGSn94Vv68jrZKS1ng1cg5GAPgTO1loXQ9mw70QgfBYhEUIIH6RtTgcgwmZhcI8Wfjtvt3aNykoDhXNXnVej6ZRSNqAN8D+t9QcV92uts4Ez/BybEEKEhMIiO2t1JgD9kpv6XIuuOjFREXRp3ZBf9h9l+57wTUbetowiMbrlbghgLEIIEZLW/ZJBYbExMXW4H7voSvXoaHTVHcg6Qc6xAr+fPxh4lYy01gVAFnAisOEIIUToSXMNXIiPjaRPZ/8PKu7R4VRlg42/Zfn9/MHAlwEM84EpgQpECCFC0ZFjBWX3cs7s2cLnCt3e6Ny6IdGRRuHUTb9m+v38wcCXq3Y/0EopNUsp1UcpFROooIQQIlSs2HqI0nrVw/v4v4sOIMJmpVu7RAA2/poZlpX7fSkHlAE4gX7AlQBKqYrHOLXWsnqsEKJecDqdZV10bZo2oEOLhIC9Vo8OSWzelU1GTj6Zufk0T4oL2GuZwZfEMRsIv3QshBC1tPvQcdKzTwLGwIVAVtHv2fHUfaNte3LqbzLSWl8bwDiEECLkpG02WkUWC5zph/I/1WnbPJ742Ejy8ovZtjuHMf3bBPT16posrieEELVQYnewavthAHp2bExSQnRAX89qsZSNqtuxJwdHmN03qtX9HddaRol4SGZa672nGZMQQgS9TTuzy1Z09Wf5n+r06JjEmh0Z5OUXsz8jj/YBvEdV13xKRkqpS4GHgR7VHGY7rYiEECIElA5ciImyMaBbszp5zZ5u84227c4Jq2TkdTedUmoq8B+MBPYmYAE+BuZiLC+xDnjc/yEKIURwycsvLpt8Oqh787I5QIHWLDGW5knGSj7hVhrIl3tG9wHbgf7A313b3tNaXwoMAhTGiq9CCBHWVm07jN1h3LOpqy46AIvFQr+uRivsl325lNiDa/nx0+FLMuoLzHKVBiq9AjYArfUW4C3gQf+GJ4QQwSdti1Ghu0nDGLq6JqPWlb6uZFRYbC9bVTYc+JKMbEC26+t81+dGbvs10NsfQQkhRLA6mHWC39OPA8bcotNdWtxX/ZKbln0dTl11viSj/UAHAK11PkZFBvdlIxRSSFUIEebclxYPRIXumiQ1jKFNU2MV2e27w2dxbV9G06UBEzh1v+hr4G6lVD5GUvsj8I1/wxNCiODhcJwq/5PcphEtGptTBaFHhyQOZJ1g58FjFBSVEBMV+lXYfGkZvQYsU0rFuh4/hNE19yhGgtqJMchBCCHC0o69OeQcN5YWN6NVVKqna30ju8PJL/uOmhaHP/lSDmgNsMbtcSbQXynVF7AD27XW4TO0QwghKvjJVf4nwmZlcI/mpsWh2iditVhwOJ1s33OEvl38v4ZSXfNlntEopVSlmV1a601a661AY6XUKL9GJ4QQQaKgqIR1v2QA0L9rUxrE+G9pcV/FRkfQqZUx4bV0LaVQ50s33VJgYjX7x7uOEUKIsLNOZ1JUbHT+mNlFV6qHq4r33ow8jp8sMjma0+dLMqpp/KKNU/OPhBAirJQOXGgYF0nvTo1NjgZ6dDgVw469ueYF4ie+Vu2urkzscCA8F2cXQtRr+zPy2OGa0zO0Z8uALC3uq+Q2DYmMMOIIhyHe1Q5gUErdBdzltulFpdRTHg5NAhoC7/kxNiGECApzl+3EibGMw5gBrc0OB4DICBtd2zZi2+4ctoXB5NeaRtPlAntcX3fEqMBwuMIxTmALsBJ4wY+xCSGE6bbvPsLmXUbxmVH9WtGqSQOTIzqlR4cktu3OISMnn+yjBTRpFGN2SLVWbTLSWs8CZgEopX4H/qK1/rouAhNCCLM5nE7mLNsJQHSkjQtGdDI5ovJ6dmzM59/vAmDbniOM7Bscrbba8GWeUXD9FIQQIsBWbz/MnkNGHbqzhrSjUXxgV3P1VYcWCcRFR3CysITtu3PqRzJSSjUBmmutt7tt6wTcCzQGZmutF/o/RCGEqHvFJQ7muVodDeMiOWtIe5MjqsxqtdC9QxLrf8lk+54cnE4nljou3OovvgwJeQlXlx2ULT2+HKMm3WXA/2TSqxAiXCz9+QBZRwsAOH9EJ2Kjg7P+Ww/X6q9HTxRxMCt0a1X7koyGAfPdHs8AWgPnuD5vB+73X2hCCGGOkwXF/DdtNwAtkmIZ1S94u796dnRbijyER9X5koxaAPvcHp8NrNVaL9BaHwJmAgP8GJsQQphi/sq95OUXA3DR6C5BMa+oKi0bx5EYHwWEdmkgX65wMRDr9ng08L3b41wg9Kv1CSHqtSPHCkhda/zf3aV1Q86oXJIzqFgslrJqDHpfDnZHaBbC8SUZ/QJcpJSyKKXOxxi0sMRtfzsg9KcBCyHqtS+X/05xifGGPn1sckgMCCjtqssvtLPbNfov1PiSjF7FaA3lAJ8BuyifjEYCm/0XmhBC1K39GXn8tCUdgAFdm9KtXaK5AXmpdBADhG5XndfJSGs9G7gGIwF9CJyttS6GsmHficCcAMQohBB14rPvd+J0gsVi3CsKFY0bxpStOrs9RAcx+DRWUWv9AfCBh+3ZwBn+CkoIIera9j05bNpZWvanNa2bBk/ZH2/07JjE4SMn+XX/UYqK7URF2swOySfBO0RECCHqiMPpZO7S3wCIirQGXdkfb/R0ddWV2B38eiD0liKXZCSEqPfW7sgou/F/1uD2JAZZ2R9vqPZJZYvOheJ9I0lGQoh6rcTu4PPvjWKoCXGRTB4afGV/vBEfG0n7lq6lyPeE3sBmSUZCiHpt6c8HyMx1lf1JCd6yP94o7arbfeg4JwuKTY7GN5KMhBD11smCEr75aTcAzZNiGd0/eMv+eKOHa76R0xl6S5FXmYyUUrtck1tLH/9dKdW7bsISQojA+3bVnrKyPxcHedkfb3Rtm0iEzbhzFGr3jaq78u2BBLfHjwJ9AxqNEELUkZzjhaSuMcr+dA6Bsj/eiI600aV1I8BYbC+UVJeMDgB9KmxzBjAWIYSoM18u30VRadmfMV1CouyPN0q76tKzT5JzvNDkaLxX3Z26r4D7lVKTOVVz7mGl1E3VPMeptR7vt+iEECIADmTm8eNmo+xP/+SmqPZJNTwjdPTs2Jgvl/8OwI49OQzr3dLkiLxTXTJ6AKMO3QSgA0arqBkQVwdxCSFEwHy2zK3sz5jQKfvjjU6tEoiJslFQZGfb7iOhn4y01vnAI64PlFIO4G6t9X/qKDYhhPA7vTeHja6yPyP7tqJNiJX9qYnNaqVbu0Q27cwOqUoMvgwduQ5IC1QgQggRaE6nkzmlZX8irFwworPJEQVGowbGYnulS2GEAq9nd2mtZ5V+7arSXVq86XdXoVQhhAhqa3Zk8Hu6UfZn0pB2JCWEXtmfcOXTVGOlVD/gZWBEhe3LgTu11pv8GJsQQvhNid3BvO93AUbpnLOHdjA5IuHO62TkmvD6IxCDMdJuq2tXL+A8YLlSarjWemsVpxBCCNMs+/kAGbn5AJyf0jGky/6EI19+Go8DxUBKxRaQK1H94DrmIv+FJ4QQpy+/sISvS8v+JMYyZkAbcwMSlfgygGEU8Kqnrjit9RbgNYxlyYUQIqi4l/25cHTnkC/7E458+Yk0AA5Vsz/ddYwQQgSNnOOFLFptlP3p1CqBwd2bmxyR8MSXZLQLmFLN/imuY4QQImh89eOpsj+XjE0Om7I/4caXe0azgX8opf4DPAXscG3vATwITAL+4t/whBCi9g5knWD5JqPsT78uTcKq7E+48SUZPQ8MBC4FZgCls6msgAWYA/zTr9EFiFLqMWA60B24XGv9ickhCSEC4HO3sj8Xh1nZn3Djy6RXOzBDKfUOMJVTk153AV9qrRf7P7yA+RW4C3jC7ECEEIGh9+aw4bcsAEb0aUWbZvEmRySq4/NAe611KpAagFjqjNb6QwCl1ENmxyKE8D+n08ncZTsBo+zP1JHhWfYnnJg660sp1QqjhTIUGATEA2O11ss8HBuNMY/pKiAJ2Ag8pLVeUmcBCyFCwjqdya6DxwCYOFjK/oQCswfbK4ylKtoCNZUSmgncA3yIkcAcwLdKqWGBDFAIEVpK7A4++95oFUnZn9Bhdj2MdUBTrXW2Umoq8IWng5RSQzAGTtyjtX7RtW02sAV4FmNCbumxy6h68u2ftdbP+yt4IUTw+X7DQTJyjLI/5w3vSFyM2W9zwhum/pS01se9PPRijFJE77g9t0Ap9S7wlFKqldY63bV9jN8DFUKEhBK7g/+t2A1As8QYxg6Usj+hIlT+ZRgA7NBa51XYvhpjWHl/jAoQXlFKRQI2jG7KSKVUDFCktQ6dxT+EEJWs2ZFBbl4RAFOGdZSyPyHEq2SklIrFmJejtdarAhuSR62AAx62lyag1j6e723gGtfXIzEm9I4FlvlykiZN6maoaLNmCXXyOvWRXNvAqetr63Q6WbrhIACJ8dFMGZ1MVKStTmOoKzVd25iYSACsVkvI/I572zIqxHgDvwswIxnFumKoqMBtv9e01tcC155eSJCdnYfD4Tzd01SrWbMEMjO97c0UvpBrGzhmXNtf9uXy275cAEb1a8XR3JN1+vp1xZtrW1BgFIV1OJxB9TtutVqq/Cfeqzasq/tqH9DQj3H5Ih/wNDYzxm2/EKIeS11jFEONsFkYO7CtydEIX/nSoToLuMo136eupWN01VVUuu1gHcYihAgymbn5rP81E4ChPVvQqEGUyREJX/kygCENuBDYoJR6DaOkTqV2sNb6Bz/F5m4DcJdSKr7CIIahrs8bA/CaQogQsWTdfpyuHvOJg9qZG4yoFV+SkXsJoJeAijdLLK5tgbhj+BlwH3Aj8CKUVWS4DvhJay0tIyHqqfzCEn7YaLwFdG+fSPsWoXHDXpTnSzK6LhABKKUedn3Zw/X5KqXUCCBXa/1vAK31KqXUXOA5VwmhnRij4Trgh4EIQojQ9eOmdAqK7ABMGtze5GhEbflStXtWgGKoWDn7etfnPcC/3bZf7Tr2aozadJuAc7TWPwUoLiFEkHM4nKSuNQYuNE+KpW9yE5MjErVl+qRXrbVXyy5qrQuAP7s+hBCCDb9lkXXUmOExcVA7rLKKa8jyKRkppdoBj2Gs6tocmKy1/k4p1QyjRtzrWus1/g9TCCEqW+Qazh0bHUFKn5YmRyNOh9dDu5VSnYC1wEXAVtwGKmitMzGWgLjR3wEKIYQnew4d5xfXJNfR/VoTE2V6R484Db789J7CWLahN8Yk04wK++cD5/kpLiGEqFZpq8hqsTD+DJnkGup8mfQ6AXhNa72PysO6wRhwIL8RQoiAy80rZPX2wwCcoZrRpFFMDc8Qwc6XZNSQ6itjRxEEAyKEEOHvu/UHsLvqQk4cLJNcq+J0BrZ2pj/5koz2Ab2q2X8m8NvphSOEENUrKraz7GejiH/n1g1JbtPI5IiCTygOKvQlGc0DrldK9Xbb5gRQSl2EscTEHD/GJoQQlazYeoi8fKMq9SRpFYUNX5LRU8B+jCUkPsRIRH9RSq3ASEIbgX/6PUIhhHBxOp2krt0PQFJCNAO7NTM5IuEvXicjrfUxYBjG0t+DMGrRTQQU8Bow1jUxVQghAmLr7iMczDoBwIQz2spKrmHEpwEHroR0F0YF7WYYCSlTax06d8mEECErdY3RKoqKtDKqv68LPItgVuvRb66JrkIIUScOZp1g865sAFL6tKKBa2ltER58TkZKqUuAaUBn16ZdwBdaaxm8IIQImMWugqggaxaFI6+TkVKqAfAlMA6jey7XtWswcIlS6mbgfK31CT/HKISo5/Lyi0nbcgiAvl2a0LJxnMkRCX/zdTTdeOAVoLXWurHWujHQ2rVtrOsYIYTwq+83HKCoxAHIcO5w5Us33Qxgrtb6bveNWutDwN1KqTauY+6u/FQhhKidEruDJeuMgQttmzWgR4ckkyMSgeBrOaCl1ez/znWMEEL4zdodGeTmFQHGvSJLKJYXEDXyJRltArpWs78rsPn0whFCiFOcTmdZde6EuEjO7NXC5IhEoPiSjB4GblJKVVomQil1AcZaRn/1V2BCCPHbgaPsPnQcgLED2hAZYavhGSJUVXnPSCn1nofNvwNfKqU0sN21rQdGFYbNwBUY3XVCCHHaSltFETYLYwfKCjXhrLoBDNdWs6+768NdX6APcMNpxiSEEGTm5rP+F2Nu/dCeLWjUIMrkiEQgVZmMtNZS9EkIYZol6/ZTuhyPTHINf5JwhBBBJ7+whOWbDgLQvX0i7VskmByRCDRJRkKIoPPj5nTyC+0ATBrc3uRoRF3wqTadUmo48EeMYdxNMMoCuXNqrbv4KTYhRD3kcDjL6tA1T4qlb3ITkyMSdcGX2nQ3AW8ARYAG9gYqKCFE/bXhtywyc42l0SYOaodVJrnWC760jP4KbADO0lpnBSYcIUR9l+oazh0bHUFKn5YmRyPqii/3jFoA70oiEkIEyp5Dx9H7cgEY3a81MVG1XnJNhBhfktF2QCoUCiECJtV1r8hqsTD+DJnkWp/4uoTEbUopWetXCOF3uXmFrNp2GICBqhlNGsWYHJGoS163gbXW85RSccA2pdRXwG7AXuEwp9b6CT/GJ4SoJ75bfwC7w5jlKmsW1T++jKbrBjyOsUzEVVUc5gQkGQkhfFJUbGfZzwcA6Ny6IcltGpkckahrvtwdfA1oDtwFLAdyAhKREKLeWbntMHn5xYCU/qmvfElGw4D/01q/EqhghBD1j9PpLBvOnZQQzRmqmckRCTP4MoDhKJAZqECEEPXTtt05HMg6AcD4M9oSYZMqZfWRLz/1OcCFgQpECFE/la5ZFBVpZXR/GaxbX/nSTfcmMEsp9SXwMsZCexVH06G1ljJBQgivpGefYPOubABS+rSiQUykyRGFF6fZAfjAl2S0FeN7GwRUWnrcjawLLITwSura/WVfT5BJrn4UevX8fElGjxNaiVYI4SdZR/PJchUv9caho4Xk5p6s9pgSh4O0zekA9O3ShFZNGpxWjCK0+TLp9dEAxiGECFJ7Dx/niVlryyakBoJMchUybEUIUa35K/cENBF1adOQHh2k7GV950sFhlHeHKe1/qH24QghgsmRYwWs3WHM6Oif3NTrFkxiYlyN3XQAVquFDi0TsMiaRfWeL/eMluHdPSMZwCBEmFiyfj8Op/Fnf15KRzq1aujV85o1SyAz83ggQxNhxpdkdF0Vz+8CXItROPXN0w9JCBEMCovs/LDhIABd2zbyOhEJURu+DGCYVdU+pdT/Aev9EpEQIiikbUnnREEJIPXiROD5ZQCD1joHeAe43x/nE0KYy+F0ssg1B6hpoxgGdpN6cSKw/DmaLgfo7MfzCSFMsnlnNoePGAMQxp/RFqtVBhiIwPJLMlJKxWCscXTIH+cTQpirdPnv6CgbI/tKvTgReL4M7X6vil2NMZaXaAb82R9BCSHMsz8jj227jeXKRvZtRVyML+OchKgdX37Lrq1i+xHgF+AerfV/TjsiIYSpSltFFqRenKg7voymk2oNQoS5YyeKWLH1MAD9uzaleVKcyRGJ+kISjBCizLKfD1BidwBSL07ULUlGQggAikscfPfzAQDat4inW7tEcwMS9Uq13XRKqa99PJ9Ta33BacQjhDDJ6u2HOXaiCDBaRVIvTtSlmu4ZTfHxfLLekRAhyOl0kupa/rtRgyiG9GhhckSivqk2GXkzaEEpNRp4DhgMpPspLiFEHdJ7c9mbkQfAuIFtiLBJD76oW7WeQKCU6g08C0wGjgN/A/7lp7iEEHVokatVFBlhZfSANiZHI+ojn5ORUqod8ARwBWAHXgae1Fpn+zk2IUQdOJxzko2/ZQEwrFcLGsZFmRyRqI98qcCQBDwE3AZEAx8DD2utdwcmNCFEXVi8dn/ZzV6pzi3MUmMyUkpFA3cDDwCJQCrwgNZ6QyADE0IE3smCYn7cZNzq7dUxiTbN4k2OSNRXNQ3tvgF4FGiNsV7RX7TWS+ogLiFEHfhhYzqFxXYAJg5ub3I0oj6rqWX0NsZw7bXAHKCfUqpfNcc7tdYv+Cs4IUTg2B0OlqwzBi60ahJH786NTY5I1Gfe3DOyYAzbHuzFsU5AkpEQIeDnX7LIPlYIwIRB7bDKJFdhopqS0dg6iUIIUedKh3M3iIlgeO+WJkcj6ruaJr1+X1eBCCHqzq6Dx/jtwFEAxgxoQ3SkzeSIRH0n06yFqIdK1yyyWS2MGyhrFgnzSTISop45cqyAtTsyABjcvTlJCdEmRySEJCMh6p3v1h/A7jCmuU6UNYvCWwiVrpZkJEQ9Ulhk5/sNxppFyW0b0alVQ5MjEoEQigMjJRkJUY+kbUnnREEJAJOk9I8IIpKMhKgnHE4nqWv3A9CkYQwDujU1OSIhTpFkJEQ9sWVXNoeOnARgwqC22Kzy5y+Ch/w2ClFPlK7kGh1lY2Tf1iZHI0R5koyEqAf2Z+axdXcOACP7tCIuptbragoREJKMhKgHSltFFowuOiGCjSQjIcLcsZNFrNh6GID+XZvSPCnO5IiEqEySkRBhbtnPByixOwCYJJNcRZCSZCREGCsucbB0vTHJtX2LeLq1SzQ3ICGqIMlIiDC2evthjp4oAmDioHZYQnFqvqgXJBkJEaacTmfZwIVGDaIY0qOFyREJUTVJRkKEqV/25bI3Iw+AsQPbEBkhf+4ieMlvpxBhqnQl1wiblTED2pgcjRDVk2QkRBg6nHOSDb9mATC8dwsaxkWZHJEQ1ZNkJEQYWrJ2f9lSNhOkOrcIAZKMhAgzJwtKWL45HYBeHZNo2yze5IiEqJkkIyHCzPJNBykssgOykqsIHZKMhAgjdoeDxa41i1o2jqN35yYmRySEdyQZCRFGfv4li+xjBYDRKrLKJFcRIiQZhYEjxwp4ce7GsgmOwn8ycvN5Yc5Glv18wOxQvLJorfE70CAmguG9WpocjRDek2QUBt757zY27czm4yW/4nA4a36C8Npr8zazeVc2sxdqs0OpUWGxnd/2HwUgpU8roqNsJkckhPckGYUBvS/X7BDCVmkFg1Dg/o9IUkK0iZEI4TtJRkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTRZgdQIiyAVitdVNqpabXaZ4Ui9N56ti6iisceHNtvT3WbDabtSzeBrGRpsdr9uuHs5qubcMGUTRPiiU+Liqofg5usVSakW1xOmXGfi2MAJabHYQQQoSokcCP7hskGdVONDAYSAfsJscihBChwga0AtYAhe47JBkJIYQwnQxgEEIIYTpJRkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSW26IKSUigYeB64CkoCNwENa6yWmBhbilFKDgWuBsUAHIBtIAx7WWv9mYmhhRyl1P/AssFFr3d/kcMKC6/f3UWA4EAnsBF7QWs80MSy/kZZRcJoJ3AN8CNwFOIBvlVLDzAwqDDwAXAgsxriubwFjgJ+VUj1MjCusKKVaAg8DJ8yOJVwopc4GfsJIQn8D/oTxe9zOzLj8SVpGQUYpNQS4FLhHa/2ia9tsYAvGf5qjzIsu5P0LuFxrXVS6QSn1KbAZI1Fda1Jc4eYZYC3GP7uJ5oYS+pRSjTD+QX1da32XyeEEjLSMgs/FQDHwTukGrXUB8C4wQinVyqzAQp3WOs09Ebm2/QpsBaRl5Aeuf6auBO41O5YwcjlGUv87gFIqQSkVPOtC+Ikko+AzANihtc6rsH01YAH613lEYcz1R90CyDI7llDnupavALO01htMDiecTAB2AOcopfYBx4AjSqlnlFKV1gUKVdJNF3xaAQc8bE93fW5dh7HUB1cAbYCHzA4kDFwN9ASmmhxHuEnGuDc0E3gO+BmYgtG1HAPcbVZg/iTJKPjEUmGdD5cCt/3CD5RS3YFXMRb5+sDkcEKaUioB417RM1rr9JqOFz6JxxhV+xet9bOubfOUUvHAbUqpJ7XWId+yl2664JOPsXhfRTFu+8Vpco34+h+QA0zXWjtMDinUPQwUYQwSEf5V+jf/cYXtH2GMrhtSt+EEhrSMgk86RlddRaXbDtZhLGHJNTrpW6ARkKK1PmRySCHNNajmbowhxy2UUqW7YoAopVRH4KjWOseUAENfOtALOFxhe+njpLoNJzCkZRR8NgDdXU1wd0NdnzfWbTjhRSkVA3wDdAOmaK21ySGFgxZAFMbUg9/dPoZijFL8HeP+hqidda7PbSpsb+v6nFmHsQSMJKPg8xlG0/vG0g2uigzXAT9praVlVEuukUefAsMwuuZWmhxSuPgdmObhYyuw2/X1bLOCCwNzXZ9vKN3gGrl4I8bE4rD4PbY4nU6zYxAVKKXmYIxIegGj5Mc1wGBgrNb6JxNDC2lKqRcxKi98A8ypsDtPa/1lXccUzpRSy4BEKQd0+pRSszDKg70LrAfOdX3cr7X+PzNj8xe5ZxScrgaecH1OAjYB50giOm39XZ/Pc3242wN8WZfBCOGDm4C9GP+YXgPsAm7RWr9palR+JC0jIYQQppN7RkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSTISQghhOklGQgghTCfJSIQUpdQYpZRTKXWt2bGcLqVUb6VUiVJqotmx1AdKqQuUUkVKqa5mxyIqk2QkhHn+hVGJPdV9o1KqsSvhfmtSXAGjlPq3UuqAq+p0VceU/sNxnz9fW2v9FbAZY6kLEWQkGQlhAqXUMGAinldGHej6vL7uIgo8VwKaCnyltTarKOZLwDSlVC+TXl9UQZKREOa4DcgC5nvYF5bJCGMZlDaYWx19HnASuMXEGIQHsoSECAtKqabAY8D5GCuPHga+Bv6utc6ucGxH4J8YLROApRjLZi8FdmutxwQ41giMFsJ/tdbFHg4J12Q0DcjFuM6m0FrnKaWWAxcDd5gVh6hMWkYi5CmlGgFpwK3AQozEssD1+EelVILbsU2A5RjrGc3EWA77BMYbZIM6CvkMIB5YXcX+gUCO1vr3OoqnrkwD5leRgOvSCqClUqq7yXEIN9IyEuHgfqAr8Eet9WulG5VSG4B/u/b/zbX5AaAtcKXW+iPXtteVUs8Bf66jeHu6Pu+suMOVOJMxsfUQCEqpHoACHjY7Fk5d917ADjMDEadIMhLhYBqQCbxVYfubwCOu/aXJ6DwgHfi4wrHPU3fJqJnr8xEP+wYAFsKvi24qUIDRYvUrpVRLjFWRuwMZwFyt9bpqnlLabdvc37GI2pNkJMJBJ2Ct1rrEfaPWukQp9Qun7sGUHrtaa+2ocGyGUirXfZtS6hLgTozlyrO01h0r7I/AuPd0FUaX9+cYrbOCGuItHUnmaXjzGa7PVSYjpdRIwNOw7yjAprW2VTj+NYwuy+Fa6xUV9i0DRmMsa/+t2/ZLgE+B/2mtp7i2dQOeA1KAGFz35bTW91YVq5tpwGKtdZ4Xx3pNKXURMA54F3gFI8FcrpS6GPhrFaP2Sq+7LHMdRCQZCVG1HIxuvhbAPR72/xUYC/QBijAGTDyHkcCqk+n63NjDvhoHL2itl2PccyqjlGoNrHXF6749FrgcoxV2I8b9kop2ADdQPsHdSOUurP9hjEa7EmNEWheMxFQtpVRbYBBwU03H+kIp1RvoqLX+o9vmPcA/lFJnYoyYe93DU0uve6aHfcIkMoBBhINdgHK1VMq4Hndz7S+1G0hWSlkrHNscSHTfprVO1Vp/gvEG58mNwNNa6wNa60zgUeBapZStiuNLbXF99lQJYCCQB/xSwznKKKWiMZLEj1rrpyvsng44MAZ1XKKUiqeyOcA4pVQz1/k6YLQGv3R7jaYY97Le0Frnaa0dWutftdYzvQhxKkYr5GtvvycvXYjneVporVcCTSv+Trgkuz5v8bBPmESSkQgHX2Lch7mxwvabXNu/cNv2DdAKuKzCsT7N9ldKJQLtgA1um9cDCUDHGp7+M3AMOLPCOeMwbvJv8HFS6BsY3WbXeth3I/AJRsIpBi71cMxxjGt0tevxDcB/gMLSA7TWWcB24D2l1KVKqS4+xDcNI1H6uyVysvQ6KaWGKaWylFLuAyTWYfwzUtGZwGGttfZzPOI0SDedCAfPYbQAXlVKDcR4sx+A8aaqXftLPYvRbfW+UmoIRlfUSGA4xiRUb5NA6XDxXLdtuRX2eaS1tiul5gFTlVLRWuvSN/1+gA2IUUr9xcNT87TWFbvh7gSmAIO11icr7OuG8b39WWtdqJT6BOOavOPh3O8C7yilXsRIaucCF1U4ZgxG0v4r0FMptRf4i9Z6TlXfq1KqMTAKY0Sjr8YrpWI8bM/SWr9RYVs/oAnluw2PUeFn4WoZjgTeq0U8IoCkZSRCntb6KMab0JvAOcDLrs9vACO01sfdjs0CRgD/Ba7HSE4NMO79WIB8L1+29JyN3LYlVthXndddx09x21Z6v2gQ8A8PH9PdT6CUGuuKf7rWereH17gR2KG1XuV6PBM401MpHK11Gsb3/yhwSGu92cMxGVrr+7XWfTHuu7wG/KeG+TpTMP7p/aKaY6oyGXjCw8fdrv2xbse+g9ECu8ZtWz/g1wrnvAiIw/hdEUFEWkYipGitl+FhFJqrC+g210dN5/gd435DGddk2CbAXi/jyFVK7cO4t1La3TMAIxHt9uL5q5VSpRN0P3dtexV41ZvXd1WRmIPR6lnmYX8kRrdbI6XUoQq7bwA8jYB7F6MVeasX8R8DnldKPUj183WmARurSJZVnXsZnkcaVrRbKTVca53mGkn5ZekO10TojlrrisPn7wK+0FrL/aIgI8lI1DtKqVitdcUWUGm3WKrbcTYg0vVhcXUZOd261d4BHnSVlynGaFXM1FrbvQzlT8BGpdQkrfUiH+KPw3jj/bpit52b84AkjATp/oZ8JfCAUuovWuuiCs95C+MeWJqH10zCmIf1EcbgCitGd14cxr2ZqqwA3q72G6q9D4GXlFIN3CufK6U6YbSgyiVcpdRUoDcwI0DxiNMgyUjUR/OVUnswBhxYgfEY3UlplC/ieRXwvtvjfIyRdR1dj58GmgJbXef5DKPCg1e01lup3d/gRRhdUN2UUp7eWHtidNF9rLXe5r5DKfUG8BDGCLdy93pcrZ3FVbxmEdASY0RcC4zBDVuB86tr9Witn6tq3+nSWjuVUncDtyulbsQYNWjFmNR8V8WahFrrLzHmYokgZHE6Zd6XqF+UUn/C6MLqiHHfYT/G0OjH3O8vCSHqjiQjIYQQppPRdEIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSTISQghhuv8HejwwbWv8RfwAAAAASUVORK5CYII=\n", + "text/plain": [ + "<Figure size 432x288 with 1 Axes>" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "# make a plot of the luminosity distribution using Seaborn and Pandas\n", "import seaborn as sns\n", @@ -412,7 +451,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "1f37d2c0-1108-4ab9-a309-20b1e6b6e3fd", "metadata": {}, "outputs": [], @@ -420,16 +459,45 @@ "# Update the probability distribution to use the three-part power law IMF \n", "population.update_grid_variable(\n", " name=\"M_1\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)\",\n", ")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "6f4463e8-1935-45f2-8c5f-e7b215f8dc47", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Do dry run? True\n", + "Doing dry run to calculate total starcount and probability\n", + "Grid has handled 39 stars with a total probability of 0.211729\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 39 *\n", + "* Total probability is 0.211729 *\n", + "**********************************\n", + "\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", + "**********************************************************\n", + "* Population-1d1d556abeae4549aa28f9740807dc84 finished! *\n", + "* The total probability is 0.211729. *\n", + "* It took a total of 3.90s to run 39 systems on 2 cores *\n", + "* = 7.80s of CPU time. *\n", + "* Maximum memory use 519.211 MB *\n", + "**********************************************************\n", + "\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" + ] + } + ], "source": [ "# Clean and re-evolve the population \n", "population.clean()\n", @@ -441,10 +509,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "id": "cfe45a9e-1121-43b6-b6b6-4de6f8946a18", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[None]" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEdCAYAAABDiROIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAABEJElEQVR4nO3dd3hUVfrA8e+kBxJIgAAhIC3wgoCA0nsVxQYKYl97Wxu7lnV1f3ZXXfvaK7ZVwYoFpYnSq3Q80msCAUIJJJAyvz/uJEySSTITZnJnkvfzPDyTnHvmzjuXyX3nnHvuOQ6n04lSSilltzC7A1BKKaVAE5JSSqkgoQlJKaVUUNCEpJRSKihoQlJKKRUUIuwOIERFA92BNCDf5liUUipUhAPJwGLgWMmNmpAqpzsw2+4glFIqRPUH5pQs1IRUOWkAmZlHKCgI7H1c9evHsW9fVkBfo6bSYxs4emwDJ5SPbViYg8TE2uA6h5akCaly8gEKCpwBT0iFr6MCQ49t4OixDZxqcGw9XurQQQ1KKaWCgiYkpZRSQUETklJKqaCgCUkppVRQ0ISklFIqKOgouxCUnX2ErKwD5OfnFZXl5hWQX+AkOjIch8PG4ELInj1hFBQU2B1GtaTHNnCC8diGhYUTERFFfHwCkZFRld6PJqQQk519hMOHM0lISCIyMgqHw0FBgZNtuw9DONSuG0OdWpX/QNQkERFh5OUF1x92daHHNnCC7dg6nU4KCvI5diybzMw9xMcnEhtbu1L70i67EJOVdYCEhCSioqJxuJpCefknPpyHjxy3KzSlVA3kcDgID4+gVq14EhIacOTIwUrvSxNSiMnPzzupJrFSSgVKZGQ0eXm5lX6+JqQQ5NCLREqpIHSy5yZNSEoppYKCJiSllFJBQROSUgEyZsx5PPHEw7a89m233chtt91oy2sXSkvbRb9+3fjxx++C5vWfeOJhxow5z7bXPuusQQF/7bJePxTU2GHfIvIIMBZoB1xmjPnM5pBqrLS0XYwde36F9f75z4cYObL4yWTfvr1ceOE5FBQUMGnSdzRu3LjU82677UaWL19Gy5at+OijiaW2z5w5nf/7v38A8PLLb3D66d2Ktq1YsZwPP3yPjRvXc+jQQRISEklNbcuwYSM488yzfH2rNd6CBfNYs2YV1113k92heG316lUsXDiPiy++jPj4eLvDKSYUj2d5amxCAtYDdwKP2R1ITZeQkMi//vWox20FBQX8978vkJ19lDZtpNT2GTOmEhMTQ3h4BNOn/8QVV1ztcT9RUVFs3ryJDRvWk5rapti2adN+IioqmuPHiy9gOXPmdB566H7atGnL2LGXEB9fh7S0XSxfvozvvvs6qBPSCy+8ancING6czIwZc4mIOHGaWbhwPpMmfWrbCfS++x70+abStWtX8f77bzNy5HleJyRP7z0QyjqeVfX6/hZa0fqRMeZjABF5wO5YarrY2FhGjBjpcdu7777JoUMHue22u2jTpm2p7dOm/US/fgOJiopi2rSfy0xIp5zSgqNHjzB9+s/FElJWVhYLF86jd+++/PrrL8We8957b9GqVWvefHMCkZGRxbZlZu738V1WrZLx2sHhcBAdHW13GMUE+gSdn59Pfn4+UVFRtr73YDz23rD9GpKIJIvIUyLyi4gcFhGniAwqo260iDwtIrtEJFtEFojI0CoOWVWR5cuX8eGH79G7d1/Gjbu81Pbt27exbt1ahg49k6FDz2TjxvVs2rSxzP0NHXomM2ZMxek8sbjZrFkzcDgc9O8/qFT9Xbt2cOqpHT2e3BMT6/n8ft5990369etWqvzHH7+jX79upKXtKiobM+Y87r//7yxevIBrr72cIUP6cu21l7N27WoApkz5nksuuZAhQ/pw2203smvXzmL7LHkNadmyJfTr141ff53JhAnvMGrU2QwZ0oc777yFHTu2l4ppxoypXHPNZQwZ0odzzx3Ov//9KAcOHChWZ/v2bTzwwD2cf/4Ihgzpw+jRI3noofvJyrJWMy15HeOJJx5m0qRPAejXr1vRv6NHjzJsWD9efPHZUnFs376Nfv268dVXk8o9tocPH+aJJx5mxIiBnHXWIB5//CGysg6XqufpGtL06T9z7bVXMHz4AM48cyBXXTWOiROtON99901efvl5AMaOPb8o5sL/q379uvHSS88xZcr3XHbZRQwZ0ofVq1eWew1nx47t3HXXrQwb1o8LLzyHTz75oNj2wv+rZcuWFCsv3Of3308u93i61y35+kuWLOKWW65l6NC+nHXWYB588L5Sn53Ca127d6dz333jGT68P+eeO4xXXnmR/HyP6+r5TTC0kAS4D9gArAT6lFN3AnAR8KKr/tXAFBEZaIyZH9AoVZU6dOggjz76LxIT6/HAA494vL9h2rSfiI+vQ48evXA4HNSrV59p037ippv+6nGfw4efxUcfvc/q1Svp1KkzYJ2M+vTpT61apac6adSoMUuWLCIjYw9JSQ39+wa9sHXrFh5//CFGjRrDmWfG8vHHH3DvveO5+ea/8sknH3LBBRdy9OgRPvnkA55++nFeeun1Cvf5wQfvEhYWzmWXXcXhw4f49NOPeOSRB3n77RMnxR9//I4nn3yEDh06ccstd7Bnz26+/PJz1q1bw9tvf0h0dDS5ubn87W+3Ex4exrhxl1G3bl12797NvHlzyMo6TEJCnVKvfcEFF7Jv3z4WLZpfrIu2Vq1aDBgwmF9+mcbtt48nPDy8aNvUqVOIiIhg6NDhZb4np9PJ/ff/nZUrlzNq1EU0b96C336bxeOPP1zh8Vi8eAEPP/wAAwcO5vzzR5Ofn8+WLZtZtWoFF198KQMHDmHXrh38/PMU7rjjb9StmwBY3czu+5g5cyqjR48lPj6eBg0alPl6eXl5/P3vt9O5c1duueUO5s2bw+uv/xeAyy//S4XxuivreJb9Xhdy99130KxZc66//haOHj3CpEmfcsst1zFhwqckJp54T3l5efztb7fRqVNn/vrXO1m8eCGfffYxKSlNGT16jE9x+iIYEtJSoIExZp+IjAK+9lRJRHoAlwDjjTEvuso+BFYDTwMD3OrOAgaW8Xr3GGNKfxVTQeXf/36MvXszePHF10hISPBYZ9q0nxgwYFBRN8ygQUOYPv1nbrzxVo8JrFWr1rRuncq0aT/RqVNn9u3by++/L+XRR5/yuP/LL/8LTz31GOPGjaJTp86cdloXunfvSceOpxEWFvjOhW3btvLWWxM49dSOACQlNeKhh+7n1Vdf5rPPvio6Oebl5fHRR++ze3c6jRqVHtThLi8vj/fe+6DomNWpU5eXXnqWTZs20KpVKnl5ebz++n9JTW3Lf//7JlFR1qwgIu14+OEH+O67rxkz5hK2bNlEWtpO3n77A9q371C0//KuDXXseBrNm7dg0aL5pbpoR4wYydSpU1i2bDHdu/cqKp827Sd69uxd9F49mTPnV5YvX8btt48vakmPGjWGO+64udxjATBv3lxatmzFE0/8x+P21NQ2iLTn55+n0L//IJKTm5Sqs337Nj76aCKnnNK8qMy9tesuJyeHfv0Gcvvt4wEYPXoM48ffxoQJ7zJ69Fhq1apVYcyFyjuenrz22kskJCTw+uvvFl0L69mzDzfffA0ffzyhKKbCOM866xyuvPIawDqe1157Od9//231TkjGmNLtas/GALnAO27PzRGRd4EnRCTZGJPmKh/k90CD3M6MLH5bmUZuXgHRkeEVPyFAYqLCOa9vS1o1Kf0N2VtffjmR2bNncfXV1xcb8ebujz/Wsn37NsaPv7eobOjQEXz11SRWrVrBaad18fi8YcNGMHHip9x5591Mnz6N2NhYevfuy4IF80rVPffcC0hKasjnn3/CsmVLWLp0Me+//zYpKU35178eo2PHTpV+j95o3bpNUTIC6NDB+rlfvwHFTtCnnmolhLS0XRUmpHPOOb/YdZTOnbsAsGvXTlq1SuWPP9aSmbmfG264pSgZAQwZMpxXX32JefPmMmbMJdSuHQfA3LmzSU1te9LXrLp160H9+g2YOvWnooS0du1qduzYzg033Fruc+fPn0tkZCQXXHBRUVl4eDgXXTSOFSt+L/e5cXFx7NmzmzVrVhcdX1+dfnq3YsmoIhdeOLbo57CwMEaPvoilSxexcuVyevUqr4Oo8vbu3cv69X9y5ZXXFBuY0bFjJzp06MT8+XOKJSSwWmDuTjutKz///GNA4itke0LyQVfgD2NMVonyRYAD6AKkebszEYkEwrGuo0WKSAxw3BgTPNPo+mDhuj2s31H5SQ39KTY6ghvP71BxRQ82btzAq6++ROfOXbnmmhvKrDd16hRq1apN48aNi66B1KtXj4SEBKZO/anMhDR06Jm8+earLFmyiKlTpzBgwOBiJ96SevbsTc+evcnJycGYdcyYMZVvv/2Ke++9i08++aJYN4e/lUwuhUmgYcNGHssPHz7k8z7j4+u4nmt9L0xPt/6ESp5gw8LCaNq0Gbt3W9ubNElh3LjLmTDhHT7//H907Xo6ffr058wzz/LY/VmR8PBwhg8/i++++5q7776f6Ohopk79idq1a9OvX/9yn5uenk6DBg2JiYkpVu5NkrjwwrH88st0brrpapKTU+jevQeDBw+je/eeXsfuqdVUlvDw8FL1mzY9BYD0dM+tKn8o6/8VoHnzFkyfPrVYWWxsLerUqVusLD4+3qvP2MkIpYSUDOz0UF6YhLz/VFjeBgo7bfsDHwKDgVmVCc5uPds35FhuflC0kIZ3b1ap5x47lsNDD/2TmJgYHnro8WLXEtwVFBQwY8Y0jh49wmWXle4+mDVrOnfddbfHEVVNmqTQoUMnPvrofdasWc1111XcrQMQExND585d6dy5K3XrJvD++2+zYMFczj77XK/fX1nzfBUUeL5QHB7uuVuwrO5Ct7EaZQoL83xMnd48uYTbbx/POeecx+zZv7Jo0QKef/5pPvzwPd58832Sk8tvqXly1lnn8NlnHzNv3mwGDBjMzJnTGDhwCNHRMRU/uZISE+vx/vv/Y9GiBSxYMI8FC+YxefLXnHPO+dx///95tQ9/x1f256TqviuX9dkLtFBKSLHAMQ/lOW7bvWaMuRprUESl1a8fdzJP91pS0okm9p49YUREFP+w5DudpCTFcenQNkRFhnNK4+C6ec9b//nPc2zZsolnnnmBJk2Sy6y3aNFi9u3by6233k7TpsWT3549u3nxxedYunQhffta36wdDgcOB0XHbcSIs3n++WdITKxHz549CQ8PIzzcOgmEh5c+viV16GC1/jIz91VY1+FwFNWpW9f6xpmdfaRYt8mePbs9vrb7c+FE/GFhxcsLTx7h4SfKC09qhb97quNeXrjPlBTre92OHdvo1u1Ed6nT6WTHju20bt262PPbtm1L27Ztue66G1i9ehXXX/8XJk/+iptuurXUvgtf3z0ud+3aCampbZg+/Wfi4+PYv38fZ589ssJj3KRJMr//voS8vGPExJw4Dezcua3U65c8LtbP0QwcOJCBAwfidDp57rmn+eKLiVxzzXU0bdrM7dh5/myEhZV+P57eu8PhID8/n4yMdFJSmhbV3bVrh+t9pBAREUZCwonPift+MzLS3WIu/3iWfP2mTU/8v5asu337VpKTk8s9RoX78lRe+niEFTtn+SKUElI24GlgfYzb9iq1b18WBQW+f7P0RVJSPBkZJy6zFRQUlFqcK9/td6fTGVSLd3nrl1+m8+23XzNmzDj69Olf7nv46acfiYuL4+KLLy/VCnI6nXzwwfv89NMUevbsW1TmdFK0z8GDh5OZmUlqaipOp4O8vALy863/x/z8E8d3yZJFdOvWo9Trz5kzB4CUlFMqPNbu/x/JySkALF26hH79rDE32dnZ/PDDd6Veu+Rz4UT8BQXFy/Nd62Hl558oL2zxFP7uqY57eeE+27RpT2JiPb76ahIjRpxTdG1o5szpZGTs4fLLryIvr4AjR7KIjo4pdvybN29FeHg4OTnHPO4bICrK+nPNzDzo8SbTESPO4e23XyM/P58GDZLo3PmMCo9xz559+Oabr/jyyy+KBjXk5+czceJnpV6/5HE5ePBAqQETLVumAnD0aA55eQVFMR88eJCGDUu3/AoKKP036eG9F772xImfF12vKSgo4MsvJxEbG0vHjp3JyysgKakx4eHhLFu2lL59T4zN+uKLE7OMVHQ8S75+QkJ92rRpy/ffT+bSS68iLs76Mr127WpWrVrJuHGXl3mMTrxPz+Wlj0dBsXOWu7AwR7lf5EMpIaVhdduVVFgWuA5YFVB792bw9NNPEBtbi9TUNmVeOE1JaUqbNsJvv/1C9+69PHbJORwOevfuyy+/TCc7O5vY2NIN58TERK677qYKV968//6/k5zchL59B5CSkkJ2dg5Llixk7tzZtG9/alELzFs9evSiUaPGPPXUY1x66RbCwsL54YfJJCQksnt3esU7qAIRERHccsvtPPnkI9x++00MG3Yme/bs5osvPqdVq9acd95owEqqL7zwDIMGDeWUU5pTUJDPzz9PweFwMHDgkDL3L9IegBdf/A89e/YmLCyMYcNGFG0fPvws3njjv8yZ8xuXXHKFV6MZ+/YdQKdOnXn11ZfYuXMHzZu35Lfffim6H6o8Tz31OIcPH+L007vRsGFDdu+23mubNm1p0aKlK+Z2ALz11msMHXomERER9O07wONnqyIxMTHMmfMrhw8fQqQ98+bNYenSRdx0021FI+zi4uIYNGgoX3zxOeAgJaUp8+bNJjMzs9T+Kjqe7m699U7uvvsObrnlWs4553yOHDnCpEmfUb9+gzJvKK9qoZSQlgN3ikhciYENhVcfV1R9SMoftm3bWnQT41NPPV5mvbPPPpe+ffuTlZVFnz79yqzXt29/fvzxO2bP/vWkpve5774HmT37V2bOnMbevRk4nVa3ylVXXcsVV/zF57v+IyIiePLJZ3nuuad45503qFevPhdffCnx8XV48slHKh2nv40ceR5RUVF88skHvPrqS9SuXZvhw8/i5ptvL7r7PzW1DT169GLevNl8++1XxMTEkJrahmeffbnc0Yf9+w9k7NhLmTbtJ6ZOnYLT6Sx2Am3QoAFnnNHDNZT5bK/iDQsL4+mnn+ell57j559/xOFw0LfvAG677S6uuab0DdXuRow4m8mTv+brr78gK+sw9erVZ8iQYVx77Y1FybBt23bcdNNf+eqrSSxcON81b+LkSiWkiIgInnvuvzz77L+ZMWMq8fF1uOmm27jyyquL1Rs//l7y8/P49tsviYyMYsiQYdx6651cddW4YvUqOp7uunfvybPPvsy7777JW2+9TlRUJN269eDWW+8M6OAcXzgqczEzUNzuQxpsjJlVYltPYAHF70OKxroPabcxpuwzlP+1ADbb0WWXnr6Vxo2Lj5Q5npvPrr1HAIiMCCMlqWqubYW6ilpIqvJO5tjee+940tJ2epwIVwX/59bTOaqQW5ddS2BLye1B0UISkQddP7Z3PV4pIv2AA8aYVwCMMQtFZBLwjIgkAxuxRsk15yQHJyilgsOePbtZuHAeN9xwi92hKBsERUKi9Izb17oetwKvuJVf5ap7FZCINdXQSGPM3IBHqJQKmF27drJq1Qq+/fYroqKiOffcUXaHpGwQFAnJGOPVQuzGmBzgHtc/pVQ1sXz5Mp588hEaN07mwQcfKXO6KFW9BUVCUkrVbCNHnldq8UVV89i+/IRSSikFmpCUUkoFCU1IISiYhuorpVShkz03aUIKMeHhEeTmHrc7DKWUKiU39xgREZVfisTrQQ0iUh9oaIxZ51bWEvgbUA/40Bjzc6UjUV6Ji0vgwIEMEhKSiIyMKnNmYKWUqgpOp5OCgnxycrI5cuQg8fGVn/XBl1F2LwFtgR4AIhIHzObEsg/jRGSIMea3SkejKhQba601c/DgXvLz8wDIy3eSlWVNaBkR5iA939MctKqksLCwKp3SvybRYxs4wXhsw8LCiYyMIjGxIZGRZa8vVhFfElJv4CO338dhJaORWPPMTQPuBTQhBVhsbO2ixASwfU8Wz3+9CICUpNo8dp33i4vVZCWnZVL+o8c2cKrzsfXlGlIjYLvb72cDS4wxPxlj0oEJWKu6qiqmnXZKqerAl4SUS/FF8AYCv7r9fgCo74eYlFJK1UC+dNn9CVwkIq8C52ENZJjhtr0ZsN+PsSmllKpBfElIr2J1y2UCtYBNFE9I/YFVfotMKaVUjeJ1l50x5kOs5R5mAB8DZxtjcqFoSHgCoAuYKKWUqhSvWkgiEg6kAD8YYz4qud0Ysw84w8+xKaWUqkG8bSFFYnXRXRfAWJRSStVgXiUk1zpEe4EjgQ1HKaVUTeXLsO8fgXMDFYiqPJ1qVSlVHfiSkO4FkkXkAxHpJCIxgQpKVZ7eJKuUClW+DPveg/VlvDNwBYCIlKzjNMboKrQ20taSUipU+ZI8PkTPd0FJW0VKqerA64RkjLk6gHEopZSq4XSBPqWUUkGhUtd7XGshJeAhoRljtp1kTEoppWognxKSiFwCPAi0L6da+ElFpJRSqkbyustOREYB/8NKYm9iXUv/FJiEtTTFUuBR/4eolFKqJvDlGtLdwDqgC/B/rrL3jDGXAN0AwVo5VimllPKZLwnpNOAD1zRChQu6hwMYY1YDbwH3+zc85Q0di6+Uqg58SUjhwD7Xz9mux7pu2w3Q0R9BqcrTe5KUUqHKl4S0A2gOYIzJxpq5wX3JCUEnX7WdtpaUUqHKl1F284BhnLh+NBm4S0SysRLbX4Hv/Bue8oa2ipRS1YEvLaTXgFkiEuv6/QGsbrqHsZLURqyBD0oppZTPfJk6aDGw2O33DKCLiJwG5APrjDEFZT1fKaWUKo8v9yENEJGkkuXGmJXGmDVAPREZ4NfolFJK1Ri+dNn9AgwvZ/tQVx2llFLKZ74kpIqunYdz4v4kpaqVAqeOX1Qq0Hyd7bu8v8o+wN6TiEVVkp4qA8fpdPKfT3/nntfmkXn4mN3hKFWtlTuoQUTuBO50K3pRRJ7wUDURqAO858fYVCXoEHD/2rTrEOu2ZgLw6fQ/uXV0J5sjUqr6qmiU3QFgq+vnFlgzNewuUccJrAYWAC/4MTalbHc870QvdFZ2ro2RKFX9lZuQjDEfAB8AiMhm4B/GmMlVEZiqHO2+U0qFKl/uQ2oZyECqkohEA29gjRqMB5YBt7mGr4cc7aZTSlUHXickEakPNDTGrHMrawn8DagHfGiM+dn/IQZEBLAJ6AWkYV0n+wZoY2NMSilVo/kyl91LQFugBxQtYz4baOLaPk5EhhhjfvNviP5njDkCPFb4u4i8AjwrIvWNMfvKfqZSSqlA8SUh9QY+cvt9HFYyGom1MN804F7Ap4QkIslYLZSeWAv9xQGDjTGzPNSNxlqV9kqskX0rgAeMMTN8eU0PegN7NBkppZR9fLkPqRGw3e33s4ElxpifjDHpwASgayViEOA+oCmwsoK6E4DxwMdYSawAmCIivSvxutaLiyRgLS74z8ruQyml1MnzpYWUC8S6/T4QK0EUOgDUr0QMS4EGxph9IjIK+NpTJRHpAVwCjDfGvOgq+xBryPnTwAC3urNc8XlyjzHmWVe9GOBb4HtjjN5DpZRSNvIlIf0JXCQirwLnYQ1kcO8qawbs9zUAY8xhL6uOwUqK77g9N0dE3gWeEJFkY0yaq3xQRTsTkXDgM6xWX0gvm6FDvZVS1YEvCelVrBZRJlALa5Sae0LqD6zyW2SldQX+MMZklShfhDXyuQvWiDlvvQ3EAGONMdXmnK5DwJVSocqX+5A+FBEnMAo4CDxpjMmFoiHhCViL+AVKMrDTQ3lhEmriYZtHItIcuAbIATJFpHDT2caY2d7up379OG+rnpSkpPhyt2flnphNICIivML66oSKjlXawZyinyMjI/TY+kCPVeBU12PrSwsJY8xHFB9pV1i+DzjDX0GVIRbwNLtljtt2rxhjtuKHxsS+fVkUFAS2cZWUFE9GRvm9mpmZR4t+zsvLr7C+snhzbA8cyC76OTc3T4+tl7w5tqpyQvnYhoU5yv0i7+ts33bKBqI9lMe4ba/xqk3fo1KqxgmlhJSG1W1XUmHZriqMJajodSOlVHUQSglpOdDONUOEu56uxxVVG45SSil/CqWE9AUQCVxfWOCaueEaYK4xpsa2kJRSqjrwaVBDoIjIg64f27serxSRfsABY8wrAMaYhSIyCXjGNd3QRuAvQHPg6ioOWSmllJ+VmZBEZBNwV+H6RyLyf8BXxpjVAYjjsRK/X+t63Aq84lZ+lavuVVhz2a0ERhpj5gYgJqWUUlWovBbSKVhrBRV6GNiANVWPXxljvLoub4zJAe5x/VMuOrIugJx6dJWqKuVdQ9oJdCpRpn+dQU5H3CmlQlV5LaRvgXtF5CxOzFH3oIjcUM5znMaYoX6LTimlVI1RXkK6D2veumFYAwecQBLWPHZK1QwObXMqVVXKTEjGmGzgIdc/RKQAa5DD/6ooNlUJ2qeqlApVvtyHdA0wL1CBqMrT7/BKqerAl9m+Pyj82TW7d0vXr5t16W+llFIny6cbY0WkM/Ay0K9E+WzgDmNMRUuQK6WUUh55nZBEpCMwB2t27W+BNa5NHbBWkJ0tIn2MMWvK2IVSKsD+3H6Aj6f+SZMGtejVoTEdW9YjIjyUZghTNZkvLaRHsZYQ71uyJeRKVr+56lzkv/CUUr6YvWIXOzKy2JGRxaJ1e4iLjaRH+4b06tCY1k3q4NBRgyqI+ZKQBgCveuqWM8asFpHXgJv9Fpnymo6sC6AQm6khr8SCkVnZucxctpOZy3aSlBBDr1Mb06tDI5Lr17YpQqXK5ktCqg2kl7M9zVVH2Ui//yqA+nWiuXBAa+avTWfN5v04nZBxIIfv5m3hu3lbaNE4nt4dGtPj1EbUrR1ld7hKAb4lpE3AucCrZWw/11VHKWWziPAwendsTO+OjTmYdYxF6/awYG06m9Ospa+3pB9mS/phPp+5gVNbJNK7Q2O6tm1ATFRQLACgaihfPn0fAv8Wkf8BTwB/uMrbA/cDZwL/8G94StmsGlxzqRsXzfDuzRjevRlp+46wYM1uFqxNJ+NADgVOJ6s372f15v1ERYZxepskenVoTIeWiYSH6WAIVbV8SUjPAqcDlwDjgAJXeRhWT9FE4Dm/RqeU8qvk+rUZPaAVo/q3ZOOuQyxYk86idXvIys7leG4BC9buZsHa3cTXiqRH+0b06tCIVsk6GEJVDV9ujM0HxonIO8AoTtwYuwn4xhgz3f/hKV+F1iV4ZReHw0FqSl1SU+pyydA2rN68nwVr0vl9/V5y8wo4fDSXGUt3MGPpDhomxtLr1Eb07tiYRok6laUKHJ87jI0x04BpAYhFVZJ+d1UnIyI8jC6pDeiS2oDsY3ks+zODBWvSWbs1E6cT9mRmM3nuFr6bu4Wxg1M5q+cpdoesqim9gqmUKhIbHUHfTsn07ZTMgaxjLFq7m/lrdrN192GcwMRfNhATHc6gLil2h6qqIU1ISimPEuKiObPHKZzZ4xQ2px3i+c+XcyQnj49+MtSKjqBH+0Z2h6iqGR1Go1Q14gzQjbwtk+sw/uIuREeG4wTe/m4tqzbpnMrKvzQhVQM6kCGAQmymhkBq1aQOt1/UiYhwB/kFTl79ahXrdxywOyxVjWhCqmZ0gIMCAnb/1Kkt6nHzBR1xOOB4XgEvTlrJtt2HA/JaqubxKiGJSKyIXCUiPQMdkFIquJ3eNolrR7YHIPtYHs9/vpz0/UdtjkpVB962kI4BbwNdAxiLUipE9O2UzKVD2wBw6Gguz332O/sP5dgclQp1XiUkY0wBsB2oE9hwlAoyOkNBmYZ3b8b5fVsAsO/QMZ77fDmHjh63NygV0ny5hvQBcKWIRAcqGHXy9BK8qkoX9GvJ0DOaApC27ygvTFxB9rE8m6NSocqX+5DmARcCy11rH60HSnUcG2N+81Nsykv6HV7ZxeFwcOmwNhzNyWP+mnS2ph/m5S9W8sRf+9kdmgpBviQk9+mCXqL0l3GHqyz8ZINSSoWOMIeDa0a2I/tYHss37MVsP8DTHy7mhnPa6/Lpyie+JKRrAhaFUiqkRYSHccuoDrwwcQV/bDvA4rW7CXfA9eeeSpheh1Ne8mW27w8CGYhSKrRFRoRz+0Wn8Z9Pf2dL+mEWrNlNregILh/eVpevUF7R9nQ1oAMZAkhnavBJbHQE4y/uTLNGcQDMXLaTb2ZvtjkqFSp8Skgi0kxE3hORHSJyXESGuMqTXOXdAxOm8pZ+D1Vg7+cgvlYUj97Yh/p1YgD4bt4Wpi7aZmNEKlR4nZBEpCWwBLgIWIPb4AVjTAbQDbje3wEqpUJPg4RY7r60C3VqRwHw2cwNzF6xy+aoVLDzpYX0BNay5R2Byyn9JexHQMd6KqUAaJRYi7+P60KtaOtS9YSf/mCp2WNzVCqY+ZKQhgGvGWO24/myxVagqV+iUipY6MX4k9KsYRx3je1MVGQYTie8OXkNa7bstzssFaR8SUh1gLRytkehC/7ZTi/Bq2CT2rQut43uRHiYg7x8J698uYqNOw/aHZYKQr4kpO1Ah3K29wI2nFw4qjL0O7wKdh1b1efG8zvgcMCx3HxenLSCHXuy7A5LBRlfEtJXwLUi0tGtzAkgIhcBY4GJfoxNKVWNdG/XkL+c1Q6AIzl5PPf5cvZk6rIV6gRfBzXsABYCH2Mlo3+IyHysRLQCeM7vESqlqo0BnZswdnBrAA4eOc6zny0n8/Axm6NSwcLrhGSMOQT0Bt7BGuLtAIYDArwGDDbG6IIoStkoFO7jPbtnc87p3RyAvQdzePqTZXwzexOrN+/jaI7OFF6T+TQIwZWU7gTuFJEkrKSUYYwJgT+DE0TkdWAUUBtrdOD9xpjvbQ3qJITUwQ81oXCGD0EXDmjFkZw8Zv2+kz0Hspk8dwtgnVBSkmqTmlKX1il1SW1al4YJsTr1UA1R6VFxrpthQ9VLwHhjTI6IdAOmi0hLY0ym3YGdLP2zVRD8o9UdDgdXDG9LQu0oFq7bTdo+61qSE9iRcYQdGUeYtdy6kTa+ViSpKXWLklSLxvFEReqiAtWRzwlJRC4GRgOtXEWbgK+NMSEzoMEY80eJomggGQj5hKRUqAgLc3B+v5ac368lWdm5bNx5kA07D7Jx50E2pR3ieG4BAIeP5vL7+r38vn4vAOFhDpo3ji+WpBLjdd3Q6sDrhCQitYFvgCFYX8QPuDZ1By4WkZuA840xR3zYZzJWF2BPrOtScVjXomZ5qBsNPApcCSRiDaJ4wBgzw9vXK7G/17CW1IgBvgfWVWY/SqmTFxcbSefUBnRObQBAXn4BOzKy2LDjRJLad8ga/JBf4GTTrkNs2nWIqYu3A9CgbsyJbr6UujRtWJvwMJ07OtT40kJ6AhgKvAw8ZYxJBxCRxsA/gDtcde7yYZ8C3Id1/9JKoE85dSdgzaP3oqv+1cAUERlojJnvw2sCYIy5VURuBwYDHULtOphS1VlEeBgtGtehReM6DOvWDID9h3LYuOtQUZLatvsw+QXWn+3egznsPZjDgrW7AYiODKdrmwZcOLAVDerG2vY+lG98SUjjgEnGmLvcC12J6S4RSXHVuav0U8u0FGhgjNknIqOArz1VEpEewCVY131edJV9CKwGngYGuNWdBQws4/XuMcY86xZ7Ptb1oztF5A9jzM8+xK5qgmC/GFOD1KsTQ706MXRv1xCA47n5bEk/zIadB4uSVFZ2LmDdfLtg7W6W/pnB2T1P4exezYnW605Bz5eEVAf4pZztM4GRvry4Meawl1XHALlYQ84Ln5sjIu8CT4hIsjEmzVU+yJcYXCKA1pV4XtDRZp6qKaIiw2nbLIG2zRIAcDqd7MnMZsPOgyzfsJelJoPcvAImz93CnFVpXDw4le7tGuqIvSDmS0JaCbQpZ3sbYNXJhVOmrsAfxpiSc40swrqe1YXy59krIiJxWEO+vwFygAuwuu3u9U+oVU//vJSyRu41qleLRvVq0bdTMn9uP8Cn09ezdfdh9h86xhvfrmHmsp1cNqwNpzSKtztc5YEvCelB4GsRmWWM+c59g4hcgLUW0ig/xuYuGdjpobwwCTXxYV9O4FrgFaxz+QbgUmOMz8m0fv04X59SKUlJ5f/xHMk70S6KCA+rsL46oaJjlXbwxL3ekZERQX9so11LPYQHwecgGF6/V5emTF+0jY+mrOVg1nH+3H6ARycs5sxeLbjirHbUjQvN0Xl2H9tAKTMhich7Hoo3A9+IiOHEqLT2WIMTVmGtkzTT30ECsYCn+UVy3LZ7xTUKcIg/gtq3L4uCgsB2kiUlxZORUX7PZub+EwMb8/ILKqyvLN4c2wMHsot+zs3NC/pjm3PMmukg3+bPgTfHtqqc3roe7a7vyeS5W5ixdAf5BU5+mr+F35bt4IJ+LRl8egoR4aEzIi+Yjq2vwsIc5X6RL6+FdHU529q5/rk7DegEXOdtcD7IxrpXqKQYt+01ll43CiCdqaFaqBUTySVD2zCgcxM+m7Ge1Zv3c/RYHp/OWM+vK3Zx6dA2dGhZz+4wa7wyE5IxJpi+MqRhdduVVFimayO76PUkpcrWpEFtxl/cmRUb9vHZjPXsOZDNrr1HeO7z5XRt04BxQ1JpmFjL7jBrrGBKOuVZDrRzDUhw19P1uKJqw1FKhSqHw0GXNg147PqejB3Umugoazj47+v38uA7C/ny143kHNdJXu0QKgnpCyASa+AEUDRzwzXAXGOMtpCUUj6JjAjj7F7N+feNvejbsTEAeflOfpi/lX++tYD5q9NxapdtlfJpLjsR6QP8FWuId31K9xA5jTE+3c8jIg+6fmzverxSRPoBB4wxrwAYYxaKyCTgGdd0QxuBvwDNKf9al1JKlSshLprrzj2VQaen8L9p69mcdogDWcd5+/u1zPx9B5cNa0vL5Dp2h1kj+DKX3Q3AG8BxwADb/BTDYyV+v9b1uBVraHahq1x1r8Kay24lMNIYM9dPcSilarDWTerywFVnMH91Ol/M2sjBI8fZuPMQj32whH6dkrloYKuQHSYeKnxpIf0T61rOCGPMXn8FYIzx6jq8a/G/e1z/VBm0g8HP9K7+GiXM4aBvp2ROb5vE9/O2MHXxdvILnMxZlcYSs4fz+7ZkWLemITVMPJT4clQbAe/6Mxkp/9BTplL+FRsdwdjBqTx+fU+6uGYgzzmez8RfNvDPtxYwZ2Ua+QUFNkdZ/fiSkNZhdZUppVSN0KheLe4Ycxp/u7gzyfWt4eB7D+bw3o/r+Nc7i1i0bjcFOvDBb3xJSE8At4qIL9P0qCqgfw6qiJ4cA6Jjq/o8cm0PrhwhJMRFAZC+/yhvfLuGR95fzPL1e3VEnh94fQ3JGPOViNQC1orIt8AWIL9ENacxpuQgBVWFtPvOz/Qko1wiwsMY3DWFvh0bM+v3nfywYCuHj+ayfU8WL3+5klZN6jB6QCtObZ6oM4pXki+j7NpirdhaB2vVVk+clB41p5SqYnpCDJyoyHDO7HEKA7o0YdqSHfy0cBvZx/LYtOsQz322HGmWwIUDW9GmaYLdoYYcX0bZvQY0xFpyfDaQGZCIlFIqBMRERXBenxYMOT2FnxdtY9riHRzLzcdsP8C/P15Gp1b1GT2gJS0a6z1M3vIlIfUG/mOM+W+gglFKqVBTOyaSCwe0Zli3Zvw4fyszl+0kL7+AVZv2sWrTPs5om8So/i1JSaqa5WpCmS8J6SCQEahAlFIqlNWpFcUlQ9swoscpfD9vC7+t2EV+gZOlf2aw7M8MenZoxAX9WtJIJ28tky+j7CYCFwYqEKWUqg4S46O5coTw5I296NupMQ6HdXF9wZrdPPDWQiZM+YP9h3Iq3E9N5EsL6U3gAxH5BngZa7G+kqPsMMb4a0ohVQk6JszPdHCAqqSkhFiuO+dURvZqzjezN7P4jz0UOJ38tmIX81anMahLCuf0aUHd2lF2hxo0fElIa7DOd92A88qpF35SESmf6SlTqeCVXL82t4zqyDm7D/PN7M0s37CXvHwn05fu4LeVuxh6RlPO7tmcuNhIu0O1nS8J6VH0C7hSSlXKKY3iuWPMaWzcdZCvf9vE2i2ZHM8tYMqCbcz6fRd/H9eFVk1q9og8X26MfTiAcaiToN8SAijEbowNrWhrptZN6nL3JV35Y2smX/22iQ07D5J9LI+JM9fzjyvOsDs8W+mUtdWMdt8pFRraNU/k/itOZ9gZTQH4c8dBtqYftjkqe/kyU8MAb+oZY36rfDhKKX/QLyahweFwcGaPZsxYtgOnE6Yv2c51555qd1i28eUa0iy86xHQQQ1KKeWlBnVjOaNtEktMBgvX7WbM4NQaO/LOl4R0TRnPb421jPgWrKHhSimlfDCsWzOWmAzy8p38+vtOzu/X0u6QbOHLoIYPytomIv8BlvklIqWUqmHaNK1L80bxbN19mF9+38nI3s1r5Kq0fnnHxphM4B3gXn/sTymlahKHw8GwbtbghoNHjrN43R6bI7KHP1NwJtDKj/tTSqkao0f7RtRxXTuatmR7jVzwzy8JSURisNZISvfH/lTl1byPcIDp1EGqikRGhDGoi7Ug95b0w2zcecjmiKqeL8O+3ytjUz2spSmSgHv8EZTyjZ4ylaoeBndN4Yf5W8kvcDJtyXZSm9a1O6Qq5csou6vLKN8P/AmMN8b876QjUj7TVlEAhVq3SYiFq4qrGxdNj/aNmL8mnaUmg/2HcqhXJ8busKqML6Psat6QjxCkrSUF6AchhA3v3pT5a9IpcDqZuWwnYwa1tjukKqNJRimlgkiLxnWKuup+Xb6TY7mlVvmptjQhKaVUkBnerRkAR3LyWLCm5owVK7fLTkQm+7g/pzHmgpOIRymlarzT2zagXp1o9h86xvQlOxjQuQmOGjDis6JrSOf6uD+9pKqUUicpPCyMIac35YtZG9m59whrt2bSoUU9u8MKuHITkjcDGURkIPAM0B1I81NcSilVow3o3ITJczZzPK+A6Yu314iEVOlrSCLSUUR+AGYCAvwLaOOvwJRSqiaLi42kd8fGAKzcuI/dmUdtjijwfE5IItJMRCYAvwNDgZeB1saYJ4wx2X6OT/lI+0z9rAb026vgVbh4nxOYsWSHvcFUAV9makgEHgBuBaKBT4EHjTFbAhOa8paeMpWqnlKS4ji1RSJrt2QyZ1UaowdU7+lCK0xIIhIN3AXcByQA04D7jDHLAxmY8p62igIoxGZqCK1olTeGdWvG2i2Z5BzPZ87KNC5rmmh3SAFTbpediFwHbACeBDYCw40xIzQZBS9tLSnQz0F1clrr+jRMjAVgxtId5BdU368dFbWQ3sb60rUEmAh0FpHO5dR3GmNe8FdwSilV04U5HAw9oymfTl/PngPZLF23m5YNa9sdVkB4cw3JgTWku7sXdZ2AJiSllPKjfp2S+fq3TeQcz2fy7I3cedFpdocUEBUlpMFVEoVSSqkyxUZH0O+0ZKYv2cGK9XvZkZFF06Q4u8Pyu4pujP21qgJRSilVtmFnNGXGkh04gelLdnD12e3sDsnvdHJVpZQKAQ0Ta9E5tQEA89ekk5Wda3NE/lejE5KI9BaRAhH5h92xKKVURYZ3s26Uzc0r4NflO22Oxv9qbEISkTCsARiL7Y7Fn6rvgFClVLvmiTRvHA/AzGU7ycsvsDki/6qxCQm4EVgIrLM7kJOl95wEkE4dpIKIw+HgvP7WCrKZh4+x7M8MmyPyL6+nDgoEEUkG7gR6At2AOGCwMWaWh7rRwKPAlUAisAJ4wBgzoxKvWx9r9olewIuViz54aKsogEJtpoYQi1f5btAZTZnw/RqysnOZvmQHPdo3sjskv7G7hSRYUxI1BVZWUHcCMB74GCuJFQBTRKR3JV73CeBFY8yBSjw3qOn3eWXRT0J1FR0ZzsAuTQDYsPMgm9MO2RyR/9jaQgKWAg2MMftEZBTwtadKItIDuAQYb4x50VX2IbAaeBoY4FZ3FjCwjNe7B5iBdZPvX/3yDpRSqooN7prClAXbKHA6mb5kOzec18HukPzC1oRkjDnsZdUxQC7wjttzc0TkXeAJEUk2xqS5ygeVtyMRuQurZbZTRADqAnki0sIYc7PPb0IppapYvToxdGuXxKJ1e1i0bg9jB6eSEBdtd1gnze4uO291Bf4wxmSVKF+E1TfRxYd9vQWkup7TBZgMvITVdaiUUiFhWLdmAOQXOJn1e/UYAm53l523kgFPR7xwyfQm3u7IGHMUKFp6UUSygSxjzEFfg6pfv2qm7khKii93e1buiaGfERHhFdZXJ1R0rHYdyCn6OSoqIuiPbXS09ScdERFme6x2v351lpQUT4MGcbSZtZH12w/w24o0rj6/I5ER4XaHdlJCJSHFAsc8lOe4ba8UY8zVlX3uvn1ZFAR4KvikpHgyMsrv2cx0W9o4Ly+/wvrK4s2xPXjgxLE9fjwv6I/tsWN5AOTlFdgaqzfHVlWO+7Ed1KUJ67cf4EDWMX74bSN9OyXbHF35wsIc5X6RD5Uuu2ysVWpLinHbrpRSNUr3dg2pGxcFwLQl20N+2H+oJKQ0rG67kgrLdlVhLEopFRQiwsMY3DUFgG27s1i/w+crD0ElVBLScqCdiJRs6/V0Pa6o2nCCV2h/PwpCOlODCnKDuqQQEW59Tqct2W5zNCcnVBLSF0AkcH1hgWvmhmuAucYYbSGpwAjxLhBV/dWpHUXPU63ZGpb9mcHeg6F7BcP2QQ0i8qDrx/auxytFpB9wwBjzCoAxZqGITAKecU03tBH4C9AcuLqKQw5q+n1egTbsaprh3Zoxd1U6Tqc16erFg1PtDqlSbE9IwGMlfr/W9bgVeMWt/CpX3auw5rJbCYw0xswNeIRKKRXETmkUT9tmCfy5/QC/Ld/FBX1bEh0VekPAbU9IxhivvssZY3Kwpv65J7ARKaVU6BnerSl/bj/A0WN5zFuTXjTYIZSEyjUkpZRS5ejaJon6daw7YaaH6BBwTUhKKVUNhIU5GHqGtaJs2r6jrNmy3+aIfKcJSSmlqon+nZOJirRO69OX7LA5Gt9pQlJKqWqidkwkfTta8wWs3LiPtH1HbI7IN5qQlFKqGhnWrWnRzzOWhlYrSRNSNRN6lzGVUv6UXL82HVvWA2DuqnSO5uTZHJH3NCEpVY2E4MAqFQCDT7eGfB/LzWfjrtCZ304TUjWjN+gr0M9BTee+emx+gJfI8SdNSEoppYKCJiSllFJBQROSUkqpoKAJSSmlVFDQhKSUUiooaEJSSikVFDQhKaWUCgq2r4cUosLBml23KlT0OlGR4TRMjAWgXt2YKourOqjoWEVHnTi2ifHRQX9sE+KjaZgYS7069n8O7H796syXc0JMVETQ/F+4xeFx9UBHKK6ZEQT6AbPtDkIppUJUf2BOyUJNSJUTDXQH0oB8m2NRSqlQEQ4kA4uBYyU3akJSSikVFHRQg1JKqaCgCUkppVRQ0ISklFIqKGhCUkopFRQ0ISmllAoKmpCUUkoFBU1ISimlgoImJKWUUkFB57ILQiISDTwKXAkkAiuAB4wxM2wNLMSJSHfgamAw0BzYB8wDHjTGbLAxtGpJRO4FngZWGGO62BxOyHN9fh8G+gCRwEbgBWPMBBvD8ittIQWnCcB44GPgTqAAmCIive0Mqhq4D7gQmI51XN8CBgG/i0h7G+OqdkSkMfAgcMTuWKoDETkbmIuViP4F/B3rc9zMzrj8TVtIQUZEegCXAOONMS+6yj4EVmN92xxgX3Qh73ngMmPM8cICEfkcWIWVrK62Ka7q6ClgCdaX3gR7QwltIlIX60vq68aYO20OJ6C0hRR8xgC5wDuFBcaYHOBdoJ+IJNsVWKgzxsxzT0ausvXAGkBbSH7i+lJ1BfA3u2OpJi7DSur/ByAi8SISHOtJ+JkmpODTFfjDGJNVonwR4AC6VHlE1ZjrD7sRsNfuWKoD1/H8L/CBMWa5zeFUF8OAP4CRIrIdOATsF5GnRMTjukKhSrvsgk8ysNNDeZrrsUkVxlITXA6kAA/YHUg1cRVwKjDK5jiqk1Ssa0UTgGeA34FzsbqZY4C77ArM3zQhBZ9YPKwTAuS4bVd+ICLtgFexFgr7yOZwQp6IxGNdO3rKGJNWUX3ltTis0bb/MMY87Sr7SkTigFtF5HFjTLVo4WuXXfDJxloAsKQYt+3qJLlGgf0AZAJjjTEFNodUHTwIHMcaPKL8p/Bv/tMS5Z9gjbrrUbXhBI62kIJPGla3XUmFZbuqMJZqyTVqaQpQF+hrjEm3OaSQ5xpscxfWkORGIlK4KQaIEpEWwEFjTKYtAYa2NKADsLtEeeHviVUbTuBoCyn4LAfauZrj7nq6HldUbTjVi4jEAN8BbYFzjTHG5pCqi0ZAFNatCZvd/vXEGsG4Geuah/LdUtdjSonypq7HjCqMJaA0IQWfL7Ca4dcXFrhmbrgGmGuM0RZSJblGJH0O9Mbqpltgc0jVyWZgtId/a4Atrp8/tCu4EDfJ9XhdYYFrNOP1WDceV5vPscPpdNodgypBRCZijVJ6AWt6kL8A3YHBxpi5NoYW0kTkRawZGr4DJpbYnGWM+aaqY6ruRGQWkKBTB50cEfkAayqxd4FlwDmuf/caY/5jZ2z+pNeQgtNVwGOux0RgJTBSk9FJ6+J6PM/1z91W4JuqDEYpH9wAbMP6cvoXYBNwszHmTVuj8jNtISmllAoKeg1JKaVUUNCEpJRSKihoQlJKKRUUNCEppZQKCpqQlFJKBQVNSEoppYKCJiSllFJBQROSUkqpoKAJSSmlVFDQhKRCiogMEhGniFxtdywnS0Q6ikieiAy3O5aaQEQuEJHjItLG7liUZ5qQlLLP81gzuE9zLxSReq6kO8WmuAJGRF4RkZ2u2arLqlP4peNuf762MeZbYBXWEhkqCGlCUsoGItIbGI7n1VVPdz0uq7qIAs+VhEYB3xpj7JpE8yVgtIh0sOn1VTk0ISllj1uBvcCPHrZVy4SEtYRKCvbOqv4VcBS42cYYVBl0+QlVLYhIA+AR4Hys1Ut3A5OB/zPG7CtRtwXwHFYLBeAXrOW3fwG2GGMGBTjWCKyWwvfGmFwPVaprQhoNHMA6zrYwxmSJyGxgDHC7XXEoz7SFpEKeiNQF5gG3AD9jJZefXL/PEZF4t7r1gdlY6yFNwFpW+wjWSbJ2FYV8BhAHLCpj++lApjFmcxXFU1VGAz+WkYSr0nygsYi0szkOVYK2kFR1cC/QBvirMea1wkIRWQ684tr+L1fxfUBT4ApjzCeustdF5BngniqK91TX48aSG1zJMxUbWxGBICLtAQEetDsWThz3DsAfdgaiitOEpKqD0UAG8FaJ8jeBh1zbCxPSeUAa8GmJus9SdQkpyfW438O2roCD6tddNwrIwWq5+pWINMZaXbkdsAeYZIxZWs5TCrtwG/o7FnVyNCGp6qAlsMQYk+deaIzJE5E/OXFNprDuImNMQYm6e0TkgHuZiFwM3IG19PleY0yLEtsjsK5FXYnV/f0lVistp4J4C0eYeRr6fIbrscyEJCL9AU9DwqOAcGNMeIn6r2F1X/YxxswvsW0WMBAYaYyZ4lZ+MfA58IMx5lxXWVvgGaAvEIPrOp0x5m9lxepmNDDdGJPlRV2vichFwBDgXeC/WEnmMhEZA/yzjNF8hcddl8sOMpqQlCpbJlaXXyNgvIft/wQGA52A41iDKJ7BSmLlyXA91vOwrcIBDcaY2VjXoIqISBNgiSte9/JY4DKs1tj1WNdPSvoDuI7iSe56Sndn/YA1Su0KrJFqrbGSU7lEpCnQDbihorq+EJGOQAtjzF/dircC/xaRXlgj6V738NTC457hYZuykQ5qUNXBJkBcLZYirt/burYX2gKkikhYiboNgQT3MmPMNGPMZ1gnOU+uB540xuw0xmQADwNXi0h4GfULrXY9epox4HQgC/izgn0UEZForEQxxxjzZInNY4ECrIEeF4tIHKVNBIaISJJrf82xWoXfuL1GA6xrW28YY7KMMQXGmPXGmAlehDgKqzUy2dv35KUL8XwfF8aYBUCDkp8Jl1TX42oP25SNNCGp6uAbrOsy15cov8FV/rVb2XdAMnBpibo+zQogIglAM2C5W/EyIB5oUcHTfwcOAb1K7LMW1oX/5T7eOPoGVhfa1R62XQ98hpV0coFLPNQ5jHWMrnL9fh3wP+BYYQVjzF5gHfCeiFwiIq19iG80VrL0d4vkaOFxEpHeIrJXRNwHTSzF+kJSUi9gtzHG+DkedZK0y05VB89gtQReFZHTsU74XbFOrMa1vdDTWF1Y74tID6xuqf5AH6wbVb1NBIVDyQ+4lR0osc0jY0y+iHwFjBKRaGNM4Ym/MxAOxIjIPzw8NcsYU7JL7g7gXKC7MeZoiW1tsd7bPcaYYyLyGdYxecfDvt8F3hGRF7ES2znARSXqDMJK3P8EThWRbcA/jDETy3qvIlIPGIA10tFXQ0UkxkP5XmPMGyXKOgP1Kd6FeIgS/xeuFmJ/4L1KxKMCTFtIKuQZYw5inYjeBEYCL7se3wD6GWMOu9XdC/QDvgeuxUpQtbGuBTmAbC9ftnCfdd3KEkpsK8/rrvrnupUVXj/qBvzbw7+x7jsQkcGu+McaY7Z4eI3rgT+MMQtdv08AenmaNscYMw/r/T8MpBtjVnmos8cYc68x5jSs6zCvAf+r4H6ec7G++H5dTp2ynAU85uHfXa7tsW5138Fqif3FrawzsL7EPi8CamF9VlSQ0RaSCinGmFl4GJ3m6g661fWvon1sxrr+UMR1w2x9YJuXcRwQke1Y11oKu366YiWjLV48f5GIFN7E+6Wr7FXgVW9e3zXbxESs1s8sD9sjsbrg6opIeonN1wGeRsa9i9WavMWL+A8Bz4rI/ZR/P89oYEUZCbOsfc/C8wjEkraISB9jzDzXCMtvCje4bpZuYYwpObT+TuBrY4xePwpCmpBUjSMiscaYki2hwi6yaW71woFI1z+Hq/vI6dbF9g5wv2sqmlys1sUEY0y+l6H8HVghImcaY6b6EH8trJPv5JJdeG7OAxKxkqT7SfkK4D4R+Ycx5niJ57yFdU1snofXTMS6T+sTrAEXYVhde7WwrtWUZT7wdrlvqPI+Bl4SkdruM6aLSEusllSxpCsio4COwLgAxaNOkiYkVRP9KCJbsQYhhAFDsbqW5lF84s8rgffdfs/GGnHXwvX7k0ADYI1rP19gzQThFWPMGir3N3gRVndUWxHxdHI9Fau77lNjzFr3DSLyBvAA1si3Ytd+XK2e6WW85nGgMdZIuUZYAx7WAOeX1/oxxjxT1raTZYxxishdwG0icj3WaMIwrBuf7yw5h6Ex5huse7VUkHI4nXpvmKpZROTvWN1ZLbCuQ+zAGjb9iPv1JqVU1dKEpJRSKijoKDullFJBQROSUkqpoKAJSSmlVFDQhKSUUiooaEJSSikVFDQhKaWUCgqakJRSSgUFTUhKKaWCwv8DfwO2Q+o/xrYAAAAASUVORK5CYII=\n", + "text/plain": [ + "<Figure size 432x288 with 1 Axes>" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "# plot luminosity distribution\n", "ldist = population.grid_results['luminosity distribution']\n", @@ -491,10 +582,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "id": "5956f746-e3b9-4912-b75f-8eb0af66d3f6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ValueError", + "evalue": "Failed to rename grid variable M_1 to lnM_1.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Input \u001b[0;32mIn [27]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Rename the old variable (M_1) because we want it to be called lnM_1 now\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mpopulation\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrename_grid_variable\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mM_1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mlnM_1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/.pyenv/versions/3.9.9/envs/dev_binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/utils/population_extensions/gridcode.py:965\u001b[0m, in \u001b[0;36mgridcode.rename_grid_variable\u001b[0;34m(self, oldname, newname)\u001b[0m\n\u001b[1;32m 963\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 964\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFailed to rename grid variable \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m to \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(oldname, newname)\n\u001b[0;32m--> 965\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(msg)\n", + "\u001b[0;31mValueError\u001b[0m: Failed to rename grid variable M_1 to lnM_1." + ] + } + ], "source": [ "# Rename the old variable (M_1) because we want it to be called lnM_1 now\n", "population.rename_grid_variable(\"M_1\",\"lnM_1\")" @@ -520,8 +624,8 @@ "# because M * dprob/dM = dprob/dlnM\n", "population.update_grid_variable(\n", " name=\"lnM_1\",\n", - " samplerfunc=\"const(math.log({min}), math.log({max}), {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " samplerfunc=\"self.const_linear(math.log({min}), math.log({max}), {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnM_1\",\n", " parameter_name=\"M_1\",\n", " precode=\"M_1=math.exp(lnM_1)\",\n", @@ -615,7 +719,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -629,7 +733,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/_sources/examples/notebook_population.ipynb.txt b/docs/build/html/_sources/examples/notebook_population.ipynb.txt index 760b1480e9f9bdcc508ced177f8f0d806cfb53eb..ebc19cff04f8dd9e8e2fe6694fa9b0346425afe9 100644 --- a/docs/build/html/_sources/examples/notebook_population.ipynb.txt +++ b/docs/build/html/_sources/examples/notebook_population.ipynb.txt @@ -25,7 +25,7 @@ "import os\n", "\n", "from binarycpython.utils.custom_logging_functions import temp_dir\n", - "from binarycpython.utils.grid import Population\n", + "from binarycpython import Population\n", "\n", "TMP_DIR = temp_dir(\"notebooks\", \"notebook_population\")\n", "\n", @@ -58,13 +58,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: M_1=10 to BSE_options\n", - "adding: orbital_period=45000000080 to BSE_options\n", - "adding: max_evolution_time=15000 to BSE_options\n", - "adding: eccentricity=0.02 to BSE_options\n", "adding: num_cores=2 to grid_options\n", - "adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_population to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", @@ -139,13 +135,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "Writing settings to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json\n" + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n" ] }, { "data": { "text/plain": [ - "'/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json'" + "'/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz'" ] }, "execution_count": 3, @@ -185,9 +185,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on method add_grid_variable in module binarycpython.utils.grid:\n", + "Help on method add_grid_variable in module binarycpython.utils.population_extensions.gridcode:\n", "\n", - "add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int], gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None) -> None method of binarycpython.utils.grid.Population instance\n", + "add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int] = -1, gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None, index: Optional[int] = None, dry_parallel: Optional[bool] = False) -> 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", @@ -198,17 +198,15 @@ " beware that if you insert some destructive piece of code, it will be executed anyway.\n", " Use at own risk.\n", " \n", - " Tasks:\n", - " - TODO: Fix this complex function.\n", - " \n", " Args:\n", " name:\n", " name of parameter used in the grid Python code.\n", " This is evaluated as a parameter and you can use it throughout\n", " the rest of the function\n", " \n", - " Examples:\n", - " name = 'lnm1'\n", + " Examples::\n", + " \n", + " name = 'lnM_1'\n", " \n", " parameter_name:\n", " name of the parameter in binary_c\n", @@ -223,47 +221,66 @@ " longname:\n", " Long name of parameter\n", " \n", - " Examples:\n", + " Examples::\n", + " \n", " longname = 'Primary mass'\n", + " \n", " range:\n", " Range of values to take. Does not get used really, the samplerfunc is used to\n", " get the values from\n", " \n", - " Examples:\n", + " Examples::\n", + " \n", " range = [math.log(m_min), math.log(m_max)]\n", + " \n", " samplerfunc:\n", " Function returning a list or numpy array of samples spaced appropriately.\n", " You can either use a real function, or a string representation of a function call.\n", " \n", - " Examples:\n", - " samplerfunc = \"const(math.log(m_min), math.log(m_max), {})\".format(resolution['M_1'])\n", + " Examples::\n", + " \n", + " samplerfunc = \"self.const_linear(math.log(m_min), math.log(m_max), {})\".format(resolution['M_1'])\n", " \n", " 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", + " sampling function (i.e. a value for lnM_1 is chosen already)\n", + " \n", + " Examples::\n", + " \n", + " precode = 'M_1=math.exp(lnM_1);'\n", " \n", - " Examples:\n", - " precode = 'M_1=math.exp(lnm1);'\n", " postcode:\n", " Code executed after the probability is calculated.\n", + " \n", " probdist:\n", " Function determining the probability that gets assigned to the sampled parameter\n", " \n", - " Examples:\n", - " probdist = 'Kroupa2001(M_1)*M_1'\n", + " Examples::\n", + " \n", + " probdist = 'self.Kroupa2001(M_1)*M_1'\n", + " \n", " dphasevol:\n", " part of the parameter space that the total probability is calculated with. Put to -1\n", " if you want to ignore any dphasevol calculations and set the value to 1\n", - " Examples:\n", - " dphasevol = 'dlnm1'\n", + " \n", + " Examples::\n", + " \n", + " dphasevol = 'dlnM_1'\n", + " \n", " condition:\n", " condition that has to be met in order for the grid generation to continue\n", - " Examples:\n", - " condition = 'self.grid_options['binary']==1'\n", + " \n", + " Examples::\n", + " \n", + " condition = \"self.grid_options['binary']==1\"\n", + " \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 'centred'\n", - " (steps starting at lower edge + 0.5 * stepsize).\n", + " (steps starting at ``lower edge + 0.5 * stepsize``).\n", + " \n", + " dry_parallel:\n", + " If True, try to parallelize this variable in dry runs.\n", " \n", " topcode:\n", " Code added at the very top of the block.\n", @@ -313,35 +330,7 @@ "execution_count": 6, "id": "47979841-2c26-4b26-8945-603d013dc93a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Added grid variable: {\n", - " \"name\": \"lnm1\",\n", - " \"parameter_name\": \"M_1\",\n", - " \"longname\": \"Primary mass\",\n", - " \"valuerange\": [\n", - " 2,\n", - " 150\n", - " ],\n", - " \"samplerfunc\": \"const(math.log(2), math.log(150), 20)\",\n", - " \"precode\": \"M_1=math.exp(lnm1)\",\n", - " \"postcode\": null,\n", - " \"probdist\": \"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", - " \"dphasevol\": \"dlnm1\",\n", - " \"condition\": \"\",\n", - " \"gridtype\": \"centred\",\n", - " \"branchpoint\": 0,\n", - " \"branchcode\": null,\n", - " \"topcode\": null,\n", - " \"bottomcode\": null,\n", - " \"grid_variable_number\": 0\n", - "}\n" - ] - } - ], + "outputs": [], "source": [ "# Add grid variables\n", "resolution = {\"M_1\": 20}\n", @@ -351,9 +340,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -364,8 +353,8 @@ "# name=\"q\",\n", "# longname=\"Mass ratio\",\n", "# valuerange=[\"0.1/M_1\", 1],\n", - "# samplerfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n", - "# probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", + "# samplerfunc=\"self.const_linear(0.1/M_1, 1, {})\".format(resolution['q']),\n", + "# probdist=\"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", "# dphasevol=\"dq\",\n", "# precode=\"M_2 = q * M_1\",\n", "# parameter_name=\"M_2\",\n", @@ -377,12 +366,12 @@ "# name=\"log10per\", # in days\n", "# longname=\"log10(Orbital_Period)\",\n", "# valuerange=[0.15, 5.5],\n", - "# samplerfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", + "# samplerfunc=\"self.const_linear(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", "# precode=\"\"\"orbital_period = 10** log10per\n", "# sep = calc_sep_from_period(M_1, M_2, orbital_period)\n", "# sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n", "# sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n", - "# probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", + "# probdist=\"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", "# parameter_name=\"orbital_period\",\n", "# dphasevol=\"dlog10per\",\n", "# )\n" @@ -434,7 +423,7 @@ ], "source": [ "# Create custom logging statement: in this case we will log when the star turns into a compact object, and then terminate the evolution.\n", - "custom_logging_statement = \"\"\"\n", + "custom_logging_code = \"\"\"\n", "if(stardata->star[0].stellar_type >= 13) \n", "{\n", " if (stardata->model.time < stardata->model.max_evolution_time)\n", @@ -454,7 +443,7 @@ "\"\"\"\n", "\n", "example_pop.set(\n", - " C_logging_code=custom_logging_statement\n", + " C_logging_code=custom_logging_code\n", ")" ] }, @@ -476,7 +465,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function parse_function at 0x1528ac7290d0> to grid_options\n" + "adding: parse_function=<function parse_function at 0x7f2b6ca163a0> to grid_options\n" ] } ], @@ -552,38 +541,41 @@ "output_type": "stream", "text": [ "adding: verbosity=0 to grid_options\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "**************************************\n", - "* Total starcount for this run is 20 *\n", - "* Total probability is 0.0444029 *\n", - "**************************************\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 19 *\n", + "* Total probability is 0.0443872 *\n", + "**********************************\n", "\n", - "Generating grid code\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.450828476487e+00 1.81563 134.653 5.27143e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 3.598268106227e+01 1.30592 8.75988 0.00193614 13\n", + "EXAMPLE_COMPACT_OBJECT 2.436983545111e+01 1.35842 10.9948 0.00144093 13\n", + "EXAMPLE_COMPACT_OBJECT 1.690157944401e+01 1.43124 13.7998 0.00107238 13\n", + "EXAMPLE_COMPACT_OBJECT 1.242397939068e+01 1.52416 17.3205 0.000798096 13\n", + "EXAMPLE_COMPACT_OBJECT 9.756794139032e+00 1.66914 21.7394 0.000593966 13\n", + "EXAMPLE_COMPACT_OBJECT 8.401414766976e+00 1.73729 27.2857 0.000442046 13\n", + "EXAMPLE_COMPACT_OBJECT 7.536373523810e+00 1.80677 34.247 0.000328983 13\n", + "EXAMPLE_COMPACT_OBJECT 7.393982410080e+00 1.82164 42.9844 0.000244839 13\n", + "EXAMPLE_COMPACT_OBJECT 7.396470605248e+00 1.82129 53.9508 0.000182216 13\n", + "Do join of subprocesses ...\n", + "EXAMPLE_COMPACT_OBJECT 7.399005684057e+00 1.82041 67.7151 0.00013561 13\n", + "EXAMPLE_COMPACT_OBJECT 7.443375325717e+00 1.81645 84.9909 0.000100925 13\n", + "EXAMPLE_COMPACT_OBJECT 7.451195752942e+00 1.81559 106.674 7.51114e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 7.452661646076e+00 1.81543 133.89 5.59e-05 13\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-50fb66cc659c46c8bbc29fe0c8651c2f finished! *\n", - "* The total probability is 0.0444029. *\n", - "* It took a total of 3.30s to run 20 systems on 2 cores *\n", - "* = 6.60s of CPU time. *\n", - "* Maximum memory use 433.070 MB *\n", + "* Population-ce756bb317f64099a459bf8b55a746ac finished! *\n", + "* The total probability is 0.0443872. *\n", + "* It took a total of 0.73s to run 19 systems on 2 cores *\n", + "* = 1.46s of CPU time. *\n", + "* Maximum memory use 293.406 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n" + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" ] } ], @@ -614,7 +606,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'population_name': '50fb66cc659c46c8bbc29fe0c8651c2f', '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': 1635760967.3245144, 'end_timestamp': 1635760970.6249793, 'total_mass_run': 684.2544031669784, 'total_probability_weighted_mass_run': 0.28134439269236855, 'zero_prob_stars_skipped': 0}\n" + "{'population_id': 'ce756bb317f64099a459bf8b55a746ac', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.044387171445641534, 'total_count': 19, 'start_timestamp': 1646563001.7193637, 'end_timestamp': 1646563002.4480088, 'time_elapsed': 0.7286450862884521, 'total_mass_run': 649.905447944397, 'total_probability_weighted_mass_run': 0.28133908148630704, 'zero_prob_stars_skipped': 0}\n" ] } ], @@ -642,9 +634,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on method write_binary_c_calls_to_file in module binarycpython.utils.grid:\n", + "Help on method write_binary_c_calls_to_file in module binarycpython.utils.population_extensions.dataIO:\n", "\n", - "write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False) -> None method of binarycpython.utils.grid.Population instance\n", + "write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False, encoding='utf-8') -> None method of binarycpython.utils.grid.Population instance\n", " Function that loops over the grid code and writes the generated parameters to a file.\n", " In the form of a command line call\n", " \n", @@ -655,10 +647,6 @@ " \n", " On default this will write to the datadir, if it exists\n", " \n", - " Tasks:\n", - " - TODO: test this function\n", - " - TODO: make sure the binary_c_python .. output file has a unique name\n", - " \n", " Args:\n", " output_dir: (optional, default = None) directory where to write the file to. If custom_options['data_dir'] is present, then that one will be used first, and then the output_dir\n", " output_filename: (optional, default = None) filename of the output. If not set it will be called \"binary_c_calls.txt\"\n", @@ -685,19 +673,19 @@ "output_type": "stream", "text": [ "Generating grid code\n", - "Generating grid code\n", - "Saving grid code to grid_options\n", - "Writing grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py [dry_run = False]\n", - "Symlinked grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid-latest2 \n", - "Loading grid code function from /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py\n", + "Save grid code to grid_options\n", + "Write grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py [dry_run = False]\n", + "Symlinked grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid-latest2 \n", + "Load grid code function from /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py\n", "Grid code loaded\n", - "Writing binary_c calls to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "/tmp/binary_c_python-izzard/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.2158744056768156 probability 0.00823663875514986\n", - "binary_c M_1 3.430936289925951 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681537 probability 0.0062211552141636295\n", - "binary_c M_1 4.2576084265970895 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.2158744056768156 probability 0.004698855121516281\n" + "Writing binary_c calls to /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "binary_c M_1 2.2406484012210224 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.011394572976608001\n", + "binary_c M_1 2.812296769855663 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191117 probability 0.008480166685456411\n", + "binary_c M_1 3.5297876799548944 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.006311182276049824\n", + "binary_c M_1 4.430329401616038 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.004696962123378559\n", + "(abridged)\n" ] } ], @@ -707,7 +695,8 @@ "print(calls_filename)\n", "\n", "with open(calls_filename, 'r') as f:\n", - " print('\\n'.join(f.read().splitlines()[:4]))" + " print('\\n'.join(f.read().splitlines()[:4]))\n", + "print(\"(abridged)\")" ] }, { @@ -715,7 +704,15 @@ "id": "60359eb1-4d0c-4d2d-8265-ec5171b944a2", "metadata": {}, "source": [ - "## Full examples of population scripts\n", + "## Full examples of population scripts" + ] + }, + { + "cell_type": "markdown", + "id": "1ee279d6-e120-4aef-9e57-845e534f5c6a", + "metadata": {}, + "source": [ + "### Single star population\n", "Below is a full setup for a population of single stars" ] }, @@ -729,43 +726,51 @@ "name": "stdout", "output_type": "stream", "text": [ - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "**************************************\n", - "* Total starcount for this run is 20 *\n", - "* Total probability is 0.0444029 *\n", - "**************************************\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 19 *\n", + "* Total probability is 0.0443872 *\n", + "**********************************\n", "\n", - "Generating grid code\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-05e51ba114934b37bab48f1db40b7333 finished! *\n", - "* The total probability is 0.0444029. *\n", - "* It took a total of 3.46s to run 20 systems on 2 cores *\n", - "* = 6.93s of CPU time. *\n", - "* Maximum memory use 437.047 MB *\n", + "* Population-0fa4c2b8707741a5ab41d209ef95a3a4 finished! *\n", + "* The total probability is 0.0443872. *\n", + "* It took a total of 0.61s to run 19 systems on 2 cores *\n", + "* = 1.23s of CPU time. *\n", + "* Maximum memory use 299.531 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n", "\n", "\n", "time mass zams_mass probability radius stellar_type\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.450828476487e+00 1.81563 134.653 5.27143e-05 1.72498e-05 13\n", + "3.598268106227e+01 1.30592 8.75988 0.00193614 1.72498e-05 13\n", + "2.436983545111e+01 1.35842 10.9948 0.00144093 1.72498e-05 13\n", + "1.690157944401e+01 1.43124 13.7998 0.00107238 1.72498e-05 13\n", + "1.242397939068e+01 1.52416 17.3205 0.000798096 1.72498e-05 13\n", + "9.756794139032e+00 1.66914 21.7394 0.000593966 1.72498e-05 13\n", + "8.401414766976e+00 1.73729 27.2857 0.000442046 1.72498e-05 13\n", + "7.536373523810e+00 1.80677 34.247 0.000328983 1.72498e-05 13\n", + "7.393982410080e+00 1.82164 42.9844 0.000244839 1.72498e-05 13\n", + "7.396470605248e+00 1.82129 53.9508 0.000182216 1.72498e-05 13\n", + "7.399005684057e+00 1.82041 67.7151 0.00013561 1.72498e-05 13\n", + "7.451195752942e+00 1.81559 106.674 7.51114e-05 1.72498e-05 13\n", + "7.443375325717e+00 1.81645 84.9909 0.000100925 1.72498e-05 13\n", + "7.452661646076e+00 1.81543 133.89 5.59e-05 1.72498e-05 13\n", "\n" ] } @@ -877,9 +882,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\",\n", @@ -908,7 +913,8 @@ "id": "c2ab0979-6575-481d-9c1c-ca98517b2437", "metadata": {}, "source": [ - "We can also set up a population that samples biinary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded top be more useful" + "### Binary star population\n", + "We can also set up a population that samples binary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded to be more useful. Also note that we run very little systems in the following example, as its just intended to show how the code works." ] }, { @@ -921,45 +927,42 @@ "name": "stdout", "output_type": "stream", "text": [ - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 27 stars with a total probability of 0.0248684\n", - "**************************************\n", - "* Total starcount for this run is 27 *\n", - "* Total probability is 0.0248684 *\n", - "**************************************\n", + "Grid has handled 8 stars with a total probability of 0.0211592\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 8 *\n", + "* Total probability is 0.0211592 *\n", + "**********************************\n", "\n", - "Generating grid code\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-8bc1eafea1c34b05894c1618639d8c37 finished! *\n", - "* The total probability is 0.0248684. *\n", - "* It took a total of 16.10s to run 27 systems on 2 cores *\n", - "* = 32.20s of CPU time. *\n", - "* Maximum memory use 437.695 MB *\n", + "* Population-0eb5c0c9abd34607a6ee060b26a7e32f finished! *\n", + "* The total probability is 0.0211592. *\n", + "* It took a total of 0.84s to run 8 systems on 2 cores *\n", + "* = 1.68s of CPU time. *\n", + "* Maximum memory use 300.125 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\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", - "1.219029061236e+01 1.60007 17.3205 0 2.97008 13 5 15 15 0.02 0.000498487\n", - "1.935920339886e+01 1.29448 17.3205 0 8.71025 13 13 15 2 0.02 0.000498487\n", - "2.123794969278e+01 1.30902 17.3205 1.58518 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.548740826516e+01 1.52415 17.3205 1.45407 14.4504 13 13 13 5 0.02 0.000220016\n", - "1.779197348711e+01 1.3228 17.3205 1.71196 14.4504 13 13 13 8 0.02 0.000287968\n", - "1.367065497322e+01 1.66003 73.0434 1.79487 12.2572 13 13 13 8 0.02 7.67586e-05\n", - "1.772169325355e+01 1.81957 73.0434 1.46573 12.2572 13 13 13 5 0.02 4.43422e-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", - "9.823059079115e+00 2.43711 73.0434 1.81689 60.8862 14 14 13 8 0.02 7.67586e-05\n", - "7.394722435913e+00 1.79092 73.0434 1.79092 60.8862 13 8 13 8 0.02 4.43422e-05\n", - "7.396288708628e+00 1.8216 73.0434 1.8216 60.8862 13 8 13 8 0.02 3.38788e-05\n", + "1.378266748188e+01 1.66293 50.9713 1.78767 12.8178 13 13 13 8 0.02 0.000339963\n", + "1.817608462595e+01 1.82104 50.9713 1.41436 12.8178 13 13 13 5 0.02 0.000193036\n", + "7.422997711686e+00 1.82479 50.9713 1.82171 38.2535 13 13 13 8 0.02 0.000193036\n", + "1.205711924468e+01 1.73765 50.9713 0 38.2535 13 13 15 8 0.02 0.000339963\n", "\n" ] } @@ -1089,9 +1092,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -1102,8 +1105,8 @@ " name=\"q\",\n", " longname=\"Mass ratio\",\n", " valuerange=[\"0.1/M_1\", 1],\n", - " samplerfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n", - " probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", + " samplerfunc=\"self.const_linear(0.1/M_1, 1, {})\".format(resolution['q']),\n", + " probdist=\"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", " dphasevol=\"dq\",\n", " precode=\"M_2 = q * M_1\",\n", " parameter_name=\"M_2\",\n", @@ -1115,12 +1118,12 @@ " name=\"log10per\", # in days\n", " longname=\"log10(Orbital_Period)\",\n", " valuerange=[0.15, 5.5],\n", - " samplerfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", + " samplerfunc=\"self.const_linear(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", " precode=\"\"\"orbital_period = 10** log10per\n", "sep = calc_sep_from_period(M_1, M_2, orbital_period)\n", "sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n", "sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n", - " probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", + " probdist=\"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", " parameter_name=\"orbital_period\",\n", " dphasevol=\"dlog10per\",\n", ")\n", @@ -1145,7 +1148,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1159,7 +1162,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/_sources/examples/old/basic_example.ipynb.txt b/docs/build/html/_sources/examples/old/basic_example.ipynb.txt index 9078cfcb5fdcd35336ee3675accb3f810c21e5fe..7146b97671caad9e82ce7454511dcad2aa416a78 100644 --- a/docs/build/html/_sources/examples/old/basic_example.ipynb.txt +++ b/docs/build/html/_sources/examples/old/basic_example.ipynb.txt @@ -1,5 +1,14 @@ { "cells": [ + { + "cell_type": "markdown", + "id": "c09b9f85-5250-4fd2-8142-bb8097d138b5", + "metadata": {}, + "source": [ + "# Basic example\n", + "Running a single system" + ] + }, { "cell_type": "code", "execution_count": 1, @@ -106,7 +115,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -120,7 +129,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/_sources/examples/old/workshop_example_notebook.ipynb.txt b/docs/build/html/_sources/examples/old/workshop_example_notebook.ipynb.txt index 4eca5879779a9fec40521c733bda59768c8c4140..78d0860ad1dfc12104b4bb639055957d527c01e7 100644 --- a/docs/build/html/_sources/examples/old/workshop_example_notebook.ipynb.txt +++ b/docs/build/html/_sources/examples/old/workshop_example_notebook.ipynb.txt @@ -619,7 +619,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -633,7 +633,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/_sources/grid.rst.txt b/docs/build/html/_sources/grid.rst.txt index 5f3347e6f42616884c86dffc98baf5da3bc8ea03..5122d6740bfbbf5649a1837271d3f987bcfe3fd4 100644 --- a/docs/build/html/_sources/grid.rst.txt +++ b/docs/build/html/_sources/grid.rst.txt @@ -1,5 +1,5 @@ -grid\_class module -================================= +Population class module +======================= .. automodule:: binarycpython.utils.grid :members: diff --git a/docs/build/html/_sources/grid_options_defaults.rst.txt b/docs/build/html/_sources/grid_options_defaults.rst.txt deleted file mode 100644 index c66555ac9989dff3ad956f893683dc34c4dc4c46..0000000000000000000000000000000000000000 --- a/docs/build/html/_sources/grid_options_defaults.rst.txt +++ /dev/null @@ -1,7 +0,0 @@ -Grid options and descriptions -============================= - -.. automodule:: binarycpython.utils.grid_options_defaults - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/build/html/_sources/grid_options_descriptions.rst.txt b/docs/build/html/_sources/grid_options_descriptions.rst.txt index 916bbac09db9d0ad680ce8dbc5eebe6917f8ea74..7d765d8cffea4b69f7e03926382da0eaee37df8d 100644 --- a/docs/build/html/_sources/grid_options_descriptions.rst.txt +++ b/docs/build/html/_sources/grid_options_descriptions.rst.txt @@ -1,7 +1,7 @@ Population grid code options ============================ The following chapter contains all grid code options, along with their descriptions -There are 9 options that are not described yet. +There are 29 options that are not described yet. Public options @@ -13,36 +13,118 @@ The following options are meant to be changed by the user. | **C_logging_code**: Variable to store the exact code that is used for the custom_logging. In this way the user can do more complex logging, as well as putting these logging strings in files. +| **HPC_force_join**: Integer, default 0. If 1, and the HPC variable ("slurm" or "condor") is 3, skip checking our own job and force the join. + +| **HPC_rebuild_joinlist**: Integer, default 0. If 1, ignore the joinlist we would usually use and rebuild it automatically + | **Moe2017_options**: No description available yet +| **cache_dir**: No description available yet + | **combine_ensemble_with_thread_joining**: Boolean 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 -| **condor**: Int flag whether to use a condor type population evolution. Not implemented yet. +| **command_line**: No description available yet + +| **condor**: Integer flag used to control HTCondor (referred to as Condor here) jobs. Default is 0 which means no Condor. 1 means launch Condor jobs. Do not manually set this to 2 (run Condor jobs) or 3 (join Condor job data) unless you know what you are doing, this is usually done for you. + +| **condor_ClusterID**: Integer. Condor ClusterID variable, equivalent to Slurm's jobid. Jobs are numbered <ClusterID>.<Process> + +| **condor_Process**: Integer. Condor Process variable, equivalent to Slurm's jobarrayindex. Jobs are numbered <ClusterID>.<Process> + +| **condor_bash**: String. Points the location of the "bash" command, e.g. /bin/bash, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **condor_batchname**: String. Condor batchname option: this is what appears in condor_q. Defaults to "binary_c-condor" + +| **condor_date**: String. Points the location of the "date" command, e.g. /usr/bin/date, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **condor_dir**: String. Working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all jobs). This directory should not exist when you launch the Condor jobs. + +| **condor_env**: String. Points the location of the "env" command, e.g. /usr/bin/env or /bin/env, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **condor_extra_settings**: Dictionary. Place to put extra configuration for the CONDOR submit file. The key and value of the dict will become the key and value of the line in te slurm batch file. Will be put in after all the other settings (and before the command). Take care not to overwrite something without really meaning to do so. + +| **condor_getenv**: Boolean. If True, the default, condor takes the environment at submission and copies it to the jobs. You almost certainly want this to be True. + +| **condor_initial_dir**: String. Directory from which condor scripts are run. If set to the default, None, this is the directory from which your script is run. + +| **condor_kill_sig**: String. Signal Condor should use to stop a process. Note that grid.py expects this to be "SIGINT" which is the default. + +| **condor_memory**: Integer. In MB, the memory use (ImageSize) of the job. + +| **condor_njobs**: Integer. Number of jobs that Condor will run + +| **condor_postpone_join**: Integer. Use to delay the joining of Condor grid data. If 1, data is not joined, e.g. if you want to do it off the condor grid (e.g. with more RAM). Default 0. + +| **condor_postpone_submit**: Integer. Debugging tool. If 1, the condor script is not submitted (useful for debugging). Default 0. + +| **condor_pwd**: String. Points the location of the "pwd" command, e.g. /bin/pwd, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **condor_q**: String. The Condor_q command, usually "/usr/bin/condor_q" but will depend on your HTCondor installation. + +| **condor_requirements**: String. Condor job requirements. These are passed to Condor directly, you should read the HTCondor manual to learn about this. If no requirements exist, leave as an string. + +| **condor_should_transfer_files**: Integer. Condor's option to transfer files at the end of the job. You should set this to "YES" + +| **condor_snapshot_on_kill**: Integer. If 1 we save a snapshot on SIGKILL before exit. + +| **condor_stream_error**: Boolean. If True, we activate Condor's stderr stream. If False, this data is copied at the end of the job. + +| **condor_stream_output**: Boolean. If True, we activate Condor's stdout stream. If False, this data is copied at the end of the job. + +| **condor_submit**: String. The Condor_submit command, usually "/usr/bin/condor_submit" but will depend on your HTCondor installation. + +| **condor_universe**: String. The HTCondor "universe": this is "vanilla" by default. + +| **condor_warn_max_memory**: Integer. In MB, the memory use (ImageSize) of the job. + +| **condor_when_to_transfer_output**: Integer. Condor's option to decide when output files are transferred. You should usually set this to "ON_EXIT_OR_EVICT" | **custom_generator**: No description available yet | **custom_logging_func_memaddr**: Memory address where the custom_logging_function is stored. Input: int +| **do_analytics**: No description available yet + | **do_dry_run**: Whether to do a dry run to calculate the total probability for this run +| **dry_run_hook**: Function hook to be called for every system in a dry run. The function is passed a dict of the system parameters. Does nothing if None (the default). + +| **dry_run_num_cores**: No description available yet + | **ensemble_factor_in_probability_weighted_mass**: Flag to multiply all the ensemble results with 1/probability_weighted_mass -| **evolution_type**: Variable containing the type of evolution used of the grid. Multiprocessing or linear processing +| **evolution_type**: Variable containing the type of evolution used of the grid. Multiprocessing, linear processing or possibly something else (e.g. for Slurm or Condor). + +| **exit_after_dry_run**: If True, exits after a dry run. Default is False. -| **exit_after_dry_run**: No description available yet +| **exit_code**: No description available yet | **failed_systems_threshold**: Variable storing the maximum number of systems that are allowed to fail before logging their command line arguments to failed_systems log files +| **function_cache**: Boolean, default True. If True, we use a cache for certain function calls. + +| **function_cache_TTL**: No description available yet + +| **function_cache_default_maxsize**: Integer, default 256. The default maxsize of the cache. Should be a power of 2. + +| **function_cache_default_type**: String. One of the following types: LRUCache, LFUCache, FIFOCache, MRUCache, RRCache, TTLCache, NullCache, NoCache. You can find details of what these mean in the Python cachetools manual, except fo NoCache which means no cache is used at all, and NullCache is a dummy cache that never matches, used for testing overheads. + +| **function_cache_functions**: No description available yet + | **gridcode_filename**: Filename for the grid code. Set and used by the population object. TODO: allow the user to provide their own function, rather than only a generated function. -| **log_args**: Boolean to log the arguments. Unused +| **joinlist**: No description available yet + +| **log_args**: Boolean to log the arguments. -| **log_args_dir**: Directory to log the arguments to. Unused +| **log_args_dir**: Directory to log the arguments to. -| **log_dt**: No description available yet +| **log_dt**: Time between verbose logging output. | **log_file**: Log file for the population object. Unused +| **log_newline**: Newline character used at the end of verbose logging statements. This is \n (newline) by default, but \x0d (carriage return) might also be what you want. + | **log_runtime_systems**: Whether to log the runtime of the systems . Each systems run by the thread is logged to a file and is stored in the tmp_dir. (1 file per thread). Don't use this if you are planning to run a lot of systems. This is mostly for debugging and finding systems that take long to run. Integer, default = 0. if value is 1 then the systems are logged | **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 @@ -51,25 +133,95 @@ The following options are meant to be changed by the user. | **multiplicity_fraction_function**: Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: Moe and di Stefano (2017) 2017 -| **n_logging_stats**: No description available yet +| **n_logging_stats**: Number of logging statistics used to calculate time remaining (etc.). E.g., if you set this to 10 the previous 10 calls to the verbose log will be used to construct an estimate of the time remaining. + +| **num_cores**: The number of cores that the population grid will use. You can set this manually by entering an integer great than 0. When 0 uses all logical cores. When -1 uses all physical cores. Input: int -| **num_cores**: The number of cores that the population grid will use. The multiprocessing is useful but make sure to figure out how many logical cores the machine has (use e.g. psutil.cpu_count(logical=False) to find the true number of cores, psutil.cpu_count(logical=True) to find the number of logical cores). The core is multi processed, not multi threaded, and will gain no extra speed when num_cores exceeds the number of logical cores. Input: int +| **num_cores_available**: No description available yet + +| **original_command_line**: No description available yet + +| **original_submission_time**: No description available yet + +| **original_working_diretory**: No description available yet | **parse_function**: Function that the user can provide to handle the output the binary_c. This function has to take the arguments (self, output). Its best not to return anything in this function, and just store stuff in the self.grid_results dictionary, or just output results to a file +| **print_stack_on_exit**: If True, prints a stack trace when the population's exit method is called. + | **repeat**: Factor of how many times a system should be repeated. Consider the evolution splitting binary_c argument for supernovae kick repeating. +| **restore_from_snapshot_dir**: No description available yet + +| **restore_from_snapshot_file**: No description available yet + +| **return_after_dry_run**: If True, return immediately after a dry run (and don't run actual stars). Default is False. + | **run_zero_probability_system**: Whether to run the zero probability systems. Default: True. Input: Boolean +| **rungrid**: No description available yet + | **save_ensemble_chunks**: No description available yet -| **slurm**: Int flag whether to use a Slurm type population evolution. +| **save_population_object**: No description available yet + +| **save_snapshots**: No description available yet + +| **skip_before**: No description available yet + +| **slurm**: Integer flag used to control Slurm jobs. Default is 0 which means no Slurm. 1 means launch Slurm jobs. Do not manually set this to 2 (run Slurm jobs) or 3 (join Slurm job data) unless you know what you are doing, this is usually done for you. + +| **slurm_array**: String. Override for Slurm's --array option, useful for rerunning jobs manually. Default None. + +| **slurm_array_max_jobs**: Integer. Override for the max number of concurrent Slurm array jobs. Default None. + +| **slurm_bash**: String. Points the location of the "bash" command, e.g. /bin/bash, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **slurm_date**: String. Points the location of the "date" command, e.g. /usr/bin/date, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **slurm_dir**: String. Working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all jobs). This directory should not exist when you launch the Slurm jobs. + +| **slurm_env**: String. Points the location of the "env" command, e.g. /usr/bin/env or /bin/env, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **slurm_extra_settings**: Dictionary of extra settings for Slurm to put in its launch script. Please see the Slurm documentation for the many options that are available to you. + +| **slurm_jobarrayindex**: Integer. Slurm job array index. Each job is numbered <slurm_jobid>.<slurm_jobarrayindex>. + +| **slurm_jobid**: Integer. Slurm job id. Each job is numbered <slurm_jobid>.<slurm_jobarrayindex>. + +| **slurm_jobname**: String which names the Slurm jobs, default "binary_c-python". + +| **slurm_memory**: String. Memory required for the job. Should be in megabytes in a format that Slurm understands, e.g. "512MB" (the default). + +| **slurm_njobs**: Integer. Number of Slurm jobs to be launched. + +| **slurm_ntasks**: Integer. Number of CPUs required per array job: usually only need this to be 1 (the default). + +| **slurm_partition**: String containing the Slurm partition name. You should check your local Slurm installation to find out partition information, e.g. using the sview command. + +| **slurm_postpone_join**: Integer, default 0. If 1 do not join job results with Slurm, instead you have to do it later manually. + +| **slurm_postpone_sbatch**: Integer, default 0. If set to 1, do not launch Slurm jobs with sbatch, just make the scripts that would have. + +| **slurm_pwd**: String. Points the location of the "pwd" command, e.g. /bin/pwd, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **slurm_sbatch**: String. The Slurm "sbatch" submission command, usually "/usr/bin/sbatch" but will depend on your Slurm installation. By default is set automatically. + +| **slurm_time**: String. The time a Slurm job is allowed to take. Default is 0 which means no limit. Please check the Slurm documentation for required format of this option. + +| **slurm_warn_max_memory**: String. If we set slurm_memory in excess of this, warn the user because this is usually a mistake. Default "1024MB". | **source_file_filename**: Variable containing the source file containing lines of binary_c command line calls. These all have to start with binary_c. | **start_at**: No description available yet -| **symlink latest gridcode**: No description available yet +| **start_time**: No description available yet + +| **status_dir**: Directory where grid status is stored + +| **stop_queue**: No description available yet + +| **symlink_latest_gridcode**: No description available yet | **tmp_dir**: Directory where certain types of output are stored. The grid code is stored in that directory, as well as the custom logging libraries. Log files and other diagnostics will usually be written to this location, unless specified otherwise @@ -77,6 +229,8 @@ The following options are meant to be changed by the user. | **weight**: Weight factor for each system. The calculated probability is multiplied by this. If the user wants each system to be repeated several times, then this variable should not be changed, rather change the _repeat variable instead, as that handles the reduction in probability per system. This is useful for systems that have a process with some random element in it. +| **working_diretory**: No description available yet + Moe & di Stefano sampler options -------------------------------- The following options are meant to be changed by the user. @@ -87,69 +241,69 @@ The following options are meant to be changed by the user. | **Mmin**: Minimum stellar mass | **multiplicity_model**: - multiplicity model (as a function of log10M1) - - You can use 'Poisson' which uses the system multiplicity - given by Moe and maps this to single/binary/triple/quad - fractions. + multiplicity model (as a function of log10M1) - Alternatively, 'data' takes the fractions directly - from the data, but then triples and quadruples are - combined (and there are NO quadruples). + You can use 'Poisson' which uses the system multiplicity + given by Moe and maps this to single/binary/triple/quad + fractions. + Alternatively, 'data' takes the fractions directly + from the data, but then triples and quadruples are + combined (and there are NO quadruples). + | **multiplicity_modulator**: - [single, binary, triple, quadruple] + [single, binary, triple, quadruple] - e.g. [1,0,0,0] for single stars only - [0,1,0,0] for binary stars only - - defaults to [1,1,0,0] i.e. singles and binaries + e.g. [1,0,0,0] for single stars only + [0,1,0,0] for binary stars only + defaults to [1,1,0,0] i.e. singles and binaries + | **normalize_multiplicities**: - 'norm': normalise so the whole population is 1.0 - after implementing the appropriate fractions - S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) - given a mix of multiplicities, you can either (noting that - here (S,B,T,Q) = appropriate modulator * model(S,B,T,Q) ) - note: if you only set one multiplicity_modulator - to 1, and all the others to 0, then normalising - will mean that you effectively have the same number - of stars as single, binary, triple or quad (whichever - is non-zero) i.e. the multiplicity fraction is ignored. - This is probably not useful except for - testing purposes or comparing to old grids. - - 'raw' : stick to what is predicted, i.e. - S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) - without normalisation - (in which case the total probability < 1.0 unless - all you use single, binary, triple and quadruple) + 'norm': normalise so the whole population is 1.0 + after implementing the appropriate fractions + S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) + given a mix of multiplicities, you can either (noting that + here (S,B,T,Q) = appropriate modulator * model(S,B,T,Q) ) + note: if you only set one multiplicity_modulator + to 1, and all the others to 0, then normalising + will mean that you effectively have the same number + of stars as single, binary, triple or quad (whichever + is non-zero) i.e. the multiplicity fraction is ignored. + This is probably not useful except for + testing purposes or comparing to old grids. - 'merge' : e.g. if you only have single and binary, - add the triples and quadruples to the binaries, so - binaries represent all multiple systems - ... - *** this is canonical binary population synthesis *** + 'raw' : stick to what is predicted, i.e. + S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) + without normalisation + (in which case the total probability < 1.0 unless + all you use single, binary, triple and quadruple) - It only takes the maximum multiplicity into account, - i.e. it doesn't multiply the resulting array by the multiplicity modulator again. - This prevents the resulting array to always be 1 if only 1 multiplicity modulator element is nonzero + 'merge' : e.g. if you only have single and binary, + add the triples and quadruples to the binaries, so + binaries represent all multiple systems + ... + *** this is canonical binary population synthesis *** - Note: if multiplicity_modulator == [1,1,1,1]. this option does nothing (equivalent to 'raw'). + It only takes the maximum multiplicity into account, + i.e. it doesn't multiply the resulting array by the multiplicity modulator again. + This prevents the resulting array to always be 1 if only 1 multiplicity modulator element is nonzero + Note: if multiplicity_modulator == [1,1,1,1]. this option does nothing (equivalent to 'raw'). + | **q_high_extrapolation_method**: Same as q_low_extrapolation_method | **q_low_extrapolation_method**: - q extrapolation (below 0.15) method - none - flat - linear2 - plaw2 - nolowq - + q extrapolation (below 0.15) method + none + flat + linear2 + plaw2 + nolowq + | **ranges**: @@ -196,6 +350,8 @@ The following options are not meant to be changed by the user, as these options | **_grid_variables**: Dictionary storing the grid_variables. These contain properties which are accessed by the _generate_grid_code function +| **_killed**: No description available yet + | **_loaded_Moe2017_data**: Internal variable storing whether the Moe and di Stefano (2017) data has been loaded into memory | **_main_pid**: Main process ID of the master process. Used and set by the population object. @@ -204,6 +360,8 @@ The following options are not meant to be changed by the user, as these options | **_probtot**: Total probability of the population. +| **_queue_done**: No description available yet + | **_set_Moe2017_grid**: Internal flag whether the Moe and di Stefano (2017) grid has been loaded | **_start_time_evolution**: Variable storing the start timestamp of the population evolution. Set by the object itself. diff --git a/docs/build/html/_sources/hpc_functions.rst.txt b/docs/build/html/_sources/hpc_functions.rst.txt deleted file mode 100644 index d336a0be090ee3eac23c4342286fe8895e0aea6f..0000000000000000000000000000000000000000 --- a/docs/build/html/_sources/hpc_functions.rst.txt +++ /dev/null @@ -1,7 +0,0 @@ -hpc\_functions module -================================= - -.. automodule:: binarycpython.utils.hpc_functions - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/build/html/_sources/modules.rst.txt b/docs/build/html/_sources/modules.rst.txt index d4aaac5025cbb089f2754ed01ef8bd92f70bf81c..ce6f94e48b1de9e38dc33e8c6dceb7b468c3934f 100644 --- a/docs/build/html/_sources/modules.rst.txt +++ b/docs/build/html/_sources/modules.rst.txt @@ -6,13 +6,25 @@ This chapter contains the (auto)documentation for all the functions and modules :maxdepth: 4 custom_logging_functions - distribution_functions + dicts + ensemble functions grid - grid_options_defaults - hpc_functions plot_functions + population_extensions/analytics + population_extensions/cache + population_extensions/condor + population_extensions/dataIO + population_extensions/distribution_functions + population_extensions/gridcode + population_extensions/grid_logging + population_extensions/grid_options_defaults + population_extensions/HPC + population_extensions/metadata + population_extensions/Moe_di_Stefano_2017 + population_extensions/slurm + population_extensions/spacing_functions + population_extensions/version_info run_system_wrapper - spacing_functions stellar_types - useful_funcs \ No newline at end of file + useful_funcs diff --git a/docs/build/html/_sources/plot_functions.rst.txt b/docs/build/html/_sources/plot_functions.rst.txt index 6af374e53223ea93532fcd50ced89130f6f917d7..466637364d3aa55437785329ead662249fc75bf8 100644 --- a/docs/build/html/_sources/plot_functions.rst.txt +++ b/docs/build/html/_sources/plot_functions.rst.txt @@ -1,5 +1,5 @@ plot\_functions module -================================= +====================== .. automodule:: binarycpython.utils.plot_functions :members: diff --git a/docs/build/html/_sources/population_extensions/HPC.rst.txt b/docs/build/html/_sources/population_extensions/HPC.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..4d615eb33e436fce836190d595b12822e2b573f2 --- /dev/null +++ b/docs/build/html/_sources/population_extensions/HPC.rst.txt @@ -0,0 +1,7 @@ +Population class extension: HPC module +====================================== + +.. automodule:: binarycpython.utils.population_extensions.HPC + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/Moe_di_Stefano_2017.rst.txt b/docs/build/html/_sources/population_extensions/Moe_di_Stefano_2017.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..703e951622f427c9261d7cdf7d07d6ba276e145f --- /dev/null +++ b/docs/build/html/_sources/population_extensions/Moe_di_Stefano_2017.rst.txt @@ -0,0 +1,7 @@ +Population class extension: Moe\_di\_Stefano\_2017 module +========================================================= + +.. automodule:: binarycpython.utils.population_extensions.Moe_di_Stefano_2017 + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/analytics.rst.txt b/docs/build/html/_sources/population_extensions/analytics.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..39d6947f399f51ad590442ae0f99f3cf4afa2851 --- /dev/null +++ b/docs/build/html/_sources/population_extensions/analytics.rst.txt @@ -0,0 +1,7 @@ +Population class extension: analytics module +============================================ + +.. automodule:: binarycpython.utils.population_extensions.analytics + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/cache.rst.txt b/docs/build/html/_sources/population_extensions/cache.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..73d4ebbf69e6614be78f02696f681616c4189d46 --- /dev/null +++ b/docs/build/html/_sources/population_extensions/cache.rst.txt @@ -0,0 +1,7 @@ +Population class extension: cache module +======================================== + +.. automodule:: binarycpython.utils.population_extensions.cache + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/condor.rst.txt b/docs/build/html/_sources/population_extensions/condor.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..65673b81c0090a608bc2fbbec6346b57418759a2 --- /dev/null +++ b/docs/build/html/_sources/population_extensions/condor.rst.txt @@ -0,0 +1,7 @@ +Population class extension: condor module +========================================= + +.. automodule:: binarycpython.utils.population_extensions.condor + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/dataIO.rst.txt b/docs/build/html/_sources/population_extensions/dataIO.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..d6ed76285b109a81e9d8cb753aac50fb55a57562 --- /dev/null +++ b/docs/build/html/_sources/population_extensions/dataIO.rst.txt @@ -0,0 +1,7 @@ +Population class extension: dataIO module +========================================= + +.. automodule:: binarycpython.utils.population_extensions.dataIO + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/distribution_functions.rst.txt b/docs/build/html/_sources/population_extensions/distribution_functions.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..cf6a9071a777c0c3e2a369189559bc07ba499d38 --- /dev/null +++ b/docs/build/html/_sources/population_extensions/distribution_functions.rst.txt @@ -0,0 +1,7 @@ +Population class extension: distribution\_functions module +========================================================== + +.. automodule:: binarycpython.utils.population_extensions.distribution_functions + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/grid_logging.rst.txt b/docs/build/html/_sources/population_extensions/grid_logging.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..dc607c6ea5031ec2f80de51ec131753e32fcc6e6 --- /dev/null +++ b/docs/build/html/_sources/population_extensions/grid_logging.rst.txt @@ -0,0 +1,7 @@ +Population class extension: grid\_logging module +================================================ + +.. automodule:: binarycpython.utils.population_extensions.grid_logging + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/grid_options_defaults.rst.txt b/docs/build/html/_sources/population_extensions/grid_options_defaults.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..30a9c025e6c22f19d3a5bb429efb19144152e331 --- /dev/null +++ b/docs/build/html/_sources/population_extensions/grid_options_defaults.rst.txt @@ -0,0 +1,7 @@ +Population class extension: grid\_options\_defaults module +========================================================== + +.. automodule:: binarycpython.utils.population_extensions.grid_options_defaults + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/gridcode.rst.txt b/docs/build/html/_sources/population_extensions/gridcode.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..c9f554ccba5192b196b05f1fee17e88852372c6f --- /dev/null +++ b/docs/build/html/_sources/population_extensions/gridcode.rst.txt @@ -0,0 +1,7 @@ +Population class extension: gridcode module +=========================================== + +.. automodule:: binarycpython.utils.population_extensions.gridcode + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/metadata.rst.txt b/docs/build/html/_sources/population_extensions/metadata.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..72a0ca4f2f76d478807b85e85c396d60058019ed --- /dev/null +++ b/docs/build/html/_sources/population_extensions/metadata.rst.txt @@ -0,0 +1,7 @@ +Population class extension: metadata module +=========================================== + +.. automodule:: binarycpython.utils.population_extensions.metadata + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/slurm.rst.txt b/docs/build/html/_sources/population_extensions/slurm.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..48d1ecb98c121204e17c9076eed8b257e628b75c --- /dev/null +++ b/docs/build/html/_sources/population_extensions/slurm.rst.txt @@ -0,0 +1,7 @@ +Population class extension: slurm module +======================================== + +.. automodule:: binarycpython.utils.population_extensions.slurm + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/spacing_functions.rst.txt b/docs/build/html/_sources/population_extensions/spacing_functions.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..1a7a70f4e9bce3892fd36359a2485472490f67f5 --- /dev/null +++ b/docs/build/html/_sources/population_extensions/spacing_functions.rst.txt @@ -0,0 +1,7 @@ +Population class extension: spacing\_functions module +===================================================== + +.. automodule:: binarycpython.utils.population_extensions.spacing_functions + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/population_extensions/version_info.rst.txt b/docs/build/html/_sources/population_extensions/version_info.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..ad9852d0541d656aae9ed9a44a92125ec59c3403 --- /dev/null +++ b/docs/build/html/_sources/population_extensions/version_info.rst.txt @@ -0,0 +1,7 @@ +Population class extension: version\_info module +================================================ + +.. automodule:: binarycpython.utils.population_extensions.version_info + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/_sources/run_system_wrapper.rst.txt b/docs/build/html/_sources/run_system_wrapper.rst.txt index 388b6878c2394eed9020aa4e3a48a9d531287ff2..d27e3f6fbd0eb9244cf3eef2481d6b07102c94d4 100644 --- a/docs/build/html/_sources/run_system_wrapper.rst.txt +++ b/docs/build/html/_sources/run_system_wrapper.rst.txt @@ -1,5 +1,5 @@ run\_system\_wrapper module -================================= +=========================== .. automodule:: binarycpython.utils.run_system_wrapper :members: diff --git a/docs/build/html/_sources/spacing_functions.rst.txt b/docs/build/html/_sources/spacing_functions.rst.txt deleted file mode 100644 index be0cf254dd52aafbde7404c588be65abcc46493e..0000000000000000000000000000000000000000 --- a/docs/build/html/_sources/spacing_functions.rst.txt +++ /dev/null @@ -1,7 +0,0 @@ -spacing\_functions module -================================= - -.. automodule:: binarycpython.utils.spacing_functions - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/build/html/_sources/useful_funcs.rst.txt b/docs/build/html/_sources/useful_funcs.rst.txt index 2b8b9d26a6b16af7bd581a2d3a42fc746da039a3..fc1ff3c6ce71d8e7c2cb15516c1e95f84596fe1a 100644 --- a/docs/build/html/_sources/useful_funcs.rst.txt +++ b/docs/build/html/_sources/useful_funcs.rst.txt @@ -1,5 +1,5 @@ useful\_funcs module -================================= +==================== .. automodule:: binarycpython.utils.useful_funcs :members: diff --git a/docs/build/html/_static/_sphinx_javascript_frameworks_compat.js b/docs/build/html/_static/_sphinx_javascript_frameworks_compat.js new file mode 100644 index 0000000000000000000000000000000000000000..8549469dc29fac0cbf16d10355e3313897cb3752 --- /dev/null +++ b/docs/build/html/_static/_sphinx_javascript_frameworks_compat.js @@ -0,0 +1,134 @@ +/* + * _sphinx_javascript_frameworks_compat.js + * ~~~~~~~~~~ + * + * Compatability shim for jQuery and underscores.js. + * + * WILL BE REMOVED IN Sphinx 6.0 + * xref RemovedInSphinx60Warning + * + */ + +/** + * select a different prefix for underscore + */ +$u = _.noConflict(); + + +/** + * small helper function to urldecode strings + * + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL + */ +jQuery.urldecode = function(x) { + if (!x) { + return x + } + return decodeURIComponent(x.replace(/\+/g, ' ')); +}; + +/** + * small helper function to urlencode strings + */ +jQuery.urlencode = encodeURIComponent; + +/** + * This function returns the parsed url parameters of the + * current request. Multiple values per key are supported, + * it will always return arrays of strings for the value parts. + */ +jQuery.getQueryParameters = function(s) { + if (typeof s === 'undefined') + s = document.location.search; + var parts = s.substr(s.indexOf('?') + 1).split('&'); + var result = {}; + for (var i = 0; i < parts.length; i++) { + var tmp = parts[i].split('=', 2); + var key = jQuery.urldecode(tmp[0]); + var value = jQuery.urldecode(tmp[1]); + if (key in result) + result[key].push(value); + else + result[key] = [value]; + } + return result; +}; + +/** + * highlight a given string on a jquery object by wrapping it in + * span elements with the given class name. + */ +jQuery.fn.highlightText = function(text, className) { + function highlight(node, addItems) { + if (node.nodeType === 3) { + var val = node.nodeValue; + var pos = val.toLowerCase().indexOf(text); + if (pos >= 0 && + !jQuery(node.parentNode).hasClass(className) && + !jQuery(node.parentNode).hasClass("nohighlight")) { + var span; + var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg"); + if (isInSVG) { + span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + } else { + span = document.createElement("span"); + span.className = className; + } + span.appendChild(document.createTextNode(val.substr(pos, text.length))); + node.parentNode.insertBefore(span, node.parentNode.insertBefore( + document.createTextNode(val.substr(pos + text.length)), + node.nextSibling)); + node.nodeValue = val.substr(0, pos); + if (isInSVG) { + var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + var bbox = node.parentElement.getBBox(); + rect.x.baseVal.value = bbox.x; + rect.y.baseVal.value = bbox.y; + rect.width.baseVal.value = bbox.width; + rect.height.baseVal.value = bbox.height; + rect.setAttribute('class', className); + addItems.push({ + "parent": node.parentNode, + "target": rect}); + } + } + } + else if (!jQuery(node).is("button, select, textarea")) { + jQuery.each(node.childNodes, function() { + highlight(this, addItems); + }); + } + } + var addItems = []; + var result = this.each(function() { + highlight(this, addItems); + }); + for (var i = 0; i < addItems.length; ++i) { + jQuery(addItems[i].parent).before(addItems[i].target); + } + return result; +}; + +/* + * backward compatibility for jQuery.browser + * This will be supported until firefox bug is fixed. + */ +if (!jQuery.browser) { + jQuery.uaMatch = function(ua) { + ua = ua.toLowerCase(); + + var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || + /(webkit)[ \/]([\w.]+)/.exec(ua) || + /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || + /(msie) ([\w.]+)/.exec(ua) || + ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || + []; + + return { + browser: match[ 1 ] || "", + version: match[ 2 ] || "0" + }; + }; + jQuery.browser = {}; + jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; +} diff --git a/docs/build/html/_static/basic.css b/docs/build/html/_static/basic.css index 912859b55d96750bff001bb79037a83a6c02332c..7d5974c3221c0d7c3e746d64ce1dbed28a32cb91 100644 --- a/docs/build/html/_static/basic.css +++ b/docs/build/html/_static/basic.css @@ -4,7 +4,7 @@ * * Sphinx stylesheet -- basic theme. * - * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ @@ -222,7 +222,7 @@ table.modindextable td { /* -- general body styles --------------------------------------------------- */ div.body { - min-width: 450px; + min-width: 360px; max-width: 800px; } @@ -236,7 +236,6 @@ div.body p, div.body dd, div.body li, div.body blockquote { a.headerlink { visibility: hidden; } - a.brackets:before, span.brackets > a:before{ content: "["; @@ -247,6 +246,7 @@ span.brackets > a:after { content: "]"; } + h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, @@ -334,13 +334,11 @@ aside.sidebar { p.sidebar-title { font-weight: bold; } - div.admonition, div.topic, blockquote { clear: left; } /* -- topics ---------------------------------------------------------------- */ - div.topic { border: 1px solid #ccc; padding: 7px; @@ -428,10 +426,6 @@ table.docutils td, table.docutils th { border-bottom: 1px solid #aaa; } -table.footnote td, table.footnote th { - border: 0 !important; -} - th { text-align: left; padding-right: 5px; @@ -615,6 +609,7 @@ ul.simple p { margin-bottom: 0; } +/* Docutils 0.17 and older (footnotes & citations) */ dl.footnote > dt, dl.citation > dt { float: left; @@ -632,6 +627,33 @@ dl.citation > dd:after { clear: both; } +/* Docutils 0.18+ (footnotes & citations) */ +aside.footnote > span, +div.citation > span { + float: left; +} +aside.footnote > span:last-of-type, +div.citation > span:last-of-type { + padding-right: 0.5em; +} +aside.footnote > p { + margin-left: 2em; +} +div.citation > p { + margin-left: 4em; +} +aside.footnote > p:last-of-type, +div.citation > p:last-of-type { + margin-bottom: 0em; +} +aside.footnote > p:last-of-type:after, +div.citation > p:last-of-type:after { + content: ""; + clear: both; +} + +/* Footnotes & citations ends */ + dl.field-list { display: grid; grid-template-columns: fit-content(30%) auto; @@ -731,8 +753,9 @@ dl.glossary dt { .classifier:before { font-style: normal; - margin: 0.5em; + margin: 0 0.5em; content: ":"; + display: inline-block; } abbr, acronym { @@ -756,6 +779,7 @@ span.pre { -ms-hyphens: none; -webkit-hyphens: none; hyphens: none; + white-space: nowrap; } div[class*="highlight-"] { diff --git a/docs/build/html/_static/css/badge_only.css b/docs/build/html/_static/css/badge_only.css index 3c33cef5450e1a6e12a4e33928cf2bdcdc4db2e0..e380325bc6e273d9142c2369883d2a4b2a069cf1 100644 --- a/docs/build/html/_static/css/badge_only.css +++ b/docs/build/html/_static/css/badge_only.css @@ -1 +1 @@ -.fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-weight:normal;font-style:normal;src:url("../fonts/fontawesome-webfont.eot");src:url("../fonts/fontawesome-webfont.eot?#iefix") format("embedded-opentype"),url("../fonts/fontawesome-webfont.woff") format("woff"),url("../fonts/fontawesome-webfont.ttf") format("truetype"),url("../fonts/fontawesome-webfont.svg#FontAwesome") format("svg")}.fa:before{display:inline-block;font-family:FontAwesome;font-style:normal;font-weight:normal;line-height:1;text-decoration:inherit}a .fa{display:inline-block;text-decoration:inherit}li .fa{display:inline-block}li .fa-large:before,li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-0.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before,ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before{content:"ï€"}.icon-book:before{content:"ï€"}.fa-caret-down:before{content:""}.icon-caret-down:before{content:""}.fa-caret-up:before{content:""}.icon-caret-up:before{content:""}.fa-caret-left:before{content:""}.icon-caret-left:before{content:""}.fa-caret-right:before{content:""}.icon-caret-right:before{content:""}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;z-index:400}.rst-versions a{color:#2980B9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27AE60;*zoom:1}.rst-versions .rst-current-version:before,.rst-versions .rst-current-version:after{display:table;content:""}.rst-versions .rst-current-version:after{clear:both}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book{float:left}.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#E74C3C;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#F1C40F;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:gray;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:solid 1px #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .icon-book{float:none}.rst-versions.rst-badge .fa-book{float:none}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book{float:left}.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge .rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width: 768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}} +.fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}} \ No newline at end of file diff --git a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff b/docs/build/html/_static/css/fonts/Roboto-Slab-Bold.woff similarity index 100% rename from docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff rename to docs/build/html/_static/css/fonts/Roboto-Slab-Bold.woff diff --git a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2 b/docs/build/html/_static/css/fonts/Roboto-Slab-Bold.woff2 similarity index 100% rename from docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2 rename to docs/build/html/_static/css/fonts/Roboto-Slab-Bold.woff2 diff --git a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff b/docs/build/html/_static/css/fonts/Roboto-Slab-Regular.woff similarity index 100% rename from docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff rename to docs/build/html/_static/css/fonts/Roboto-Slab-Regular.woff diff --git a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2 b/docs/build/html/_static/css/fonts/Roboto-Slab-Regular.woff2 similarity index 100% rename from docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2 rename to docs/build/html/_static/css/fonts/Roboto-Slab-Regular.woff2 diff --git a/docs/build/html/_static/fonts/fontawesome-webfont.eot b/docs/build/html/_static/css/fonts/fontawesome-webfont.eot similarity index 100% rename from docs/build/html/_static/fonts/fontawesome-webfont.eot rename to docs/build/html/_static/css/fonts/fontawesome-webfont.eot diff --git a/docs/build/html/_static/fonts/fontawesome-webfont.svg b/docs/build/html/_static/css/fonts/fontawesome-webfont.svg similarity index 100% rename from docs/build/html/_static/fonts/fontawesome-webfont.svg rename to docs/build/html/_static/css/fonts/fontawesome-webfont.svg diff --git a/docs/build/html/_static/fonts/fontawesome-webfont.ttf b/docs/build/html/_static/css/fonts/fontawesome-webfont.ttf similarity index 100% rename from docs/build/html/_static/fonts/fontawesome-webfont.ttf rename to docs/build/html/_static/css/fonts/fontawesome-webfont.ttf diff --git a/docs/build/html/_static/fonts/fontawesome-webfont.woff b/docs/build/html/_static/css/fonts/fontawesome-webfont.woff similarity index 100% rename from docs/build/html/_static/fonts/fontawesome-webfont.woff rename to docs/build/html/_static/css/fonts/fontawesome-webfont.woff diff --git a/docs/build/html/_static/fonts/fontawesome-webfont.woff2 b/docs/build/html/_static/css/fonts/fontawesome-webfont.woff2 similarity index 100% rename from docs/build/html/_static/fonts/fontawesome-webfont.woff2 rename to docs/build/html/_static/css/fonts/fontawesome-webfont.woff2 diff --git a/docs/build/html/_static/fonts/Lato/lato-bolditalic.woff b/docs/build/html/_static/css/fonts/lato-bold-italic.woff similarity index 100% rename from docs/build/html/_static/fonts/Lato/lato-bolditalic.woff rename to docs/build/html/_static/css/fonts/lato-bold-italic.woff diff --git a/docs/build/html/_static/fonts/Lato/lato-bolditalic.woff2 b/docs/build/html/_static/css/fonts/lato-bold-italic.woff2 similarity index 100% rename from docs/build/html/_static/fonts/Lato/lato-bolditalic.woff2 rename to docs/build/html/_static/css/fonts/lato-bold-italic.woff2 diff --git a/docs/build/html/_static/fonts/Lato/lato-bold.woff b/docs/build/html/_static/css/fonts/lato-bold.woff similarity index 100% rename from docs/build/html/_static/fonts/Lato/lato-bold.woff rename to docs/build/html/_static/css/fonts/lato-bold.woff diff --git a/docs/build/html/_static/fonts/Lato/lato-bold.woff2 b/docs/build/html/_static/css/fonts/lato-bold.woff2 similarity index 100% rename from docs/build/html/_static/fonts/Lato/lato-bold.woff2 rename to docs/build/html/_static/css/fonts/lato-bold.woff2 diff --git a/docs/build/html/_static/fonts/Lato/lato-italic.woff b/docs/build/html/_static/css/fonts/lato-normal-italic.woff similarity index 100% rename from docs/build/html/_static/fonts/Lato/lato-italic.woff rename to docs/build/html/_static/css/fonts/lato-normal-italic.woff diff --git a/docs/build/html/_static/fonts/Lato/lato-italic.woff2 b/docs/build/html/_static/css/fonts/lato-normal-italic.woff2 similarity index 100% rename from docs/build/html/_static/fonts/Lato/lato-italic.woff2 rename to docs/build/html/_static/css/fonts/lato-normal-italic.woff2 diff --git a/docs/build/html/_static/fonts/Lato/lato-regular.woff b/docs/build/html/_static/css/fonts/lato-normal.woff similarity index 100% rename from docs/build/html/_static/fonts/Lato/lato-regular.woff rename to docs/build/html/_static/css/fonts/lato-normal.woff diff --git a/docs/build/html/_static/fonts/Lato/lato-regular.woff2 b/docs/build/html/_static/css/fonts/lato-normal.woff2 similarity index 100% rename from docs/build/html/_static/fonts/Lato/lato-regular.woff2 rename to docs/build/html/_static/css/fonts/lato-normal.woff2 diff --git a/docs/build/html/_static/css/theme.css b/docs/build/html/_static/css/theme.css index aed8cef0668288648615f650e93e648e00e8c4d0..0d9ae7e1a45b82198c53548383a570d924993371 100644 --- a/docs/build/html/_static/css/theme.css +++ b/docs/build/html/_static/css/theme.css @@ -1,6 +1,4 @@ -/* sphinx_rtd_theme version 0.4.3 | MIT license */ -/* Built 20190212 16:02 */ -*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}[hidden]{display:none}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}a:hover,a:active{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}blockquote{margin:0}dfn{font-style:italic}ins{background:#ff9;color:#000;text-decoration:none}mark{background:#ff0;color:#000;font-style:italic;font-weight:bold}pre,code,.rst-content tt,.rst-content code,kbd,samp{font-family:monospace,serif;_font-family:"courier new",monospace;font-size:1em}pre{white-space:pre}q{quotes:none}q:before,q:after{content:"";content:none}small{font-size:85%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}ul,ol,dl{margin:0;padding:0;list-style:none;list-style-image:none}li{list-style:none}dd{margin:0}img{border:0;-ms-interpolation-mode:bicubic;vertical-align:middle;max-width:100%}svg:not(:root){overflow:hidden}figure{margin:0}form{margin:0}fieldset{border:0;margin:0;padding:0}label{cursor:pointer}legend{border:0;*margin-left:-7px;padding:0;white-space:normal}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button;*overflow:visible}button[disabled],input[disabled]{cursor:default}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0;*width:13px;*height:13px}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:vertical}table{border-collapse:collapse;border-spacing:0}td{vertical-align:top}.chromeframe{margin:.2em 0;background:#ccc;color:#000;padding:.2em 0}.ir{display:block;border:0;text-indent:-999em;overflow:hidden;background-color:transparent;background-repeat:no-repeat;text-align:left;direction:ltr;*line-height:0}.ir br{display:none}.hidden{display:none !important;visibility:hidden}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.visuallyhidden.focusable:active,.visuallyhidden.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.invisible{visibility:hidden}.relative{position:relative}big,small{font-size:100%}@media print{html,body,section{background:none !important}*{box-shadow:none !important;text-shadow:none !important;filter:none !important;-ms-filter:none !important}a,a:visited{text-decoration:underline}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:.5cm}p,h2,.rst-content .toctree-wrapper p.caption,h3{orphans:3;widows:3}h2,.rst-content .toctree-wrapper p.caption,h3{page-break-after:avoid}}.fa:before,.wy-menu-vertical li span.toctree-expand:before,.wy-menu-vertical li.on a span.toctree-expand:before,.wy-menu-vertical li.current>a span.toctree-expand:before,.rst-content .admonition-title:before,.rst-content h1 .headerlink:before,.rst-content h2 .headerlink:before,.rst-content h3 .headerlink:before,.rst-content h4 .headerlink:before,.rst-content h5 .headerlink:before,.rst-content h6 .headerlink:before,.rst-content dl dt .headerlink:before,.rst-content p.caption .headerlink:before,.rst-content table>caption .headerlink:before,.rst-content .code-block-caption .headerlink:before,.rst-content tt.download span:first-child:before,.rst-content code.download span:first-child:before,.icon:before,.wy-dropdown .caret:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.wy-alert,.rst-content .note,.rst-content .attention,.rst-content .caution,.rst-content .danger,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .tip,.rst-content .warning,.rst-content .seealso,.rst-content .admonition-todo,.rst-content .admonition,.btn,input[type="text"],input[type="password"],input[type="email"],input[type="url"],input[type="date"],input[type="month"],input[type="time"],input[type="datetime"],input[type="datetime-local"],input[type="week"],input[type="number"],input[type="search"],input[type="tel"],input[type="color"],select,textarea,.wy-menu-vertical li.on a,.wy-menu-vertical li.current>a,.wy-side-nav-search>a,.wy-side-nav-search .wy-dropdown>a,.wy-nav-top a{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}/*! +html{box-sizing:border-box}*,:after,:before{box-sizing:inherit}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden],audio:not([controls]){display:none}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}blockquote{margin:0}dfn{font-style:italic}ins{background:#ff9;text-decoration:none}ins,mark{color:#000}mark{background:#ff0;font-style:italic;font-weight:700}.rst-content code,.rst-content tt,code,kbd,pre,samp{font-family:monospace,serif;_font-family:courier new,monospace;font-size:1em}pre{white-space:pre}q{quotes:none}q:after,q:before{content:"";content:none}small{font-size:85%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}dl,ol,ul{margin:0;padding:0;list-style:none;list-style-image:none}li{list-style:none}dd{margin:0}img{border:0;-ms-interpolation-mode:bicubic;vertical-align:middle;max-width:100%}svg:not(:root){overflow:hidden}figure,form{margin:0}label{cursor:pointer}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal}button,input[type=button],input[type=reset],input[type=submit]{cursor:pointer;-webkit-appearance:button;*overflow:visible}button[disabled],input[disabled]{cursor:default}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}textarea{resize:vertical}table{border-collapse:collapse;border-spacing:0}td{vertical-align:top}.chromeframe{margin:.2em 0;background:#ccc;color:#000;padding:.2em 0}.ir{display:block;border:0;text-indent:-999em;overflow:hidden;background-color:transparent;background-repeat:no-repeat;text-align:left;direction:ltr;*line-height:0}.ir br{display:none}.hidden{display:none!important;visibility:hidden}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.visuallyhidden.focusable:active,.visuallyhidden.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.invisible{visibility:hidden}.relative{position:relative}big,small{font-size:100%}@media print{body,html,section{background:none!important}*{box-shadow:none!important;text-shadow:none!important;filter:none!important;-ms-filter:none!important}a,a:visited{text-decoration:underline}.ir a:after,a[href^="#"]:after,a[href^="javascript:"]:after{content:""}blockquote,pre{page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}.rst-content .toctree-wrapper>p.caption,h2,h3,p{orphans:3;widows:3}.rst-content .toctree-wrapper>p.caption,h2,h3{page-break-after:avoid}}.btn,.fa:before,.icon:before,.rst-content .admonition,.rst-content .admonition-title:before,.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .code-block-caption .headerlink:before,.rst-content .danger,.rst-content .eqno .headerlink:before,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .note,.rst-content .seealso,.rst-content .tip,.rst-content .warning,.rst-content code.download span:first-child:before,.rst-content dl dt .headerlink:before,.rst-content h1 .headerlink:before,.rst-content h2 .headerlink:before,.rst-content h3 .headerlink:before,.rst-content h4 .headerlink:before,.rst-content h5 .headerlink:before,.rst-content h6 .headerlink:before,.rst-content p.caption .headerlink:before,.rst-content p .headerlink:before,.rst-content table>caption .headerlink:before,.rst-content tt.download span:first-child:before,.wy-alert,.wy-dropdown .caret:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before,.wy-menu-vertical li.current>a,.wy-menu-vertical li.current>a button.toctree-expand:before,.wy-menu-vertical li.on a,.wy-menu-vertical li.on a button.toctree-expand:before,.wy-menu-vertical li button.toctree-expand:before,.wy-nav-top a,.wy-side-nav-search .wy-dropdown>a,.wy-side-nav-search>a,input[type=color],input[type=date],input[type=datetime-local],input[type=datetime],input[type=email],input[type=month],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=time],input[type=url],input[type=week],select,textarea{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}/*! * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */@font-face{font-family:'FontAwesome';src:url("../fonts/fontawesome-webfont.eot?v=4.7.0");src:url("../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0") format("embedded-opentype"),url("../fonts/fontawesome-webfont.woff2?v=4.7.0") format("woff2"),url("../fonts/fontawesome-webfont.woff?v=4.7.0") format("woff"),url("../fonts/fontawesome-webfont.ttf?v=4.7.0") format("truetype"),url("../fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular") format("svg");font-weight:normal;font-style:normal}.fa,.wy-menu-vertical li span.toctree-expand,.wy-menu-vertical li.on a span.toctree-expand,.wy-menu-vertical li.current>a span.toctree-expand,.rst-content .admonition-title,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content dl dt .headerlink,.rst-content p.caption .headerlink,.rst-content table>caption .headerlink,.rst-content .code-block-caption .headerlink,.rst-content tt.download span:first-child,.rst-content code.download span:first-child,.icon{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.3333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857em;text-align:center}.fa-ul{padding-left:0;margin-left:2.1428571429em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.1428571429em;width:2.1428571429em;top:.1428571429em;text-align:center}.fa-li.fa-lg{left:-1.8571428571em}.fa-border{padding:.2em .25em .15em;border:solid 0.08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left,.wy-menu-vertical li span.fa-pull-left.toctree-expand,.wy-menu-vertical li.on a span.fa-pull-left.toctree-expand,.wy-menu-vertical li.current>a span.fa-pull-left.toctree-expand,.rst-content .fa-pull-left.admonition-title,.rst-content h1 .fa-pull-left.headerlink,.rst-content h2 .fa-pull-left.headerlink,.rst-content h3 .fa-pull-left.headerlink,.rst-content h4 .fa-pull-left.headerlink,.rst-content h5 .fa-pull-left.headerlink,.rst-content h6 .fa-pull-left.headerlink,.rst-content dl dt .fa-pull-left.headerlink,.rst-content p.caption .fa-pull-left.headerlink,.rst-content table>caption .fa-pull-left.headerlink,.rst-content .code-block-caption .fa-pull-left.headerlink,.rst-content tt.download span.fa-pull-left:first-child,.rst-content code.download span.fa-pull-left:first-child,.fa-pull-left.icon{margin-right:.3em}.fa.fa-pull-right,.wy-menu-vertical li span.fa-pull-right.toctree-expand,.wy-menu-vertical li.on a span.fa-pull-right.toctree-expand,.wy-menu-vertical li.current>a span.fa-pull-right.toctree-expand,.rst-content .fa-pull-right.admonition-title,.rst-content h1 .fa-pull-right.headerlink,.rst-content h2 .fa-pull-right.headerlink,.rst-content h3 .fa-pull-right.headerlink,.rst-content h4 .fa-pull-right.headerlink,.rst-content h5 .fa-pull-right.headerlink,.rst-content h6 .fa-pull-right.headerlink,.rst-content dl dt .fa-pull-right.headerlink,.rst-content p.caption .fa-pull-right.headerlink,.rst-content table>caption .fa-pull-right.headerlink,.rst-content .code-block-caption .fa-pull-right.headerlink,.rst-content tt.download span.fa-pull-right:first-child,.rst-content code.download span.fa-pull-right:first-child,.fa-pull-right.icon{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left,.wy-menu-vertical li span.pull-left.toctree-expand,.wy-menu-vertical li.on a span.pull-left.toctree-expand,.wy-menu-vertical li.current>a span.pull-left.toctree-expand,.rst-content .pull-left.admonition-title,.rst-content h1 .pull-left.headerlink,.rst-content h2 .pull-left.headerlink,.rst-content h3 .pull-left.headerlink,.rst-content h4 .pull-left.headerlink,.rst-content h5 .pull-left.headerlink,.rst-content h6 .pull-left.headerlink,.rst-content dl dt .pull-left.headerlink,.rst-content p.caption .pull-left.headerlink,.rst-content table>caption .pull-left.headerlink,.rst-content .code-block-caption .pull-left.headerlink,.rst-content tt.download span.pull-left:first-child,.rst-content code.download span.pull-left:first-child,.pull-left.icon{margin-right:.3em}.fa.pull-right,.wy-menu-vertical li span.pull-right.toctree-expand,.wy-menu-vertical li.on a span.pull-right.toctree-expand,.wy-menu-vertical li.current>a span.pull-right.toctree-expand,.rst-content .pull-right.admonition-title,.rst-content h1 .pull-right.headerlink,.rst-content h2 .pull-right.headerlink,.rst-content h3 .pull-right.headerlink,.rst-content h4 .pull-right.headerlink,.rst-content h5 .pull-right.headerlink,.rst-content h6 .pull-right.headerlink,.rst-content dl dt .pull-right.headerlink,.rst-content p.caption .pull-right.headerlink,.rst-content table>caption .pull-right.headerlink,.rst-content .code-block-caption .pull-right.headerlink,.rst-content tt.download span.pull-right:first-child,.rst-content code.download span.pull-right:first-child,.pull-right.icon{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:""}.fa-music:before{content:"ï€"}.fa-search:before,.icon-search:before{content:""}.fa-envelope-o:before{content:""}.fa-heart:before{content:""}.fa-star:before{content:""}.fa-star-o:before{content:""}.fa-user:before{content:""}.fa-film:before{content:""}.fa-th-large:before{content:""}.fa-th:before{content:""}.fa-th-list:before{content:""}.fa-check:before{content:""}.fa-remove:before,.fa-close:before,.fa-times:before{content:"ï€"}.fa-search-plus:before{content:""}.fa-search-minus:before{content:"ï€"}.fa-power-off:before{content:""}.fa-signal:before{content:""}.fa-gear:before,.fa-cog:before{content:""}.fa-trash-o:before{content:""}.fa-home:before,.icon-home:before{content:""}.fa-file-o:before{content:""}.fa-clock-o:before{content:""}.fa-road:before{content:""}.fa-download:before,.rst-content tt.download span:first-child:before,.rst-content code.download span:first-child:before{content:""}.fa-arrow-circle-o-down:before{content:""}.fa-arrow-circle-o-up:before{content:""}.fa-inbox:before{content:""}.fa-play-circle-o:before{content:"ï€"}.fa-rotate-right:before,.fa-repeat:before{content:""}.fa-refresh:before{content:""}.fa-list-alt:before{content:""}.fa-lock:before{content:""}.fa-flag:before{content:""}.fa-headphones:before{content:""}.fa-volume-off:before{content:""}.fa-volume-down:before{content:""}.fa-volume-up:before{content:""}.fa-qrcode:before{content:""}.fa-barcode:before{content:""}.fa-tag:before{content:""}.fa-tags:before{content:""}.fa-book:before,.icon-book:before{content:"ï€"}.fa-bookmark:before{content:""}.fa-print:before{content:""}.fa-camera:before{content:""}.fa-font:before{content:""}.fa-bold:before{content:""}.fa-italic:before{content:""}.fa-text-height:before{content:""}.fa-text-width:before{content:""}.fa-align-left:before{content:""}.fa-align-center:before{content:""}.fa-align-right:before{content:""}.fa-align-justify:before{content:""}.fa-list:before{content:""}.fa-dedent:before,.fa-outdent:before{content:""}.fa-indent:before{content:""}.fa-video-camera:before{content:""}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:""}.fa-pencil:before{content:"ï€"}.fa-map-marker:before{content:"ï"}.fa-adjust:before{content:"ï‚"}.fa-tint:before{content:"ïƒ"}.fa-edit:before,.fa-pencil-square-o:before{content:"ï„"}.fa-share-square-o:before{content:"ï…"}.fa-check-square-o:before{content:"ï†"}.fa-arrows:before{content:"ï‡"}.fa-step-backward:before{content:"ïˆ"}.fa-fast-backward:before{content:"ï‰"}.fa-backward:before{content:"ïŠ"}.fa-play:before{content:"ï‹"}.fa-pause:before{content:"ïŒ"}.fa-stop:before{content:"ï"}.fa-forward:before{content:"ïŽ"}.fa-fast-forward:before{content:"ï"}.fa-step-forward:before{content:"ï‘"}.fa-eject:before{content:"ï’"}.fa-chevron-left:before{content:"ï“"}.fa-chevron-right:before{content:"ï”"}.fa-plus-circle:before{content:"ï•"}.fa-minus-circle:before{content:"ï–"}.fa-times-circle:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before{content:"ï—"}.fa-check-circle:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before{content:"ï˜"}.fa-question-circle:before{content:"ï™"}.fa-info-circle:before{content:"ïš"}.fa-crosshairs:before{content:"ï›"}.fa-times-circle-o:before{content:"ïœ"}.fa-check-circle-o:before{content:"ï"}.fa-ban:before{content:"ïž"}.fa-arrow-left:before{content:"ï "}.fa-arrow-right:before{content:"ï¡"}.fa-arrow-up:before{content:"ï¢"}.fa-arrow-down:before{content:"ï£"}.fa-mail-forward:before,.fa-share:before{content:"ï¤"}.fa-expand:before{content:"ï¥"}.fa-compress:before{content:"ï¦"}.fa-plus:before{content:"ï§"}.fa-minus:before{content:"ï¨"}.fa-asterisk:before{content:"ï©"}.fa-exclamation-circle:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.rst-content .admonition-title:before{content:"ïª"}.fa-gift:before{content:"ï«"}.fa-leaf:before{content:"ï¬"}.fa-fire:before,.icon-fire:before{content:"ï"}.fa-eye:before{content:"ï®"}.fa-eye-slash:before{content:"ï°"}.fa-warning:before,.fa-exclamation-triangle:before{content:"ï±"}.fa-plane:before{content:"ï²"}.fa-calendar:before{content:"ï³"}.fa-random:before{content:"ï´"}.fa-comment:before{content:"ïµ"}.fa-magnet:before{content:"ï¶"}.fa-chevron-up:before{content:"ï·"}.fa-chevron-down:before{content:"ï¸"}.fa-retweet:before{content:"ï¹"}.fa-shopping-cart:before{content:"ïº"}.fa-folder:before{content:"ï»"}.fa-folder-open:before{content:"ï¼"}.fa-arrows-v:before{content:"ï½"}.fa-arrows-h:before{content:"ï¾"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"ï‚€"}.fa-twitter-square:before{content:"ï‚"}.fa-facebook-square:before{content:"ï‚‚"}.fa-camera-retro:before{content:""}.fa-key:before{content:"ï‚„"}.fa-gears:before,.fa-cogs:before{content:"ï‚…"}.fa-comments:before{content:""}.fa-thumbs-o-up:before{content:""}.fa-thumbs-o-down:before{content:""}.fa-star-half:before{content:""}.fa-heart-o:before{content:""}.fa-sign-out:before{content:"ï‚‹"}.fa-linkedin-square:before{content:""}.fa-thumb-tack:before{content:"ï‚"}.fa-external-link:before{content:""}.fa-sign-in:before{content:"ï‚"}.fa-trophy:before{content:"ï‚‘"}.fa-github-square:before{content:"ï‚’"}.fa-upload:before{content:"ï‚“"}.fa-lemon-o:before{content:"ï‚”"}.fa-phone:before{content:"ï‚•"}.fa-square-o:before{content:"ï‚–"}.fa-bookmark-o:before{content:"ï‚—"}.fa-phone-square:before{content:""}.fa-twitter:before{content:"ï‚™"}.fa-facebook-f:before,.fa-facebook:before{content:""}.fa-github:before,.icon-github:before{content:"ï‚›"}.fa-unlock:before{content:""}.fa-credit-card:before{content:"ï‚"}.fa-feed:before,.fa-rss:before{content:""}.fa-hdd-o:before{content:"ï‚ "}.fa-bullhorn:before{content:"ï‚¡"}.fa-bell:before{content:""}.fa-certificate:before{content:"ï‚£"}.fa-hand-o-right:before{content:""}.fa-hand-o-left:before{content:"ï‚¥"}.fa-hand-o-up:before{content:""}.fa-hand-o-down:before{content:"ï‚§"}.fa-arrow-circle-left:before,.icon-circle-arrow-left:before{content:""}.fa-arrow-circle-right:before,.icon-circle-arrow-right:before{content:"ï‚©"}.fa-arrow-circle-up:before{content:""}.fa-arrow-circle-down:before{content:"ï‚«"}.fa-globe:before{content:""}.fa-wrench:before{content:"ï‚"}.fa-tasks:before{content:"ï‚®"}.fa-filter:before{content:"ï‚°"}.fa-briefcase:before{content:""}.fa-arrows-alt:before{content:""}.fa-group:before,.fa-users:before{content:""}.fa-chain:before,.fa-link:before,.icon-link:before{content:"ïƒ"}.fa-cloud:before{content:""}.fa-flask:before{content:""}.fa-cut:before,.fa-scissors:before{content:""}.fa-copy:before,.fa-files-o:before{content:""}.fa-paperclip:before{content:""}.fa-save:before,.fa-floppy-o:before{content:""}.fa-square:before{content:""}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:""}.fa-list-ul:before{content:""}.fa-list-ol:before{content:""}.fa-strikethrough:before{content:""}.fa-underline:before{content:"ïƒ"}.fa-table:before{content:""}.fa-magic:before{content:"ïƒ"}.fa-truck:before{content:""}.fa-pinterest:before{content:""}.fa-pinterest-square:before{content:""}.fa-google-plus-square:before{content:""}.fa-google-plus:before{content:""}.fa-money:before{content:""}.fa-caret-down:before,.wy-dropdown .caret:before,.icon-caret-down:before{content:""}.fa-caret-up:before{content:""}.fa-caret-left:before{content:""}.fa-caret-right:before{content:""}.fa-columns:before{content:""}.fa-unsorted:before,.fa-sort:before{content:""}.fa-sort-down:before,.fa-sort-desc:before{content:"ïƒ"}.fa-sort-up:before,.fa-sort-asc:before{content:""}.fa-envelope:before{content:"ïƒ "}.fa-linkedin:before{content:""}.fa-rotate-left:before,.fa-undo:before{content:""}.fa-legal:before,.fa-gavel:before{content:""}.fa-dashboard:before,.fa-tachometer:before{content:""}.fa-comment-o:before{content:""}.fa-comments-o:before{content:""}.fa-flash:before,.fa-bolt:before{content:""}.fa-sitemap:before{content:""}.fa-umbrella:before{content:""}.fa-paste:before,.fa-clipboard:before{content:""}.fa-lightbulb-o:before{content:""}.fa-exchange:before{content:""}.fa-cloud-download:before{content:"ïƒ"}.fa-cloud-upload:before{content:""}.fa-user-md:before{content:""}.fa-stethoscope:before{content:""}.fa-suitcase:before{content:""}.fa-bell-o:before{content:"ï‚¢"}.fa-coffee:before{content:""}.fa-cutlery:before{content:""}.fa-file-text-o:before{content:""}.fa-building-o:before{content:""}.fa-hospital-o:before{content:""}.fa-ambulance:before{content:""}.fa-medkit:before{content:""}.fa-fighter-jet:before{content:""}.fa-beer:before{content:""}.fa-h-square:before{content:""}.fa-plus-square:before{content:""}.fa-angle-double-left:before{content:"ï„€"}.fa-angle-double-right:before{content:"ï„"}.fa-angle-double-up:before{content:"ï„‚"}.fa-angle-double-down:before{content:""}.fa-angle-left:before{content:"ï„„"}.fa-angle-right:before{content:"ï„…"}.fa-angle-up:before{content:""}.fa-angle-down:before{content:""}.fa-desktop:before{content:""}.fa-laptop:before{content:""}.fa-tablet:before{content:""}.fa-mobile-phone:before,.fa-mobile:before{content:"ï„‹"}.fa-circle-o:before{content:""}.fa-quote-left:before{content:"ï„"}.fa-quote-right:before{content:""}.fa-spinner:before{content:"ï„"}.fa-circle:before{content:"ï„‘"}.fa-mail-reply:before,.fa-reply:before{content:"ï„’"}.fa-github-alt:before{content:"ï„“"}.fa-folder-o:before{content:"ï„”"}.fa-folder-open-o:before{content:"ï„•"}.fa-smile-o:before{content:""}.fa-frown-o:before{content:"ï„™"}.fa-meh-o:before{content:""}.fa-gamepad:before{content:"ï„›"}.fa-keyboard-o:before{content:""}.fa-flag-o:before{content:"ï„"}.fa-flag-checkered:before{content:""}.fa-terminal:before{content:"ï„ "}.fa-code:before{content:"ï„¡"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"ï„¢"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"ï„£"}.fa-location-arrow:before{content:""}.fa-crop:before{content:"ï„¥"}.fa-code-fork:before{content:""}.fa-unlink:before,.fa-chain-broken:before{content:"ï„§"}.fa-question:before{content:""}.fa-info:before{content:"ï„©"}.fa-exclamation:before{content:""}.fa-superscript:before{content:"ï„«"}.fa-subscript:before{content:""}.fa-eraser:before{content:"ï„"}.fa-puzzle-piece:before{content:"ï„®"}.fa-microphone:before{content:"ï„°"}.fa-microphone-slash:before{content:""}.fa-shield:before{content:""}.fa-calendar-o:before{content:""}.fa-fire-extinguisher:before{content:"ï„´"}.fa-rocket:before{content:""}.fa-maxcdn:before{content:"ï„¶"}.fa-chevron-circle-left:before{content:"ï„·"}.fa-chevron-circle-right:before{content:""}.fa-chevron-circle-up:before{content:""}.fa-chevron-circle-down:before{content:""}.fa-html5:before{content:"ï„»"}.fa-css3:before{content:""}.fa-anchor:before{content:""}.fa-unlock-alt:before{content:""}.fa-bullseye:before{content:"ï…€"}.fa-ellipsis-h:before{content:"ï…"}.fa-ellipsis-v:before{content:"ï…‚"}.fa-rss-square:before{content:"ï…ƒ"}.fa-play-circle:before{content:"ï…„"}.fa-ticket:before{content:"ï……"}.fa-minus-square:before{content:"ï…†"}.fa-minus-square-o:before,.wy-menu-vertical li.on a span.toctree-expand:before,.wy-menu-vertical li.current>a span.toctree-expand:before{content:"ï…‡"}.fa-level-up:before{content:"ï…ˆ"}.fa-level-down:before{content:"ï…‰"}.fa-check-square:before{content:"ï…Š"}.fa-pencil-square:before{content:"ï…‹"}.fa-external-link-square:before{content:"ï…Œ"}.fa-share-square:before{content:"ï…"}.fa-compass:before{content:"ï…Ž"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"ï…"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"ï…‘"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"ï…’"}.fa-euro:before,.fa-eur:before{content:"ï…“"}.fa-gbp:before{content:"ï…”"}.fa-dollar:before,.fa-usd:before{content:"ï…•"}.fa-rupee:before,.fa-inr:before{content:"ï…–"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"ï…—"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"ï…˜"}.fa-won:before,.fa-krw:before{content:"ï…™"}.fa-bitcoin:before,.fa-btc:before{content:"ï…š"}.fa-file:before{content:"ï…›"}.fa-file-text:before{content:"ï…œ"}.fa-sort-alpha-asc:before{content:"ï…"}.fa-sort-alpha-desc:before{content:"ï…ž"}.fa-sort-amount-asc:before{content:"ï… "}.fa-sort-amount-desc:before{content:"ï…¡"}.fa-sort-numeric-asc:before{content:"ï…¢"}.fa-sort-numeric-desc:before{content:"ï…£"}.fa-thumbs-up:before{content:"ï…¤"}.fa-thumbs-down:before{content:"ï…¥"}.fa-youtube-square:before{content:"ï…¦"}.fa-youtube:before{content:"ï…§"}.fa-xing:before{content:"ï…¨"}.fa-xing-square:before{content:"ï…©"}.fa-youtube-play:before{content:"ï…ª"}.fa-dropbox:before{content:"ï…«"}.fa-stack-overflow:before{content:"ï…¬"}.fa-instagram:before{content:"ï…"}.fa-flickr:before{content:"ï…®"}.fa-adn:before{content:"ï…°"}.fa-bitbucket:before,.icon-bitbucket:before{content:"ï…±"}.fa-bitbucket-square:before{content:"ï…²"}.fa-tumblr:before{content:"ï…³"}.fa-tumblr-square:before{content:"ï…´"}.fa-long-arrow-down:before{content:"ï…µ"}.fa-long-arrow-up:before{content:"ï…¶"}.fa-long-arrow-left:before{content:"ï…·"}.fa-long-arrow-right:before{content:"ï…¸"}.fa-apple:before{content:"ï…¹"}.fa-windows:before{content:"ï…º"}.fa-android:before{content:"ï…»"}.fa-linux:before{content:"ï…¼"}.fa-dribbble:before{content:"ï…½"}.fa-skype:before{content:"ï…¾"}.fa-foursquare:before{content:""}.fa-trello:before{content:"ï†"}.fa-female:before{content:""}.fa-male:before{content:""}.fa-gittip:before,.fa-gratipay:before{content:""}.fa-sun-o:before{content:""}.fa-moon-o:before{content:""}.fa-archive:before{content:""}.fa-bug:before{content:""}.fa-vk:before{content:""}.fa-weibo:before{content:""}.fa-renren:before{content:""}.fa-pagelines:before{content:""}.fa-stack-exchange:before{content:"ï†"}.fa-arrow-circle-o-right:before{content:""}.fa-arrow-circle-o-left:before{content:"ï†"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:""}.fa-dot-circle-o:before{content:""}.fa-wheelchair:before{content:""}.fa-vimeo-square:before{content:""}.fa-turkish-lira:before,.fa-try:before{content:""}.fa-plus-square-o:before,.wy-menu-vertical li span.toctree-expand:before{content:""}.fa-space-shuttle:before{content:""}.fa-slack:before{content:""}.fa-envelope-square:before{content:""}.fa-wordpress:before{content:""}.fa-openid:before{content:""}.fa-institution:before,.fa-bank:before,.fa-university:before{content:""}.fa-mortar-board:before,.fa-graduation-cap:before{content:"ï†"}.fa-yahoo:before{content:""}.fa-google:before{content:"ï† "}.fa-reddit:before{content:""}.fa-reddit-square:before{content:""}.fa-stumbleupon-circle:before{content:""}.fa-stumbleupon:before{content:""}.fa-delicious:before{content:""}.fa-digg:before{content:""}.fa-pied-piper-pp:before{content:""}.fa-pied-piper-alt:before{content:""}.fa-drupal:before{content:""}.fa-joomla:before{content:""}.fa-language:before{content:""}.fa-fax:before{content:""}.fa-building:before{content:"ï†"}.fa-child:before{content:""}.fa-paw:before{content:""}.fa-spoon:before{content:""}.fa-cube:before{content:""}.fa-cubes:before{content:""}.fa-behance:before{content:""}.fa-behance-square:before{content:""}.fa-steam:before{content:""}.fa-steam-square:before{content:""}.fa-recycle:before{content:""}.fa-automobile:before,.fa-car:before{content:""}.fa-cab:before,.fa-taxi:before{content:""}.fa-tree:before{content:""}.fa-spotify:before{content:""}.fa-deviantart:before{content:""}.fa-soundcloud:before{content:""}.fa-database:before{content:""}.fa-file-pdf-o:before{content:"ï‡"}.fa-file-word-o:before{content:""}.fa-file-excel-o:before{content:""}.fa-file-powerpoint-o:before{content:""}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:""}.fa-file-zip-o:before,.fa-file-archive-o:before{content:""}.fa-file-sound-o:before,.fa-file-audio-o:before{content:""}.fa-file-movie-o:before,.fa-file-video-o:before{content:""}.fa-file-code-o:before{content:""}.fa-vine:before{content:""}.fa-codepen:before{content:""}.fa-jsfiddle:before{content:""}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"ï‡"}.fa-circle-o-notch:before{content:""}.fa-ra:before,.fa-resistance:before,.fa-rebel:before{content:"ï‡"}.fa-ge:before,.fa-empire:before{content:""}.fa-git-square:before{content:""}.fa-git:before{content:""}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:""}.fa-tencent-weibo:before{content:""}.fa-qq:before{content:""}.fa-wechat:before,.fa-weixin:before{content:""}.fa-send:before,.fa-paper-plane:before{content:""}.fa-send-o:before,.fa-paper-plane-o:before{content:""}.fa-history:before{content:""}.fa-circle-thin:before{content:""}.fa-header:before{content:""}.fa-paragraph:before{content:"ï‡"}.fa-sliders:before{content:""}.fa-share-alt:before{content:"ï‡ "}.fa-share-alt-square:before{content:""}.fa-bomb:before{content:""}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:""}.fa-tty:before{content:""}.fa-binoculars:before{content:""}.fa-plug:before{content:""}.fa-slideshare:before{content:""}.fa-twitch:before{content:""}.fa-yelp:before{content:""}.fa-newspaper-o:before{content:""}.fa-wifi:before{content:""}.fa-calculator:before{content:""}.fa-paypal:before{content:"ï‡"}.fa-google-wallet:before{content:""}.fa-cc-visa:before{content:""}.fa-cc-mastercard:before{content:""}.fa-cc-discover:before{content:""}.fa-cc-amex:before{content:""}.fa-cc-paypal:before{content:""}.fa-cc-stripe:before{content:""}.fa-bell-slash:before{content:""}.fa-bell-slash-o:before{content:""}.fa-trash:before{content:""}.fa-copyright:before{content:""}.fa-at:before{content:""}.fa-eyedropper:before{content:""}.fa-paint-brush:before{content:""}.fa-birthday-cake:before{content:""}.fa-area-chart:before{content:""}.fa-pie-chart:before{content:""}.fa-line-chart:before{content:"ïˆ"}.fa-lastfm:before{content:""}.fa-lastfm-square:before{content:""}.fa-toggle-off:before{content:""}.fa-toggle-on:before{content:""}.fa-bicycle:before{content:""}.fa-bus:before{content:""}.fa-ioxhost:before{content:""}.fa-angellist:before{content:""}.fa-cc:before{content:""}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:""}.fa-meanpath:before{content:""}.fa-buysellads:before{content:"ïˆ"}.fa-connectdevelop:before{content:""}.fa-dashcube:before{content:"ïˆ"}.fa-forumbee:before{content:""}.fa-leanpub:before{content:""}.fa-sellsy:before{content:""}.fa-shirtsinbulk:before{content:""}.fa-simplybuilt:before{content:""}.fa-skyatlas:before{content:""}.fa-cart-plus:before{content:""}.fa-cart-arrow-down:before{content:""}.fa-diamond:before{content:""}.fa-ship:before{content:""}.fa-user-secret:before{content:""}.fa-motorcycle:before{content:""}.fa-street-view:before{content:"ïˆ"}.fa-heartbeat:before{content:""}.fa-venus:before{content:""}.fa-mars:before{content:""}.fa-mercury:before{content:""}.fa-intersex:before,.fa-transgender:before{content:""}.fa-transgender-alt:before{content:""}.fa-venus-double:before{content:""}.fa-mars-double:before{content:""}.fa-venus-mars:before{content:""}.fa-mars-stroke:before{content:""}.fa-mars-stroke-v:before{content:""}.fa-mars-stroke-h:before{content:""}.fa-neuter:before{content:""}.fa-genderless:before{content:"ïˆ"}.fa-facebook-official:before{content:""}.fa-pinterest-p:before{content:""}.fa-whatsapp:before{content:""}.fa-server:before{content:""}.fa-user-plus:before{content:""}.fa-user-times:before{content:""}.fa-hotel:before,.fa-bed:before{content:""}.fa-viacoin:before{content:""}.fa-train:before{content:""}.fa-subway:before{content:""}.fa-medium:before{content:""}.fa-yc:before,.fa-y-combinator:before{content:""}.fa-optin-monster:before{content:""}.fa-opencart:before{content:""}.fa-expeditedssl:before{content:""}.fa-battery-4:before,.fa-battery:before,.fa-battery-full:before{content:""}.fa-battery-3:before,.fa-battery-three-quarters:before{content:"ï‰"}.fa-battery-2:before,.fa-battery-half:before{content:""}.fa-battery-1:before,.fa-battery-quarter:before{content:""}.fa-battery-0:before,.fa-battery-empty:before{content:""}.fa-mouse-pointer:before{content:""}.fa-i-cursor:before{content:""}.fa-object-group:before{content:""}.fa-object-ungroup:before{content:""}.fa-sticky-note:before{content:""}.fa-sticky-note-o:before{content:""}.fa-cc-jcb:before{content:""}.fa-cc-diners-club:before{content:""}.fa-clone:before{content:"ï‰"}.fa-balance-scale:before{content:""}.fa-hourglass-o:before{content:"ï‰"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:""}.fa-hourglass-2:before,.fa-hourglass-half:before{content:""}.fa-hourglass-3:before,.fa-hourglass-end:before{content:""}.fa-hourglass:before{content:""}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:""}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:""}.fa-hand-scissors-o:before{content:""}.fa-hand-lizard-o:before{content:""}.fa-hand-spock-o:before{content:""}.fa-hand-pointer-o:before{content:""}.fa-hand-peace-o:before{content:""}.fa-trademark:before{content:""}.fa-registered:before{content:"ï‰"}.fa-creative-commons:before{content:""}.fa-gg:before{content:"ï‰ "}.fa-gg-circle:before{content:""}.fa-tripadvisor:before{content:""}.fa-odnoklassniki:before{content:""}.fa-odnoklassniki-square:before{content:""}.fa-get-pocket:before{content:""}.fa-wikipedia-w:before{content:""}.fa-safari:before{content:""}.fa-chrome:before{content:""}.fa-firefox:before{content:""}.fa-opera:before{content:""}.fa-internet-explorer:before{content:""}.fa-tv:before,.fa-television:before{content:""}.fa-contao:before{content:"ï‰"}.fa-500px:before{content:""}.fa-amazon:before{content:""}.fa-calendar-plus-o:before{content:""}.fa-calendar-minus-o:before{content:""}.fa-calendar-times-o:before{content:""}.fa-calendar-check-o:before{content:""}.fa-industry:before{content:""}.fa-map-pin:before{content:""}.fa-map-signs:before{content:""}.fa-map-o:before{content:""}.fa-map:before{content:""}.fa-commenting:before{content:""}.fa-commenting-o:before{content:""}.fa-houzz:before{content:""}.fa-vimeo:before{content:""}.fa-black-tie:before{content:""}.fa-fonticons:before{content:""}.fa-reddit-alien:before{content:"ïŠ"}.fa-edge:before{content:""}.fa-credit-card-alt:before{content:""}.fa-codiepie:before{content:""}.fa-modx:before{content:""}.fa-fort-awesome:before{content:""}.fa-usb:before{content:""}.fa-product-hunt:before{content:""}.fa-mixcloud:before{content:""}.fa-scribd:before{content:""}.fa-pause-circle:before{content:""}.fa-pause-circle-o:before{content:""}.fa-stop-circle:before{content:"ïŠ"}.fa-stop-circle-o:before{content:""}.fa-shopping-bag:before{content:"ïŠ"}.fa-shopping-basket:before{content:""}.fa-hashtag:before{content:""}.fa-bluetooth:before{content:""}.fa-bluetooth-b:before{content:""}.fa-percent:before{content:""}.fa-gitlab:before,.icon-gitlab:before{content:""}.fa-wpbeginner:before{content:""}.fa-wpforms:before{content:""}.fa-envira:before{content:""}.fa-universal-access:before{content:""}.fa-wheelchair-alt:before{content:""}.fa-question-circle-o:before{content:""}.fa-blind:before{content:"ïŠ"}.fa-audio-description:before{content:""}.fa-volume-control-phone:before{content:"ïŠ "}.fa-braille:before{content:""}.fa-assistive-listening-systems:before{content:""}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:""}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:""}.fa-glide:before{content:""}.fa-glide-g:before{content:""}.fa-signing:before,.fa-sign-language:before{content:""}.fa-low-vision:before{content:""}.fa-viadeo:before{content:""}.fa-viadeo-square:before{content:""}.fa-snapchat:before{content:""}.fa-snapchat-ghost:before{content:""}.fa-snapchat-square:before{content:"ïŠ"}.fa-pied-piper:before{content:""}.fa-first-order:before{content:""}.fa-yoast:before{content:""}.fa-themeisle:before{content:""}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:""}.fa-fa:before,.fa-font-awesome:before{content:""}.fa-handshake-o:before{content:""}.fa-envelope-open:before{content:""}.fa-envelope-open-o:before{content:""}.fa-linode:before{content:""}.fa-address-book:before{content:""}.fa-address-book-o:before{content:""}.fa-vcard:before,.fa-address-card:before{content:""}.fa-vcard-o:before,.fa-address-card-o:before{content:""}.fa-user-circle:before{content:""}.fa-user-circle-o:before{content:""}.fa-user-o:before{content:"ï‹€"}.fa-id-badge:before{content:"ï‹"}.fa-drivers-license:before,.fa-id-card:before{content:"ï‹‚"}.fa-drivers-license-o:before,.fa-id-card-o:before{content:""}.fa-quora:before{content:"ï‹„"}.fa-free-code-camp:before{content:"ï‹…"}.fa-telegram:before{content:""}.fa-thermometer-4:before,.fa-thermometer:before,.fa-thermometer-full:before{content:""}.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:""}.fa-thermometer-2:before,.fa-thermometer-half:before{content:""}.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:""}.fa-thermometer-0:before,.fa-thermometer-empty:before{content:"ï‹‹"}.fa-shower:before{content:""}.fa-bathtub:before,.fa-s15:before,.fa-bath:before{content:"ï‹"}.fa-podcast:before{content:""}.fa-window-maximize:before{content:"ï‹"}.fa-window-minimize:before{content:"ï‹‘"}.fa-window-restore:before{content:"ï‹’"}.fa-times-rectangle:before,.fa-window-close:before{content:"ï‹“"}.fa-times-rectangle-o:before,.fa-window-close-o:before{content:"ï‹”"}.fa-bandcamp:before{content:"ï‹•"}.fa-grav:before{content:"ï‹–"}.fa-etsy:before{content:"ï‹—"}.fa-imdb:before{content:""}.fa-ravelry:before{content:"ï‹™"}.fa-eercast:before{content:""}.fa-microchip:before{content:"ï‹›"}.fa-snowflake-o:before{content:""}.fa-superpowers:before{content:"ï‹"}.fa-wpexplorer:before{content:""}.fa-meetup:before{content:"ï‹ "}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.fa,.wy-menu-vertical li span.toctree-expand,.wy-menu-vertical li.on a span.toctree-expand,.wy-menu-vertical li.current>a span.toctree-expand,.rst-content .admonition-title,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content dl dt .headerlink,.rst-content p.caption .headerlink,.rst-content table>caption .headerlink,.rst-content .code-block-caption .headerlink,.rst-content tt.download span:first-child,.rst-content code.download span:first-child,.icon,.wy-dropdown .caret,.wy-inline-validate.wy-inline-validate-success .wy-input-context,.wy-inline-validate.wy-inline-validate-danger .wy-input-context,.wy-inline-validate.wy-inline-validate-warning .wy-input-context,.wy-inline-validate.wy-inline-validate-info .wy-input-context{font-family:inherit}.fa:before,.wy-menu-vertical li span.toctree-expand:before,.wy-menu-vertical li.on a span.toctree-expand:before,.wy-menu-vertical li.current>a span.toctree-expand:before,.rst-content .admonition-title:before,.rst-content h1 .headerlink:before,.rst-content h2 .headerlink:before,.rst-content h3 .headerlink:before,.rst-content h4 .headerlink:before,.rst-content h5 .headerlink:before,.rst-content h6 .headerlink:before,.rst-content dl dt .headerlink:before,.rst-content p.caption .headerlink:before,.rst-content table>caption .headerlink:before,.rst-content .code-block-caption .headerlink:before,.rst-content tt.download span:first-child:before,.rst-content code.download span:first-child:before,.icon:before,.wy-dropdown .caret:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before{font-family:"FontAwesome";display:inline-block;font-style:normal;font-weight:normal;line-height:1;text-decoration:inherit}a .fa,a .wy-menu-vertical li span.toctree-expand,.wy-menu-vertical li a span.toctree-expand,.wy-menu-vertical li.on a span.toctree-expand,.wy-menu-vertical li.current>a span.toctree-expand,a .rst-content .admonition-title,.rst-content a .admonition-title,a .rst-content h1 .headerlink,.rst-content h1 a .headerlink,a .rst-content h2 .headerlink,.rst-content h2 a .headerlink,a .rst-content h3 .headerlink,.rst-content h3 a .headerlink,a .rst-content h4 .headerlink,.rst-content h4 a .headerlink,a .rst-content h5 .headerlink,.rst-content h5 a .headerlink,a .rst-content h6 .headerlink,.rst-content h6 a .headerlink,a .rst-content dl dt .headerlink,.rst-content dl dt a .headerlink,a .rst-content p.caption .headerlink,.rst-content p.caption a .headerlink,a .rst-content table>caption .headerlink,.rst-content table>caption a .headerlink,a .rst-content .code-block-caption .headerlink,.rst-content .code-block-caption a .headerlink,a .rst-content tt.download span:first-child,.rst-content tt.download a span:first-child,a .rst-content code.download span:first-child,.rst-content code.download a span:first-child,a .icon{display:inline-block;text-decoration:inherit}.btn .fa,.btn .wy-menu-vertical li span.toctree-expand,.wy-menu-vertical li .btn span.toctree-expand,.btn .wy-menu-vertical li.on a span.toctree-expand,.wy-menu-vertical li.on a .btn span.toctree-expand,.btn .wy-menu-vertical li.current>a span.toctree-expand,.wy-menu-vertical li.current>a .btn span.toctree-expand,.btn .rst-content .admonition-title,.rst-content .btn .admonition-title,.btn .rst-content h1 .headerlink,.rst-content h1 .btn .headerlink,.btn .rst-content h2 .headerlink,.rst-content h2 .btn .headerlink,.btn .rst-content h3 .headerlink,.rst-content h3 .btn .headerlink,.btn .rst-content h4 .headerlink,.rst-content h4 .btn .headerlink,.btn .rst-content h5 .headerlink,.rst-content h5 .btn .headerlink,.btn .rst-content h6 .headerlink,.rst-content h6 .btn .headerlink,.btn .rst-content dl dt .headerlink,.rst-content dl dt .btn .headerlink,.btn .rst-content p.caption .headerlink,.rst-content p.caption .btn .headerlink,.btn .rst-content table>caption .headerlink,.rst-content table>caption .btn .headerlink,.btn .rst-content .code-block-caption .headerlink,.rst-content .code-block-caption .btn .headerlink,.btn .rst-content tt.download span:first-child,.rst-content tt.download .btn span:first-child,.btn .rst-content code.download span:first-child,.rst-content code.download .btn span:first-child,.btn .icon,.nav .fa,.nav .wy-menu-vertical li span.toctree-expand,.wy-menu-vertical li .nav span.toctree-expand,.nav .wy-menu-vertical li.on a span.toctree-expand,.wy-menu-vertical li.on a .nav span.toctree-expand,.nav .wy-menu-vertical li.current>a span.toctree-expand,.wy-menu-vertical li.current>a .nav span.toctree-expand,.nav .rst-content .admonition-title,.rst-content .nav .admonition-title,.nav .rst-content h1 .headerlink,.rst-content h1 .nav .headerlink,.nav .rst-content h2 .headerlink,.rst-content h2 .nav .headerlink,.nav .rst-content h3 .headerlink,.rst-content h3 .nav .headerlink,.nav .rst-content h4 .headerlink,.rst-content h4 .nav .headerlink,.nav .rst-content h5 .headerlink,.rst-content h5 .nav .headerlink,.nav .rst-content h6 .headerlink,.rst-content h6 .nav .headerlink,.nav .rst-content dl dt .headerlink,.rst-content dl dt .nav .headerlink,.nav .rst-content p.caption .headerlink,.rst-content p.caption .nav .headerlink,.nav .rst-content table>caption .headerlink,.rst-content table>caption .nav .headerlink,.nav .rst-content .code-block-caption .headerlink,.rst-content .code-block-caption .nav .headerlink,.nav .rst-content tt.download span:first-child,.rst-content tt.download .nav span:first-child,.nav .rst-content code.download span:first-child,.rst-content code.download .nav span:first-child,.nav .icon{display:inline}.btn .fa.fa-large,.btn .wy-menu-vertical li span.fa-large.toctree-expand,.wy-menu-vertical li .btn span.fa-large.toctree-expand,.btn .rst-content .fa-large.admonition-title,.rst-content .btn .fa-large.admonition-title,.btn .rst-content h1 .fa-large.headerlink,.rst-content h1 .btn .fa-large.headerlink,.btn .rst-content h2 .fa-large.headerlink,.rst-content h2 .btn .fa-large.headerlink,.btn .rst-content h3 .fa-large.headerlink,.rst-content h3 .btn .fa-large.headerlink,.btn .rst-content h4 .fa-large.headerlink,.rst-content h4 .btn .fa-large.headerlink,.btn .rst-content h5 .fa-large.headerlink,.rst-content h5 .btn .fa-large.headerlink,.btn .rst-content h6 .fa-large.headerlink,.rst-content h6 .btn .fa-large.headerlink,.btn .rst-content dl dt .fa-large.headerlink,.rst-content dl dt .btn .fa-large.headerlink,.btn .rst-content p.caption .fa-large.headerlink,.rst-content p.caption .btn .fa-large.headerlink,.btn .rst-content table>caption .fa-large.headerlink,.rst-content table>caption .btn .fa-large.headerlink,.btn .rst-content .code-block-caption .fa-large.headerlink,.rst-content .code-block-caption .btn .fa-large.headerlink,.btn .rst-content tt.download span.fa-large:first-child,.rst-content tt.download .btn span.fa-large:first-child,.btn .rst-content code.download span.fa-large:first-child,.rst-content code.download .btn span.fa-large:first-child,.btn .fa-large.icon,.nav .fa.fa-large,.nav .wy-menu-vertical li span.fa-large.toctree-expand,.wy-menu-vertical li .nav span.fa-large.toctree-expand,.nav .rst-content .fa-large.admonition-title,.rst-content .nav .fa-large.admonition-title,.nav .rst-content h1 .fa-large.headerlink,.rst-content h1 .nav .fa-large.headerlink,.nav .rst-content h2 .fa-large.headerlink,.rst-content h2 .nav .fa-large.headerlink,.nav .rst-content h3 .fa-large.headerlink,.rst-content h3 .nav .fa-large.headerlink,.nav .rst-content h4 .fa-large.headerlink,.rst-content h4 .nav .fa-large.headerlink,.nav .rst-content h5 .fa-large.headerlink,.rst-content h5 .nav .fa-large.headerlink,.nav .rst-content h6 .fa-large.headerlink,.rst-content h6 .nav .fa-large.headerlink,.nav .rst-content dl dt .fa-large.headerlink,.rst-content dl dt .nav .fa-large.headerlink,.nav .rst-content p.caption .fa-large.headerlink,.rst-content p.caption .nav .fa-large.headerlink,.nav .rst-content table>caption .fa-large.headerlink,.rst-content table>caption .nav .fa-large.headerlink,.nav .rst-content .code-block-caption .fa-large.headerlink,.rst-content .code-block-caption .nav .fa-large.headerlink,.nav .rst-content tt.download span.fa-large:first-child,.rst-content tt.download .nav span.fa-large:first-child,.nav .rst-content code.download span.fa-large:first-child,.rst-content code.download .nav span.fa-large:first-child,.nav .fa-large.icon{line-height:.9em}.btn .fa.fa-spin,.btn .wy-menu-vertical li span.fa-spin.toctree-expand,.wy-menu-vertical li .btn span.fa-spin.toctree-expand,.btn .rst-content .fa-spin.admonition-title,.rst-content .btn .fa-spin.admonition-title,.btn .rst-content h1 .fa-spin.headerlink,.rst-content h1 .btn .fa-spin.headerlink,.btn .rst-content h2 .fa-spin.headerlink,.rst-content h2 .btn .fa-spin.headerlink,.btn .rst-content h3 .fa-spin.headerlink,.rst-content h3 .btn .fa-spin.headerlink,.btn .rst-content h4 .fa-spin.headerlink,.rst-content h4 .btn .fa-spin.headerlink,.btn .rst-content h5 .fa-spin.headerlink,.rst-content h5 .btn .fa-spin.headerlink,.btn .rst-content h6 .fa-spin.headerlink,.rst-content h6 .btn .fa-spin.headerlink,.btn .rst-content dl dt .fa-spin.headerlink,.rst-content dl dt .btn .fa-spin.headerlink,.btn .rst-content p.caption .fa-spin.headerlink,.rst-content p.caption .btn .fa-spin.headerlink,.btn .rst-content table>caption .fa-spin.headerlink,.rst-content table>caption .btn .fa-spin.headerlink,.btn .rst-content .code-block-caption .fa-spin.headerlink,.rst-content .code-block-caption .btn .fa-spin.headerlink,.btn .rst-content tt.download span.fa-spin:first-child,.rst-content tt.download .btn span.fa-spin:first-child,.btn .rst-content code.download span.fa-spin:first-child,.rst-content code.download .btn span.fa-spin:first-child,.btn .fa-spin.icon,.nav .fa.fa-spin,.nav .wy-menu-vertical li span.fa-spin.toctree-expand,.wy-menu-vertical li .nav span.fa-spin.toctree-expand,.nav .rst-content .fa-spin.admonition-title,.rst-content .nav .fa-spin.admonition-title,.nav .rst-content h1 .fa-spin.headerlink,.rst-content h1 .nav .fa-spin.headerlink,.nav .rst-content h2 .fa-spin.headerlink,.rst-content h2 .nav .fa-spin.headerlink,.nav .rst-content h3 .fa-spin.headerlink,.rst-content h3 .nav .fa-spin.headerlink,.nav .rst-content h4 .fa-spin.headerlink,.rst-content h4 .nav .fa-spin.headerlink,.nav .rst-content h5 .fa-spin.headerlink,.rst-content h5 .nav .fa-spin.headerlink,.nav .rst-content h6 .fa-spin.headerlink,.rst-content h6 .nav .fa-spin.headerlink,.nav .rst-content dl dt .fa-spin.headerlink,.rst-content dl dt .nav .fa-spin.headerlink,.nav .rst-content p.caption .fa-spin.headerlink,.rst-content p.caption .nav .fa-spin.headerlink,.nav .rst-content table>caption .fa-spin.headerlink,.rst-content table>caption .nav .fa-spin.headerlink,.nav .rst-content .code-block-caption .fa-spin.headerlink,.rst-content .code-block-caption .nav .fa-spin.headerlink,.nav .rst-content tt.download span.fa-spin:first-child,.rst-content tt.download .nav span.fa-spin:first-child,.nav .rst-content code.download span.fa-spin:first-child,.rst-content code.download .nav span.fa-spin:first-child,.nav .fa-spin.icon{display:inline-block}.btn.fa:before,.wy-menu-vertical li span.btn.toctree-expand:before,.rst-content .btn.admonition-title:before,.rst-content h1 .btn.headerlink:before,.rst-content h2 .btn.headerlink:before,.rst-content h3 .btn.headerlink:before,.rst-content h4 .btn.headerlink:before,.rst-content h5 .btn.headerlink:before,.rst-content h6 .btn.headerlink:before,.rst-content dl dt .btn.headerlink:before,.rst-content p.caption .btn.headerlink:before,.rst-content table>caption .btn.headerlink:before,.rst-content .code-block-caption .btn.headerlink:before,.rst-content tt.download span.btn:first-child:before,.rst-content code.download span.btn:first-child:before,.btn.icon:before{opacity:.5;-webkit-transition:opacity .05s ease-in;-moz-transition:opacity .05s ease-in;transition:opacity .05s ease-in}.btn.fa:hover:before,.wy-menu-vertical li span.btn.toctree-expand:hover:before,.rst-content .btn.admonition-title:hover:before,.rst-content h1 .btn.headerlink:hover:before,.rst-content h2 .btn.headerlink:hover:before,.rst-content h3 .btn.headerlink:hover:before,.rst-content h4 .btn.headerlink:hover:before,.rst-content h5 .btn.headerlink:hover:before,.rst-content h6 .btn.headerlink:hover:before,.rst-content dl dt .btn.headerlink:hover:before,.rst-content p.caption .btn.headerlink:hover:before,.rst-content table>caption .btn.headerlink:hover:before,.rst-content .code-block-caption .btn.headerlink:hover:before,.rst-content tt.download span.btn:first-child:hover:before,.rst-content code.download span.btn:first-child:hover:before,.btn.icon:hover:before{opacity:1}.btn-mini .fa:before,.btn-mini .wy-menu-vertical li span.toctree-expand:before,.wy-menu-vertical li .btn-mini span.toctree-expand:before,.btn-mini .rst-content .admonition-title:before,.rst-content .btn-mini .admonition-title:before,.btn-mini .rst-content h1 .headerlink:before,.rst-content h1 .btn-mini .headerlink:before,.btn-mini .rst-content h2 .headerlink:before,.rst-content h2 .btn-mini .headerlink:before,.btn-mini .rst-content h3 .headerlink:before,.rst-content h3 .btn-mini .headerlink:before,.btn-mini .rst-content h4 .headerlink:before,.rst-content h4 .btn-mini .headerlink:before,.btn-mini .rst-content h5 .headerlink:before,.rst-content h5 .btn-mini .headerlink:before,.btn-mini .rst-content h6 .headerlink:before,.rst-content h6 .btn-mini .headerlink:before,.btn-mini .rst-content dl dt .headerlink:before,.rst-content dl dt .btn-mini .headerlink:before,.btn-mini .rst-content p.caption .headerlink:before,.rst-content p.caption .btn-mini .headerlink:before,.btn-mini .rst-content table>caption .headerlink:before,.rst-content table>caption .btn-mini .headerlink:before,.btn-mini .rst-content .code-block-caption .headerlink:before,.rst-content .code-block-caption .btn-mini .headerlink:before,.btn-mini .rst-content tt.download span:first-child:before,.rst-content tt.download .btn-mini span:first-child:before,.btn-mini .rst-content code.download span:first-child:before,.rst-content code.download .btn-mini span:first-child:before,.btn-mini .icon:before{font-size:14px;vertical-align:-15%}.wy-alert,.rst-content .note,.rst-content .attention,.rst-content .caution,.rst-content .danger,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .tip,.rst-content .warning,.rst-content .seealso,.rst-content .admonition-todo,.rst-content .admonition{padding:12px;line-height:24px;margin-bottom:24px;background:#e7f2fa}.wy-alert-title,.rst-content .admonition-title{color:#fff;font-weight:bold;display:block;color:#fff;background:#6ab0de;margin:-12px;padding:6px 12px;margin-bottom:12px}.wy-alert.wy-alert-danger,.rst-content .wy-alert-danger.note,.rst-content .wy-alert-danger.attention,.rst-content .wy-alert-danger.caution,.rst-content .danger,.rst-content .error,.rst-content .wy-alert-danger.hint,.rst-content .wy-alert-danger.important,.rst-content .wy-alert-danger.tip,.rst-content .wy-alert-danger.warning,.rst-content .wy-alert-danger.seealso,.rst-content .wy-alert-danger.admonition-todo,.rst-content .wy-alert-danger.admonition{background:#fdf3f2}.wy-alert.wy-alert-danger .wy-alert-title,.rst-content .wy-alert-danger.note .wy-alert-title,.rst-content .wy-alert-danger.attention .wy-alert-title,.rst-content .wy-alert-danger.caution .wy-alert-title,.rst-content .danger .wy-alert-title,.rst-content .error .wy-alert-title,.rst-content .wy-alert-danger.hint .wy-alert-title,.rst-content .wy-alert-danger.important .wy-alert-title,.rst-content .wy-alert-danger.tip .wy-alert-title,.rst-content .wy-alert-danger.warning .wy-alert-title,.rst-content .wy-alert-danger.seealso .wy-alert-title,.rst-content .wy-alert-danger.admonition-todo .wy-alert-title,.rst-content .wy-alert-danger.admonition .wy-alert-title,.wy-alert.wy-alert-danger .rst-content .admonition-title,.rst-content .wy-alert.wy-alert-danger .admonition-title,.rst-content .wy-alert-danger.note .admonition-title,.rst-content .wy-alert-danger.attention .admonition-title,.rst-content .wy-alert-danger.caution .admonition-title,.rst-content .danger .admonition-title,.rst-content .error .admonition-title,.rst-content .wy-alert-danger.hint .admonition-title,.rst-content .wy-alert-danger.important .admonition-title,.rst-content .wy-alert-danger.tip .admonition-title,.rst-content .wy-alert-danger.warning .admonition-title,.rst-content .wy-alert-danger.seealso .admonition-title,.rst-content .wy-alert-danger.admonition-todo .admonition-title,.rst-content .wy-alert-danger.admonition .admonition-title{background:#f29f97}.wy-alert.wy-alert-warning,.rst-content .wy-alert-warning.note,.rst-content .attention,.rst-content .caution,.rst-content .wy-alert-warning.danger,.rst-content .wy-alert-warning.error,.rst-content .wy-alert-warning.hint,.rst-content .wy-alert-warning.important,.rst-content .wy-alert-warning.tip,.rst-content .warning,.rst-content .wy-alert-warning.seealso,.rst-content .admonition-todo,.rst-content .wy-alert-warning.admonition{background:#ffedcc}.wy-alert.wy-alert-warning .wy-alert-title,.rst-content .wy-alert-warning.note .wy-alert-title,.rst-content .attention .wy-alert-title,.rst-content .caution .wy-alert-title,.rst-content .wy-alert-warning.danger .wy-alert-title,.rst-content .wy-alert-warning.error .wy-alert-title,.rst-content .wy-alert-warning.hint .wy-alert-title,.rst-content .wy-alert-warning.important .wy-alert-title,.rst-content .wy-alert-warning.tip .wy-alert-title,.rst-content .warning .wy-alert-title,.rst-content .wy-alert-warning.seealso .wy-alert-title,.rst-content .admonition-todo .wy-alert-title,.rst-content .wy-alert-warning.admonition .wy-alert-title,.wy-alert.wy-alert-warning .rst-content .admonition-title,.rst-content .wy-alert.wy-alert-warning .admonition-title,.rst-content .wy-alert-warning.note .admonition-title,.rst-content .attention .admonition-title,.rst-content .caution .admonition-title,.rst-content .wy-alert-warning.danger .admonition-title,.rst-content .wy-alert-warning.error .admonition-title,.rst-content .wy-alert-warning.hint .admonition-title,.rst-content .wy-alert-warning.important .admonition-title,.rst-content .wy-alert-warning.tip .admonition-title,.rst-content .warning .admonition-title,.rst-content .wy-alert-warning.seealso .admonition-title,.rst-content .admonition-todo .admonition-title,.rst-content .wy-alert-warning.admonition .admonition-title{background:#f0b37e}.wy-alert.wy-alert-info,.rst-content .note,.rst-content .wy-alert-info.attention,.rst-content .wy-alert-info.caution,.rst-content .wy-alert-info.danger,.rst-content .wy-alert-info.error,.rst-content .wy-alert-info.hint,.rst-content .wy-alert-info.important,.rst-content .wy-alert-info.tip,.rst-content .wy-alert-info.warning,.rst-content .seealso,.rst-content .wy-alert-info.admonition-todo,.rst-content .wy-alert-info.admonition{background:#e7f2fa}.wy-alert.wy-alert-info .wy-alert-title,.rst-content .note .wy-alert-title,.rst-content .wy-alert-info.attention .wy-alert-title,.rst-content .wy-alert-info.caution .wy-alert-title,.rst-content .wy-alert-info.danger .wy-alert-title,.rst-content .wy-alert-info.error .wy-alert-title,.rst-content .wy-alert-info.hint .wy-alert-title,.rst-content .wy-alert-info.important .wy-alert-title,.rst-content .wy-alert-info.tip .wy-alert-title,.rst-content .wy-alert-info.warning .wy-alert-title,.rst-content .seealso .wy-alert-title,.rst-content .wy-alert-info.admonition-todo .wy-alert-title,.rst-content .wy-alert-info.admonition .wy-alert-title,.wy-alert.wy-alert-info .rst-content .admonition-title,.rst-content .wy-alert.wy-alert-info .admonition-title,.rst-content .note .admonition-title,.rst-content .wy-alert-info.attention .admonition-title,.rst-content .wy-alert-info.caution .admonition-title,.rst-content .wy-alert-info.danger .admonition-title,.rst-content .wy-alert-info.error .admonition-title,.rst-content .wy-alert-info.hint .admonition-title,.rst-content .wy-alert-info.important .admonition-title,.rst-content .wy-alert-info.tip .admonition-title,.rst-content .wy-alert-info.warning .admonition-title,.rst-content .seealso .admonition-title,.rst-content .wy-alert-info.admonition-todo .admonition-title,.rst-content .wy-alert-info.admonition .admonition-title{background:#6ab0de}.wy-alert.wy-alert-success,.rst-content .wy-alert-success.note,.rst-content .wy-alert-success.attention,.rst-content .wy-alert-success.caution,.rst-content .wy-alert-success.danger,.rst-content .wy-alert-success.error,.rst-content .hint,.rst-content .important,.rst-content .tip,.rst-content .wy-alert-success.warning,.rst-content .wy-alert-success.seealso,.rst-content .wy-alert-success.admonition-todo,.rst-content .wy-alert-success.admonition{background:#dbfaf4}.wy-alert.wy-alert-success .wy-alert-title,.rst-content .wy-alert-success.note .wy-alert-title,.rst-content .wy-alert-success.attention .wy-alert-title,.rst-content .wy-alert-success.caution .wy-alert-title,.rst-content .wy-alert-success.danger .wy-alert-title,.rst-content .wy-alert-success.error .wy-alert-title,.rst-content .hint .wy-alert-title,.rst-content .important .wy-alert-title,.rst-content .tip .wy-alert-title,.rst-content .wy-alert-success.warning .wy-alert-title,.rst-content .wy-alert-success.seealso .wy-alert-title,.rst-content .wy-alert-success.admonition-todo .wy-alert-title,.rst-content .wy-alert-success.admonition .wy-alert-title,.wy-alert.wy-alert-success .rst-content .admonition-title,.rst-content .wy-alert.wy-alert-success .admonition-title,.rst-content .wy-alert-success.note .admonition-title,.rst-content .wy-alert-success.attention .admonition-title,.rst-content .wy-alert-success.caution .admonition-title,.rst-content .wy-alert-success.danger .admonition-title,.rst-content .wy-alert-success.error .admonition-title,.rst-content .hint .admonition-title,.rst-content .important .admonition-title,.rst-content .tip .admonition-title,.rst-content .wy-alert-success.warning .admonition-title,.rst-content .wy-alert-success.seealso .admonition-title,.rst-content .wy-alert-success.admonition-todo .admonition-title,.rst-content .wy-alert-success.admonition .admonition-title{background:#1abc9c}.wy-alert.wy-alert-neutral,.rst-content .wy-alert-neutral.note,.rst-content .wy-alert-neutral.attention,.rst-content .wy-alert-neutral.caution,.rst-content .wy-alert-neutral.danger,.rst-content .wy-alert-neutral.error,.rst-content .wy-alert-neutral.hint,.rst-content .wy-alert-neutral.important,.rst-content .wy-alert-neutral.tip,.rst-content .wy-alert-neutral.warning,.rst-content .wy-alert-neutral.seealso,.rst-content .wy-alert-neutral.admonition-todo,.rst-content .wy-alert-neutral.admonition{background:#f3f6f6}.wy-alert.wy-alert-neutral .wy-alert-title,.rst-content .wy-alert-neutral.note .wy-alert-title,.rst-content .wy-alert-neutral.attention .wy-alert-title,.rst-content .wy-alert-neutral.caution .wy-alert-title,.rst-content .wy-alert-neutral.danger .wy-alert-title,.rst-content .wy-alert-neutral.error .wy-alert-title,.rst-content .wy-alert-neutral.hint .wy-alert-title,.rst-content .wy-alert-neutral.important .wy-alert-title,.rst-content .wy-alert-neutral.tip .wy-alert-title,.rst-content .wy-alert-neutral.warning .wy-alert-title,.rst-content .wy-alert-neutral.seealso .wy-alert-title,.rst-content .wy-alert-neutral.admonition-todo .wy-alert-title,.rst-content .wy-alert-neutral.admonition .wy-alert-title,.wy-alert.wy-alert-neutral .rst-content .admonition-title,.rst-content .wy-alert.wy-alert-neutral .admonition-title,.rst-content .wy-alert-neutral.note .admonition-title,.rst-content .wy-alert-neutral.attention .admonition-title,.rst-content .wy-alert-neutral.caution .admonition-title,.rst-content .wy-alert-neutral.danger .admonition-title,.rst-content .wy-alert-neutral.error .admonition-title,.rst-content .wy-alert-neutral.hint .admonition-title,.rst-content .wy-alert-neutral.important .admonition-title,.rst-content .wy-alert-neutral.tip .admonition-title,.rst-content .wy-alert-neutral.warning .admonition-title,.rst-content .wy-alert-neutral.seealso .admonition-title,.rst-content .wy-alert-neutral.admonition-todo .admonition-title,.rst-content .wy-alert-neutral.admonition .admonition-title{color:#404040;background:#e1e4e5}.wy-alert.wy-alert-neutral a,.rst-content .wy-alert-neutral.note a,.rst-content .wy-alert-neutral.attention a,.rst-content .wy-alert-neutral.caution a,.rst-content .wy-alert-neutral.danger a,.rst-content .wy-alert-neutral.error a,.rst-content .wy-alert-neutral.hint a,.rst-content .wy-alert-neutral.important a,.rst-content .wy-alert-neutral.tip a,.rst-content .wy-alert-neutral.warning a,.rst-content .wy-alert-neutral.seealso a,.rst-content .wy-alert-neutral.admonition-todo a,.rst-content .wy-alert-neutral.admonition a{color:#2980B9}.wy-alert p:last-child,.rst-content .note p:last-child,.rst-content .attention p:last-child,.rst-content .caution p:last-child,.rst-content .danger p:last-child,.rst-content .error p:last-child,.rst-content .hint p:last-child,.rst-content .important p:last-child,.rst-content .tip p:last-child,.rst-content .warning p:last-child,.rst-content .seealso p:last-child,.rst-content .admonition-todo p:last-child,.rst-content .admonition p:last-child{margin-bottom:0}.wy-tray-container{position:fixed;bottom:0px;left:0;z-index:600}.wy-tray-container li{display:block;width:300px;background:transparent;color:#fff;text-align:center;box-shadow:0 5px 5px 0 rgba(0,0,0,0.1);padding:0 24px;min-width:20%;opacity:0;height:0;line-height:56px;overflow:hidden;-webkit-transition:all .3s ease-in;-moz-transition:all .3s ease-in;transition:all .3s ease-in}.wy-tray-container li.wy-tray-item-success{background:#27AE60}.wy-tray-container li.wy-tray-item-info{background:#2980B9}.wy-tray-container li.wy-tray-item-warning{background:#E67E22}.wy-tray-container li.wy-tray-item-danger{background:#E74C3C}.wy-tray-container li.on{opacity:1;height:56px}@media screen and (max-width: 768px){.wy-tray-container{bottom:auto;top:0;width:100%}.wy-tray-container li{width:100%}}button{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle;cursor:pointer;line-height:normal;-webkit-appearance:button;*overflow:visible}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}button[disabled]{cursor:default}.btn{display:inline-block;border-radius:2px;line-height:normal;white-space:nowrap;text-align:center;cursor:pointer;font-size:100%;padding:6px 12px 8px 12px;color:#fff;border:1px solid rgba(0,0,0,0.1);background-color:#27AE60;text-decoration:none;font-weight:normal;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;box-shadow:0px 1px 2px -1px rgba(255,255,255,0.5) inset,0px -2px 0px 0px rgba(0,0,0,0.1) inset;outline-none:false;vertical-align:middle;*display:inline;zoom:1;-webkit-user-drag:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transition:all .1s linear;-moz-transition:all .1s linear;transition:all .1s linear}.btn-hover{background:#2e8ece;color:#fff}.btn:hover{background:#2cc36b;color:#fff}.btn:focus{background:#2cc36b;outline:0}.btn:active{box-shadow:0px -1px 0px 0px rgba(0,0,0,0.05) inset,0px 2px 0px 0px rgba(0,0,0,0.1) inset;padding:8px 12px 6px 12px}.btn:visited{color:#fff}.btn:disabled{background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);filter:alpha(opacity=40);opacity:.4;cursor:not-allowed;box-shadow:none}.btn-disabled{background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);filter:alpha(opacity=40);opacity:.4;cursor:not-allowed;box-shadow:none}.btn-disabled:hover,.btn-disabled:focus,.btn-disabled:active{background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);filter:alpha(opacity=40);opacity:.4;cursor:not-allowed;box-shadow:none}.btn::-moz-focus-inner{padding:0;border:0}.btn-small{font-size:80%}.btn-info{background-color:#2980B9 !important}.btn-info:hover{background-color:#2e8ece !important}.btn-neutral{background-color:#f3f6f6 !important;color:#404040 !important}.btn-neutral:hover{background-color:#e5ebeb !important;color:#404040}.btn-neutral:visited{color:#404040 !important}.btn-success{background-color:#27AE60 !important}.btn-success:hover{background-color:#295 !important}.btn-danger{background-color:#E74C3C !important}.btn-danger:hover{background-color:#ea6153 !important}.btn-warning{background-color:#E67E22 !important}.btn-warning:hover{background-color:#e98b39 !important}.btn-invert{background-color:#222}.btn-invert:hover{background-color:#2f2f2f !important}.btn-link{background-color:transparent !important;color:#2980B9;box-shadow:none;border-color:transparent !important}.btn-link:hover{background-color:transparent !important;color:#409ad5 !important;box-shadow:none}.btn-link:active{background-color:transparent !important;color:#409ad5 !important;box-shadow:none}.btn-link:visited{color:#9B59B6}.wy-btn-group .btn,.wy-control .btn{vertical-align:middle}.wy-btn-group{margin-bottom:24px;*zoom:1}.wy-btn-group:before,.wy-btn-group:after{display:table;content:""}.wy-btn-group:after{clear:both}.wy-dropdown{position:relative;display:inline-block}.wy-dropdown-active .wy-dropdown-menu{display:block}.wy-dropdown-menu{position:absolute;left:0;display:none;float:left;top:100%;min-width:100%;background:#fcfcfc;z-index:100;border:solid 1px #cfd7dd;box-shadow:0 2px 2px 0 rgba(0,0,0,0.1);padding:12px}.wy-dropdown-menu>dd>a{display:block;clear:both;color:#404040;white-space:nowrap;font-size:90%;padding:0 12px;cursor:pointer}.wy-dropdown-menu>dd>a:hover{background:#2980B9;color:#fff}.wy-dropdown-menu>dd.divider{border-top:solid 1px #cfd7dd;margin:6px 0}.wy-dropdown-menu>dd.search{padding-bottom:12px}.wy-dropdown-menu>dd.search input[type="search"]{width:100%}.wy-dropdown-menu>dd.call-to-action{background:#e3e3e3;text-transform:uppercase;font-weight:500;font-size:80%}.wy-dropdown-menu>dd.call-to-action:hover{background:#e3e3e3}.wy-dropdown-menu>dd.call-to-action .btn{color:#fff}.wy-dropdown.wy-dropdown-up .wy-dropdown-menu{bottom:100%;top:auto;left:auto;right:0}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu{background:#fcfcfc;margin-top:2px}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu a{padding:6px 12px}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu a:hover{background:#2980B9;color:#fff}.wy-dropdown.wy-dropdown-left .wy-dropdown-menu{right:0;left:auto;text-align:right}.wy-dropdown-arrow:before{content:" ";border-bottom:5px solid #f5f5f5;border-left:5px solid transparent;border-right:5px solid transparent;position:absolute;display:block;top:-4px;left:50%;margin-left:-3px}.wy-dropdown-arrow.wy-dropdown-arrow-left:before{left:11px}.wy-form-stacked select{display:block}.wy-form-aligned input,.wy-form-aligned textarea,.wy-form-aligned select,.wy-form-aligned .wy-help-inline,.wy-form-aligned label{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.wy-form-aligned .wy-control-group>label{display:inline-block;vertical-align:middle;width:10em;margin:6px 12px 0 0;float:left}.wy-form-aligned .wy-control{float:left}.wy-form-aligned .wy-control label{display:block}.wy-form-aligned .wy-control select{margin-top:6px}fieldset{border:0;margin:0;padding:0}legend{display:block;width:100%;border:0;padding:0;white-space:normal;margin-bottom:24px;font-size:150%;*margin-left:-7px}label{display:block;margin:0 0 .3125em 0;color:#333;font-size:90%}input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}.wy-control-group{margin-bottom:24px;*zoom:1;max-width:68em;margin-left:auto;margin-right:auto;*zoom:1}.wy-control-group:before,.wy-control-group:after{display:table;content:""}.wy-control-group:after{clear:both}.wy-control-group:before,.wy-control-group:after{display:table;content:""}.wy-control-group:after{clear:both}.wy-control-group.wy-control-group-required>label:after{content:" *";color:#E74C3C}.wy-control-group .wy-form-full,.wy-control-group .wy-form-halves,.wy-control-group .wy-form-thirds{padding-bottom:12px}.wy-control-group .wy-form-full select,.wy-control-group .wy-form-halves select,.wy-control-group .wy-form-thirds select{width:100%}.wy-control-group .wy-form-full input[type="text"],.wy-control-group .wy-form-full input[type="password"],.wy-control-group .wy-form-full input[type="email"],.wy-control-group .wy-form-full input[type="url"],.wy-control-group .wy-form-full input[type="date"],.wy-control-group .wy-form-full input[type="month"],.wy-control-group .wy-form-full input[type="time"],.wy-control-group .wy-form-full input[type="datetime"],.wy-control-group .wy-form-full input[type="datetime-local"],.wy-control-group .wy-form-full input[type="week"],.wy-control-group .wy-form-full input[type="number"],.wy-control-group .wy-form-full input[type="search"],.wy-control-group .wy-form-full input[type="tel"],.wy-control-group .wy-form-full input[type="color"],.wy-control-group .wy-form-halves input[type="text"],.wy-control-group .wy-form-halves input[type="password"],.wy-control-group .wy-form-halves input[type="email"],.wy-control-group .wy-form-halves input[type="url"],.wy-control-group .wy-form-halves input[type="date"],.wy-control-group .wy-form-halves input[type="month"],.wy-control-group .wy-form-halves input[type="time"],.wy-control-group .wy-form-halves input[type="datetime"],.wy-control-group .wy-form-halves input[type="datetime-local"],.wy-control-group .wy-form-halves input[type="week"],.wy-control-group .wy-form-halves input[type="number"],.wy-control-group .wy-form-halves input[type="search"],.wy-control-group .wy-form-halves input[type="tel"],.wy-control-group .wy-form-halves input[type="color"],.wy-control-group .wy-form-thirds input[type="text"],.wy-control-group .wy-form-thirds input[type="password"],.wy-control-group .wy-form-thirds input[type="email"],.wy-control-group .wy-form-thirds input[type="url"],.wy-control-group .wy-form-thirds input[type="date"],.wy-control-group .wy-form-thirds input[type="month"],.wy-control-group .wy-form-thirds input[type="time"],.wy-control-group .wy-form-thirds input[type="datetime"],.wy-control-group .wy-form-thirds input[type="datetime-local"],.wy-control-group .wy-form-thirds input[type="week"],.wy-control-group .wy-form-thirds input[type="number"],.wy-control-group .wy-form-thirds input[type="search"],.wy-control-group .wy-form-thirds input[type="tel"],.wy-control-group .wy-form-thirds input[type="color"]{width:100%}.wy-control-group .wy-form-full{float:left;display:block;margin-right:2.3576515979%;width:100%;margin-right:0}.wy-control-group .wy-form-full:last-child{margin-right:0}.wy-control-group .wy-form-halves{float:left;display:block;margin-right:2.3576515979%;width:48.821174201%}.wy-control-group .wy-form-halves:last-child{margin-right:0}.wy-control-group .wy-form-halves:nth-of-type(2n){margin-right:0}.wy-control-group .wy-form-halves:nth-of-type(2n+1){clear:left}.wy-control-group .wy-form-thirds{float:left;display:block;margin-right:2.3576515979%;width:31.7615656014%}.wy-control-group .wy-form-thirds:last-child{margin-right:0}.wy-control-group .wy-form-thirds:nth-of-type(3n){margin-right:0}.wy-control-group .wy-form-thirds:nth-of-type(3n+1){clear:left}.wy-control-group.wy-control-group-no-input .wy-control{margin:6px 0 0 0;font-size:90%}.wy-control-no-input{display:inline-block;margin:6px 0 0 0;font-size:90%}.wy-control-group.fluid-input input[type="text"],.wy-control-group.fluid-input input[type="password"],.wy-control-group.fluid-input input[type="email"],.wy-control-group.fluid-input input[type="url"],.wy-control-group.fluid-input input[type="date"],.wy-control-group.fluid-input input[type="month"],.wy-control-group.fluid-input input[type="time"],.wy-control-group.fluid-input input[type="datetime"],.wy-control-group.fluid-input input[type="datetime-local"],.wy-control-group.fluid-input input[type="week"],.wy-control-group.fluid-input input[type="number"],.wy-control-group.fluid-input input[type="search"],.wy-control-group.fluid-input input[type="tel"],.wy-control-group.fluid-input input[type="color"]{width:100%}.wy-form-message-inline{display:inline-block;padding-left:.3em;color:#666;vertical-align:middle;font-size:90%}.wy-form-message{display:block;color:#999;font-size:70%;margin-top:.3125em;font-style:italic}.wy-form-message p{font-size:inherit;font-style:italic;margin-bottom:6px}.wy-form-message p:last-child{margin-bottom:0}input{line-height:normal}input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;*overflow:visible}input[type="text"],input[type="password"],input[type="email"],input[type="url"],input[type="date"],input[type="month"],input[type="time"],input[type="datetime"],input[type="datetime-local"],input[type="week"],input[type="number"],input[type="search"],input[type="tel"],input[type="color"]{-webkit-appearance:none;padding:6px;display:inline-block;border:1px solid #ccc;font-size:80%;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;box-shadow:inset 0 1px 3px #ddd;border-radius:0;-webkit-transition:border .3s linear;-moz-transition:border .3s linear;transition:border .3s linear}input[type="datetime-local"]{padding:.34375em .625em}input[disabled]{cursor:default}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0;margin-right:.3125em;*height:13px;*width:13px}input[type="search"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}input[type="text"]:focus,input[type="password"]:focus,input[type="email"]:focus,input[type="url"]:focus,input[type="date"]:focus,input[type="month"]:focus,input[type="time"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="week"]:focus,input[type="number"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="color"]:focus{outline:0;outline:thin dotted \9;border-color:#333}input.no-focus:focus{border-color:#ccc !important}input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:1px auto #129FEA}input[type="text"][disabled],input[type="password"][disabled],input[type="email"][disabled],input[type="url"][disabled],input[type="date"][disabled],input[type="month"][disabled],input[type="time"][disabled],input[type="datetime"][disabled],input[type="datetime-local"][disabled],input[type="week"][disabled],input[type="number"][disabled],input[type="search"][disabled],input[type="tel"][disabled],input[type="color"][disabled]{cursor:not-allowed;background-color:#fafafa}input:focus:invalid,textarea:focus:invalid,select:focus:invalid{color:#E74C3C;border:1px solid #E74C3C}input:focus:invalid:focus,textarea:focus:invalid:focus,select:focus:invalid:focus{border-color:#E74C3C}input[type="file"]:focus:invalid:focus,input[type="radio"]:focus:invalid:focus,input[type="checkbox"]:focus:invalid:focus{outline-color:#E74C3C}input.wy-input-large{padding:12px;font-size:100%}textarea{overflow:auto;vertical-align:top;width:100%;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif}select,textarea{padding:.5em .625em;display:inline-block;border:1px solid #ccc;font-size:80%;box-shadow:inset 0 1px 3px #ddd;-webkit-transition:border .3s linear;-moz-transition:border .3s linear;transition:border .3s linear}select{border:1px solid #ccc;background-color:#fff}select[multiple]{height:auto}select:focus,textarea:focus{outline:0}select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{cursor:not-allowed;background-color:#fafafa}input[type="radio"][disabled],input[type="checkbox"][disabled]{cursor:not-allowed}.wy-checkbox,.wy-radio{margin:6px 0;color:#404040;display:block}.wy-checkbox input,.wy-radio input{vertical-align:baseline}.wy-form-message-inline{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.wy-input-prefix,.wy-input-suffix{white-space:nowrap;padding:6px}.wy-input-prefix .wy-input-context,.wy-input-suffix .wy-input-context{line-height:27px;padding:0 8px;display:inline-block;font-size:80%;background-color:#f3f6f6;border:solid 1px #ccc;color:#999}.wy-input-suffix .wy-input-context{border-left:0}.wy-input-prefix .wy-input-context{border-right:0}.wy-switch{position:relative;display:block;height:24px;margin-top:12px;cursor:pointer}.wy-switch:before{position:absolute;content:"";display:block;left:0;top:0;width:36px;height:12px;border-radius:4px;background:#ccc;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.wy-switch:after{position:absolute;content:"";display:block;width:18px;height:18px;border-radius:4px;background:#999;left:-3px;top:-3px;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.wy-switch span{position:absolute;left:48px;display:block;font-size:12px;color:#ccc;line-height:1}.wy-switch.active:before{background:#1e8449}.wy-switch.active:after{left:24px;background:#27AE60}.wy-switch.disabled{cursor:not-allowed;opacity:.8}.wy-control-group.wy-control-group-error .wy-form-message,.wy-control-group.wy-control-group-error>label{color:#E74C3C}.wy-control-group.wy-control-group-error input[type="text"],.wy-control-group.wy-control-group-error input[type="password"],.wy-control-group.wy-control-group-error input[type="email"],.wy-control-group.wy-control-group-error input[type="url"],.wy-control-group.wy-control-group-error input[type="date"],.wy-control-group.wy-control-group-error input[type="month"],.wy-control-group.wy-control-group-error input[type="time"],.wy-control-group.wy-control-group-error input[type="datetime"],.wy-control-group.wy-control-group-error input[type="datetime-local"],.wy-control-group.wy-control-group-error input[type="week"],.wy-control-group.wy-control-group-error input[type="number"],.wy-control-group.wy-control-group-error input[type="search"],.wy-control-group.wy-control-group-error input[type="tel"],.wy-control-group.wy-control-group-error input[type="color"]{border:solid 1px #E74C3C}.wy-control-group.wy-control-group-error textarea{border:solid 1px #E74C3C}.wy-inline-validate{white-space:nowrap}.wy-inline-validate .wy-input-context{padding:.5em .625em;display:inline-block;font-size:80%}.wy-inline-validate.wy-inline-validate-success .wy-input-context{color:#27AE60}.wy-inline-validate.wy-inline-validate-danger .wy-input-context{color:#E74C3C}.wy-inline-validate.wy-inline-validate-warning .wy-input-context{color:#E67E22}.wy-inline-validate.wy-inline-validate-info .wy-input-context{color:#2980B9}.rotate-90{-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg)}.rotate-180{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);-ms-transform:rotate(180deg);-o-transform:rotate(180deg);transform:rotate(180deg)}.rotate-270{-webkit-transform:rotate(270deg);-moz-transform:rotate(270deg);-ms-transform:rotate(270deg);-o-transform:rotate(270deg);transform:rotate(270deg)}.mirror{-webkit-transform:scaleX(-1);-moz-transform:scaleX(-1);-ms-transform:scaleX(-1);-o-transform:scaleX(-1);transform:scaleX(-1)}.mirror.rotate-90{-webkit-transform:scaleX(-1) rotate(90deg);-moz-transform:scaleX(-1) rotate(90deg);-ms-transform:scaleX(-1) rotate(90deg);-o-transform:scaleX(-1) rotate(90deg);transform:scaleX(-1) rotate(90deg)}.mirror.rotate-180{-webkit-transform:scaleX(-1) rotate(180deg);-moz-transform:scaleX(-1) rotate(180deg);-ms-transform:scaleX(-1) rotate(180deg);-o-transform:scaleX(-1) rotate(180deg);transform:scaleX(-1) rotate(180deg)}.mirror.rotate-270{-webkit-transform:scaleX(-1) rotate(270deg);-moz-transform:scaleX(-1) rotate(270deg);-ms-transform:scaleX(-1) rotate(270deg);-o-transform:scaleX(-1) rotate(270deg);transform:scaleX(-1) rotate(270deg)}@media only screen and (max-width: 480px){.wy-form button[type="submit"]{margin:.7em 0 0}.wy-form input[type="text"],.wy-form input[type="password"],.wy-form input[type="email"],.wy-form input[type="url"],.wy-form input[type="date"],.wy-form input[type="month"],.wy-form input[type="time"],.wy-form input[type="datetime"],.wy-form input[type="datetime-local"],.wy-form input[type="week"],.wy-form input[type="number"],.wy-form input[type="search"],.wy-form input[type="tel"],.wy-form input[type="color"]{margin-bottom:.3em;display:block}.wy-form label{margin-bottom:.3em;display:block}.wy-form input[type="password"],.wy-form input[type="email"],.wy-form input[type="url"],.wy-form input[type="date"],.wy-form input[type="month"],.wy-form input[type="time"],.wy-form input[type="datetime"],.wy-form input[type="datetime-local"],.wy-form input[type="week"],.wy-form input[type="number"],.wy-form input[type="search"],.wy-form input[type="tel"],.wy-form input[type="color"]{margin-bottom:0}.wy-form-aligned .wy-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.wy-form-aligned .wy-control{margin:1.5em 0 0 0}.wy-form .wy-help-inline,.wy-form-message-inline,.wy-form-message{display:block;font-size:80%;padding:6px 0}}@media screen and (max-width: 768px){.tablet-hide{display:none}}@media screen and (max-width: 480px){.mobile-hide{display:none}}.float-left{float:left}.float-right{float:right}.full-width{width:100%}.wy-table,.rst-content table.docutils,.rst-content table.field-list{border-collapse:collapse;border-spacing:0;empty-cells:show;margin-bottom:24px}.wy-table caption,.rst-content table.docutils caption,.rst-content table.field-list caption{color:#000;font:italic 85%/1 arial,sans-serif;padding:1em 0;text-align:center}.wy-table td,.rst-content table.docutils td,.rst-content table.field-list td,.wy-table th,.rst-content table.docutils th,.rst-content table.field-list th{font-size:90%;margin:0;overflow:visible;padding:8px 16px}.wy-table td:first-child,.rst-content table.docutils td:first-child,.rst-content table.field-list td:first-child,.wy-table th:first-child,.rst-content table.docutils th:first-child,.rst-content table.field-list th:first-child{border-left-width:0}.wy-table thead,.rst-content table.docutils thead,.rst-content table.field-list thead{color:#000;text-align:left;vertical-align:bottom;white-space:nowrap}.wy-table thead th,.rst-content table.docutils thead th,.rst-content table.field-list thead th{font-weight:bold;border-bottom:solid 2px #e1e4e5}.wy-table td,.rst-content table.docutils td,.rst-content table.field-list td{background-color:transparent;vertical-align:middle}.wy-table td p,.rst-content table.docutils td p,.rst-content table.field-list td p{line-height:18px}.wy-table td p:last-child,.rst-content table.docutils td p:last-child,.rst-content table.field-list td p:last-child{margin-bottom:0}.wy-table .wy-table-cell-min,.rst-content table.docutils .wy-table-cell-min,.rst-content table.field-list .wy-table-cell-min{width:1%;padding-right:0}.wy-table .wy-table-cell-min input[type=checkbox],.rst-content table.docutils .wy-table-cell-min input[type=checkbox],.rst-content table.field-list .wy-table-cell-min input[type=checkbox],.wy-table .wy-table-cell-min input[type=checkbox],.rst-content table.docutils .wy-table-cell-min input[type=checkbox],.rst-content table.field-list .wy-table-cell-min input[type=checkbox]{margin:0}.wy-table-secondary{color:gray;font-size:90%}.wy-table-tertiary{color:gray;font-size:80%}.wy-table-odd td,.wy-table-striped tr:nth-child(2n-1) td,.rst-content table.docutils:not(.field-list) tr:nth-child(2n-1) td{background-color:#f3f6f6}.wy-table-backed{background-color:#f3f6f6}.wy-table-bordered-all,.rst-content table.docutils{border:1px solid #e1e4e5}.wy-table-bordered-all td,.rst-content table.docutils td{border-bottom:1px solid #e1e4e5;border-left:1px solid #e1e4e5}.wy-table-bordered-all tbody>tr:last-child td,.rst-content table.docutils tbody>tr:last-child td{border-bottom-width:0}.wy-table-bordered{border:1px solid #e1e4e5}.wy-table-bordered-rows td{border-bottom:1px solid #e1e4e5}.wy-table-bordered-rows tbody>tr:last-child td{border-bottom-width:0}.wy-table-horizontal tbody>tr:last-child td{border-bottom-width:0}.wy-table-horizontal td,.wy-table-horizontal th{border-width:0 0 1px 0;border-bottom:1px solid #e1e4e5}.wy-table-horizontal tbody>tr:last-child td{border-bottom-width:0}.wy-table-responsive{margin-bottom:24px;max-width:100%;overflow:auto}.wy-table-responsive table{margin-bottom:0 !important}.wy-table-responsive table td,.wy-table-responsive table th{white-space:nowrap}a{color:#2980B9;text-decoration:none;cursor:pointer}a:hover{color:#3091d1}a:visited{color:#9B59B6}html{height:100%;overflow-x:hidden}body{font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;font-weight:normal;color:#404040;min-height:100%;overflow-x:hidden;background:#edf0f2}.wy-text-left{text-align:left}.wy-text-center{text-align:center}.wy-text-right{text-align:right}.wy-text-large{font-size:120%}.wy-text-normal{font-size:100%}.wy-text-small,small{font-size:80%}.wy-text-strike{text-decoration:line-through}.wy-text-warning{color:#E67E22 !important}a.wy-text-warning:hover{color:#eb9950 !important}.wy-text-info{color:#2980B9 !important}a.wy-text-info:hover{color:#409ad5 !important}.wy-text-success{color:#27AE60 !important}a.wy-text-success:hover{color:#36d278 !important}.wy-text-danger{color:#E74C3C !important}a.wy-text-danger:hover{color:#ed7669 !important}.wy-text-neutral{color:#404040 !important}a.wy-text-neutral:hover{color:#595959 !important}h1,h2,.rst-content .toctree-wrapper p.caption,h3,h4,h5,h6,legend{margin-top:0;font-weight:700;font-family:"Roboto Slab","ff-tisa-web-pro","Georgia",Arial,sans-serif}p{line-height:24px;margin:0;font-size:16px;margin-bottom:24px}h1{font-size:175%}h2,.rst-content .toctree-wrapper p.caption{font-size:150%}h3{font-size:125%}h4{font-size:115%}h5{font-size:110%}h6{font-size:100%}hr{display:block;height:1px;border:0;border-top:1px solid #e1e4e5;margin:24px 0;padding:0}code,.rst-content tt,.rst-content code{white-space:nowrap;max-width:100%;background:#fff;border:solid 1px #e1e4e5;font-size:75%;padding:0 5px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace;color:#E74C3C;overflow-x:auto}code.code-large,.rst-content tt.code-large{font-size:90%}.wy-plain-list-disc,.rst-content .section ul,.rst-content .toctree-wrapper ul,article ul{list-style:disc;line-height:24px;margin-bottom:24px}.wy-plain-list-disc li,.rst-content .section ul li,.rst-content .toctree-wrapper ul li,article ul li{list-style:disc;margin-left:24px}.wy-plain-list-disc li p:last-child,.rst-content .section ul li p:last-child,.rst-content .toctree-wrapper ul li p:last-child,article ul li p:last-child{margin-bottom:0}.wy-plain-list-disc li ul,.rst-content .section ul li ul,.rst-content .toctree-wrapper ul li ul,article ul li ul{margin-bottom:0}.wy-plain-list-disc li li,.rst-content .section ul li li,.rst-content .toctree-wrapper ul li li,article ul li li{list-style:circle}.wy-plain-list-disc li li li,.rst-content .section ul li li li,.rst-content .toctree-wrapper ul li li li,article ul li li li{list-style:square}.wy-plain-list-disc li ol li,.rst-content .section ul li ol li,.rst-content .toctree-wrapper ul li ol li,article ul li ol li{list-style:decimal}.wy-plain-list-decimal,.rst-content .section ol,.rst-content ol.arabic,article ol{list-style:decimal;line-height:24px;margin-bottom:24px}.wy-plain-list-decimal li,.rst-content .section ol li,.rst-content ol.arabic li,article ol li{list-style:decimal;margin-left:24px}.wy-plain-list-decimal li p:last-child,.rst-content .section ol li p:last-child,.rst-content ol.arabic li p:last-child,article ol li p:last-child{margin-bottom:0}.wy-plain-list-decimal li ul,.rst-content .section ol li ul,.rst-content ol.arabic li ul,article ol li ul{margin-bottom:0}.wy-plain-list-decimal li ul li,.rst-content .section ol li ul li,.rst-content ol.arabic li ul li,article ol li ul li{list-style:disc}.wy-breadcrumbs{*zoom:1}.wy-breadcrumbs:before,.wy-breadcrumbs:after{display:table;content:""}.wy-breadcrumbs:after{clear:both}.wy-breadcrumbs li{display:inline-block}.wy-breadcrumbs li.wy-breadcrumbs-aside{float:right}.wy-breadcrumbs li a{display:inline-block;padding:5px}.wy-breadcrumbs li a:first-child{padding-left:0}.wy-breadcrumbs li code,.wy-breadcrumbs li .rst-content tt,.rst-content .wy-breadcrumbs li tt{padding:5px;border:none;background:none}.wy-breadcrumbs li code.literal,.wy-breadcrumbs li .rst-content tt.literal,.rst-content .wy-breadcrumbs li tt.literal{color:#404040}.wy-breadcrumbs-extra{margin-bottom:0;color:#b3b3b3;font-size:80%;display:inline-block}@media screen and (max-width: 480px){.wy-breadcrumbs-extra{display:none}.wy-breadcrumbs li.wy-breadcrumbs-aside{display:none}}@media print{.wy-breadcrumbs li.wy-breadcrumbs-aside{display:none}}html{font-size:16px}.wy-affix{position:fixed;top:1.618em}.wy-menu a:hover{text-decoration:none}.wy-menu-horiz{*zoom:1}.wy-menu-horiz:before,.wy-menu-horiz:after{display:table;content:""}.wy-menu-horiz:after{clear:both}.wy-menu-horiz ul,.wy-menu-horiz li{display:inline-block}.wy-menu-horiz li:hover{background:rgba(255,255,255,0.1)}.wy-menu-horiz li.divide-left{border-left:solid 1px #404040}.wy-menu-horiz li.divide-right{border-right:solid 1px #404040}.wy-menu-horiz a{height:32px;display:inline-block;line-height:32px;padding:0 16px}.wy-menu-vertical{width:300px}.wy-menu-vertical header,.wy-menu-vertical p.caption{color:#3a7ca8;height:32px;display:inline-block;line-height:32px;padding:0 1.618em;margin:12px 0 0 0;display:block;font-weight:bold;text-transform:uppercase;font-size:85%;white-space:nowrap}.wy-menu-vertical ul{margin-bottom:0}.wy-menu-vertical li.divide-top{border-top:solid 1px #404040}.wy-menu-vertical li.divide-bottom{border-bottom:solid 1px #404040}.wy-menu-vertical li.current{background:#e3e3e3}.wy-menu-vertical li.current a{color:gray;border-right:solid 1px #c9c9c9;padding:.4045em 2.427em}.wy-menu-vertical li.current a:hover{background:#d6d6d6}.wy-menu-vertical li code,.wy-menu-vertical li .rst-content tt,.rst-content .wy-menu-vertical li tt{border:none;background:inherit;color:inherit;padding-left:0;padding-right:0}.wy-menu-vertical li span.toctree-expand{display:block;float:left;margin-left:-1.2em;font-size:.8em;line-height:1.6em;color:#4d4d4d}.wy-menu-vertical li.on a,.wy-menu-vertical li.current>a{color:#404040;padding:.4045em 1.618em;font-weight:bold;position:relative;background:#fcfcfc;border:none;padding-left:1.618em -4px}.wy-menu-vertical li.on a:hover,.wy-menu-vertical li.current>a:hover{background:#fcfcfc}.wy-menu-vertical li.on a:hover span.toctree-expand,.wy-menu-vertical li.current>a:hover span.toctree-expand{color:gray}.wy-menu-vertical li.on a span.toctree-expand,.wy-menu-vertical li.current>a span.toctree-expand{display:block;font-size:.8em;line-height:1.6em;color:#333}.wy-menu-vertical li.toctree-l1.current>a{border-bottom:solid 1px #c9c9c9;border-top:solid 1px #c9c9c9}.wy-menu-vertical li.toctree-l2 a,.wy-menu-vertical li.toctree-l3 a,.wy-menu-vertical li.toctree-l4 a{color:#404040}.wy-menu-vertical li.toctree-l1.current li.toctree-l2>ul,.wy-menu-vertical li.toctree-l2.current li.toctree-l3>ul{display:none}.wy-menu-vertical li.toctree-l1.current li.toctree-l2.current>ul,.wy-menu-vertical li.toctree-l2.current li.toctree-l3.current>ul{display:block}.wy-menu-vertical li.toctree-l2.current>a{background:#c9c9c9;padding:.4045em 2.427em}.wy-menu-vertical li.toctree-l2.current li.toctree-l3>a{display:block;background:#c9c9c9;padding:.4045em 4.045em}.wy-menu-vertical li.toctree-l2 a:hover span.toctree-expand{color:gray}.wy-menu-vertical li.toctree-l2 span.toctree-expand{color:#a3a3a3}.wy-menu-vertical li.toctree-l3{font-size:.9em}.wy-menu-vertical li.toctree-l3.current>a{background:#bdbdbd;padding:.4045em 4.045em}.wy-menu-vertical li.toctree-l3.current li.toctree-l4>a{display:block;background:#bdbdbd;padding:.4045em 5.663em}.wy-menu-vertical li.toctree-l3 a:hover span.toctree-expand{color:gray}.wy-menu-vertical li.toctree-l3 span.toctree-expand{color:#969696}.wy-menu-vertical li.toctree-l4{font-size:.9em}.wy-menu-vertical li.current ul{display:block}.wy-menu-vertical li ul{margin-bottom:0;display:none}.wy-menu-vertical li ul li a{margin-bottom:0;color:#d9d9d9;font-weight:normal}.wy-menu-vertical a{display:inline-block;line-height:18px;padding:.4045em 1.618em;display:block;position:relative;font-size:90%;color:#d9d9d9}.wy-menu-vertical a:hover{background-color:#4e4a4a;cursor:pointer}.wy-menu-vertical a:hover span.toctree-expand{color:#d9d9d9}.wy-menu-vertical a:active{background-color:#2980B9;cursor:pointer;color:#fff}.wy-menu-vertical a:active span.toctree-expand{color:#fff}.wy-side-nav-search{display:block;width:300px;padding:.809em;margin-bottom:.809em;z-index:200;background-color:#2980B9;text-align:center;padding:.809em;display:block;color:#fcfcfc;margin-bottom:.809em}.wy-side-nav-search input[type=text]{width:100%;border-radius:50px;padding:6px 12px;border-color:#2472a4}.wy-side-nav-search img{display:block;margin:auto auto .809em auto;height:45px;width:45px;background-color:#2980B9;padding:5px;border-radius:100%}.wy-side-nav-search>a,.wy-side-nav-search .wy-dropdown>a{color:#fcfcfc;font-size:100%;font-weight:bold;display:inline-block;padding:4px 6px;margin-bottom:.809em}.wy-side-nav-search>a:hover,.wy-side-nav-search .wy-dropdown>a:hover{background:rgba(255,255,255,0.1)}.wy-side-nav-search>a img.logo,.wy-side-nav-search .wy-dropdown>a img.logo{display:block;margin:0 auto;height:auto;width:auto;border-radius:0;max-width:100%;background:transparent}.wy-side-nav-search>a.icon img.logo,.wy-side-nav-search .wy-dropdown>a.icon img.logo{margin-top:.85em}.wy-side-nav-search>div.version{margin-top:-.4045em;margin-bottom:.809em;font-weight:normal;color:rgba(255,255,255,0.3)}.wy-nav .wy-menu-vertical header{color:#2980B9}.wy-nav .wy-menu-vertical a{color:#b3b3b3}.wy-nav .wy-menu-vertical a:hover{background-color:#2980B9;color:#fff}[data-menu-wrap]{-webkit-transition:all .2s ease-in;-moz-transition:all .2s ease-in;transition:all .2s ease-in;position:absolute;opacity:1;width:100%;opacity:0}[data-menu-wrap].move-center{left:0;right:auto;opacity:1}[data-menu-wrap].move-left{right:auto;left:-100%;opacity:0}[data-menu-wrap].move-right{right:-100%;left:auto;opacity:0}.wy-body-for-nav{background:#fcfcfc}.wy-grid-for-nav{position:absolute;width:100%;height:100%}.wy-nav-side{position:fixed;top:0;bottom:0;left:0;padding-bottom:2em;width:300px;overflow-x:hidden;overflow-y:hidden;min-height:100%;color:#9b9b9b;background:#343131;z-index:200}.wy-side-scroll{width:320px;position:relative;overflow-x:hidden;overflow-y:scroll;height:100%}.wy-nav-top{display:none;background:#2980B9;color:#fff;padding:.4045em .809em;position:relative;line-height:50px;text-align:center;font-size:100%;*zoom:1}.wy-nav-top:before,.wy-nav-top:after{display:table;content:""}.wy-nav-top:after{clear:both}.wy-nav-top a{color:#fff;font-weight:bold}.wy-nav-top img{margin-right:12px;height:45px;width:45px;background-color:#2980B9;padding:5px;border-radius:100%}.wy-nav-top i{font-size:30px;float:left;cursor:pointer;padding-top:inherit}.wy-nav-content-wrap{margin-left:300px;background:#fcfcfc;min-height:100%}.wy-nav-content{padding:1.618em 3.236em;height:100%;max-width:800px;margin:auto}.wy-body-mask{position:fixed;width:100%;height:100%;background:rgba(0,0,0,0.2);display:none;z-index:499}.wy-body-mask.on{display:block}footer{color:gray}footer p{margin-bottom:12px}footer span.commit code,footer span.commit .rst-content tt,.rst-content footer span.commit tt{padding:0px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace;font-size:1em;background:none;border:none;color:gray}.rst-footer-buttons{*zoom:1}.rst-footer-buttons:before,.rst-footer-buttons:after{width:100%}.rst-footer-buttons:before,.rst-footer-buttons:after{display:table;content:""}.rst-footer-buttons:after{clear:both}.rst-breadcrumbs-buttons{margin-top:12px;*zoom:1}.rst-breadcrumbs-buttons:before,.rst-breadcrumbs-buttons:after{display:table;content:""}.rst-breadcrumbs-buttons:after{clear:both}#search-results .search li{margin-bottom:24px;border-bottom:solid 1px #e1e4e5;padding-bottom:24px}#search-results .search li:first-child{border-top:solid 1px #e1e4e5;padding-top:24px}#search-results .search li a{font-size:120%;margin-bottom:12px;display:inline-block}#search-results .context{color:gray;font-size:90%}.genindextable li>ul{margin-left:24px}@media screen and (max-width: 768px){.wy-body-for-nav{background:#fcfcfc}.wy-nav-top{display:block}.wy-nav-side{left:-300px}.wy-nav-side.shift{width:85%;left:0}.wy-side-scroll{width:auto}.wy-side-nav-search{width:auto}.wy-menu.wy-menu-vertical{width:auto}.wy-nav-content-wrap{margin-left:0}.wy-nav-content-wrap .wy-nav-content{padding:1.618em}.wy-nav-content-wrap.shift{position:fixed;min-width:100%;left:85%;top:0;height:100%;overflow:hidden}}@media screen and (min-width: 1100px){.wy-nav-content-wrap{background:rgba(0,0,0,0.05)}.wy-nav-content{margin:0;background:#fcfcfc}}@media print{.rst-versions,footer,.wy-nav-side{display:none}.wy-nav-content-wrap{margin-left:0}}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;z-index:400}.rst-versions a{color:#2980B9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27AE60;*zoom:1}.rst-versions .rst-current-version:before,.rst-versions .rst-current-version:after{display:table;content:""}.rst-versions .rst-current-version:after{clear:both}.rst-versions .rst-current-version .fa,.rst-versions .rst-current-version .wy-menu-vertical li span.toctree-expand,.wy-menu-vertical li .rst-versions .rst-current-version span.toctree-expand,.rst-versions .rst-current-version .rst-content .admonition-title,.rst-content .rst-versions .rst-current-version .admonition-title,.rst-versions .rst-current-version .rst-content h1 .headerlink,.rst-content h1 .rst-versions .rst-current-version .headerlink,.rst-versions .rst-current-version .rst-content h2 .headerlink,.rst-content h2 .rst-versions .rst-current-version .headerlink,.rst-versions .rst-current-version .rst-content h3 .headerlink,.rst-content h3 .rst-versions .rst-current-version .headerlink,.rst-versions .rst-current-version .rst-content h4 .headerlink,.rst-content h4 .rst-versions .rst-current-version .headerlink,.rst-versions .rst-current-version .rst-content h5 .headerlink,.rst-content h5 .rst-versions .rst-current-version .headerlink,.rst-versions .rst-current-version .rst-content h6 .headerlink,.rst-content h6 .rst-versions .rst-current-version .headerlink,.rst-versions .rst-current-version .rst-content dl dt .headerlink,.rst-content dl dt .rst-versions .rst-current-version .headerlink,.rst-versions .rst-current-version .rst-content p.caption .headerlink,.rst-content p.caption .rst-versions .rst-current-version .headerlink,.rst-versions .rst-current-version .rst-content table>caption .headerlink,.rst-content table>caption .rst-versions .rst-current-version .headerlink,.rst-versions .rst-current-version .rst-content .code-block-caption .headerlink,.rst-content .code-block-caption .rst-versions .rst-current-version .headerlink,.rst-versions .rst-current-version .rst-content tt.download span:first-child,.rst-content tt.download .rst-versions .rst-current-version span:first-child,.rst-versions .rst-current-version .rst-content code.download span:first-child,.rst-content code.download .rst-versions .rst-current-version span:first-child,.rst-versions .rst-current-version .icon{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#E74C3C;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#F1C40F;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:gray;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:solid 1px #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .icon-book{float:none}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge .rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width: 768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}.rst-content img{max-width:100%;height:auto}.rst-content div.figure{margin-bottom:24px}.rst-content div.figure p.caption{font-style:italic}.rst-content div.figure p:last-child.caption{margin-bottom:0px}.rst-content div.figure.align-center{text-align:center}.rst-content .section>img,.rst-content .section>a>img{margin-bottom:24px}.rst-content abbr[title]{text-decoration:none}.rst-content.style-external-links a.reference.external:after{font-family:FontAwesome;content:"";color:#b3b3b3;vertical-align:super;font-size:60%;margin:0 .2em}.rst-content blockquote{margin-left:24px;line-height:24px;margin-bottom:24px}.rst-content pre.literal-block{white-space:pre;margin:0;padding:12px 12px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace;display:block;overflow:auto}.rst-content pre.literal-block,.rst-content div[class^='highlight']{border:1px solid #e1e4e5;overflow-x:auto;margin:1px 0 24px 0}.rst-content pre.literal-block div[class^='highlight'],.rst-content div[class^='highlight'] div[class^='highlight']{padding:0px;border:none;margin:0}.rst-content div[class^='highlight'] td.code{width:100%}.rst-content .linenodiv pre{border-right:solid 1px #e6e9ea;margin:0;padding:12px 12px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace;user-select:none;pointer-events:none}.rst-content div[class^='highlight'] pre{white-space:pre;margin:0;padding:12px 12px;display:block;overflow:auto}.rst-content div[class^='highlight'] pre .hll{display:block;margin:0 -12px;padding:0 12px}.rst-content pre.literal-block,.rst-content div[class^='highlight'] pre,.rst-content .linenodiv pre{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace;font-size:12px;line-height:1.4}.rst-content .code-block-caption{font-style:italic;font-size:85%;line-height:1;padding:1em 0;text-align:center}@media print{.rst-content .codeblock,.rst-content div[class^='highlight'],.rst-content div[class^='highlight'] pre{white-space:pre-wrap}}.rst-content .note .last,.rst-content .attention .last,.rst-content .caution .last,.rst-content .danger .last,.rst-content .error .last,.rst-content .hint .last,.rst-content .important .last,.rst-content .tip .last,.rst-content .warning .last,.rst-content .seealso .last,.rst-content .admonition-todo .last,.rst-content .admonition .last{margin-bottom:0}.rst-content .admonition-title:before{margin-right:4px}.rst-content .admonition table{border-color:rgba(0,0,0,0.1)}.rst-content .admonition table td,.rst-content .admonition table th{background:transparent !important;border-color:rgba(0,0,0,0.1) !important}.rst-content .section ol.loweralpha,.rst-content .section ol.loweralpha li{list-style:lower-alpha}.rst-content .section ol.upperalpha,.rst-content .section ol.upperalpha li{list-style:upper-alpha}.rst-content .section ol p,.rst-content .section ul p{margin-bottom:12px}.rst-content .section ol p:last-child,.rst-content .section ul p:last-child{margin-bottom:24px}.rst-content .line-block{margin-left:0px;margin-bottom:24px;line-height:24px}.rst-content .line-block .line-block{margin-left:24px;margin-bottom:0px}.rst-content .topic-title{font-weight:bold;margin-bottom:12px}.rst-content .toc-backref{color:#404040}.rst-content .align-right{float:right;margin:0px 0px 24px 24px}.rst-content .align-left{float:left;margin:0px 24px 24px 0px}.rst-content .align-center{margin:auto}.rst-content .align-center:not(table){display:block}.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content .toctree-wrapper p.caption .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content dl dt .headerlink,.rst-content p.caption .headerlink,.rst-content table>caption .headerlink,.rst-content .code-block-caption .headerlink{visibility:hidden;font-size:14px}.rst-content h1 .headerlink:after,.rst-content h2 .headerlink:after,.rst-content .toctree-wrapper p.caption .headerlink:after,.rst-content h3 .headerlink:after,.rst-content h4 .headerlink:after,.rst-content h5 .headerlink:after,.rst-content h6 .headerlink:after,.rst-content dl dt .headerlink:after,.rst-content p.caption .headerlink:after,.rst-content table>caption .headerlink:after,.rst-content .code-block-caption .headerlink:after{content:"ïƒ";font-family:FontAwesome}.rst-content h1:hover .headerlink:after,.rst-content h2:hover .headerlink:after,.rst-content .toctree-wrapper p.caption:hover .headerlink:after,.rst-content h3:hover .headerlink:after,.rst-content h4:hover .headerlink:after,.rst-content h5:hover .headerlink:after,.rst-content h6:hover .headerlink:after,.rst-content dl dt:hover .headerlink:after,.rst-content p.caption:hover .headerlink:after,.rst-content table>caption:hover .headerlink:after,.rst-content .code-block-caption:hover .headerlink:after{visibility:visible}.rst-content table>caption .headerlink:after{font-size:12px}.rst-content .centered{text-align:center}.rst-content .sidebar{float:right;width:40%;display:block;margin:0 0 24px 24px;padding:24px;background:#f3f6f6;border:solid 1px #e1e4e5}.rst-content .sidebar p,.rst-content .sidebar ul,.rst-content .sidebar dl{font-size:90%}.rst-content .sidebar .last{margin-bottom:0}.rst-content .sidebar .sidebar-title{display:block;font-family:"Roboto Slab","ff-tisa-web-pro","Georgia",Arial,sans-serif;font-weight:bold;background:#e1e4e5;padding:6px 12px;margin:-24px;margin-bottom:24px;font-size:100%}.rst-content .highlighted{background:#F1C40F;display:inline-block;font-weight:bold;padding:0 6px}.rst-content .footnote-reference,.rst-content .citation-reference{vertical-align:baseline;position:relative;top:-0.4em;line-height:0;font-size:90%}.rst-content table.docutils.citation,.rst-content table.docutils.footnote{background:none;border:none;color:gray}.rst-content table.docutils.citation td,.rst-content table.docutils.citation tr,.rst-content table.docutils.footnote td,.rst-content table.docutils.footnote tr{border:none;background-color:transparent !important;white-space:normal}.rst-content table.docutils.citation td.label,.rst-content table.docutils.footnote td.label{padding-left:0;padding-right:0;vertical-align:top}.rst-content table.docutils.citation tt,.rst-content table.docutils.citation code,.rst-content table.docutils.footnote tt,.rst-content table.docutils.footnote code{color:#555}.rst-content .wy-table-responsive.citation,.rst-content .wy-table-responsive.footnote{margin-bottom:0}.rst-content .wy-table-responsive.citation+:not(.citation),.rst-content .wy-table-responsive.footnote+:not(.footnote){margin-top:24px}.rst-content .wy-table-responsive.citation:last-child,.rst-content .wy-table-responsive.footnote:last-child{margin-bottom:24px}.rst-content table.docutils th{border-color:#e1e4e5}.rst-content table.docutils td .last,.rst-content table.docutils td .last :last-child{margin-bottom:0}.rst-content table.field-list{border:none}.rst-content table.field-list td{border:none}.rst-content table.field-list td p{font-size:inherit;line-height:inherit}.rst-content table.field-list td>strong{display:inline-block}.rst-content table.field-list .field-name{padding-right:10px;text-align:left;white-space:nowrap}.rst-content table.field-list .field-body{text-align:left}.rst-content tt,.rst-content tt,.rst-content code{color:#000;font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace;padding:2px 5px}.rst-content tt big,.rst-content tt em,.rst-content tt big,.rst-content code big,.rst-content tt em,.rst-content code em{font-size:100% !important;line-height:normal}.rst-content tt.literal,.rst-content tt.literal,.rst-content code.literal{color:#E74C3C}.rst-content tt.xref,a .rst-content tt,.rst-content tt.xref,.rst-content code.xref,a .rst-content tt,a .rst-content code{font-weight:bold;color:#404040}.rst-content pre,.rst-content kbd,.rst-content samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace}.rst-content a tt,.rst-content a tt,.rst-content a code{color:#2980B9}.rst-content dl{margin-bottom:24px}.rst-content dl dt{font-weight:bold;margin-bottom:12px}.rst-content dl p,.rst-content dl table,.rst-content dl ul,.rst-content dl ol{margin-bottom:12px !important}.rst-content dl dd{margin:0 0 12px 24px;line-height:24px}.rst-content dl:not(.docutils){margin-bottom:24px}.rst-content dl:not(.docutils) dt{display:table;margin:6px 0;font-size:90%;line-height:normal;background:#e7f2fa;color:#2980B9;border-top:solid 3px #6ab0de;padding:6px;position:relative}.rst-content dl:not(.docutils) dt:before{color:#6ab0de}.rst-content dl:not(.docutils) dt .headerlink{color:#404040;font-size:100% !important}.rst-content dl:not(.docutils) dl dt{margin-bottom:6px;border:none;border-left:solid 3px #ccc;background:#f0f0f0;color:#555}.rst-content dl:not(.docutils) dl dt .headerlink{color:#404040;font-size:100% !important}.rst-content dl:not(.docutils) dt:first-child{margin-top:0}.rst-content dl:not(.docutils) tt,.rst-content dl:not(.docutils) tt,.rst-content dl:not(.docutils) code{font-weight:bold}.rst-content dl:not(.docutils) tt.descname,.rst-content dl:not(.docutils) tt.descclassname,.rst-content dl:not(.docutils) tt.descname,.rst-content dl:not(.docutils) code.descname,.rst-content dl:not(.docutils) tt.descclassname,.rst-content dl:not(.docutils) code.descclassname{background-color:transparent;border:none;padding:0;font-size:100% !important}.rst-content dl:not(.docutils) tt.descname,.rst-content dl:not(.docutils) tt.descname,.rst-content dl:not(.docutils) code.descname{font-weight:bold}.rst-content dl:not(.docutils) .optional{display:inline-block;padding:0 4px;color:#000;font-weight:bold}.rst-content dl:not(.docutils) .property{display:inline-block;padding-right:8px}.rst-content .viewcode-link,.rst-content .viewcode-back{display:inline-block;color:#27AE60;font-size:80%;padding-left:24px}.rst-content .viewcode-back{display:block;float:right}.rst-content p.rubric{margin-bottom:12px;font-weight:bold}.rst-content tt.download,.rst-content code.download{background:inherit;padding:inherit;font-weight:normal;font-family:inherit;font-size:inherit;color:inherit;border:inherit;white-space:inherit}.rst-content tt.download span:first-child,.rst-content code.download span:first-child{-webkit-font-smoothing:subpixel-antialiased}.rst-content tt.download span:first-child:before,.rst-content code.download span:first-child:before{margin-right:4px}.rst-content .guilabel{border:1px solid #7fbbe3;background:#e7f2fa;font-size:80%;font-weight:700;border-radius:4px;padding:2.4px 6px;margin:auto 2px}.rst-content .versionmodified{font-style:italic}@media screen and (max-width: 480px){.rst-content .sidebar{width:100%}}span[id*='MathJax-Span']{color:#404040}.math{text-align:center}@font-face{font-family:"Lato";src:url("../fonts/Lato/lato-regular.eot");src:url("../fonts/Lato/lato-regular.eot?#iefix") format("embedded-opentype"),url("../fonts/Lato/lato-regular.woff2") format("woff2"),url("../fonts/Lato/lato-regular.woff") format("woff"),url("../fonts/Lato/lato-regular.ttf") format("truetype");font-weight:400;font-style:normal}@font-face{font-family:"Lato";src:url("../fonts/Lato/lato-bold.eot");src:url("../fonts/Lato/lato-bold.eot?#iefix") format("embedded-opentype"),url("../fonts/Lato/lato-bold.woff2") format("woff2"),url("../fonts/Lato/lato-bold.woff") format("woff"),url("../fonts/Lato/lato-bold.ttf") format("truetype");font-weight:700;font-style:normal}@font-face{font-family:"Lato";src:url("../fonts/Lato/lato-bolditalic.eot");src:url("../fonts/Lato/lato-bolditalic.eot?#iefix") format("embedded-opentype"),url("../fonts/Lato/lato-bolditalic.woff2") format("woff2"),url("../fonts/Lato/lato-bolditalic.woff") format("woff"),url("../fonts/Lato/lato-bolditalic.ttf") format("truetype");font-weight:700;font-style:italic}@font-face{font-family:"Lato";src:url("../fonts/Lato/lato-italic.eot");src:url("../fonts/Lato/lato-italic.eot?#iefix") format("embedded-opentype"),url("../fonts/Lato/lato-italic.woff2") format("woff2"),url("../fonts/Lato/lato-italic.woff") format("woff"),url("../fonts/Lato/lato-italic.ttf") format("truetype");font-weight:400;font-style:italic}@font-face{font-family:"Roboto Slab";font-style:normal;font-weight:400;src:url("../fonts/RobotoSlab/roboto-slab.eot");src:url("../fonts/RobotoSlab/roboto-slab-v7-regular.eot?#iefix") format("embedded-opentype"),url("../fonts/RobotoSlab/roboto-slab-v7-regular.woff2") format("woff2"),url("../fonts/RobotoSlab/roboto-slab-v7-regular.woff") format("woff"),url("../fonts/RobotoSlab/roboto-slab-v7-regular.ttf") format("truetype")}@font-face{font-family:"Roboto Slab";font-style:normal;font-weight:700;src:url("../fonts/RobotoSlab/roboto-slab-v7-bold.eot");src:url("../fonts/RobotoSlab/roboto-slab-v7-bold.eot?#iefix") format("embedded-opentype"),url("../fonts/RobotoSlab/roboto-slab-v7-bold.woff2") format("woff2"),url("../fonts/RobotoSlab/roboto-slab-v7-bold.woff") format("woff"),url("../fonts/RobotoSlab/roboto-slab-v7-bold.ttf") format("truetype")} + */@font-face{font-family:FontAwesome;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713);src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix&v=4.7.0) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#fontawesomeregular) format("svg");font-weight:400;font-style:normal}.fa,.icon,.rst-content .admonition-title,.rst-content .code-block-caption .headerlink,.rst-content .eqno .headerlink,.rst-content code.download span:first-child,.rst-content dl dt .headerlink,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content p.caption .headerlink,.rst-content p .headerlink,.rst-content table>caption .headerlink,.rst-content tt.download span:first-child,.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand,.wy-menu-vertical li button.toctree-expand{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14286em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14286em;width:2.14286em;top:.14286em;text-align:center}.fa-li.fa-lg{left:-1.85714em}.fa-border{padding:.2em .25em .15em;border:.08em solid #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa-pull-left.icon,.fa.fa-pull-left,.rst-content .code-block-caption .fa-pull-left.headerlink,.rst-content .eqno .fa-pull-left.headerlink,.rst-content .fa-pull-left.admonition-title,.rst-content code.download span.fa-pull-left:first-child,.rst-content dl dt .fa-pull-left.headerlink,.rst-content h1 .fa-pull-left.headerlink,.rst-content h2 .fa-pull-left.headerlink,.rst-content h3 .fa-pull-left.headerlink,.rst-content h4 .fa-pull-left.headerlink,.rst-content h5 .fa-pull-left.headerlink,.rst-content h6 .fa-pull-left.headerlink,.rst-content p .fa-pull-left.headerlink,.rst-content table>caption .fa-pull-left.headerlink,.rst-content tt.download span.fa-pull-left:first-child,.wy-menu-vertical li.current>a button.fa-pull-left.toctree-expand,.wy-menu-vertical li.on a button.fa-pull-left.toctree-expand,.wy-menu-vertical li button.fa-pull-left.toctree-expand{margin-right:.3em}.fa-pull-right.icon,.fa.fa-pull-right,.rst-content .code-block-caption .fa-pull-right.headerlink,.rst-content .eqno .fa-pull-right.headerlink,.rst-content .fa-pull-right.admonition-title,.rst-content code.download span.fa-pull-right:first-child,.rst-content dl dt .fa-pull-right.headerlink,.rst-content h1 .fa-pull-right.headerlink,.rst-content h2 .fa-pull-right.headerlink,.rst-content h3 .fa-pull-right.headerlink,.rst-content h4 .fa-pull-right.headerlink,.rst-content h5 .fa-pull-right.headerlink,.rst-content h6 .fa-pull-right.headerlink,.rst-content p .fa-pull-right.headerlink,.rst-content table>caption .fa-pull-right.headerlink,.rst-content tt.download span.fa-pull-right:first-child,.wy-menu-vertical li.current>a button.fa-pull-right.toctree-expand,.wy-menu-vertical li.on a button.fa-pull-right.toctree-expand,.wy-menu-vertical li button.fa-pull-right.toctree-expand{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left,.pull-left.icon,.rst-content .code-block-caption .pull-left.headerlink,.rst-content .eqno .pull-left.headerlink,.rst-content .pull-left.admonition-title,.rst-content code.download span.pull-left:first-child,.rst-content dl dt .pull-left.headerlink,.rst-content h1 .pull-left.headerlink,.rst-content h2 .pull-left.headerlink,.rst-content h3 .pull-left.headerlink,.rst-content h4 .pull-left.headerlink,.rst-content h5 .pull-left.headerlink,.rst-content h6 .pull-left.headerlink,.rst-content p .pull-left.headerlink,.rst-content table>caption .pull-left.headerlink,.rst-content tt.download span.pull-left:first-child,.wy-menu-vertical li.current>a button.pull-left.toctree-expand,.wy-menu-vertical li.on a button.pull-left.toctree-expand,.wy-menu-vertical li button.pull-left.toctree-expand{margin-right:.3em}.fa.pull-right,.pull-right.icon,.rst-content .code-block-caption .pull-right.headerlink,.rst-content .eqno .pull-right.headerlink,.rst-content .pull-right.admonition-title,.rst-content code.download span.pull-right:first-child,.rst-content dl dt .pull-right.headerlink,.rst-content h1 .pull-right.headerlink,.rst-content h2 .pull-right.headerlink,.rst-content h3 .pull-right.headerlink,.rst-content h4 .pull-right.headerlink,.rst-content h5 .pull-right.headerlink,.rst-content h6 .pull-right.headerlink,.rst-content p .pull-right.headerlink,.rst-content table>caption .pull-right.headerlink,.rst-content tt.download span.pull-right:first-child,.wy-menu-vertical li.current>a button.pull-right.toctree-expand,.wy-menu-vertical li.on a button.pull-right.toctree-expand,.wy-menu-vertical li button.pull-right.toctree-expand{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s linear infinite;animation:fa-spin 2s linear infinite}.fa-pulse{-webkit-animation:fa-spin 1s steps(8) infinite;animation:fa-spin 1s steps(8) infinite}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scaleX(-1);-ms-transform:scaleX(-1);transform:scaleX(-1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scaleY(-1);-ms-transform:scaleY(-1);transform:scaleY(-1)}:root .fa-flip-horizontal,:root .fa-flip-vertical,:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:""}.fa-music:before{content:"ï€"}.fa-search:before,.icon-search:before{content:""}.fa-envelope-o:before{content:""}.fa-heart:before{content:""}.fa-star:before{content:""}.fa-star-o:before{content:""}.fa-user:before{content:""}.fa-film:before{content:""}.fa-th-large:before{content:""}.fa-th:before{content:""}.fa-th-list:before{content:""}.fa-check:before{content:""}.fa-close:before,.fa-remove:before,.fa-times:before{content:"ï€"}.fa-search-plus:before{content:""}.fa-search-minus:before{content:"ï€"}.fa-power-off:before{content:""}.fa-signal:before{content:""}.fa-cog:before,.fa-gear:before{content:""}.fa-trash-o:before{content:""}.fa-home:before,.icon-home:before{content:""}.fa-file-o:before{content:""}.fa-clock-o:before{content:""}.fa-road:before{content:""}.fa-download:before,.rst-content code.download span:first-child:before,.rst-content tt.download span:first-child:before{content:""}.fa-arrow-circle-o-down:before{content:""}.fa-arrow-circle-o-up:before{content:""}.fa-inbox:before{content:""}.fa-play-circle-o:before{content:"ï€"}.fa-repeat:before,.fa-rotate-right:before{content:""}.fa-refresh:before{content:""}.fa-list-alt:before{content:""}.fa-lock:before{content:""}.fa-flag:before{content:""}.fa-headphones:before{content:""}.fa-volume-off:before{content:""}.fa-volume-down:before{content:""}.fa-volume-up:before{content:""}.fa-qrcode:before{content:""}.fa-barcode:before{content:""}.fa-tag:before{content:""}.fa-tags:before{content:""}.fa-book:before,.icon-book:before{content:"ï€"}.fa-bookmark:before{content:""}.fa-print:before{content:""}.fa-camera:before{content:""}.fa-font:before{content:""}.fa-bold:before{content:""}.fa-italic:before{content:""}.fa-text-height:before{content:""}.fa-text-width:before{content:""}.fa-align-left:before{content:""}.fa-align-center:before{content:""}.fa-align-right:before{content:""}.fa-align-justify:before{content:""}.fa-list:before{content:""}.fa-dedent:before,.fa-outdent:before{content:""}.fa-indent:before{content:""}.fa-video-camera:before{content:""}.fa-image:before,.fa-photo:before,.fa-picture-o:before{content:""}.fa-pencil:before{content:"ï€"}.fa-map-marker:before{content:"ï"}.fa-adjust:before{content:"ï‚"}.fa-tint:before{content:"ïƒ"}.fa-edit:before,.fa-pencil-square-o:before{content:"ï„"}.fa-share-square-o:before{content:"ï…"}.fa-check-square-o:before{content:"ï†"}.fa-arrows:before{content:"ï‡"}.fa-step-backward:before{content:"ïˆ"}.fa-fast-backward:before{content:"ï‰"}.fa-backward:before{content:"ïŠ"}.fa-play:before{content:"ï‹"}.fa-pause:before{content:"ïŒ"}.fa-stop:before{content:"ï"}.fa-forward:before{content:"ïŽ"}.fa-fast-forward:before{content:"ï"}.fa-step-forward:before{content:"ï‘"}.fa-eject:before{content:"ï’"}.fa-chevron-left:before{content:"ï“"}.fa-chevron-right:before{content:"ï”"}.fa-plus-circle:before{content:"ï•"}.fa-minus-circle:before{content:"ï–"}.fa-times-circle:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before{content:"ï—"}.fa-check-circle:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before{content:"ï˜"}.fa-question-circle:before{content:"ï™"}.fa-info-circle:before{content:"ïš"}.fa-crosshairs:before{content:"ï›"}.fa-times-circle-o:before{content:"ïœ"}.fa-check-circle-o:before{content:"ï"}.fa-ban:before{content:"ïž"}.fa-arrow-left:before{content:"ï "}.fa-arrow-right:before{content:"ï¡"}.fa-arrow-up:before{content:"ï¢"}.fa-arrow-down:before{content:"ï£"}.fa-mail-forward:before,.fa-share:before{content:"ï¤"}.fa-expand:before{content:"ï¥"}.fa-compress:before{content:"ï¦"}.fa-plus:before{content:"ï§"}.fa-minus:before{content:"ï¨"}.fa-asterisk:before{content:"ï©"}.fa-exclamation-circle:before,.rst-content .admonition-title:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before{content:"ïª"}.fa-gift:before{content:"ï«"}.fa-leaf:before{content:"ï¬"}.fa-fire:before,.icon-fire:before{content:"ï"}.fa-eye:before{content:"ï®"}.fa-eye-slash:before{content:"ï°"}.fa-exclamation-triangle:before,.fa-warning:before{content:"ï±"}.fa-plane:before{content:"ï²"}.fa-calendar:before{content:"ï³"}.fa-random:before{content:"ï´"}.fa-comment:before{content:"ïµ"}.fa-magnet:before{content:"ï¶"}.fa-chevron-up:before{content:"ï·"}.fa-chevron-down:before{content:"ï¸"}.fa-retweet:before{content:"ï¹"}.fa-shopping-cart:before{content:"ïº"}.fa-folder:before{content:"ï»"}.fa-folder-open:before{content:"ï¼"}.fa-arrows-v:before{content:"ï½"}.fa-arrows-h:before{content:"ï¾"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"ï‚€"}.fa-twitter-square:before{content:"ï‚"}.fa-facebook-square:before{content:"ï‚‚"}.fa-camera-retro:before{content:""}.fa-key:before{content:"ï‚„"}.fa-cogs:before,.fa-gears:before{content:"ï‚…"}.fa-comments:before{content:""}.fa-thumbs-o-up:before{content:""}.fa-thumbs-o-down:before{content:""}.fa-star-half:before{content:""}.fa-heart-o:before{content:""}.fa-sign-out:before{content:"ï‚‹"}.fa-linkedin-square:before{content:""}.fa-thumb-tack:before{content:"ï‚"}.fa-external-link:before{content:""}.fa-sign-in:before{content:"ï‚"}.fa-trophy:before{content:"ï‚‘"}.fa-github-square:before{content:"ï‚’"}.fa-upload:before{content:"ï‚“"}.fa-lemon-o:before{content:"ï‚”"}.fa-phone:before{content:"ï‚•"}.fa-square-o:before{content:"ï‚–"}.fa-bookmark-o:before{content:"ï‚—"}.fa-phone-square:before{content:""}.fa-twitter:before{content:"ï‚™"}.fa-facebook-f:before,.fa-facebook:before{content:""}.fa-github:before,.icon-github:before{content:"ï‚›"}.fa-unlock:before{content:""}.fa-credit-card:before{content:"ï‚"}.fa-feed:before,.fa-rss:before{content:""}.fa-hdd-o:before{content:"ï‚ "}.fa-bullhorn:before{content:"ï‚¡"}.fa-bell:before{content:""}.fa-certificate:before{content:"ï‚£"}.fa-hand-o-right:before{content:""}.fa-hand-o-left:before{content:"ï‚¥"}.fa-hand-o-up:before{content:""}.fa-hand-o-down:before{content:"ï‚§"}.fa-arrow-circle-left:before,.icon-circle-arrow-left:before{content:""}.fa-arrow-circle-right:before,.icon-circle-arrow-right:before{content:"ï‚©"}.fa-arrow-circle-up:before{content:""}.fa-arrow-circle-down:before{content:"ï‚«"}.fa-globe:before{content:""}.fa-wrench:before{content:"ï‚"}.fa-tasks:before{content:"ï‚®"}.fa-filter:before{content:"ï‚°"}.fa-briefcase:before{content:""}.fa-arrows-alt:before{content:""}.fa-group:before,.fa-users:before{content:""}.fa-chain:before,.fa-link:before,.icon-link:before{content:"ïƒ"}.fa-cloud:before{content:""}.fa-flask:before{content:""}.fa-cut:before,.fa-scissors:before{content:""}.fa-copy:before,.fa-files-o:before{content:""}.fa-paperclip:before{content:""}.fa-floppy-o:before,.fa-save:before{content:""}.fa-square:before{content:""}.fa-bars:before,.fa-navicon:before,.fa-reorder:before{content:""}.fa-list-ul:before{content:""}.fa-list-ol:before{content:""}.fa-strikethrough:before{content:""}.fa-underline:before{content:"ïƒ"}.fa-table:before{content:""}.fa-magic:before{content:"ïƒ"}.fa-truck:before{content:""}.fa-pinterest:before{content:""}.fa-pinterest-square:before{content:""}.fa-google-plus-square:before{content:""}.fa-google-plus:before{content:""}.fa-money:before{content:""}.fa-caret-down:before,.icon-caret-down:before,.wy-dropdown .caret:before{content:""}.fa-caret-up:before{content:""}.fa-caret-left:before{content:""}.fa-caret-right:before{content:""}.fa-columns:before{content:""}.fa-sort:before,.fa-unsorted:before{content:""}.fa-sort-desc:before,.fa-sort-down:before{content:"ïƒ"}.fa-sort-asc:before,.fa-sort-up:before{content:""}.fa-envelope:before{content:"ïƒ "}.fa-linkedin:before{content:""}.fa-rotate-left:before,.fa-undo:before{content:""}.fa-gavel:before,.fa-legal:before{content:""}.fa-dashboard:before,.fa-tachometer:before{content:""}.fa-comment-o:before{content:""}.fa-comments-o:before{content:""}.fa-bolt:before,.fa-flash:before{content:""}.fa-sitemap:before{content:""}.fa-umbrella:before{content:""}.fa-clipboard:before,.fa-paste:before{content:""}.fa-lightbulb-o:before{content:""}.fa-exchange:before{content:""}.fa-cloud-download:before{content:"ïƒ"}.fa-cloud-upload:before{content:""}.fa-user-md:before{content:""}.fa-stethoscope:before{content:""}.fa-suitcase:before{content:""}.fa-bell-o:before{content:"ï‚¢"}.fa-coffee:before{content:""}.fa-cutlery:before{content:""}.fa-file-text-o:before{content:""}.fa-building-o:before{content:""}.fa-hospital-o:before{content:""}.fa-ambulance:before{content:""}.fa-medkit:before{content:""}.fa-fighter-jet:before{content:""}.fa-beer:before{content:""}.fa-h-square:before{content:""}.fa-plus-square:before{content:""}.fa-angle-double-left:before{content:"ï„€"}.fa-angle-double-right:before{content:"ï„"}.fa-angle-double-up:before{content:"ï„‚"}.fa-angle-double-down:before{content:""}.fa-angle-left:before{content:"ï„„"}.fa-angle-right:before{content:"ï„…"}.fa-angle-up:before{content:""}.fa-angle-down:before{content:""}.fa-desktop:before{content:""}.fa-laptop:before{content:""}.fa-tablet:before{content:""}.fa-mobile-phone:before,.fa-mobile:before{content:"ï„‹"}.fa-circle-o:before{content:""}.fa-quote-left:before{content:"ï„"}.fa-quote-right:before{content:""}.fa-spinner:before{content:"ï„"}.fa-circle:before{content:"ï„‘"}.fa-mail-reply:before,.fa-reply:before{content:"ï„’"}.fa-github-alt:before{content:"ï„“"}.fa-folder-o:before{content:"ï„”"}.fa-folder-open-o:before{content:"ï„•"}.fa-smile-o:before{content:""}.fa-frown-o:before{content:"ï„™"}.fa-meh-o:before{content:""}.fa-gamepad:before{content:"ï„›"}.fa-keyboard-o:before{content:""}.fa-flag-o:before{content:"ï„"}.fa-flag-checkered:before{content:""}.fa-terminal:before{content:"ï„ "}.fa-code:before{content:"ï„¡"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"ï„¢"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"ï„£"}.fa-location-arrow:before{content:""}.fa-crop:before{content:"ï„¥"}.fa-code-fork:before{content:""}.fa-chain-broken:before,.fa-unlink:before{content:"ï„§"}.fa-question:before{content:""}.fa-info:before{content:"ï„©"}.fa-exclamation:before{content:""}.fa-superscript:before{content:"ï„«"}.fa-subscript:before{content:""}.fa-eraser:before{content:"ï„"}.fa-puzzle-piece:before{content:"ï„®"}.fa-microphone:before{content:"ï„°"}.fa-microphone-slash:before{content:""}.fa-shield:before{content:""}.fa-calendar-o:before{content:""}.fa-fire-extinguisher:before{content:"ï„´"}.fa-rocket:before{content:""}.fa-maxcdn:before{content:"ï„¶"}.fa-chevron-circle-left:before{content:"ï„·"}.fa-chevron-circle-right:before{content:""}.fa-chevron-circle-up:before{content:""}.fa-chevron-circle-down:before{content:""}.fa-html5:before{content:"ï„»"}.fa-css3:before{content:""}.fa-anchor:before{content:""}.fa-unlock-alt:before{content:""}.fa-bullseye:before{content:"ï…€"}.fa-ellipsis-h:before{content:"ï…"}.fa-ellipsis-v:before{content:"ï…‚"}.fa-rss-square:before{content:"ï…ƒ"}.fa-play-circle:before{content:"ï…„"}.fa-ticket:before{content:"ï……"}.fa-minus-square:before{content:"ï…†"}.fa-minus-square-o:before,.wy-menu-vertical li.current>a button.toctree-expand:before,.wy-menu-vertical li.on a button.toctree-expand:before{content:"ï…‡"}.fa-level-up:before{content:"ï…ˆ"}.fa-level-down:before{content:"ï…‰"}.fa-check-square:before{content:"ï…Š"}.fa-pencil-square:before{content:"ï…‹"}.fa-external-link-square:before{content:"ï…Œ"}.fa-share-square:before{content:"ï…"}.fa-compass:before{content:"ï…Ž"}.fa-caret-square-o-down:before,.fa-toggle-down:before{content:"ï…"}.fa-caret-square-o-up:before,.fa-toggle-up:before{content:"ï…‘"}.fa-caret-square-o-right:before,.fa-toggle-right:before{content:"ï…’"}.fa-eur:before,.fa-euro:before{content:"ï…“"}.fa-gbp:before{content:"ï…”"}.fa-dollar:before,.fa-usd:before{content:"ï…•"}.fa-inr:before,.fa-rupee:before{content:"ï…–"}.fa-cny:before,.fa-jpy:before,.fa-rmb:before,.fa-yen:before{content:"ï…—"}.fa-rouble:before,.fa-rub:before,.fa-ruble:before{content:"ï…˜"}.fa-krw:before,.fa-won:before{content:"ï…™"}.fa-bitcoin:before,.fa-btc:before{content:"ï…š"}.fa-file:before{content:"ï…›"}.fa-file-text:before{content:"ï…œ"}.fa-sort-alpha-asc:before{content:"ï…"}.fa-sort-alpha-desc:before{content:"ï…ž"}.fa-sort-amount-asc:before{content:"ï… "}.fa-sort-amount-desc:before{content:"ï…¡"}.fa-sort-numeric-asc:before{content:"ï…¢"}.fa-sort-numeric-desc:before{content:"ï…£"}.fa-thumbs-up:before{content:"ï…¤"}.fa-thumbs-down:before{content:"ï…¥"}.fa-youtube-square:before{content:"ï…¦"}.fa-youtube:before{content:"ï…§"}.fa-xing:before{content:"ï…¨"}.fa-xing-square:before{content:"ï…©"}.fa-youtube-play:before{content:"ï…ª"}.fa-dropbox:before{content:"ï…«"}.fa-stack-overflow:before{content:"ï…¬"}.fa-instagram:before{content:"ï…"}.fa-flickr:before{content:"ï…®"}.fa-adn:before{content:"ï…°"}.fa-bitbucket:before,.icon-bitbucket:before{content:"ï…±"}.fa-bitbucket-square:before{content:"ï…²"}.fa-tumblr:before{content:"ï…³"}.fa-tumblr-square:before{content:"ï…´"}.fa-long-arrow-down:before{content:"ï…µ"}.fa-long-arrow-up:before{content:"ï…¶"}.fa-long-arrow-left:before{content:"ï…·"}.fa-long-arrow-right:before{content:"ï…¸"}.fa-apple:before{content:"ï…¹"}.fa-windows:before{content:"ï…º"}.fa-android:before{content:"ï…»"}.fa-linux:before{content:"ï…¼"}.fa-dribbble:before{content:"ï…½"}.fa-skype:before{content:"ï…¾"}.fa-foursquare:before{content:""}.fa-trello:before{content:"ï†"}.fa-female:before{content:""}.fa-male:before{content:""}.fa-gittip:before,.fa-gratipay:before{content:""}.fa-sun-o:before{content:""}.fa-moon-o:before{content:""}.fa-archive:before{content:""}.fa-bug:before{content:""}.fa-vk:before{content:""}.fa-weibo:before{content:""}.fa-renren:before{content:""}.fa-pagelines:before{content:""}.fa-stack-exchange:before{content:"ï†"}.fa-arrow-circle-o-right:before{content:""}.fa-arrow-circle-o-left:before{content:"ï†"}.fa-caret-square-o-left:before,.fa-toggle-left:before{content:""}.fa-dot-circle-o:before{content:""}.fa-wheelchair:before{content:""}.fa-vimeo-square:before{content:""}.fa-try:before,.fa-turkish-lira:before{content:""}.fa-plus-square-o:before,.wy-menu-vertical li button.toctree-expand:before{content:""}.fa-space-shuttle:before{content:""}.fa-slack:before{content:""}.fa-envelope-square:before{content:""}.fa-wordpress:before{content:""}.fa-openid:before{content:""}.fa-bank:before,.fa-institution:before,.fa-university:before{content:""}.fa-graduation-cap:before,.fa-mortar-board:before{content:"ï†"}.fa-yahoo:before{content:""}.fa-google:before{content:"ï† "}.fa-reddit:before{content:""}.fa-reddit-square:before{content:""}.fa-stumbleupon-circle:before{content:""}.fa-stumbleupon:before{content:""}.fa-delicious:before{content:""}.fa-digg:before{content:""}.fa-pied-piper-pp:before{content:""}.fa-pied-piper-alt:before{content:""}.fa-drupal:before{content:""}.fa-joomla:before{content:""}.fa-language:before{content:""}.fa-fax:before{content:""}.fa-building:before{content:"ï†"}.fa-child:before{content:""}.fa-paw:before{content:""}.fa-spoon:before{content:""}.fa-cube:before{content:""}.fa-cubes:before{content:""}.fa-behance:before{content:""}.fa-behance-square:before{content:""}.fa-steam:before{content:""}.fa-steam-square:before{content:""}.fa-recycle:before{content:""}.fa-automobile:before,.fa-car:before{content:""}.fa-cab:before,.fa-taxi:before{content:""}.fa-tree:before{content:""}.fa-spotify:before{content:""}.fa-deviantart:before{content:""}.fa-soundcloud:before{content:""}.fa-database:before{content:""}.fa-file-pdf-o:before{content:"ï‡"}.fa-file-word-o:before{content:""}.fa-file-excel-o:before{content:""}.fa-file-powerpoint-o:before{content:""}.fa-file-image-o:before,.fa-file-photo-o:before,.fa-file-picture-o:before{content:""}.fa-file-archive-o:before,.fa-file-zip-o:before{content:""}.fa-file-audio-o:before,.fa-file-sound-o:before{content:""}.fa-file-movie-o:before,.fa-file-video-o:before{content:""}.fa-file-code-o:before{content:""}.fa-vine:before{content:""}.fa-codepen:before{content:""}.fa-jsfiddle:before{content:""}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-ring:before,.fa-life-saver:before,.fa-support:before{content:"ï‡"}.fa-circle-o-notch:before{content:""}.fa-ra:before,.fa-rebel:before,.fa-resistance:before{content:"ï‡"}.fa-empire:before,.fa-ge:before{content:""}.fa-git-square:before{content:""}.fa-git:before{content:""}.fa-hacker-news:before,.fa-y-combinator-square:before,.fa-yc-square:before{content:""}.fa-tencent-weibo:before{content:""}.fa-qq:before{content:""}.fa-wechat:before,.fa-weixin:before{content:""}.fa-paper-plane:before,.fa-send:before{content:""}.fa-paper-plane-o:before,.fa-send-o:before{content:""}.fa-history:before{content:""}.fa-circle-thin:before{content:""}.fa-header:before{content:""}.fa-paragraph:before{content:"ï‡"}.fa-sliders:before{content:""}.fa-share-alt:before{content:"ï‡ "}.fa-share-alt-square:before{content:""}.fa-bomb:before{content:""}.fa-futbol-o:before,.fa-soccer-ball-o:before{content:""}.fa-tty:before{content:""}.fa-binoculars:before{content:""}.fa-plug:before{content:""}.fa-slideshare:before{content:""}.fa-twitch:before{content:""}.fa-yelp:before{content:""}.fa-newspaper-o:before{content:""}.fa-wifi:before{content:""}.fa-calculator:before{content:""}.fa-paypal:before{content:"ï‡"}.fa-google-wallet:before{content:""}.fa-cc-visa:before{content:""}.fa-cc-mastercard:before{content:""}.fa-cc-discover:before{content:""}.fa-cc-amex:before{content:""}.fa-cc-paypal:before{content:""}.fa-cc-stripe:before{content:""}.fa-bell-slash:before{content:""}.fa-bell-slash-o:before{content:""}.fa-trash:before{content:""}.fa-copyright:before{content:""}.fa-at:before{content:""}.fa-eyedropper:before{content:""}.fa-paint-brush:before{content:""}.fa-birthday-cake:before{content:""}.fa-area-chart:before{content:""}.fa-pie-chart:before{content:""}.fa-line-chart:before{content:"ïˆ"}.fa-lastfm:before{content:""}.fa-lastfm-square:before{content:""}.fa-toggle-off:before{content:""}.fa-toggle-on:before{content:""}.fa-bicycle:before{content:""}.fa-bus:before{content:""}.fa-ioxhost:before{content:""}.fa-angellist:before{content:""}.fa-cc:before{content:""}.fa-ils:before,.fa-shekel:before,.fa-sheqel:before{content:""}.fa-meanpath:before{content:""}.fa-buysellads:before{content:"ïˆ"}.fa-connectdevelop:before{content:""}.fa-dashcube:before{content:"ïˆ"}.fa-forumbee:before{content:""}.fa-leanpub:before{content:""}.fa-sellsy:before{content:""}.fa-shirtsinbulk:before{content:""}.fa-simplybuilt:before{content:""}.fa-skyatlas:before{content:""}.fa-cart-plus:before{content:""}.fa-cart-arrow-down:before{content:""}.fa-diamond:before{content:""}.fa-ship:before{content:""}.fa-user-secret:before{content:""}.fa-motorcycle:before{content:""}.fa-street-view:before{content:"ïˆ"}.fa-heartbeat:before{content:""}.fa-venus:before{content:""}.fa-mars:before{content:""}.fa-mercury:before{content:""}.fa-intersex:before,.fa-transgender:before{content:""}.fa-transgender-alt:before{content:""}.fa-venus-double:before{content:""}.fa-mars-double:before{content:""}.fa-venus-mars:before{content:""}.fa-mars-stroke:before{content:""}.fa-mars-stroke-v:before{content:""}.fa-mars-stroke-h:before{content:""}.fa-neuter:before{content:""}.fa-genderless:before{content:"ïˆ"}.fa-facebook-official:before{content:""}.fa-pinterest-p:before{content:""}.fa-whatsapp:before{content:""}.fa-server:before{content:""}.fa-user-plus:before{content:""}.fa-user-times:before{content:""}.fa-bed:before,.fa-hotel:before{content:""}.fa-viacoin:before{content:""}.fa-train:before{content:""}.fa-subway:before{content:""}.fa-medium:before{content:""}.fa-y-combinator:before,.fa-yc:before{content:""}.fa-optin-monster:before{content:""}.fa-opencart:before{content:""}.fa-expeditedssl:before{content:""}.fa-battery-4:before,.fa-battery-full:before,.fa-battery:before{content:""}.fa-battery-3:before,.fa-battery-three-quarters:before{content:"ï‰"}.fa-battery-2:before,.fa-battery-half:before{content:""}.fa-battery-1:before,.fa-battery-quarter:before{content:""}.fa-battery-0:before,.fa-battery-empty:before{content:""}.fa-mouse-pointer:before{content:""}.fa-i-cursor:before{content:""}.fa-object-group:before{content:""}.fa-object-ungroup:before{content:""}.fa-sticky-note:before{content:""}.fa-sticky-note-o:before{content:""}.fa-cc-jcb:before{content:""}.fa-cc-diners-club:before{content:""}.fa-clone:before{content:"ï‰"}.fa-balance-scale:before{content:""}.fa-hourglass-o:before{content:"ï‰"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:""}.fa-hourglass-2:before,.fa-hourglass-half:before{content:""}.fa-hourglass-3:before,.fa-hourglass-end:before{content:""}.fa-hourglass:before{content:""}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:""}.fa-hand-paper-o:before,.fa-hand-stop-o:before{content:""}.fa-hand-scissors-o:before{content:""}.fa-hand-lizard-o:before{content:""}.fa-hand-spock-o:before{content:""}.fa-hand-pointer-o:before{content:""}.fa-hand-peace-o:before{content:""}.fa-trademark:before{content:""}.fa-registered:before{content:"ï‰"}.fa-creative-commons:before{content:""}.fa-gg:before{content:"ï‰ "}.fa-gg-circle:before{content:""}.fa-tripadvisor:before{content:""}.fa-odnoklassniki:before{content:""}.fa-odnoklassniki-square:before{content:""}.fa-get-pocket:before{content:""}.fa-wikipedia-w:before{content:""}.fa-safari:before{content:""}.fa-chrome:before{content:""}.fa-firefox:before{content:""}.fa-opera:before{content:""}.fa-internet-explorer:before{content:""}.fa-television:before,.fa-tv:before{content:""}.fa-contao:before{content:"ï‰"}.fa-500px:before{content:""}.fa-amazon:before{content:""}.fa-calendar-plus-o:before{content:""}.fa-calendar-minus-o:before{content:""}.fa-calendar-times-o:before{content:""}.fa-calendar-check-o:before{content:""}.fa-industry:before{content:""}.fa-map-pin:before{content:""}.fa-map-signs:before{content:""}.fa-map-o:before{content:""}.fa-map:before{content:""}.fa-commenting:before{content:""}.fa-commenting-o:before{content:""}.fa-houzz:before{content:""}.fa-vimeo:before{content:""}.fa-black-tie:before{content:""}.fa-fonticons:before{content:""}.fa-reddit-alien:before{content:"ïŠ"}.fa-edge:before{content:""}.fa-credit-card-alt:before{content:""}.fa-codiepie:before{content:""}.fa-modx:before{content:""}.fa-fort-awesome:before{content:""}.fa-usb:before{content:""}.fa-product-hunt:before{content:""}.fa-mixcloud:before{content:""}.fa-scribd:before{content:""}.fa-pause-circle:before{content:""}.fa-pause-circle-o:before{content:""}.fa-stop-circle:before{content:"ïŠ"}.fa-stop-circle-o:before{content:""}.fa-shopping-bag:before{content:"ïŠ"}.fa-shopping-basket:before{content:""}.fa-hashtag:before{content:""}.fa-bluetooth:before{content:""}.fa-bluetooth-b:before{content:""}.fa-percent:before{content:""}.fa-gitlab:before,.icon-gitlab:before{content:""}.fa-wpbeginner:before{content:""}.fa-wpforms:before{content:""}.fa-envira:before{content:""}.fa-universal-access:before{content:""}.fa-wheelchair-alt:before{content:""}.fa-question-circle-o:before{content:""}.fa-blind:before{content:"ïŠ"}.fa-audio-description:before{content:""}.fa-volume-control-phone:before{content:"ïŠ "}.fa-braille:before{content:""}.fa-assistive-listening-systems:before{content:""}.fa-american-sign-language-interpreting:before,.fa-asl-interpreting:before{content:""}.fa-deaf:before,.fa-deafness:before,.fa-hard-of-hearing:before{content:""}.fa-glide:before{content:""}.fa-glide-g:before{content:""}.fa-sign-language:before,.fa-signing:before{content:""}.fa-low-vision:before{content:""}.fa-viadeo:before{content:""}.fa-viadeo-square:before{content:""}.fa-snapchat:before{content:""}.fa-snapchat-ghost:before{content:""}.fa-snapchat-square:before{content:"ïŠ"}.fa-pied-piper:before{content:""}.fa-first-order:before{content:""}.fa-yoast:before{content:""}.fa-themeisle:before{content:""}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:""}.fa-fa:before,.fa-font-awesome:before{content:""}.fa-handshake-o:before{content:""}.fa-envelope-open:before{content:""}.fa-envelope-open-o:before{content:""}.fa-linode:before{content:""}.fa-address-book:before{content:""}.fa-address-book-o:before{content:""}.fa-address-card:before,.fa-vcard:before{content:""}.fa-address-card-o:before,.fa-vcard-o:before{content:""}.fa-user-circle:before{content:""}.fa-user-circle-o:before{content:""}.fa-user-o:before{content:"ï‹€"}.fa-id-badge:before{content:"ï‹"}.fa-drivers-license:before,.fa-id-card:before{content:"ï‹‚"}.fa-drivers-license-o:before,.fa-id-card-o:before{content:""}.fa-quora:before{content:"ï‹„"}.fa-free-code-camp:before{content:"ï‹…"}.fa-telegram:before{content:""}.fa-thermometer-4:before,.fa-thermometer-full:before,.fa-thermometer:before{content:""}.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:""}.fa-thermometer-2:before,.fa-thermometer-half:before{content:""}.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:""}.fa-thermometer-0:before,.fa-thermometer-empty:before{content:"ï‹‹"}.fa-shower:before{content:""}.fa-bath:before,.fa-bathtub:before,.fa-s15:before{content:"ï‹"}.fa-podcast:before{content:""}.fa-window-maximize:before{content:"ï‹"}.fa-window-minimize:before{content:"ï‹‘"}.fa-window-restore:before{content:"ï‹’"}.fa-times-rectangle:before,.fa-window-close:before{content:"ï‹“"}.fa-times-rectangle-o:before,.fa-window-close-o:before{content:"ï‹”"}.fa-bandcamp:before{content:"ï‹•"}.fa-grav:before{content:"ï‹–"}.fa-etsy:before{content:"ï‹—"}.fa-imdb:before{content:""}.fa-ravelry:before{content:"ï‹™"}.fa-eercast:before{content:""}.fa-microchip:before{content:"ï‹›"}.fa-snowflake-o:before{content:""}.fa-superpowers:before{content:"ï‹"}.fa-wpexplorer:before{content:""}.fa-meetup:before{content:"ï‹ "}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.fa,.icon,.rst-content .admonition-title,.rst-content .code-block-caption .headerlink,.rst-content .eqno .headerlink,.rst-content code.download span:first-child,.rst-content dl dt .headerlink,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content p.caption .headerlink,.rst-content p .headerlink,.rst-content table>caption .headerlink,.rst-content tt.download span:first-child,.wy-dropdown .caret,.wy-inline-validate.wy-inline-validate-danger .wy-input-context,.wy-inline-validate.wy-inline-validate-info .wy-input-context,.wy-inline-validate.wy-inline-validate-success .wy-input-context,.wy-inline-validate.wy-inline-validate-warning .wy-input-context,.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand,.wy-menu-vertical li button.toctree-expand{font-family:inherit}.fa:before,.icon:before,.rst-content .admonition-title:before,.rst-content .code-block-caption .headerlink:before,.rst-content .eqno .headerlink:before,.rst-content code.download span:first-child:before,.rst-content dl dt .headerlink:before,.rst-content h1 .headerlink:before,.rst-content h2 .headerlink:before,.rst-content h3 .headerlink:before,.rst-content h4 .headerlink:before,.rst-content h5 .headerlink:before,.rst-content h6 .headerlink:before,.rst-content p.caption .headerlink:before,.rst-content p .headerlink:before,.rst-content table>caption .headerlink:before,.rst-content tt.download span:first-child:before,.wy-dropdown .caret:before,.wy-inline-validate.wy-inline-validate-danger .wy-input-context:before,.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,.wy-inline-validate.wy-inline-validate-success .wy-input-context:before,.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before,.wy-menu-vertical li.current>a button.toctree-expand:before,.wy-menu-vertical li.on a button.toctree-expand:before,.wy-menu-vertical li button.toctree-expand:before{font-family:FontAwesome;display:inline-block;font-style:normal;font-weight:400;line-height:1;text-decoration:inherit}.rst-content .code-block-caption a .headerlink,.rst-content .eqno a .headerlink,.rst-content a .admonition-title,.rst-content code.download a span:first-child,.rst-content dl dt a .headerlink,.rst-content h1 a .headerlink,.rst-content h2 a .headerlink,.rst-content h3 a .headerlink,.rst-content h4 a .headerlink,.rst-content h5 a .headerlink,.rst-content h6 a .headerlink,.rst-content p.caption a .headerlink,.rst-content p a .headerlink,.rst-content table>caption a .headerlink,.rst-content tt.download a span:first-child,.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand,.wy-menu-vertical li a button.toctree-expand,a .fa,a .icon,a .rst-content .admonition-title,a .rst-content .code-block-caption .headerlink,a .rst-content .eqno .headerlink,a .rst-content code.download span:first-child,a .rst-content dl dt .headerlink,a .rst-content h1 .headerlink,a .rst-content h2 .headerlink,a .rst-content h3 .headerlink,a .rst-content h4 .headerlink,a .rst-content h5 .headerlink,a .rst-content h6 .headerlink,a .rst-content p.caption .headerlink,a .rst-content p .headerlink,a .rst-content table>caption .headerlink,a .rst-content tt.download span:first-child,a .wy-menu-vertical li button.toctree-expand{display:inline-block;text-decoration:inherit}.btn .fa,.btn .icon,.btn .rst-content .admonition-title,.btn .rst-content .code-block-caption .headerlink,.btn .rst-content .eqno .headerlink,.btn .rst-content code.download span:first-child,.btn .rst-content dl dt .headerlink,.btn .rst-content h1 .headerlink,.btn .rst-content h2 .headerlink,.btn .rst-content h3 .headerlink,.btn .rst-content h4 .headerlink,.btn .rst-content h5 .headerlink,.btn .rst-content h6 .headerlink,.btn .rst-content p .headerlink,.btn .rst-content table>caption .headerlink,.btn .rst-content tt.download span:first-child,.btn .wy-menu-vertical li.current>a button.toctree-expand,.btn .wy-menu-vertical li.on a button.toctree-expand,.btn .wy-menu-vertical li button.toctree-expand,.nav .fa,.nav .icon,.nav .rst-content .admonition-title,.nav .rst-content .code-block-caption .headerlink,.nav .rst-content .eqno .headerlink,.nav .rst-content code.download span:first-child,.nav .rst-content dl dt .headerlink,.nav .rst-content h1 .headerlink,.nav .rst-content h2 .headerlink,.nav .rst-content h3 .headerlink,.nav .rst-content h4 .headerlink,.nav .rst-content h5 .headerlink,.nav .rst-content h6 .headerlink,.nav .rst-content p .headerlink,.nav .rst-content table>caption .headerlink,.nav .rst-content tt.download span:first-child,.nav .wy-menu-vertical li.current>a button.toctree-expand,.nav .wy-menu-vertical li.on a button.toctree-expand,.nav .wy-menu-vertical li button.toctree-expand,.rst-content .btn .admonition-title,.rst-content .code-block-caption .btn .headerlink,.rst-content .code-block-caption .nav .headerlink,.rst-content .eqno .btn .headerlink,.rst-content .eqno .nav .headerlink,.rst-content .nav .admonition-title,.rst-content code.download .btn span:first-child,.rst-content code.download .nav span:first-child,.rst-content dl dt .btn .headerlink,.rst-content dl dt .nav .headerlink,.rst-content h1 .btn .headerlink,.rst-content h1 .nav .headerlink,.rst-content h2 .btn .headerlink,.rst-content h2 .nav .headerlink,.rst-content h3 .btn .headerlink,.rst-content h3 .nav .headerlink,.rst-content h4 .btn .headerlink,.rst-content h4 .nav .headerlink,.rst-content h5 .btn .headerlink,.rst-content h5 .nav .headerlink,.rst-content h6 .btn .headerlink,.rst-content h6 .nav .headerlink,.rst-content p .btn .headerlink,.rst-content p .nav .headerlink,.rst-content table>caption .btn .headerlink,.rst-content table>caption .nav .headerlink,.rst-content tt.download .btn span:first-child,.rst-content tt.download .nav span:first-child,.wy-menu-vertical li .btn button.toctree-expand,.wy-menu-vertical li.current>a .btn button.toctree-expand,.wy-menu-vertical li.current>a .nav button.toctree-expand,.wy-menu-vertical li .nav button.toctree-expand,.wy-menu-vertical li.on a .btn button.toctree-expand,.wy-menu-vertical li.on a .nav button.toctree-expand{display:inline}.btn .fa-large.icon,.btn .fa.fa-large,.btn .rst-content .code-block-caption .fa-large.headerlink,.btn .rst-content .eqno .fa-large.headerlink,.btn .rst-content .fa-large.admonition-title,.btn .rst-content code.download span.fa-large:first-child,.btn .rst-content dl dt .fa-large.headerlink,.btn .rst-content h1 .fa-large.headerlink,.btn .rst-content h2 .fa-large.headerlink,.btn .rst-content h3 .fa-large.headerlink,.btn .rst-content h4 .fa-large.headerlink,.btn .rst-content h5 .fa-large.headerlink,.btn .rst-content h6 .fa-large.headerlink,.btn .rst-content p .fa-large.headerlink,.btn .rst-content table>caption .fa-large.headerlink,.btn .rst-content tt.download span.fa-large:first-child,.btn .wy-menu-vertical li button.fa-large.toctree-expand,.nav .fa-large.icon,.nav .fa.fa-large,.nav .rst-content .code-block-caption .fa-large.headerlink,.nav .rst-content .eqno .fa-large.headerlink,.nav .rst-content .fa-large.admonition-title,.nav .rst-content code.download span.fa-large:first-child,.nav .rst-content dl dt .fa-large.headerlink,.nav .rst-content h1 .fa-large.headerlink,.nav .rst-content h2 .fa-large.headerlink,.nav .rst-content h3 .fa-large.headerlink,.nav .rst-content h4 .fa-large.headerlink,.nav .rst-content h5 .fa-large.headerlink,.nav .rst-content h6 .fa-large.headerlink,.nav .rst-content p .fa-large.headerlink,.nav .rst-content table>caption .fa-large.headerlink,.nav .rst-content tt.download span.fa-large:first-child,.nav .wy-menu-vertical li button.fa-large.toctree-expand,.rst-content .btn .fa-large.admonition-title,.rst-content .code-block-caption .btn .fa-large.headerlink,.rst-content .code-block-caption .nav .fa-large.headerlink,.rst-content .eqno .btn .fa-large.headerlink,.rst-content .eqno .nav .fa-large.headerlink,.rst-content .nav .fa-large.admonition-title,.rst-content code.download .btn span.fa-large:first-child,.rst-content code.download .nav span.fa-large:first-child,.rst-content dl dt .btn .fa-large.headerlink,.rst-content dl dt .nav .fa-large.headerlink,.rst-content h1 .btn .fa-large.headerlink,.rst-content h1 .nav .fa-large.headerlink,.rst-content h2 .btn .fa-large.headerlink,.rst-content h2 .nav .fa-large.headerlink,.rst-content h3 .btn .fa-large.headerlink,.rst-content h3 .nav .fa-large.headerlink,.rst-content h4 .btn .fa-large.headerlink,.rst-content h4 .nav .fa-large.headerlink,.rst-content h5 .btn .fa-large.headerlink,.rst-content h5 .nav .fa-large.headerlink,.rst-content h6 .btn .fa-large.headerlink,.rst-content h6 .nav .fa-large.headerlink,.rst-content p .btn .fa-large.headerlink,.rst-content p .nav .fa-large.headerlink,.rst-content table>caption .btn .fa-large.headerlink,.rst-content table>caption .nav .fa-large.headerlink,.rst-content tt.download .btn span.fa-large:first-child,.rst-content tt.download .nav span.fa-large:first-child,.wy-menu-vertical li .btn button.fa-large.toctree-expand,.wy-menu-vertical li .nav button.fa-large.toctree-expand{line-height:.9em}.btn .fa-spin.icon,.btn .fa.fa-spin,.btn .rst-content .code-block-caption .fa-spin.headerlink,.btn .rst-content .eqno .fa-spin.headerlink,.btn .rst-content .fa-spin.admonition-title,.btn .rst-content code.download span.fa-spin:first-child,.btn .rst-content dl dt .fa-spin.headerlink,.btn .rst-content h1 .fa-spin.headerlink,.btn .rst-content h2 .fa-spin.headerlink,.btn .rst-content h3 .fa-spin.headerlink,.btn .rst-content h4 .fa-spin.headerlink,.btn .rst-content h5 .fa-spin.headerlink,.btn .rst-content h6 .fa-spin.headerlink,.btn .rst-content p .fa-spin.headerlink,.btn .rst-content table>caption .fa-spin.headerlink,.btn .rst-content tt.download span.fa-spin:first-child,.btn .wy-menu-vertical li button.fa-spin.toctree-expand,.nav .fa-spin.icon,.nav .fa.fa-spin,.nav .rst-content .code-block-caption .fa-spin.headerlink,.nav .rst-content .eqno .fa-spin.headerlink,.nav .rst-content .fa-spin.admonition-title,.nav .rst-content code.download span.fa-spin:first-child,.nav .rst-content dl dt .fa-spin.headerlink,.nav .rst-content h1 .fa-spin.headerlink,.nav .rst-content h2 .fa-spin.headerlink,.nav .rst-content h3 .fa-spin.headerlink,.nav .rst-content h4 .fa-spin.headerlink,.nav .rst-content h5 .fa-spin.headerlink,.nav .rst-content h6 .fa-spin.headerlink,.nav .rst-content p .fa-spin.headerlink,.nav .rst-content table>caption .fa-spin.headerlink,.nav .rst-content tt.download span.fa-spin:first-child,.nav .wy-menu-vertical li button.fa-spin.toctree-expand,.rst-content .btn .fa-spin.admonition-title,.rst-content .code-block-caption .btn .fa-spin.headerlink,.rst-content .code-block-caption .nav .fa-spin.headerlink,.rst-content .eqno .btn .fa-spin.headerlink,.rst-content .eqno .nav .fa-spin.headerlink,.rst-content .nav .fa-spin.admonition-title,.rst-content code.download .btn span.fa-spin:first-child,.rst-content code.download .nav span.fa-spin:first-child,.rst-content dl dt .btn .fa-spin.headerlink,.rst-content dl dt .nav .fa-spin.headerlink,.rst-content h1 .btn .fa-spin.headerlink,.rst-content h1 .nav .fa-spin.headerlink,.rst-content h2 .btn .fa-spin.headerlink,.rst-content h2 .nav .fa-spin.headerlink,.rst-content h3 .btn .fa-spin.headerlink,.rst-content h3 .nav .fa-spin.headerlink,.rst-content h4 .btn .fa-spin.headerlink,.rst-content h4 .nav .fa-spin.headerlink,.rst-content h5 .btn .fa-spin.headerlink,.rst-content h5 .nav .fa-spin.headerlink,.rst-content h6 .btn .fa-spin.headerlink,.rst-content h6 .nav .fa-spin.headerlink,.rst-content p .btn .fa-spin.headerlink,.rst-content p .nav .fa-spin.headerlink,.rst-content table>caption .btn .fa-spin.headerlink,.rst-content table>caption .nav .fa-spin.headerlink,.rst-content tt.download .btn span.fa-spin:first-child,.rst-content tt.download .nav span.fa-spin:first-child,.wy-menu-vertical li .btn button.fa-spin.toctree-expand,.wy-menu-vertical li .nav button.fa-spin.toctree-expand{display:inline-block}.btn.fa:before,.btn.icon:before,.rst-content .btn.admonition-title:before,.rst-content .code-block-caption .btn.headerlink:before,.rst-content .eqno .btn.headerlink:before,.rst-content code.download span.btn:first-child:before,.rst-content dl dt .btn.headerlink:before,.rst-content h1 .btn.headerlink:before,.rst-content h2 .btn.headerlink:before,.rst-content h3 .btn.headerlink:before,.rst-content h4 .btn.headerlink:before,.rst-content h5 .btn.headerlink:before,.rst-content h6 .btn.headerlink:before,.rst-content p .btn.headerlink:before,.rst-content table>caption .btn.headerlink:before,.rst-content tt.download span.btn:first-child:before,.wy-menu-vertical li button.btn.toctree-expand:before{opacity:.5;-webkit-transition:opacity .05s ease-in;-moz-transition:opacity .05s ease-in;transition:opacity .05s ease-in}.btn.fa:hover:before,.btn.icon:hover:before,.rst-content .btn.admonition-title:hover:before,.rst-content .code-block-caption .btn.headerlink:hover:before,.rst-content .eqno .btn.headerlink:hover:before,.rst-content code.download span.btn:first-child:hover:before,.rst-content dl dt .btn.headerlink:hover:before,.rst-content h1 .btn.headerlink:hover:before,.rst-content h2 .btn.headerlink:hover:before,.rst-content h3 .btn.headerlink:hover:before,.rst-content h4 .btn.headerlink:hover:before,.rst-content h5 .btn.headerlink:hover:before,.rst-content h6 .btn.headerlink:hover:before,.rst-content p .btn.headerlink:hover:before,.rst-content table>caption .btn.headerlink:hover:before,.rst-content tt.download span.btn:first-child:hover:before,.wy-menu-vertical li button.btn.toctree-expand:hover:before{opacity:1}.btn-mini .fa:before,.btn-mini .icon:before,.btn-mini .rst-content .admonition-title:before,.btn-mini .rst-content .code-block-caption .headerlink:before,.btn-mini .rst-content .eqno .headerlink:before,.btn-mini .rst-content code.download span:first-child:before,.btn-mini .rst-content dl dt .headerlink:before,.btn-mini .rst-content h1 .headerlink:before,.btn-mini .rst-content h2 .headerlink:before,.btn-mini .rst-content h3 .headerlink:before,.btn-mini .rst-content h4 .headerlink:before,.btn-mini .rst-content h5 .headerlink:before,.btn-mini .rst-content h6 .headerlink:before,.btn-mini .rst-content p .headerlink:before,.btn-mini .rst-content table>caption .headerlink:before,.btn-mini .rst-content tt.download span:first-child:before,.btn-mini .wy-menu-vertical li button.toctree-expand:before,.rst-content .btn-mini .admonition-title:before,.rst-content .code-block-caption .btn-mini .headerlink:before,.rst-content .eqno .btn-mini .headerlink:before,.rst-content code.download .btn-mini span:first-child:before,.rst-content dl dt .btn-mini .headerlink:before,.rst-content h1 .btn-mini .headerlink:before,.rst-content h2 .btn-mini .headerlink:before,.rst-content h3 .btn-mini .headerlink:before,.rst-content h4 .btn-mini .headerlink:before,.rst-content h5 .btn-mini .headerlink:before,.rst-content h6 .btn-mini .headerlink:before,.rst-content p .btn-mini .headerlink:before,.rst-content table>caption .btn-mini .headerlink:before,.rst-content tt.download .btn-mini span:first-child:before,.wy-menu-vertical li .btn-mini button.toctree-expand:before{font-size:14px;vertical-align:-15%}.rst-content .admonition,.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .danger,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .note,.rst-content .seealso,.rst-content .tip,.rst-content .warning,.wy-alert{padding:12px;line-height:24px;margin-bottom:24px;background:#e7f2fa}.rst-content .admonition-title,.wy-alert-title{font-weight:700;display:block;color:#fff;background:#6ab0de;padding:6px 12px;margin:-12px -12px 12px}.rst-content .danger,.rst-content .error,.rst-content .wy-alert-danger.admonition,.rst-content .wy-alert-danger.admonition-todo,.rst-content .wy-alert-danger.attention,.rst-content .wy-alert-danger.caution,.rst-content .wy-alert-danger.hint,.rst-content .wy-alert-danger.important,.rst-content .wy-alert-danger.note,.rst-content .wy-alert-danger.seealso,.rst-content .wy-alert-danger.tip,.rst-content .wy-alert-danger.warning,.wy-alert.wy-alert-danger{background:#fdf3f2}.rst-content .danger .admonition-title,.rst-content .danger .wy-alert-title,.rst-content .error .admonition-title,.rst-content .error .wy-alert-title,.rst-content .wy-alert-danger.admonition-todo .admonition-title,.rst-content .wy-alert-danger.admonition-todo .wy-alert-title,.rst-content .wy-alert-danger.admonition .admonition-title,.rst-content .wy-alert-danger.admonition .wy-alert-title,.rst-content .wy-alert-danger.attention .admonition-title,.rst-content .wy-alert-danger.attention .wy-alert-title,.rst-content .wy-alert-danger.caution .admonition-title,.rst-content .wy-alert-danger.caution .wy-alert-title,.rst-content .wy-alert-danger.hint .admonition-title,.rst-content .wy-alert-danger.hint .wy-alert-title,.rst-content .wy-alert-danger.important .admonition-title,.rst-content .wy-alert-danger.important .wy-alert-title,.rst-content .wy-alert-danger.note .admonition-title,.rst-content .wy-alert-danger.note .wy-alert-title,.rst-content .wy-alert-danger.seealso .admonition-title,.rst-content .wy-alert-danger.seealso .wy-alert-title,.rst-content .wy-alert-danger.tip .admonition-title,.rst-content .wy-alert-danger.tip .wy-alert-title,.rst-content .wy-alert-danger.warning .admonition-title,.rst-content .wy-alert-danger.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-danger .admonition-title,.wy-alert.wy-alert-danger .rst-content .admonition-title,.wy-alert.wy-alert-danger .wy-alert-title{background:#f29f97}.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .warning,.rst-content .wy-alert-warning.admonition,.rst-content .wy-alert-warning.danger,.rst-content .wy-alert-warning.error,.rst-content .wy-alert-warning.hint,.rst-content .wy-alert-warning.important,.rst-content .wy-alert-warning.note,.rst-content .wy-alert-warning.seealso,.rst-content .wy-alert-warning.tip,.wy-alert.wy-alert-warning{background:#ffedcc}.rst-content .admonition-todo .admonition-title,.rst-content .admonition-todo .wy-alert-title,.rst-content .attention .admonition-title,.rst-content .attention .wy-alert-title,.rst-content .caution .admonition-title,.rst-content .caution .wy-alert-title,.rst-content .warning .admonition-title,.rst-content .warning .wy-alert-title,.rst-content .wy-alert-warning.admonition .admonition-title,.rst-content .wy-alert-warning.admonition .wy-alert-title,.rst-content .wy-alert-warning.danger .admonition-title,.rst-content .wy-alert-warning.danger .wy-alert-title,.rst-content .wy-alert-warning.error .admonition-title,.rst-content .wy-alert-warning.error .wy-alert-title,.rst-content .wy-alert-warning.hint .admonition-title,.rst-content .wy-alert-warning.hint .wy-alert-title,.rst-content .wy-alert-warning.important .admonition-title,.rst-content .wy-alert-warning.important .wy-alert-title,.rst-content .wy-alert-warning.note .admonition-title,.rst-content .wy-alert-warning.note .wy-alert-title,.rst-content .wy-alert-warning.seealso .admonition-title,.rst-content .wy-alert-warning.seealso .wy-alert-title,.rst-content .wy-alert-warning.tip .admonition-title,.rst-content .wy-alert-warning.tip .wy-alert-title,.rst-content .wy-alert.wy-alert-warning .admonition-title,.wy-alert.wy-alert-warning .rst-content .admonition-title,.wy-alert.wy-alert-warning .wy-alert-title{background:#f0b37e}.rst-content .note,.rst-content .seealso,.rst-content .wy-alert-info.admonition,.rst-content .wy-alert-info.admonition-todo,.rst-content .wy-alert-info.attention,.rst-content .wy-alert-info.caution,.rst-content .wy-alert-info.danger,.rst-content .wy-alert-info.error,.rst-content .wy-alert-info.hint,.rst-content .wy-alert-info.important,.rst-content .wy-alert-info.tip,.rst-content .wy-alert-info.warning,.wy-alert.wy-alert-info{background:#e7f2fa}.rst-content .note .admonition-title,.rst-content .note .wy-alert-title,.rst-content .seealso .admonition-title,.rst-content .seealso .wy-alert-title,.rst-content .wy-alert-info.admonition-todo .admonition-title,.rst-content .wy-alert-info.admonition-todo .wy-alert-title,.rst-content .wy-alert-info.admonition .admonition-title,.rst-content .wy-alert-info.admonition .wy-alert-title,.rst-content .wy-alert-info.attention .admonition-title,.rst-content .wy-alert-info.attention .wy-alert-title,.rst-content .wy-alert-info.caution .admonition-title,.rst-content .wy-alert-info.caution .wy-alert-title,.rst-content .wy-alert-info.danger .admonition-title,.rst-content .wy-alert-info.danger .wy-alert-title,.rst-content .wy-alert-info.error .admonition-title,.rst-content .wy-alert-info.error .wy-alert-title,.rst-content .wy-alert-info.hint .admonition-title,.rst-content .wy-alert-info.hint .wy-alert-title,.rst-content .wy-alert-info.important .admonition-title,.rst-content .wy-alert-info.important .wy-alert-title,.rst-content .wy-alert-info.tip .admonition-title,.rst-content .wy-alert-info.tip .wy-alert-title,.rst-content .wy-alert-info.warning .admonition-title,.rst-content .wy-alert-info.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-info .admonition-title,.wy-alert.wy-alert-info .rst-content .admonition-title,.wy-alert.wy-alert-info .wy-alert-title{background:#6ab0de}.rst-content .hint,.rst-content .important,.rst-content .tip,.rst-content .wy-alert-success.admonition,.rst-content .wy-alert-success.admonition-todo,.rst-content .wy-alert-success.attention,.rst-content .wy-alert-success.caution,.rst-content .wy-alert-success.danger,.rst-content .wy-alert-success.error,.rst-content .wy-alert-success.note,.rst-content .wy-alert-success.seealso,.rst-content .wy-alert-success.warning,.wy-alert.wy-alert-success{background:#dbfaf4}.rst-content .hint .admonition-title,.rst-content .hint .wy-alert-title,.rst-content .important .admonition-title,.rst-content .important .wy-alert-title,.rst-content .tip .admonition-title,.rst-content .tip .wy-alert-title,.rst-content .wy-alert-success.admonition-todo .admonition-title,.rst-content .wy-alert-success.admonition-todo .wy-alert-title,.rst-content .wy-alert-success.admonition .admonition-title,.rst-content .wy-alert-success.admonition .wy-alert-title,.rst-content .wy-alert-success.attention .admonition-title,.rst-content .wy-alert-success.attention .wy-alert-title,.rst-content .wy-alert-success.caution .admonition-title,.rst-content .wy-alert-success.caution .wy-alert-title,.rst-content .wy-alert-success.danger .admonition-title,.rst-content .wy-alert-success.danger .wy-alert-title,.rst-content .wy-alert-success.error .admonition-title,.rst-content .wy-alert-success.error .wy-alert-title,.rst-content .wy-alert-success.note .admonition-title,.rst-content .wy-alert-success.note .wy-alert-title,.rst-content .wy-alert-success.seealso .admonition-title,.rst-content .wy-alert-success.seealso .wy-alert-title,.rst-content .wy-alert-success.warning .admonition-title,.rst-content .wy-alert-success.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-success .admonition-title,.wy-alert.wy-alert-success .rst-content .admonition-title,.wy-alert.wy-alert-success .wy-alert-title{background:#1abc9c}.rst-content .wy-alert-neutral.admonition,.rst-content .wy-alert-neutral.admonition-todo,.rst-content .wy-alert-neutral.attention,.rst-content .wy-alert-neutral.caution,.rst-content .wy-alert-neutral.danger,.rst-content .wy-alert-neutral.error,.rst-content .wy-alert-neutral.hint,.rst-content .wy-alert-neutral.important,.rst-content .wy-alert-neutral.note,.rst-content .wy-alert-neutral.seealso,.rst-content .wy-alert-neutral.tip,.rst-content .wy-alert-neutral.warning,.wy-alert.wy-alert-neutral{background:#f3f6f6}.rst-content .wy-alert-neutral.admonition-todo .admonition-title,.rst-content .wy-alert-neutral.admonition-todo .wy-alert-title,.rst-content .wy-alert-neutral.admonition .admonition-title,.rst-content .wy-alert-neutral.admonition .wy-alert-title,.rst-content .wy-alert-neutral.attention .admonition-title,.rst-content .wy-alert-neutral.attention .wy-alert-title,.rst-content .wy-alert-neutral.caution .admonition-title,.rst-content .wy-alert-neutral.caution .wy-alert-title,.rst-content .wy-alert-neutral.danger .admonition-title,.rst-content .wy-alert-neutral.danger .wy-alert-title,.rst-content .wy-alert-neutral.error .admonition-title,.rst-content .wy-alert-neutral.error .wy-alert-title,.rst-content .wy-alert-neutral.hint .admonition-title,.rst-content .wy-alert-neutral.hint .wy-alert-title,.rst-content .wy-alert-neutral.important .admonition-title,.rst-content .wy-alert-neutral.important .wy-alert-title,.rst-content .wy-alert-neutral.note .admonition-title,.rst-content .wy-alert-neutral.note .wy-alert-title,.rst-content .wy-alert-neutral.seealso .admonition-title,.rst-content .wy-alert-neutral.seealso .wy-alert-title,.rst-content .wy-alert-neutral.tip .admonition-title,.rst-content .wy-alert-neutral.tip .wy-alert-title,.rst-content .wy-alert-neutral.warning .admonition-title,.rst-content .wy-alert-neutral.warning .wy-alert-title,.rst-content .wy-alert.wy-alert-neutral .admonition-title,.wy-alert.wy-alert-neutral .rst-content .admonition-title,.wy-alert.wy-alert-neutral .wy-alert-title{color:#404040;background:#e1e4e5}.rst-content .wy-alert-neutral.admonition-todo a,.rst-content .wy-alert-neutral.admonition a,.rst-content .wy-alert-neutral.attention a,.rst-content .wy-alert-neutral.caution a,.rst-content .wy-alert-neutral.danger a,.rst-content .wy-alert-neutral.error a,.rst-content .wy-alert-neutral.hint a,.rst-content .wy-alert-neutral.important a,.rst-content .wy-alert-neutral.note a,.rst-content .wy-alert-neutral.seealso a,.rst-content .wy-alert-neutral.tip a,.rst-content .wy-alert-neutral.warning a,.wy-alert.wy-alert-neutral a{color:#2980b9}.rst-content .admonition-todo p:last-child,.rst-content .admonition p:last-child,.rst-content .attention p:last-child,.rst-content .caution p:last-child,.rst-content .danger p:last-child,.rst-content .error p:last-child,.rst-content .hint p:last-child,.rst-content .important p:last-child,.rst-content .note p:last-child,.rst-content .seealso p:last-child,.rst-content .tip p:last-child,.rst-content .warning p:last-child,.wy-alert p:last-child{margin-bottom:0}.wy-tray-container{position:fixed;bottom:0;left:0;z-index:600}.wy-tray-container li{display:block;width:300px;background:transparent;color:#fff;text-align:center;box-shadow:0 5px 5px 0 rgba(0,0,0,.1);padding:0 24px;min-width:20%;opacity:0;height:0;line-height:56px;overflow:hidden;-webkit-transition:all .3s ease-in;-moz-transition:all .3s ease-in;transition:all .3s ease-in}.wy-tray-container li.wy-tray-item-success{background:#27ae60}.wy-tray-container li.wy-tray-item-info{background:#2980b9}.wy-tray-container li.wy-tray-item-warning{background:#e67e22}.wy-tray-container li.wy-tray-item-danger{background:#e74c3c}.wy-tray-container li.on{opacity:1;height:56px}@media screen and (max-width:768px){.wy-tray-container{bottom:auto;top:0;width:100%}.wy-tray-container li{width:100%}}button{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle;cursor:pointer;line-height:normal;-webkit-appearance:button;*overflow:visible}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}button[disabled]{cursor:default}.btn{display:inline-block;border-radius:2px;line-height:normal;white-space:nowrap;text-align:center;cursor:pointer;font-size:100%;padding:6px 12px 8px;color:#fff;border:1px solid rgba(0,0,0,.1);background-color:#27ae60;text-decoration:none;font-weight:400;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;box-shadow:inset 0 1px 2px -1px hsla(0,0%,100%,.5),inset 0 -2px 0 0 rgba(0,0,0,.1);outline-none:false;vertical-align:middle;*display:inline;zoom:1;-webkit-user-drag:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transition:all .1s linear;-moz-transition:all .1s linear;transition:all .1s linear}.btn-hover{background:#2e8ece;color:#fff}.btn:hover{background:#2cc36b;color:#fff}.btn:focus{background:#2cc36b;outline:0}.btn:active{box-shadow:inset 0 -1px 0 0 rgba(0,0,0,.05),inset 0 2px 0 0 rgba(0,0,0,.1);padding:8px 12px 6px}.btn:visited{color:#fff}.btn-disabled,.btn-disabled:active,.btn-disabled:focus,.btn-disabled:hover,.btn:disabled{background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);filter:alpha(opacity=40);opacity:.4;cursor:not-allowed;box-shadow:none}.btn::-moz-focus-inner{padding:0;border:0}.btn-small{font-size:80%}.btn-info{background-color:#2980b9!important}.btn-info:hover{background-color:#2e8ece!important}.btn-neutral{background-color:#f3f6f6!important;color:#404040!important}.btn-neutral:hover{background-color:#e5ebeb!important;color:#404040}.btn-neutral:visited{color:#404040!important}.btn-success{background-color:#27ae60!important}.btn-success:hover{background-color:#295!important}.btn-danger{background-color:#e74c3c!important}.btn-danger:hover{background-color:#ea6153!important}.btn-warning{background-color:#e67e22!important}.btn-warning:hover{background-color:#e98b39!important}.btn-invert{background-color:#222}.btn-invert:hover{background-color:#2f2f2f!important}.btn-link{background-color:transparent!important;color:#2980b9;box-shadow:none;border-color:transparent!important}.btn-link:active,.btn-link:hover{background-color:transparent!important;color:#409ad5!important;box-shadow:none}.btn-link:visited{color:#9b59b6}.wy-btn-group .btn,.wy-control .btn{vertical-align:middle}.wy-btn-group{margin-bottom:24px;*zoom:1}.wy-btn-group:after,.wy-btn-group:before{display:table;content:""}.wy-btn-group:after{clear:both}.wy-dropdown{position:relative;display:inline-block}.wy-dropdown-active .wy-dropdown-menu{display:block}.wy-dropdown-menu{position:absolute;left:0;display:none;float:left;top:100%;min-width:100%;background:#fcfcfc;z-index:100;border:1px solid #cfd7dd;box-shadow:0 2px 2px 0 rgba(0,0,0,.1);padding:12px}.wy-dropdown-menu>dd>a{display:block;clear:both;color:#404040;white-space:nowrap;font-size:90%;padding:0 12px;cursor:pointer}.wy-dropdown-menu>dd>a:hover{background:#2980b9;color:#fff}.wy-dropdown-menu>dd.divider{border-top:1px solid #cfd7dd;margin:6px 0}.wy-dropdown-menu>dd.search{padding-bottom:12px}.wy-dropdown-menu>dd.search input[type=search]{width:100%}.wy-dropdown-menu>dd.call-to-action{background:#e3e3e3;text-transform:uppercase;font-weight:500;font-size:80%}.wy-dropdown-menu>dd.call-to-action:hover{background:#e3e3e3}.wy-dropdown-menu>dd.call-to-action .btn{color:#fff}.wy-dropdown.wy-dropdown-up .wy-dropdown-menu{bottom:100%;top:auto;left:auto;right:0}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu{background:#fcfcfc;margin-top:2px}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu a{padding:6px 12px}.wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu a:hover{background:#2980b9;color:#fff}.wy-dropdown.wy-dropdown-left .wy-dropdown-menu{right:0;left:auto;text-align:right}.wy-dropdown-arrow:before{content:" ";border-bottom:5px solid #f5f5f5;border-left:5px solid transparent;border-right:5px solid transparent;position:absolute;display:block;top:-4px;left:50%;margin-left:-3px}.wy-dropdown-arrow.wy-dropdown-arrow-left:before{left:11px}.wy-form-stacked select{display:block}.wy-form-aligned .wy-help-inline,.wy-form-aligned input,.wy-form-aligned label,.wy-form-aligned select,.wy-form-aligned textarea{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.wy-form-aligned .wy-control-group>label{display:inline-block;vertical-align:middle;width:10em;margin:6px 12px 0 0;float:left}.wy-form-aligned .wy-control{float:left}.wy-form-aligned .wy-control label{display:block}.wy-form-aligned .wy-control select{margin-top:6px}fieldset{margin:0}fieldset,legend{border:0;padding:0}legend{width:100%;white-space:normal;margin-bottom:24px;font-size:150%;*margin-left:-7px}label,legend{display:block}label{margin:0 0 .3125em;color:#333;font-size:90%}input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}.wy-control-group{margin-bottom:24px;max-width:1200px;margin-left:auto;margin-right:auto;*zoom:1}.wy-control-group:after,.wy-control-group:before{display:table;content:""}.wy-control-group:after{clear:both}.wy-control-group.wy-control-group-required>label:after{content:" *";color:#e74c3c}.wy-control-group .wy-form-full,.wy-control-group .wy-form-halves,.wy-control-group .wy-form-thirds{padding-bottom:12px}.wy-control-group .wy-form-full input[type=color],.wy-control-group .wy-form-full input[type=date],.wy-control-group .wy-form-full input[type=datetime-local],.wy-control-group .wy-form-full input[type=datetime],.wy-control-group .wy-form-full input[type=email],.wy-control-group .wy-form-full input[type=month],.wy-control-group .wy-form-full input[type=number],.wy-control-group .wy-form-full input[type=password],.wy-control-group .wy-form-full input[type=search],.wy-control-group .wy-form-full input[type=tel],.wy-control-group .wy-form-full input[type=text],.wy-control-group .wy-form-full input[type=time],.wy-control-group .wy-form-full input[type=url],.wy-control-group .wy-form-full input[type=week],.wy-control-group .wy-form-full select,.wy-control-group .wy-form-halves input[type=color],.wy-control-group .wy-form-halves input[type=date],.wy-control-group .wy-form-halves input[type=datetime-local],.wy-control-group .wy-form-halves input[type=datetime],.wy-control-group .wy-form-halves input[type=email],.wy-control-group .wy-form-halves input[type=month],.wy-control-group .wy-form-halves input[type=number],.wy-control-group .wy-form-halves input[type=password],.wy-control-group .wy-form-halves input[type=search],.wy-control-group .wy-form-halves input[type=tel],.wy-control-group .wy-form-halves input[type=text],.wy-control-group .wy-form-halves input[type=time],.wy-control-group .wy-form-halves input[type=url],.wy-control-group .wy-form-halves input[type=week],.wy-control-group .wy-form-halves select,.wy-control-group .wy-form-thirds input[type=color],.wy-control-group .wy-form-thirds input[type=date],.wy-control-group .wy-form-thirds input[type=datetime-local],.wy-control-group .wy-form-thirds input[type=datetime],.wy-control-group .wy-form-thirds input[type=email],.wy-control-group .wy-form-thirds input[type=month],.wy-control-group .wy-form-thirds input[type=number],.wy-control-group .wy-form-thirds input[type=password],.wy-control-group .wy-form-thirds input[type=search],.wy-control-group .wy-form-thirds input[type=tel],.wy-control-group .wy-form-thirds input[type=text],.wy-control-group .wy-form-thirds input[type=time],.wy-control-group .wy-form-thirds input[type=url],.wy-control-group .wy-form-thirds input[type=week],.wy-control-group .wy-form-thirds select{width:100%}.wy-control-group .wy-form-full{float:left;display:block;width:100%;margin-right:0}.wy-control-group .wy-form-full:last-child{margin-right:0}.wy-control-group .wy-form-halves{float:left;display:block;margin-right:2.35765%;width:48.82117%}.wy-control-group .wy-form-halves:last-child,.wy-control-group .wy-form-halves:nth-of-type(2n){margin-right:0}.wy-control-group .wy-form-halves:nth-of-type(odd){clear:left}.wy-control-group .wy-form-thirds{float:left;display:block;margin-right:2.35765%;width:31.76157%}.wy-control-group .wy-form-thirds:last-child,.wy-control-group .wy-form-thirds:nth-of-type(3n){margin-right:0}.wy-control-group .wy-form-thirds:nth-of-type(3n+1){clear:left}.wy-control-group.wy-control-group-no-input .wy-control,.wy-control-no-input{margin:6px 0 0;font-size:90%}.wy-control-no-input{display:inline-block}.wy-control-group.fluid-input input[type=color],.wy-control-group.fluid-input input[type=date],.wy-control-group.fluid-input input[type=datetime-local],.wy-control-group.fluid-input input[type=datetime],.wy-control-group.fluid-input input[type=email],.wy-control-group.fluid-input input[type=month],.wy-control-group.fluid-input input[type=number],.wy-control-group.fluid-input input[type=password],.wy-control-group.fluid-input input[type=search],.wy-control-group.fluid-input input[type=tel],.wy-control-group.fluid-input input[type=text],.wy-control-group.fluid-input input[type=time],.wy-control-group.fluid-input input[type=url],.wy-control-group.fluid-input input[type=week]{width:100%}.wy-form-message-inline{padding-left:.3em;color:#666;font-size:90%}.wy-form-message{display:block;color:#999;font-size:70%;margin-top:.3125em;font-style:italic}.wy-form-message p{font-size:inherit;font-style:italic;margin-bottom:6px}.wy-form-message p:last-child{margin-bottom:0}input{line-height:normal}input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;*overflow:visible}input[type=color],input[type=date],input[type=datetime-local],input[type=datetime],input[type=email],input[type=month],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=time],input[type=url],input[type=week]{-webkit-appearance:none;padding:6px;display:inline-block;border:1px solid #ccc;font-size:80%;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;box-shadow:inset 0 1px 3px #ddd;border-radius:0;-webkit-transition:border .3s linear;-moz-transition:border .3s linear;transition:border .3s linear}input[type=datetime-local]{padding:.34375em .625em}input[disabled]{cursor:default}input[type=checkbox],input[type=radio]{padding:0;margin-right:.3125em;*height:13px;*width:13px}input[type=checkbox],input[type=radio],input[type=search]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}input[type=color]:focus,input[type=date]:focus,input[type=datetime-local]:focus,input[type=datetime]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,input[type=password]:focus,input[type=search]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus{outline:0;outline:thin dotted\9;border-color:#333}input.no-focus:focus{border-color:#ccc!important}input[type=checkbox]:focus,input[type=file]:focus,input[type=radio]:focus{outline:thin dotted #333;outline:1px auto #129fea}input[type=color][disabled],input[type=date][disabled],input[type=datetime-local][disabled],input[type=datetime][disabled],input[type=email][disabled],input[type=month][disabled],input[type=number][disabled],input[type=password][disabled],input[type=search][disabled],input[type=tel][disabled],input[type=text][disabled],input[type=time][disabled],input[type=url][disabled],input[type=week][disabled]{cursor:not-allowed;background-color:#fafafa}input:focus:invalid,select:focus:invalid,textarea:focus:invalid{color:#e74c3c;border:1px solid #e74c3c}input:focus:invalid:focus,select:focus:invalid:focus,textarea:focus:invalid:focus{border-color:#e74c3c}input[type=checkbox]:focus:invalid:focus,input[type=file]:focus:invalid:focus,input[type=radio]:focus:invalid:focus{outline-color:#e74c3c}input.wy-input-large{padding:12px;font-size:100%}textarea{overflow:auto;vertical-align:top;width:100%;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif}select,textarea{padding:.5em .625em;display:inline-block;border:1px solid #ccc;font-size:80%;box-shadow:inset 0 1px 3px #ddd;-webkit-transition:border .3s linear;-moz-transition:border .3s linear;transition:border .3s linear}select{border:1px solid #ccc;background-color:#fff}select[multiple]{height:auto}select:focus,textarea:focus{outline:0}input[readonly],select[disabled],select[readonly],textarea[disabled],textarea[readonly]{cursor:not-allowed;background-color:#fafafa}input[type=checkbox][disabled],input[type=radio][disabled]{cursor:not-allowed}.wy-checkbox,.wy-radio{margin:6px 0;color:#404040;display:block}.wy-checkbox input,.wy-radio input{vertical-align:baseline}.wy-form-message-inline{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.wy-input-prefix,.wy-input-suffix{white-space:nowrap;padding:6px}.wy-input-prefix .wy-input-context,.wy-input-suffix .wy-input-context{line-height:27px;padding:0 8px;display:inline-block;font-size:80%;background-color:#f3f6f6;border:1px solid #ccc;color:#999}.wy-input-suffix .wy-input-context{border-left:0}.wy-input-prefix .wy-input-context{border-right:0}.wy-switch{position:relative;display:block;height:24px;margin-top:12px;cursor:pointer}.wy-switch:before{left:0;top:0;width:36px;height:12px;background:#ccc}.wy-switch:after,.wy-switch:before{position:absolute;content:"";display:block;border-radius:4px;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.wy-switch:after{width:18px;height:18px;background:#999;left:-3px;top:-3px}.wy-switch span{position:absolute;left:48px;display:block;font-size:12px;color:#ccc;line-height:1}.wy-switch.active:before{background:#1e8449}.wy-switch.active:after{left:24px;background:#27ae60}.wy-switch.disabled{cursor:not-allowed;opacity:.8}.wy-control-group.wy-control-group-error .wy-form-message,.wy-control-group.wy-control-group-error>label{color:#e74c3c}.wy-control-group.wy-control-group-error input[type=color],.wy-control-group.wy-control-group-error input[type=date],.wy-control-group.wy-control-group-error input[type=datetime-local],.wy-control-group.wy-control-group-error input[type=datetime],.wy-control-group.wy-control-group-error input[type=email],.wy-control-group.wy-control-group-error input[type=month],.wy-control-group.wy-control-group-error input[type=number],.wy-control-group.wy-control-group-error input[type=password],.wy-control-group.wy-control-group-error input[type=search],.wy-control-group.wy-control-group-error input[type=tel],.wy-control-group.wy-control-group-error input[type=text],.wy-control-group.wy-control-group-error input[type=time],.wy-control-group.wy-control-group-error input[type=url],.wy-control-group.wy-control-group-error input[type=week],.wy-control-group.wy-control-group-error textarea{border:1px solid #e74c3c}.wy-inline-validate{white-space:nowrap}.wy-inline-validate .wy-input-context{padding:.5em .625em;display:inline-block;font-size:80%}.wy-inline-validate.wy-inline-validate-success .wy-input-context{color:#27ae60}.wy-inline-validate.wy-inline-validate-danger .wy-input-context{color:#e74c3c}.wy-inline-validate.wy-inline-validate-warning .wy-input-context{color:#e67e22}.wy-inline-validate.wy-inline-validate-info .wy-input-context{color:#2980b9}.rotate-90{-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg)}.rotate-180{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);-ms-transform:rotate(180deg);-o-transform:rotate(180deg);transform:rotate(180deg)}.rotate-270{-webkit-transform:rotate(270deg);-moz-transform:rotate(270deg);-ms-transform:rotate(270deg);-o-transform:rotate(270deg);transform:rotate(270deg)}.mirror{-webkit-transform:scaleX(-1);-moz-transform:scaleX(-1);-ms-transform:scaleX(-1);-o-transform:scaleX(-1);transform:scaleX(-1)}.mirror.rotate-90{-webkit-transform:scaleX(-1) rotate(90deg);-moz-transform:scaleX(-1) rotate(90deg);-ms-transform:scaleX(-1) rotate(90deg);-o-transform:scaleX(-1) rotate(90deg);transform:scaleX(-1) rotate(90deg)}.mirror.rotate-180{-webkit-transform:scaleX(-1) rotate(180deg);-moz-transform:scaleX(-1) rotate(180deg);-ms-transform:scaleX(-1) rotate(180deg);-o-transform:scaleX(-1) rotate(180deg);transform:scaleX(-1) rotate(180deg)}.mirror.rotate-270{-webkit-transform:scaleX(-1) rotate(270deg);-moz-transform:scaleX(-1) rotate(270deg);-ms-transform:scaleX(-1) rotate(270deg);-o-transform:scaleX(-1) rotate(270deg);transform:scaleX(-1) rotate(270deg)}@media only screen and (max-width:480px){.wy-form button[type=submit]{margin:.7em 0 0}.wy-form input[type=color],.wy-form input[type=date],.wy-form input[type=datetime-local],.wy-form input[type=datetime],.wy-form input[type=email],.wy-form input[type=month],.wy-form input[type=number],.wy-form input[type=password],.wy-form input[type=search],.wy-form input[type=tel],.wy-form input[type=text],.wy-form input[type=time],.wy-form input[type=url],.wy-form input[type=week],.wy-form label{margin-bottom:.3em;display:block}.wy-form input[type=color],.wy-form input[type=date],.wy-form input[type=datetime-local],.wy-form input[type=datetime],.wy-form input[type=email],.wy-form input[type=month],.wy-form input[type=number],.wy-form input[type=password],.wy-form input[type=search],.wy-form input[type=tel],.wy-form input[type=time],.wy-form input[type=url],.wy-form input[type=week]{margin-bottom:0}.wy-form-aligned .wy-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.wy-form-aligned .wy-control{margin:1.5em 0 0}.wy-form-message,.wy-form-message-inline,.wy-form .wy-help-inline{display:block;font-size:80%;padding:6px 0}}@media screen and (max-width:768px){.tablet-hide{display:none}}@media screen and (max-width:480px){.mobile-hide{display:none}}.float-left{float:left}.float-right{float:right}.full-width{width:100%}.rst-content table.docutils,.rst-content table.field-list,.wy-table{border-collapse:collapse;border-spacing:0;empty-cells:show;margin-bottom:24px}.rst-content table.docutils caption,.rst-content table.field-list caption,.wy-table caption{color:#000;font:italic 85%/1 arial,sans-serif;padding:1em 0;text-align:center}.rst-content table.docutils td,.rst-content table.docutils th,.rst-content table.field-list td,.rst-content table.field-list th,.wy-table td,.wy-table th{font-size:90%;margin:0;overflow:visible;padding:8px 16px}.rst-content table.docutils td:first-child,.rst-content table.docutils th:first-child,.rst-content table.field-list td:first-child,.rst-content table.field-list th:first-child,.wy-table td:first-child,.wy-table th:first-child{border-left-width:0}.rst-content table.docutils thead,.rst-content table.field-list thead,.wy-table thead{color:#000;text-align:left;vertical-align:bottom;white-space:nowrap}.rst-content table.docutils thead th,.rst-content table.field-list thead th,.wy-table thead th{font-weight:700;border-bottom:2px solid #e1e4e5}.rst-content table.docutils td,.rst-content table.field-list td,.wy-table td{background-color:transparent;vertical-align:middle}.rst-content table.docutils td p,.rst-content table.field-list td p,.wy-table td p{line-height:18px}.rst-content table.docutils td p:last-child,.rst-content table.field-list td p:last-child,.wy-table td p:last-child{margin-bottom:0}.rst-content table.docutils .wy-table-cell-min,.rst-content table.field-list .wy-table-cell-min,.wy-table .wy-table-cell-min{width:1%;padding-right:0}.rst-content table.docutils .wy-table-cell-min input[type=checkbox],.rst-content table.field-list .wy-table-cell-min input[type=checkbox],.wy-table .wy-table-cell-min input[type=checkbox]{margin:0}.wy-table-secondary{color:grey;font-size:90%}.wy-table-tertiary{color:grey;font-size:80%}.rst-content table.docutils:not(.field-list) tr:nth-child(2n-1) td,.wy-table-backed,.wy-table-odd td,.wy-table-striped tr:nth-child(2n-1) td{background-color:#f3f6f6}.rst-content table.docutils,.wy-table-bordered-all{border:1px solid #e1e4e5}.rst-content table.docutils td,.wy-table-bordered-all td{border-bottom:1px solid #e1e4e5;border-left:1px solid #e1e4e5}.rst-content table.docutils tbody>tr:last-child td,.wy-table-bordered-all tbody>tr:last-child td{border-bottom-width:0}.wy-table-bordered{border:1px solid #e1e4e5}.wy-table-bordered-rows td{border-bottom:1px solid #e1e4e5}.wy-table-bordered-rows tbody>tr:last-child td{border-bottom-width:0}.wy-table-horizontal td,.wy-table-horizontal th{border-width:0 0 1px;border-bottom:1px solid #e1e4e5}.wy-table-horizontal tbody>tr:last-child td{border-bottom-width:0}.wy-table-responsive{margin-bottom:24px;max-width:100%;overflow:auto}.wy-table-responsive table{margin-bottom:0!important}.wy-table-responsive table td,.wy-table-responsive table th{white-space:nowrap}a{color:#2980b9;text-decoration:none;cursor:pointer}a:hover{color:#3091d1}a:visited{color:#9b59b6}html{height:100%}body,html{overflow-x:hidden}body{font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;font-weight:400;color:#404040;min-height:100%;background:#edf0f2}.wy-text-left{text-align:left}.wy-text-center{text-align:center}.wy-text-right{text-align:right}.wy-text-large{font-size:120%}.wy-text-normal{font-size:100%}.wy-text-small,small{font-size:80%}.wy-text-strike{text-decoration:line-through}.wy-text-warning{color:#e67e22!important}a.wy-text-warning:hover{color:#eb9950!important}.wy-text-info{color:#2980b9!important}a.wy-text-info:hover{color:#409ad5!important}.wy-text-success{color:#27ae60!important}a.wy-text-success:hover{color:#36d278!important}.wy-text-danger{color:#e74c3c!important}a.wy-text-danger:hover{color:#ed7669!important}.wy-text-neutral{color:#404040!important}a.wy-text-neutral:hover{color:#595959!important}.rst-content .toctree-wrapper>p.caption,h1,h2,h3,h4,h5,h6,legend{margin-top:0;font-weight:700;font-family:Roboto Slab,ff-tisa-web-pro,Georgia,Arial,sans-serif}p{line-height:24px;font-size:16px;margin:0 0 24px}h1{font-size:175%}.rst-content .toctree-wrapper>p.caption,h2{font-size:150%}h3{font-size:125%}h4{font-size:115%}h5{font-size:110%}h6{font-size:100%}hr{display:block;height:1px;border:0;border-top:1px solid #e1e4e5;margin:24px 0;padding:0}.rst-content code,.rst-content tt,code{white-space:nowrap;max-width:100%;background:#fff;border:1px solid #e1e4e5;font-size:75%;padding:0 5px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;color:#e74c3c;overflow-x:auto}.rst-content tt.code-large,code.code-large{font-size:90%}.rst-content .section ul,.rst-content .toctree-wrapper ul,.rst-content section ul,.wy-plain-list-disc,article ul{list-style:disc;line-height:24px;margin-bottom:24px}.rst-content .section ul li,.rst-content .toctree-wrapper ul li,.rst-content section ul li,.wy-plain-list-disc li,article ul li{list-style:disc;margin-left:24px}.rst-content .section ul li p:last-child,.rst-content .section ul li ul,.rst-content .toctree-wrapper ul li p:last-child,.rst-content .toctree-wrapper ul li ul,.rst-content section ul li p:last-child,.rst-content section ul li ul,.wy-plain-list-disc li p:last-child,.wy-plain-list-disc li ul,article ul li p:last-child,article ul li ul{margin-bottom:0}.rst-content .section ul li li,.rst-content .toctree-wrapper ul li li,.rst-content section ul li li,.wy-plain-list-disc li li,article ul li li{list-style:circle}.rst-content .section ul li li li,.rst-content .toctree-wrapper ul li li li,.rst-content section ul li li li,.wy-plain-list-disc li li li,article ul li li li{list-style:square}.rst-content .section ul li ol li,.rst-content .toctree-wrapper ul li ol li,.rst-content section ul li ol li,.wy-plain-list-disc li ol li,article ul li ol li{list-style:decimal}.rst-content .section ol,.rst-content .section ol.arabic,.rst-content .toctree-wrapper ol,.rst-content .toctree-wrapper ol.arabic,.rst-content section ol,.rst-content section ol.arabic,.wy-plain-list-decimal,article ol{list-style:decimal;line-height:24px;margin-bottom:24px}.rst-content .section ol.arabic li,.rst-content .section ol li,.rst-content .toctree-wrapper ol.arabic li,.rst-content .toctree-wrapper ol li,.rst-content section ol.arabic li,.rst-content section ol li,.wy-plain-list-decimal li,article ol li{list-style:decimal;margin-left:24px}.rst-content .section ol.arabic li ul,.rst-content .section ol li p:last-child,.rst-content .section ol li ul,.rst-content .toctree-wrapper ol.arabic li ul,.rst-content .toctree-wrapper ol li p:last-child,.rst-content .toctree-wrapper ol li ul,.rst-content section ol.arabic li ul,.rst-content section ol li p:last-child,.rst-content section ol li ul,.wy-plain-list-decimal li p:last-child,.wy-plain-list-decimal li ul,article ol li p:last-child,article ol li ul{margin-bottom:0}.rst-content .section ol.arabic li ul li,.rst-content .section ol li ul li,.rst-content .toctree-wrapper ol.arabic li ul li,.rst-content .toctree-wrapper ol li ul li,.rst-content section ol.arabic li ul li,.rst-content section ol li ul li,.wy-plain-list-decimal li ul li,article ol li ul li{list-style:disc}.wy-breadcrumbs{*zoom:1}.wy-breadcrumbs:after,.wy-breadcrumbs:before{display:table;content:""}.wy-breadcrumbs:after{clear:both}.wy-breadcrumbs li{display:inline-block}.wy-breadcrumbs li.wy-breadcrumbs-aside{float:right}.wy-breadcrumbs li a{display:inline-block;padding:5px}.wy-breadcrumbs li a:first-child{padding-left:0}.rst-content .wy-breadcrumbs li tt,.wy-breadcrumbs li .rst-content tt,.wy-breadcrumbs li code{padding:5px;border:none;background:none}.rst-content .wy-breadcrumbs li tt.literal,.wy-breadcrumbs li .rst-content tt.literal,.wy-breadcrumbs li code.literal{color:#404040}.wy-breadcrumbs-extra{margin-bottom:0;color:#b3b3b3;font-size:80%;display:inline-block}@media screen and (max-width:480px){.wy-breadcrumbs-extra,.wy-breadcrumbs li.wy-breadcrumbs-aside{display:none}}@media print{.wy-breadcrumbs li.wy-breadcrumbs-aside{display:none}}html{font-size:16px}.wy-affix{position:fixed;top:1.618em}.wy-menu a:hover{text-decoration:none}.wy-menu-horiz{*zoom:1}.wy-menu-horiz:after,.wy-menu-horiz:before{display:table;content:""}.wy-menu-horiz:after{clear:both}.wy-menu-horiz li,.wy-menu-horiz ul{display:inline-block}.wy-menu-horiz li:hover{background:hsla(0,0%,100%,.1)}.wy-menu-horiz li.divide-left{border-left:1px solid #404040}.wy-menu-horiz li.divide-right{border-right:1px solid #404040}.wy-menu-horiz a{height:32px;display:inline-block;line-height:32px;padding:0 16px}.wy-menu-vertical{width:300px}.wy-menu-vertical header,.wy-menu-vertical p.caption{color:#55a5d9;height:32px;line-height:32px;padding:0 1.618em;margin:12px 0 0;display:block;font-weight:700;text-transform:uppercase;font-size:85%;white-space:nowrap}.wy-menu-vertical ul{margin-bottom:0}.wy-menu-vertical li.divide-top{border-top:1px solid #404040}.wy-menu-vertical li.divide-bottom{border-bottom:1px solid #404040}.wy-menu-vertical li.current{background:#e3e3e3}.wy-menu-vertical li.current a{color:grey;border-right:1px solid #c9c9c9;padding:.4045em 2.427em}.wy-menu-vertical li.current a:hover{background:#d6d6d6}.rst-content .wy-menu-vertical li tt,.wy-menu-vertical li .rst-content tt,.wy-menu-vertical li code{border:none;background:inherit;color:inherit;padding-left:0;padding-right:0}.wy-menu-vertical li button.toctree-expand{display:block;float:left;margin-left:-1.2em;line-height:18px;color:#4d4d4d;border:none;background:none;padding:0}.wy-menu-vertical li.current>a,.wy-menu-vertical li.on a{color:#404040;font-weight:700;position:relative;background:#fcfcfc;border:none;padding:.4045em 1.618em}.wy-menu-vertical li.current>a:hover,.wy-menu-vertical li.on a:hover{background:#fcfcfc}.wy-menu-vertical li.current>a:hover button.toctree-expand,.wy-menu-vertical li.on a:hover button.toctree-expand{color:grey}.wy-menu-vertical li.current>a button.toctree-expand,.wy-menu-vertical li.on a button.toctree-expand{display:block;line-height:18px;color:#333}.wy-menu-vertical li.toctree-l1.current>a{border-bottom:1px solid #c9c9c9;border-top:1px solid #c9c9c9}.wy-menu-vertical .toctree-l1.current .toctree-l2>ul,.wy-menu-vertical .toctree-l2.current .toctree-l3>ul,.wy-menu-vertical .toctree-l3.current .toctree-l4>ul,.wy-menu-vertical .toctree-l4.current .toctree-l5>ul,.wy-menu-vertical .toctree-l5.current .toctree-l6>ul,.wy-menu-vertical .toctree-l6.current .toctree-l7>ul,.wy-menu-vertical .toctree-l7.current .toctree-l8>ul,.wy-menu-vertical .toctree-l8.current .toctree-l9>ul,.wy-menu-vertical .toctree-l9.current .toctree-l10>ul,.wy-menu-vertical .toctree-l10.current .toctree-l11>ul{display:none}.wy-menu-vertical .toctree-l1.current .current.toctree-l2>ul,.wy-menu-vertical .toctree-l2.current .current.toctree-l3>ul,.wy-menu-vertical .toctree-l3.current .current.toctree-l4>ul,.wy-menu-vertical .toctree-l4.current .current.toctree-l5>ul,.wy-menu-vertical .toctree-l5.current .current.toctree-l6>ul,.wy-menu-vertical .toctree-l6.current .current.toctree-l7>ul,.wy-menu-vertical .toctree-l7.current .current.toctree-l8>ul,.wy-menu-vertical .toctree-l8.current .current.toctree-l9>ul,.wy-menu-vertical .toctree-l9.current .current.toctree-l10>ul,.wy-menu-vertical .toctree-l10.current .current.toctree-l11>ul{display:block}.wy-menu-vertical li.toctree-l3,.wy-menu-vertical li.toctree-l4{font-size:.9em}.wy-menu-vertical li.toctree-l2 a,.wy-menu-vertical li.toctree-l3 a,.wy-menu-vertical li.toctree-l4 a,.wy-menu-vertical li.toctree-l5 a,.wy-menu-vertical li.toctree-l6 a,.wy-menu-vertical li.toctree-l7 a,.wy-menu-vertical li.toctree-l8 a,.wy-menu-vertical li.toctree-l9 a,.wy-menu-vertical li.toctree-l10 a{color:#404040}.wy-menu-vertical li.toctree-l2 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l3 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l4 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l5 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l6 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l7 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l8 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l9 a:hover button.toctree-expand,.wy-menu-vertical li.toctree-l10 a:hover button.toctree-expand{color:grey}.wy-menu-vertical li.toctree-l2.current li.toctree-l3>a,.wy-menu-vertical li.toctree-l3.current li.toctree-l4>a,.wy-menu-vertical li.toctree-l4.current li.toctree-l5>a,.wy-menu-vertical li.toctree-l5.current li.toctree-l6>a,.wy-menu-vertical li.toctree-l6.current li.toctree-l7>a,.wy-menu-vertical li.toctree-l7.current li.toctree-l8>a,.wy-menu-vertical li.toctree-l8.current li.toctree-l9>a,.wy-menu-vertical li.toctree-l9.current li.toctree-l10>a,.wy-menu-vertical li.toctree-l10.current li.toctree-l11>a{display:block}.wy-menu-vertical li.toctree-l2.current>a{padding:.4045em 2.427em}.wy-menu-vertical li.toctree-l2.current li.toctree-l3>a{padding:.4045em 1.618em .4045em 4.045em}.wy-menu-vertical li.toctree-l3.current>a{padding:.4045em 4.045em}.wy-menu-vertical li.toctree-l3.current li.toctree-l4>a{padding:.4045em 1.618em .4045em 5.663em}.wy-menu-vertical li.toctree-l4.current>a{padding:.4045em 5.663em}.wy-menu-vertical li.toctree-l4.current li.toctree-l5>a{padding:.4045em 1.618em .4045em 7.281em}.wy-menu-vertical li.toctree-l5.current>a{padding:.4045em 7.281em}.wy-menu-vertical li.toctree-l5.current li.toctree-l6>a{padding:.4045em 1.618em .4045em 8.899em}.wy-menu-vertical li.toctree-l6.current>a{padding:.4045em 8.899em}.wy-menu-vertical li.toctree-l6.current li.toctree-l7>a{padding:.4045em 1.618em .4045em 10.517em}.wy-menu-vertical li.toctree-l7.current>a{padding:.4045em 10.517em}.wy-menu-vertical li.toctree-l7.current li.toctree-l8>a{padding:.4045em 1.618em .4045em 12.135em}.wy-menu-vertical li.toctree-l8.current>a{padding:.4045em 12.135em}.wy-menu-vertical li.toctree-l8.current li.toctree-l9>a{padding:.4045em 1.618em .4045em 13.753em}.wy-menu-vertical li.toctree-l9.current>a{padding:.4045em 13.753em}.wy-menu-vertical li.toctree-l9.current li.toctree-l10>a{padding:.4045em 1.618em .4045em 15.371em}.wy-menu-vertical li.toctree-l10.current>a{padding:.4045em 15.371em}.wy-menu-vertical li.toctree-l10.current li.toctree-l11>a{padding:.4045em 1.618em .4045em 16.989em}.wy-menu-vertical li.toctree-l2.current>a,.wy-menu-vertical li.toctree-l2.current li.toctree-l3>a{background:#c9c9c9}.wy-menu-vertical li.toctree-l2 button.toctree-expand{color:#a3a3a3}.wy-menu-vertical li.toctree-l3.current>a,.wy-menu-vertical li.toctree-l3.current li.toctree-l4>a{background:#bdbdbd}.wy-menu-vertical li.toctree-l3 button.toctree-expand{color:#969696}.wy-menu-vertical li.current ul{display:block}.wy-menu-vertical li ul{margin-bottom:0;display:none}.wy-menu-vertical li ul li a{margin-bottom:0;color:#d9d9d9;font-weight:400}.wy-menu-vertical a{line-height:18px;padding:.4045em 1.618em;display:block;position:relative;font-size:90%;color:#d9d9d9}.wy-menu-vertical a:hover{background-color:#4e4a4a;cursor:pointer}.wy-menu-vertical a:hover button.toctree-expand{color:#d9d9d9}.wy-menu-vertical a:active{background-color:#2980b9;cursor:pointer;color:#fff}.wy-menu-vertical a:active button.toctree-expand{color:#fff}.wy-side-nav-search{display:block;width:300px;padding:.809em;margin-bottom:.809em;z-index:200;background-color:#2980b9;text-align:center;color:#fcfcfc}.wy-side-nav-search input[type=text]{width:100%;border-radius:50px;padding:6px 12px;border-color:#2472a4}.wy-side-nav-search img{display:block;margin:auto auto .809em;height:45px;width:45px;background-color:#2980b9;padding:5px;border-radius:100%}.wy-side-nav-search .wy-dropdown>a,.wy-side-nav-search>a{color:#fcfcfc;font-size:100%;font-weight:700;display:inline-block;padding:4px 6px;margin-bottom:.809em;max-width:100%}.wy-side-nav-search .wy-dropdown>a:hover,.wy-side-nav-search>a:hover{background:hsla(0,0%,100%,.1)}.wy-side-nav-search .wy-dropdown>a img.logo,.wy-side-nav-search>a img.logo{display:block;margin:0 auto;height:auto;width:auto;border-radius:0;max-width:100%;background:transparent}.wy-side-nav-search .wy-dropdown>a.icon img.logo,.wy-side-nav-search>a.icon img.logo{margin-top:.85em}.wy-side-nav-search>div.version{margin-top:-.4045em;margin-bottom:.809em;font-weight:400;color:hsla(0,0%,100%,.3)}.wy-nav .wy-menu-vertical header{color:#2980b9}.wy-nav .wy-menu-vertical a{color:#b3b3b3}.wy-nav .wy-menu-vertical a:hover{background-color:#2980b9;color:#fff}[data-menu-wrap]{-webkit-transition:all .2s ease-in;-moz-transition:all .2s ease-in;transition:all .2s ease-in;position:absolute;opacity:1;width:100%;opacity:0}[data-menu-wrap].move-center{left:0;right:auto;opacity:1}[data-menu-wrap].move-left{right:auto;left:-100%;opacity:0}[data-menu-wrap].move-right{right:-100%;left:auto;opacity:0}.wy-body-for-nav{background:#fcfcfc}.wy-grid-for-nav{position:absolute;width:100%;height:100%}.wy-nav-side{position:fixed;top:0;bottom:0;left:0;padding-bottom:2em;width:300px;overflow-x:hidden;overflow-y:hidden;min-height:100%;color:#9b9b9b;background:#343131;z-index:200}.wy-side-scroll{width:320px;position:relative;overflow-x:hidden;overflow-y:scroll;height:100%}.wy-nav-top{display:none;background:#2980b9;color:#fff;padding:.4045em .809em;position:relative;line-height:50px;text-align:center;font-size:100%;*zoom:1}.wy-nav-top:after,.wy-nav-top:before{display:table;content:""}.wy-nav-top:after{clear:both}.wy-nav-top a{color:#fff;font-weight:700}.wy-nav-top img{margin-right:12px;height:45px;width:45px;background-color:#2980b9;padding:5px;border-radius:100%}.wy-nav-top i{font-size:30px;float:left;cursor:pointer;padding-top:inherit}.wy-nav-content-wrap{margin-left:300px;background:#fcfcfc;min-height:100%}.wy-nav-content{padding:1.618em 3.236em;height:100%;max-width:800px;margin:auto}.wy-body-mask{position:fixed;width:100%;height:100%;background:rgba(0,0,0,.2);display:none;z-index:499}.wy-body-mask.on{display:block}footer{color:grey}footer p{margin-bottom:12px}.rst-content footer span.commit tt,footer span.commit .rst-content tt,footer span.commit code{padding:0;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;font-size:1em;background:none;border:none;color:grey}.rst-footer-buttons{*zoom:1}.rst-footer-buttons:after,.rst-footer-buttons:before{width:100%;display:table;content:""}.rst-footer-buttons:after{clear:both}.rst-breadcrumbs-buttons{margin-top:12px;*zoom:1}.rst-breadcrumbs-buttons:after,.rst-breadcrumbs-buttons:before{display:table;content:""}.rst-breadcrumbs-buttons:after{clear:both}#search-results .search li{margin-bottom:24px;border-bottom:1px solid #e1e4e5;padding-bottom:24px}#search-results .search li:first-child{border-top:1px solid #e1e4e5;padding-top:24px}#search-results .search li a{font-size:120%;margin-bottom:12px;display:inline-block}#search-results .context{color:grey;font-size:90%}.genindextable li>ul{margin-left:24px}@media screen and (max-width:768px){.wy-body-for-nav{background:#fcfcfc}.wy-nav-top{display:block}.wy-nav-side{left:-300px}.wy-nav-side.shift{width:85%;left:0}.wy-menu.wy-menu-vertical,.wy-side-nav-search,.wy-side-scroll{width:auto}.wy-nav-content-wrap{margin-left:0}.wy-nav-content-wrap .wy-nav-content{padding:1.618em}.wy-nav-content-wrap.shift{position:fixed;min-width:100%;left:85%;top:0;height:100%;overflow:hidden}}@media screen and (min-width:1100px){.wy-nav-content-wrap{background:rgba(0,0,0,.05)}.wy-nav-content{margin:0;background:#fcfcfc}}@media print{.rst-versions,.wy-nav-side,footer{display:none}.wy-nav-content-wrap{margin-left:0}}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60;*zoom:1}.rst-versions .rst-current-version:after,.rst-versions .rst-current-version:before{display:table;content:""}.rst-versions .rst-current-version:after{clear:both}.rst-content .code-block-caption .rst-versions .rst-current-version .headerlink,.rst-content .eqno .rst-versions .rst-current-version .headerlink,.rst-content .rst-versions .rst-current-version .admonition-title,.rst-content code.download .rst-versions .rst-current-version span:first-child,.rst-content dl dt .rst-versions .rst-current-version .headerlink,.rst-content h1 .rst-versions .rst-current-version .headerlink,.rst-content h2 .rst-versions .rst-current-version .headerlink,.rst-content h3 .rst-versions .rst-current-version .headerlink,.rst-content h4 .rst-versions .rst-current-version .headerlink,.rst-content h5 .rst-versions .rst-current-version .headerlink,.rst-content h6 .rst-versions .rst-current-version .headerlink,.rst-content p .rst-versions .rst-current-version .headerlink,.rst-content table>caption .rst-versions .rst-current-version .headerlink,.rst-content tt.download .rst-versions .rst-current-version span:first-child,.rst-versions .rst-current-version .fa,.rst-versions .rst-current-version .icon,.rst-versions .rst-current-version .rst-content .admonition-title,.rst-versions .rst-current-version .rst-content .code-block-caption .headerlink,.rst-versions .rst-current-version .rst-content .eqno .headerlink,.rst-versions .rst-current-version .rst-content code.download span:first-child,.rst-versions .rst-current-version .rst-content dl dt .headerlink,.rst-versions .rst-current-version .rst-content h1 .headerlink,.rst-versions .rst-current-version .rst-content h2 .headerlink,.rst-versions .rst-current-version .rst-content h3 .headerlink,.rst-versions .rst-current-version .rst-content h4 .headerlink,.rst-versions .rst-current-version .rst-content h5 .headerlink,.rst-versions .rst-current-version .rst-content h6 .headerlink,.rst-versions .rst-current-version .rst-content p .headerlink,.rst-versions .rst-current-version .rst-content table>caption .headerlink,.rst-versions .rst-current-version .rst-content tt.download span:first-child,.rst-versions .rst-current-version .wy-menu-vertical li button.toctree-expand,.wy-menu-vertical li .rst-versions .rst-current-version button.toctree-expand{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}.rst-content .toctree-wrapper>p.caption,.rst-content h1,.rst-content h2,.rst-content h3,.rst-content h4,.rst-content h5,.rst-content h6{margin-bottom:24px}.rst-content img{max-width:100%;height:auto}.rst-content div.figure,.rst-content figure{margin-bottom:24px}.rst-content div.figure .caption-text,.rst-content figure .caption-text{font-style:italic}.rst-content div.figure p:last-child.caption,.rst-content figure p:last-child.caption{margin-bottom:0}.rst-content div.figure.align-center,.rst-content figure.align-center{text-align:center}.rst-content .section>a>img,.rst-content .section>img,.rst-content section>a>img,.rst-content section>img{margin-bottom:24px}.rst-content abbr[title]{text-decoration:none}.rst-content.style-external-links a.reference.external:after{font-family:FontAwesome;content:"\f08e";color:#b3b3b3;vertical-align:super;font-size:60%;margin:0 .2em}.rst-content blockquote{margin-left:24px;line-height:24px;margin-bottom:24px}.rst-content pre.literal-block{white-space:pre;margin:0;padding:12px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;display:block;overflow:auto}.rst-content div[class^=highlight],.rst-content pre.literal-block{border:1px solid #e1e4e5;overflow-x:auto;margin:1px 0 24px}.rst-content div[class^=highlight] div[class^=highlight],.rst-content pre.literal-block div[class^=highlight]{padding:0;border:none;margin:0}.rst-content div[class^=highlight] td.code{width:100%}.rst-content .linenodiv pre{border-right:1px solid #e6e9ea;margin:0;padding:12px;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;user-select:none;pointer-events:none}.rst-content div[class^=highlight] pre{white-space:pre;margin:0;padding:12px;display:block;overflow:auto}.rst-content div[class^=highlight] pre .hll{display:block;margin:0 -12px;padding:0 12px}.rst-content .linenodiv pre,.rst-content div[class^=highlight] pre,.rst-content pre.literal-block{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;font-size:12px;line-height:1.4}.rst-content div.highlight .gp,.rst-content div.highlight span.linenos{user-select:none;pointer-events:none}.rst-content div.highlight span.linenos{display:inline-block;padding-left:0;padding-right:12px;margin-right:12px;border-right:1px solid #e6e9ea}.rst-content .code-block-caption{font-style:italic;font-size:85%;line-height:1;padding:1em 0;text-align:center}@media print{.rst-content .codeblock,.rst-content div[class^=highlight],.rst-content div[class^=highlight] pre{white-space:pre-wrap}}.rst-content .admonition,.rst-content .admonition-todo,.rst-content .attention,.rst-content .caution,.rst-content .danger,.rst-content .error,.rst-content .hint,.rst-content .important,.rst-content .note,.rst-content .seealso,.rst-content .tip,.rst-content .warning{clear:both}.rst-content .admonition-todo .last,.rst-content .admonition-todo>:last-child,.rst-content .admonition .last,.rst-content .admonition>:last-child,.rst-content .attention .last,.rst-content .attention>:last-child,.rst-content .caution .last,.rst-content .caution>:last-child,.rst-content .danger .last,.rst-content .danger>:last-child,.rst-content .error .last,.rst-content .error>:last-child,.rst-content .hint .last,.rst-content .hint>:last-child,.rst-content .important .last,.rst-content .important>:last-child,.rst-content .note .last,.rst-content .note>:last-child,.rst-content .seealso .last,.rst-content .seealso>:last-child,.rst-content .tip .last,.rst-content .tip>:last-child,.rst-content .warning .last,.rst-content .warning>:last-child{margin-bottom:0}.rst-content .admonition-title:before{margin-right:4px}.rst-content .admonition table{border-color:rgba(0,0,0,.1)}.rst-content .admonition table td,.rst-content .admonition table th{background:transparent!important;border-color:rgba(0,0,0,.1)!important}.rst-content .section ol.loweralpha,.rst-content .section ol.loweralpha>li,.rst-content .toctree-wrapper ol.loweralpha,.rst-content .toctree-wrapper ol.loweralpha>li,.rst-content section ol.loweralpha,.rst-content section ol.loweralpha>li{list-style:lower-alpha}.rst-content .section ol.upperalpha,.rst-content .section ol.upperalpha>li,.rst-content .toctree-wrapper ol.upperalpha,.rst-content .toctree-wrapper ol.upperalpha>li,.rst-content section ol.upperalpha,.rst-content section ol.upperalpha>li{list-style:upper-alpha}.rst-content .section ol li>*,.rst-content .section ul li>*,.rst-content .toctree-wrapper ol li>*,.rst-content .toctree-wrapper ul li>*,.rst-content section ol li>*,.rst-content section ul li>*{margin-top:12px;margin-bottom:12px}.rst-content .section ol li>:first-child,.rst-content .section ul li>:first-child,.rst-content .toctree-wrapper ol li>:first-child,.rst-content .toctree-wrapper ul li>:first-child,.rst-content section ol li>:first-child,.rst-content section ul li>:first-child{margin-top:0}.rst-content .section ol li>p,.rst-content .section ol li>p:last-child,.rst-content .section ul li>p,.rst-content .section ul li>p:last-child,.rst-content .toctree-wrapper ol li>p,.rst-content .toctree-wrapper ol li>p:last-child,.rst-content .toctree-wrapper ul li>p,.rst-content .toctree-wrapper ul li>p:last-child,.rst-content section ol li>p,.rst-content section ol li>p:last-child,.rst-content section ul li>p,.rst-content section ul li>p:last-child{margin-bottom:12px}.rst-content .section ol li>p:only-child,.rst-content .section ol li>p:only-child:last-child,.rst-content .section ul li>p:only-child,.rst-content .section ul li>p:only-child:last-child,.rst-content .toctree-wrapper ol li>p:only-child,.rst-content .toctree-wrapper ol li>p:only-child:last-child,.rst-content .toctree-wrapper ul li>p:only-child,.rst-content .toctree-wrapper ul li>p:only-child:last-child,.rst-content section ol li>p:only-child,.rst-content section ol li>p:only-child:last-child,.rst-content section ul li>p:only-child,.rst-content section ul li>p:only-child:last-child{margin-bottom:0}.rst-content .section ol li>ol,.rst-content .section ol li>ul,.rst-content .section ul li>ol,.rst-content .section ul li>ul,.rst-content .toctree-wrapper ol li>ol,.rst-content .toctree-wrapper ol li>ul,.rst-content .toctree-wrapper ul li>ol,.rst-content .toctree-wrapper ul li>ul,.rst-content section ol li>ol,.rst-content section ol li>ul,.rst-content section ul li>ol,.rst-content section ul li>ul{margin-bottom:12px}.rst-content .section ol.simple li>*,.rst-content .section ol.simple li ol,.rst-content .section ol.simple li ul,.rst-content .section ul.simple li>*,.rst-content .section ul.simple li ol,.rst-content .section ul.simple li ul,.rst-content .toctree-wrapper ol.simple li>*,.rst-content .toctree-wrapper ol.simple li ol,.rst-content .toctree-wrapper ol.simple li ul,.rst-content .toctree-wrapper ul.simple li>*,.rst-content .toctree-wrapper ul.simple li ol,.rst-content .toctree-wrapper ul.simple li ul,.rst-content section ol.simple li>*,.rst-content section ol.simple li ol,.rst-content section ol.simple li ul,.rst-content section ul.simple li>*,.rst-content section ul.simple li ol,.rst-content section ul.simple li ul{margin-top:0;margin-bottom:0}.rst-content .line-block{margin-left:0;margin-bottom:24px;line-height:24px}.rst-content .line-block .line-block{margin-left:24px;margin-bottom:0}.rst-content .topic-title{font-weight:700;margin-bottom:12px}.rst-content .toc-backref{color:#404040}.rst-content .align-right{float:right;margin:0 0 24px 24px}.rst-content .align-left{float:left;margin:0 24px 24px 0}.rst-content .align-center{margin:auto}.rst-content .align-center:not(table){display:block}.rst-content .code-block-caption .headerlink,.rst-content .eqno .headerlink,.rst-content .toctree-wrapper>p.caption .headerlink,.rst-content dl dt .headerlink,.rst-content h1 .headerlink,.rst-content h2 .headerlink,.rst-content h3 .headerlink,.rst-content h4 .headerlink,.rst-content h5 .headerlink,.rst-content h6 .headerlink,.rst-content p.caption .headerlink,.rst-content p .headerlink,.rst-content table>caption .headerlink{opacity:0;font-size:14px;font-family:FontAwesome;margin-left:.5em}.rst-content .code-block-caption .headerlink:focus,.rst-content .code-block-caption:hover .headerlink,.rst-content .eqno .headerlink:focus,.rst-content .eqno:hover .headerlink,.rst-content .toctree-wrapper>p.caption .headerlink:focus,.rst-content .toctree-wrapper>p.caption:hover .headerlink,.rst-content dl dt .headerlink:focus,.rst-content dl dt:hover .headerlink,.rst-content h1 .headerlink:focus,.rst-content h1:hover .headerlink,.rst-content h2 .headerlink:focus,.rst-content h2:hover .headerlink,.rst-content h3 .headerlink:focus,.rst-content h3:hover .headerlink,.rst-content h4 .headerlink:focus,.rst-content h4:hover .headerlink,.rst-content h5 .headerlink:focus,.rst-content h5:hover .headerlink,.rst-content h6 .headerlink:focus,.rst-content h6:hover .headerlink,.rst-content p.caption .headerlink:focus,.rst-content p.caption:hover .headerlink,.rst-content p .headerlink:focus,.rst-content p:hover .headerlink,.rst-content table>caption .headerlink:focus,.rst-content table>caption:hover .headerlink{opacity:1}.rst-content .btn:focus{outline:2px solid}.rst-content table>caption .headerlink:after{font-size:12px}.rst-content .centered{text-align:center}.rst-content .sidebar{float:right;width:40%;display:block;margin:0 0 24px 24px;padding:24px;background:#f3f6f6;border:1px solid #e1e4e5}.rst-content .sidebar dl,.rst-content .sidebar p,.rst-content .sidebar ul{font-size:90%}.rst-content .sidebar .last,.rst-content .sidebar>:last-child{margin-bottom:0}.rst-content .sidebar .sidebar-title{display:block;font-family:Roboto Slab,ff-tisa-web-pro,Georgia,Arial,sans-serif;font-weight:700;background:#e1e4e5;padding:6px 12px;margin:-24px -24px 24px;font-size:100%}.rst-content .highlighted{background:#f1c40f;box-shadow:0 0 0 2px #f1c40f;display:inline;font-weight:700}.rst-content .citation-reference,.rst-content .footnote-reference{vertical-align:baseline;position:relative;top:-.4em;line-height:0;font-size:90%}.rst-content .hlist{width:100%}.rst-content dl dt span.classifier:before{content:" : "}.rst-content dl dt span.classifier-delimiter{display:none!important}html.writer-html4 .rst-content table.docutils.citation,html.writer-html4 .rst-content table.docutils.footnote{background:none;border:none}html.writer-html4 .rst-content table.docutils.citation td,html.writer-html4 .rst-content table.docutils.citation tr,html.writer-html4 .rst-content table.docutils.footnote td,html.writer-html4 .rst-content table.docutils.footnote tr{border:none;background-color:transparent!important;white-space:normal}html.writer-html4 .rst-content table.docutils.citation td.label,html.writer-html4 .rst-content table.docutils.footnote td.label{padding-left:0;padding-right:0;vertical-align:top}html.writer-html5 .rst-content dl.field-list,html.writer-html5 .rst-content dl.footnote{display:grid;grid-template-columns:max-content auto}html.writer-html5 .rst-content dl.field-list>dt,html.writer-html5 .rst-content dl.footnote>dt{padding-left:1rem}html.writer-html5 .rst-content dl.field-list>dt:after,html.writer-html5 .rst-content dl.footnote>dt:after{content:":"}html.writer-html5 .rst-content dl.field-list>dd,html.writer-html5 .rst-content dl.field-list>dt,html.writer-html5 .rst-content dl.footnote>dd,html.writer-html5 .rst-content dl.footnote>dt{margin-bottom:0}html.writer-html5 .rst-content dl.footnote{font-size:.9rem}html.writer-html5 .rst-content dl.footnote>dt{margin:0 .5rem .5rem 0;line-height:1.2rem;word-break:break-all;font-weight:400}html.writer-html5 .rst-content dl.footnote>dt>span.brackets{margin-right:.5rem}html.writer-html5 .rst-content dl.footnote>dt>span.brackets:before{content:"["}html.writer-html5 .rst-content dl.footnote>dt>span.brackets:after{content:"]"}html.writer-html5 .rst-content dl.footnote>dt>span.fn-backref{font-style:italic}html.writer-html5 .rst-content dl.footnote>dd{margin:0 0 .5rem;line-height:1.2rem}html.writer-html5 .rst-content dl.footnote>dd p,html.writer-html5 .rst-content dl.option-list kbd{font-size:.9rem}.rst-content table.docutils.footnote,html.writer-html4 .rst-content table.docutils.citation,html.writer-html5 .rst-content dl.footnote{color:grey}.rst-content table.docutils.footnote code,.rst-content table.docutils.footnote tt,html.writer-html4 .rst-content table.docutils.citation code,html.writer-html4 .rst-content table.docutils.citation tt,html.writer-html5 .rst-content dl.footnote code,html.writer-html5 .rst-content dl.footnote tt{color:#555}.rst-content .wy-table-responsive.citation,.rst-content .wy-table-responsive.footnote{margin-bottom:0}.rst-content .wy-table-responsive.citation+:not(.citation),.rst-content .wy-table-responsive.footnote+:not(.footnote){margin-top:24px}.rst-content .wy-table-responsive.citation:last-child,.rst-content .wy-table-responsive.footnote:last-child{margin-bottom:24px}.rst-content table.docutils th{border-color:#e1e4e5}html.writer-html5 .rst-content table.docutils th{border:1px solid #e1e4e5}html.writer-html5 .rst-content table.docutils td>p,html.writer-html5 .rst-content table.docutils th>p{line-height:1rem;margin-bottom:0;font-size:.9rem}.rst-content table.docutils td .last,.rst-content table.docutils td .last>:last-child{margin-bottom:0}.rst-content table.field-list,.rst-content table.field-list td{border:none}.rst-content table.field-list td p{font-size:inherit;line-height:inherit}.rst-content table.field-list td>strong{display:inline-block}.rst-content table.field-list .field-name{padding-right:10px;text-align:left;white-space:nowrap}.rst-content table.field-list .field-body{text-align:left}.rst-content code,.rst-content tt{color:#000;font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;padding:2px 5px}.rst-content code big,.rst-content code em,.rst-content tt big,.rst-content tt em{font-size:100%!important;line-height:normal}.rst-content code.literal,.rst-content tt.literal{color:#e74c3c;white-space:normal}.rst-content code.xref,.rst-content tt.xref,a .rst-content code,a .rst-content tt{font-weight:700;color:#404040}.rst-content kbd,.rst-content pre,.rst-content samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace}.rst-content a code,.rst-content a tt{color:#2980b9}.rst-content dl{margin-bottom:24px}.rst-content dl dt{font-weight:700;margin-bottom:12px}.rst-content dl ol,.rst-content dl p,.rst-content dl table,.rst-content dl ul{margin-bottom:12px}.rst-content dl dd{margin:0 0 12px 24px;line-height:24px}html.writer-html4 .rst-content dl:not(.docutils),html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple){margin-bottom:24px}html.writer-html4 .rst-content dl:not(.docutils)>dt,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple)>dt{display:table;margin:6px 0;font-size:90%;line-height:normal;background:#e7f2fa;color:#2980b9;border-top:3px solid #6ab0de;padding:6px;position:relative}html.writer-html4 .rst-content dl:not(.docutils)>dt:before,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple)>dt:before{color:#6ab0de}html.writer-html4 .rst-content dl:not(.docutils)>dt .headerlink,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple)>dt .headerlink{color:#404040;font-size:100%!important}html.writer-html4 .rst-content dl:not(.docutils) dl:not(.field-list)>dt,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) dl:not(.field-list)>dt{margin-bottom:6px;border:none;border-left:3px solid #ccc;background:#f0f0f0;color:#555}html.writer-html4 .rst-content dl:not(.docutils) dl:not(.field-list)>dt .headerlink,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) dl:not(.field-list)>dt .headerlink{color:#404040;font-size:100%!important}html.writer-html4 .rst-content dl:not(.docutils)>dt:first-child,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple)>dt:first-child{margin-top:0}html.writer-html4 .rst-content dl:not(.docutils) code.descclassname,html.writer-html4 .rst-content dl:not(.docutils) code.descname,html.writer-html4 .rst-content dl:not(.docutils) tt.descclassname,html.writer-html4 .rst-content dl:not(.docutils) tt.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) code.descclassname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) code.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) tt.descclassname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) tt.descname{background-color:transparent;border:none;padding:0;font-size:100%!important}html.writer-html4 .rst-content dl:not(.docutils) code.descname,html.writer-html4 .rst-content dl:not(.docutils) tt.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) code.descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) tt.descname{font-weight:700}html.writer-html4 .rst-content dl:not(.docutils) .optional,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .optional{display:inline-block;padding:0 4px;color:#000;font-weight:700}html.writer-html4 .rst-content dl:not(.docutils) .property,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .property{display:inline-block;padding-right:8px;max-width:100%}html.writer-html4 .rst-content dl:not(.docutils) .k,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .k{font-style:italic}html.writer-html4 .rst-content dl:not(.docutils) .descclassname,html.writer-html4 .rst-content dl:not(.docutils) .descname,html.writer-html4 .rst-content dl:not(.docutils) .sig-name,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .descclassname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .descname,html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .sig-name{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;color:#000}.rst-content .viewcode-back,.rst-content .viewcode-link{display:inline-block;color:#27ae60;font-size:80%;padding-left:24px}.rst-content .viewcode-back{display:block;float:right}.rst-content p.rubric{margin-bottom:12px;font-weight:700}.rst-content code.download,.rst-content tt.download{background:inherit;padding:inherit;font-weight:400;font-family:inherit;font-size:inherit;color:inherit;border:inherit;white-space:inherit}.rst-content code.download span:first-child,.rst-content tt.download span:first-child{-webkit-font-smoothing:subpixel-antialiased}.rst-content code.download span:first-child:before,.rst-content tt.download span:first-child:before{margin-right:4px}.rst-content .guilabel{border:1px solid #7fbbe3;background:#e7f2fa;font-size:80%;font-weight:700;border-radius:4px;padding:2.4px 6px;margin:auto 2px}.rst-content .versionmodified{font-style:italic}@media screen and (max-width:480px){.rst-content .sidebar{width:100%}}span[id*=MathJax-Span]{color:#404040}.math{text-align:center}@font-face{font-family:Lato;src:url(fonts/lato-normal.woff2?bd03a2cc277bbbc338d464e679fe9942) format("woff2"),url(fonts/lato-normal.woff?27bd77b9162d388cb8d4c4217c7c5e2a) format("woff");font-weight:400;font-style:normal;font-display:block}@font-face{font-family:Lato;src:url(fonts/lato-bold.woff2?cccb897485813c7c256901dbca54ecf2) format("woff2"),url(fonts/lato-bold.woff?d878b6c29b10beca227e9eef4246111b) format("woff");font-weight:700;font-style:normal;font-display:block}@font-face{font-family:Lato;src:url(fonts/lato-bold-italic.woff2?0b6bb6725576b072c5d0b02ecdd1900d) format("woff2"),url(fonts/lato-bold-italic.woff?9c7e4e9eb485b4a121c760e61bc3707c) format("woff");font-weight:700;font-style:italic;font-display:block}@font-face{font-family:Lato;src:url(fonts/lato-normal-italic.woff2?4eb103b4d12be57cb1d040ed5e162e9d) format("woff2"),url(fonts/lato-normal-italic.woff?f28f2d6482446544ef1ea1ccc6dd5892) format("woff");font-weight:400;font-style:italic;font-display:block}@font-face{font-family:Roboto Slab;font-style:normal;font-weight:400;src:url(fonts/Roboto-Slab-Regular.woff2?7abf5b8d04d26a2cafea937019bca958) format("woff2"),url(fonts/Roboto-Slab-Regular.woff?c1be9284088d487c5e3ff0a10a92e58c) format("woff");font-display:block}@font-face{font-family:Roboto Slab;font-style:normal;font-weight:700;src:url(fonts/Roboto-Slab-Bold.woff2?9984f4a9bda09be08e83f2506954adbe) format("woff2"),url(fonts/Roboto-Slab-Bold.woff?bed5564a116b05148e3b3bea6fb1162a) format("woff");font-display:block} \ No newline at end of file diff --git a/docs/build/html/_static/doctools.js b/docs/build/html/_static/doctools.js index 8cbf1b161a6527c8c6ad1c4f1fdc156e065ab262..c3db08d1c3896f616576ba6e6b96dc80fcfc50b9 100644 --- a/docs/build/html/_static/doctools.js +++ b/docs/build/html/_static/doctools.js @@ -2,322 +2,263 @@ * doctools.js * ~~~~~~~~~~~ * - * Sphinx JavaScript utilities for all documentation. + * Base JavaScript utilities for all Sphinx HTML documentation. * - * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ +"use strict"; -/** - * select a different prefix for underscore - */ -$u = _.noConflict(); - -/** - * make the code below compatible with browsers without - * an installed firebug like debugger -if (!window.console || !console.firebug) { - var names = ["log", "debug", "info", "warn", "error", "assert", "dir", - "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", - "profile", "profileEnd"]; - window.console = {}; - for (var i = 0; i < names.length; ++i) - window.console[names[i]] = function() {}; -} - */ - -/** - * small helper function to urldecode strings - * - * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL - */ -jQuery.urldecode = function(x) { - if (!x) { - return x +const _ready = (callback) => { + if (document.readyState !== "loading") { + callback(); + } else { + document.addEventListener("DOMContentLoaded", callback); } - return decodeURIComponent(x.replace(/\+/g, ' ')); }; /** - * small helper function to urlencode strings + * highlight a given string on a node by wrapping it in + * span elements with the given class name. */ -jQuery.urlencode = encodeURIComponent; +const _highlight = (node, addItems, text, className) => { + if (node.nodeType === Node.TEXT_NODE) { + const val = node.nodeValue; + const parent = node.parentNode; + const pos = val.toLowerCase().indexOf(text); + if ( + pos >= 0 && + !parent.classList.contains(className) && + !parent.classList.contains("nohighlight") + ) { + let span; -/** - * This function returns the parsed url parameters of the - * current request. Multiple values per key are supported, - * it will always return arrays of strings for the value parts. - */ -jQuery.getQueryParameters = function(s) { - if (typeof s === 'undefined') - s = document.location.search; - var parts = s.substr(s.indexOf('?') + 1).split('&'); - var result = {}; - for (var i = 0; i < parts.length; i++) { - var tmp = parts[i].split('=', 2); - var key = jQuery.urldecode(tmp[0]); - var value = jQuery.urldecode(tmp[1]); - if (key in result) - result[key].push(value); - else - result[key] = [value]; - } - return result; -}; + const closestNode = parent.closest("body, svg, foreignObject"); + const isInSVG = closestNode && closestNode.matches("svg"); + if (isInSVG) { + span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + } else { + span = document.createElement("span"); + span.classList.add(className); + } -/** - * highlight a given string on a jquery object by wrapping it in - * span elements with the given class name. - */ -jQuery.fn.highlightText = function(text, className) { - function highlight(node, addItems) { - if (node.nodeType === 3) { - var val = node.nodeValue; - var pos = val.toLowerCase().indexOf(text); - if (pos >= 0 && - !jQuery(node.parentNode).hasClass(className) && - !jQuery(node.parentNode).hasClass("nohighlight")) { - var span; - var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg"); - if (isInSVG) { - span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); - } else { - span = document.createElement("span"); - span.className = className; - } - span.appendChild(document.createTextNode(val.substr(pos, text.length))); - node.parentNode.insertBefore(span, node.parentNode.insertBefore( + span.appendChild(document.createTextNode(val.substr(pos, text.length))); + parent.insertBefore( + span, + parent.insertBefore( document.createTextNode(val.substr(pos + text.length)), - node.nextSibling)); - node.nodeValue = val.substr(0, pos); - if (isInSVG) { - var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); - var bbox = node.parentElement.getBBox(); - rect.x.baseVal.value = bbox.x; - rect.y.baseVal.value = bbox.y; - rect.width.baseVal.value = bbox.width; - rect.height.baseVal.value = bbox.height; - rect.setAttribute('class', className); - addItems.push({ - "parent": node.parentNode, - "target": rect}); - } + node.nextSibling + ) + ); + node.nodeValue = val.substr(0, pos); + + if (isInSVG) { + const rect = document.createElementNS( + "http://www.w3.org/2000/svg", + "rect" + ); + const bbox = parent.getBBox(); + rect.x.baseVal.value = bbox.x; + rect.y.baseVal.value = bbox.y; + rect.width.baseVal.value = bbox.width; + rect.height.baseVal.value = bbox.height; + rect.setAttribute("class", className); + addItems.push({ parent: parent, target: rect }); } } - else if (!jQuery(node).is("button, select, textarea")) { - jQuery.each(node.childNodes, function() { - highlight(this, addItems); - }); - } + } else if (node.matches && !node.matches("button, select, textarea")) { + node.childNodes.forEach((el) => _highlight(el, addItems, text, className)); } - var addItems = []; - var result = this.each(function() { - highlight(this, addItems); - }); - for (var i = 0; i < addItems.length; ++i) { - jQuery(addItems[i].parent).before(addItems[i].target); - } - return result; }; - -/* - * backward compatibility for jQuery.browser - * This will be supported until firefox bug is fixed. - */ -if (!jQuery.browser) { - jQuery.uaMatch = function(ua) { - ua = ua.toLowerCase(); - - var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || - /(webkit)[ \/]([\w.]+)/.exec(ua) || - /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || - /(msie) ([\w.]+)/.exec(ua) || - ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || - []; - - return { - browser: match[ 1 ] || "", - version: match[ 2 ] || "0" - }; - }; - jQuery.browser = {}; - jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; -} +const _highlightText = (thisNode, text, className) => { + let addItems = []; + _highlight(thisNode, addItems, text, className); + addItems.forEach((obj) => + obj.parent.insertAdjacentElement("beforebegin", obj.target) + ); +}; /** * Small JavaScript module for the documentation. */ -var Documentation = { - - init : function() { - this.fixFirefoxAnchorBug(); - this.highlightSearchWords(); - this.initIndexTable(); - if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) { - this.initOnKeyListeners(); - } +const Documentation = { + init: () => { + Documentation.highlightSearchWords(); + Documentation.initDomainIndexTable(); + Documentation.initOnKeyListeners(); }, /** * i18n support */ - TRANSLATIONS : {}, - PLURAL_EXPR : function(n) { return n === 1 ? 0 : 1; }, - LOCALE : 'unknown', + TRANSLATIONS: {}, + PLURAL_EXPR: (n) => (n === 1 ? 0 : 1), + LOCALE: "unknown", // gettext and ngettext don't access this so that the functions // can safely bound to a different name (_ = Documentation.gettext) - gettext : function(string) { - var translated = Documentation.TRANSLATIONS[string]; - if (typeof translated === 'undefined') - return string; - return (typeof translated === 'string') ? translated : translated[0]; - }, - - ngettext : function(singular, plural, n) { - var translated = Documentation.TRANSLATIONS[singular]; - if (typeof translated === 'undefined') - return (n == 1) ? singular : plural; - return translated[Documentation.PLURALEXPR(n)]; - }, - - addTranslations : function(catalog) { - for (var key in catalog.messages) - this.TRANSLATIONS[key] = catalog.messages[key]; - this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); - this.LOCALE = catalog.locale; + gettext: (string) => { + const translated = Documentation.TRANSLATIONS[string]; + switch (typeof translated) { + case "undefined": + return string; // no translation + case "string": + return translated; // translation exists + default: + return translated[0]; // (singular, plural) translation tuple exists + } }, - /** - * add context elements like header anchor links - */ - addContextElements : function() { - $('div[id] > :header:first').each(function() { - $('<a class="headerlink">\u00B6</a>'). - attr('href', '#' + this.id). - attr('title', _('Permalink to this headline')). - appendTo(this); - }); - $('dt[id]').each(function() { - $('<a class="headerlink">\u00B6</a>'). - attr('href', '#' + this.id). - attr('title', _('Permalink to this definition')). - appendTo(this); - }); + ngettext: (singular, plural, n) => { + const translated = Documentation.TRANSLATIONS[singular]; + if (typeof translated !== "undefined") + return translated[Documentation.PLURAL_EXPR(n)]; + return n === 1 ? singular : plural; }, - /** - * workaround a firefox stupidity - * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075 - */ - fixFirefoxAnchorBug : function() { - if (document.location.hash && $.browser.mozilla) - window.setTimeout(function() { - document.location.href += ''; - }, 10); + addTranslations: (catalog) => { + Object.assign(Documentation.TRANSLATIONS, catalog.messages); + Documentation.PLURAL_EXPR = new Function( + "n", + `return (${catalog.plural_expr})` + ); + Documentation.LOCALE = catalog.locale; }, /** * highlight the search words provided in the url in the text */ - highlightSearchWords : function() { - var params = $.getQueryParameters(); - var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; - if (terms.length) { - var body = $('div.body'); - if (!body.length) { - body = $('body'); - } - window.setTimeout(function() { - $.each(terms, function() { - body.highlightText(this.toLowerCase(), 'highlighted'); - }); - }, 10); - $('<p class="highlight-link"><a href="javascript:Documentation.' + - 'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>') - .appendTo($('#searchbox')); - } - }, + highlightSearchWords: () => { + const highlight = + new URLSearchParams(window.location.search).get("highlight") || ""; + const terms = highlight.toLowerCase().split(/\s+/).filter(x => x); + if (terms.length === 0) return; // nothing to do - /** - * init the domain index toggle buttons - */ - initIndexTable : function() { - var togglers = $('img.toggler').click(function() { - var src = $(this).attr('src'); - var idnum = $(this).attr('id').substr(7); - $('tr.cg-' + idnum).toggle(); - if (src.substr(-9) === 'minus.png') - $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); - else - $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); - }).css('display', ''); - if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { - togglers.click(); - } + // There should never be more than one element matching "div.body" + const divBody = document.querySelectorAll("div.body"); + const body = divBody.length ? divBody[0] : document.querySelector("body"); + window.setTimeout(() => { + terms.forEach((term) => _highlightText(body, term, "highlighted")); + }, 10); + + const searchBox = document.getElementById("searchbox"); + if (searchBox === null) return; + searchBox.appendChild( + document + .createRange() + .createContextualFragment( + '<p class="highlight-link">' + + '<a href="javascript:Documentation.hideSearchWords()">' + + Documentation.gettext("Hide Search Matches") + + "</a></p>" + ) + ); }, /** * helper function to hide the search marks again */ - hideSearchWords : function() { - $('#searchbox .highlight-link').fadeOut(300); - $('span.highlighted').removeClass('highlighted'); + hideSearchWords: () => { + document + .querySelectorAll("#searchbox .highlight-link") + .forEach((el) => el.remove()); + document + .querySelectorAll("span.highlighted") + .forEach((el) => el.classList.remove("highlighted")); + const url = new URL(window.location); + url.searchParams.delete("highlight"); + window.history.replaceState({}, "", url); }, /** - * make the url absolute + * helper function to focus on search bar */ - makeURL : function(relativeURL) { - return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; + focusSearchBar: () => { + document.querySelectorAll("input[name=q]")[0]?.focus(); }, /** - * get the current relative url + * Initialise the domain index toggle buttons */ - getCurrentURL : function() { - var path = document.location.pathname; - var parts = path.split(/\//); - $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { - if (this === '..') - parts.pop(); - }); - var url = parts.join('/'); - return path.substring(url.lastIndexOf('/') + 1, path.length - 1); + initDomainIndexTable: () => { + const toggler = (el) => { + const idNumber = el.id.substr(7); + const toggledRows = document.querySelectorAll(`tr.cg-${idNumber}`); + if (el.src.substr(-9) === "minus.png") { + el.src = `${el.src.substr(0, el.src.length - 9)}plus.png`; + toggledRows.forEach((el) => (el.style.display = "none")); + } else { + el.src = `${el.src.substr(0, el.src.length - 8)}minus.png`; + toggledRows.forEach((el) => (el.style.display = "")); + } + }; + + const togglerElements = document.querySelectorAll("img.toggler"); + togglerElements.forEach((el) => + el.addEventListener("click", (event) => toggler(event.currentTarget)) + ); + togglerElements.forEach((el) => (el.style.display = "")); + if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler); }, - initOnKeyListeners: function() { - $(document).keydown(function(event) { - var activeElementType = document.activeElement.tagName; - // don't navigate when in search box, textarea, dropdown or button - if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT' - && activeElementType !== 'BUTTON' && !event.altKey && !event.ctrlKey && !event.metaKey - && !event.shiftKey) { - switch (event.keyCode) { - case 37: // left - var prevHref = $('link[rel="prev"]').prop('href'); - if (prevHref) { - window.location.href = prevHref; - return false; + initOnKeyListeners: () => { + // only install a listener if it is really needed + if ( + !DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS && + !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS + ) + return; + + const blacklistedElements = new Set([ + "TEXTAREA", + "INPUT", + "SELECT", + "BUTTON", + ]); + document.addEventListener("keydown", (event) => { + if (blacklistedElements.has(document.activeElement.tagName)) return; // bail for input elements + if (event.altKey || event.ctrlKey || event.metaKey) return; // bail with special keys + + if (!event.shiftKey) { + switch (event.key) { + case "ArrowLeft": + if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; + + const prevLink = document.querySelector('link[rel="prev"]'); + if (prevLink && prevLink.href) { + window.location.href = prevLink.href; + event.preventDefault(); } break; - case 39: // right - var nextHref = $('link[rel="next"]').prop('href'); - if (nextHref) { - window.location.href = nextHref; - return false; + case "ArrowRight": + if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; + + const nextLink = document.querySelector('link[rel="next"]'); + if (nextLink && nextLink.href) { + window.location.href = nextLink.href; + event.preventDefault(); } break; + case "Escape": + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break; + Documentation.hideSearchWords(); + event.preventDefault(); } } + + // some keyboard layouts may need Shift to get / + switch (event.key) { + case "/": + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break; + Documentation.focusSearchBar(); + event.preventDefault(); + } }); - } + }, }; // quick alias for translations -_ = Documentation.gettext; +const _ = Documentation.gettext; -$(document).ready(function() { - Documentation.init(); -}); +_ready(Documentation.init); diff --git a/docs/build/html/_static/documentation_options.js b/docs/build/html/_static/documentation_options.js index 2fa8c97fe42aebc1d50251eca054fdc6b40ed084..a750e4d5eefe934637d6f14b3647b6b084f924a5 100644 --- a/docs/build/html/_static/documentation_options.js +++ b/docs/build/html/_static/documentation_options.js @@ -1,12 +1,14 @@ var DOCUMENTATION_OPTIONS = { URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), VERSION: '', - LANGUAGE: 'None', + LANGUAGE: 'en', COLLAPSE_INDEX: false, BUILDER: 'html', FILE_SUFFIX: '.html', LINK_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt', - NAVIGATION_WITH_KEYS: false + NAVIGATION_WITH_KEYS: false, + SHOW_SEARCH_SUMMARY: true, + ENABLE_SEARCH_SHORTCUTS: false, }; \ No newline at end of file diff --git a/docs/build/html/_static/fonts/Inconsolata-Bold.ttf b/docs/build/html/_static/fonts/Inconsolata-Bold.ttf deleted file mode 100644 index 809c1f5828f86235347019a50e78b4b486a6a045..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Inconsolata-Bold.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/Inconsolata-Regular.ttf b/docs/build/html/_static/fonts/Inconsolata-Regular.ttf deleted file mode 100644 index fc981ce7ad6c42d2384f0ef74b73174b9302ee65..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Inconsolata-Regular.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/Inconsolata.ttf b/docs/build/html/_static/fonts/Inconsolata.ttf deleted file mode 100644 index 4b8a36d249a05a0fe1575dc3d96ef7079dba6b07..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Inconsolata.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/Lato-Bold.ttf b/docs/build/html/_static/fonts/Lato-Bold.ttf deleted file mode 100644 index 1d23c7066e095b5bff2c373d4064dc4f33659783..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Lato-Bold.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/Lato-Regular.ttf b/docs/build/html/_static/fonts/Lato-Regular.ttf deleted file mode 100644 index 0f3d0f837d24834b9b5b0a6b735459c56f5e75c3..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Lato-Regular.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/Lato/lato-bold.eot b/docs/build/html/_static/fonts/Lato/lato-bold.eot deleted file mode 100644 index 3361183a419c188282a8545eaa8d8e298b8ffaab..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Lato/lato-bold.eot and /dev/null differ diff --git a/docs/build/html/_static/fonts/Lato/lato-bold.ttf b/docs/build/html/_static/fonts/Lato/lato-bold.ttf deleted file mode 100644 index 29f691d5ed0c2d3d224423bb0288e6bd59292511..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Lato/lato-bold.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/Lato/lato-bolditalic.eot b/docs/build/html/_static/fonts/Lato/lato-bolditalic.eot deleted file mode 100644 index 3d4154936b42522fac84900c689a901ac12875c0..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Lato/lato-bolditalic.eot and /dev/null differ diff --git a/docs/build/html/_static/fonts/Lato/lato-bolditalic.ttf b/docs/build/html/_static/fonts/Lato/lato-bolditalic.ttf deleted file mode 100644 index f402040b3e5360b90f3a12ca2afab2cd7244e16f..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Lato/lato-bolditalic.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/Lato/lato-italic.eot b/docs/build/html/_static/fonts/Lato/lato-italic.eot deleted file mode 100644 index 3f826421a1d97b09797fad3d781a666a39eb45c9..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Lato/lato-italic.eot and /dev/null differ diff --git a/docs/build/html/_static/fonts/Lato/lato-italic.ttf b/docs/build/html/_static/fonts/Lato/lato-italic.ttf deleted file mode 100644 index b4bfc9b24aa993977662352c881c6e42f99f77e0..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Lato/lato-italic.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/Lato/lato-regular.eot b/docs/build/html/_static/fonts/Lato/lato-regular.eot deleted file mode 100644 index 11e3f2a5f0f9b8c7ef6affae8c543d20f7c112be..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Lato/lato-regular.eot and /dev/null differ diff --git a/docs/build/html/_static/fonts/Lato/lato-regular.ttf b/docs/build/html/_static/fonts/Lato/lato-regular.ttf deleted file mode 100644 index 74decd9ebb8d805201934266b3bda6a9d5831024..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/Lato/lato-regular.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/RobotoSlab-Bold.ttf b/docs/build/html/_static/fonts/RobotoSlab-Bold.ttf deleted file mode 100644 index df5d1df2730433013f41bf2698cbe249b075aa02..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/RobotoSlab-Bold.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/RobotoSlab-Regular.ttf b/docs/build/html/_static/fonts/RobotoSlab-Regular.ttf deleted file mode 100644 index eb52a7907362cc3392eb74892883f5d9e260b638..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/RobotoSlab-Regular.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot b/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot deleted file mode 100644 index 79dc8efed3447d6588baa2bb74122d56f3500038..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot and /dev/null differ diff --git a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf b/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf deleted file mode 100644 index df5d1df2730433013f41bf2698cbe249b075aa02..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf and /dev/null differ diff --git a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot b/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot deleted file mode 100644 index 2f7ca78a1eb34f0f98feb07ab1231d077b248940..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot and /dev/null differ diff --git a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf b/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf deleted file mode 100644 index eb52a7907362cc3392eb74892883f5d9e260b638..0000000000000000000000000000000000000000 Binary files a/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf and /dev/null differ diff --git a/docs/build/html/_static/jquery-3.5.1.js b/docs/build/html/_static/jquery-3.6.0.js similarity index 98% rename from docs/build/html/_static/jquery-3.5.1.js rename to docs/build/html/_static/jquery-3.6.0.js index 50937333b99a5e168ac9e8292b22edd7e96c3e6a..fc6c299b73e792ef288e785c22393a5df9dded4b 100644 --- a/docs/build/html/_static/jquery-3.5.1.js +++ b/docs/build/html/_static/jquery-3.6.0.js @@ -1,15 +1,15 @@ /*! - * jQuery JavaScript Library v3.5.1 + * jQuery JavaScript Library v3.6.0 * https://jquery.com/ * * Includes Sizzle.js * https://sizzlejs.com/ * - * Copyright JS Foundation and other contributors + * Copyright OpenJS Foundation and other contributors * Released under the MIT license * https://jquery.org/license * - * Date: 2020-05-04T22:49Z + * Date: 2021-03-02T17:08Z */ ( function( global, factory ) { @@ -76,12 +76,16 @@ var support = {}; var isFunction = function isFunction( obj ) { - // Support: Chrome <=57, Firefox <=52 - // In some browsers, typeof returns "function" for HTML <object> elements - // (i.e., `typeof document.createElement( "object" ) === "function"`). - // We don't want to classify *any* DOM node as a function. - return typeof obj === "function" && typeof obj.nodeType !== "number"; - }; + // Support: Chrome <=57, Firefox <=52 + // In some browsers, typeof returns "function" for HTML <object> elements + // (i.e., `typeof document.createElement( "object" ) === "function"`). + // We don't want to classify *any* DOM node as a function. + // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5 + // Plus for old WebKit, typeof returns "function" for HTML collections + // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756) + return typeof obj === "function" && typeof obj.nodeType !== "number" && + typeof obj.item !== "function"; + }; var isWindow = function isWindow( obj ) { @@ -147,7 +151,7 @@ function toType( obj ) { var - version = "3.5.1", + version = "3.6.0", // Define a local copy of jQuery jQuery = function( selector, context ) { @@ -401,7 +405,7 @@ jQuery.extend( { if ( isArrayLike( Object( arr ) ) ) { jQuery.merge( ret, typeof arr === "string" ? - [ arr ] : arr + [ arr ] : arr ); } else { push.call( ret, arr ); @@ -496,9 +500,9 @@ if ( typeof Symbol === "function" ) { // Populate the class2type map jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), -function( _i, name ) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); -} ); + function( _i, name ) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); + } ); function isArrayLike( obj ) { @@ -518,14 +522,14 @@ function isArrayLike( obj ) { } var Sizzle = /*! - * Sizzle CSS Selector Engine v2.3.5 + * Sizzle CSS Selector Engine v2.3.6 * https://sizzlejs.com/ * * Copyright JS Foundation and other contributors * Released under the MIT license * https://js.foundation/ * - * Date: 2020-03-14 + * Date: 2021-02-16 */ ( function( window ) { var i, @@ -1108,8 +1112,8 @@ support = Sizzle.support = {}; * @returns {Boolean} True iff elem is a non-HTML XML node */ isXML = Sizzle.isXML = function( elem ) { - var namespace = elem.namespaceURI, - docElem = ( elem.ownerDocument || elem ).documentElement; + var namespace = elem && elem.namespaceURI, + docElem = elem && ( elem.ownerDocument || elem ).documentElement; // Support: IE <=8 // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes @@ -3024,9 +3028,9 @@ var rneedsContext = jQuery.expr.match.needsContext; function nodeName( elem, name ) { - return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); -}; +} var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); @@ -3997,8 +4001,8 @@ jQuery.extend( { resolveContexts = Array( i ), resolveValues = slice.call( arguments ), - // the master Deferred - master = jQuery.Deferred(), + // the primary Deferred + primary = jQuery.Deferred(), // subordinate callback factory updateFunc = function( i ) { @@ -4006,30 +4010,30 @@ jQuery.extend( { resolveContexts[ i ] = this; resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; if ( !( --remaining ) ) { - master.resolveWith( resolveContexts, resolveValues ); + primary.resolveWith( resolveContexts, resolveValues ); } }; }; // Single- and empty arguments are adopted like Promise.resolve if ( remaining <= 1 ) { - adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject, + adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject, !remaining ); // Use .then() to unwrap secondary thenables (cf. gh-3000) - if ( master.state() === "pending" || + if ( primary.state() === "pending" || isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { - return master.then(); + return primary.then(); } } // Multiple arguments are aggregated like Promise.all array elements while ( i-- ) { - adoptValue( resolveValues[ i ], updateFunc( i ), master.reject ); + adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject ); } - return master.promise(); + return primary.promise(); } } ); @@ -4180,8 +4184,8 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { for ( ; i < len; i++ ) { fn( elems[ i ], key, raw ? - value : - value.call( elems[ i ], i, fn( elems[ i ], key ) ) + value : + value.call( elems[ i ], i, fn( elems[ i ], key ) ) ); } } @@ -5089,10 +5093,7 @@ function buildFragment( elems, context, scripts, selection, ignored ) { } -var - rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, - rtypenamespace = /^([^.]*)(?:\.(.+)|)/; +var rtypenamespace = /^([^.]*)(?:\.(.+)|)/; function returnTrue() { return true; @@ -5387,8 +5388,8 @@ jQuery.event = { event = jQuery.event.fix( nativeEvent ), handlers = ( - dataPriv.get( this, "events" ) || Object.create( null ) - )[ event.type ] || [], + dataPriv.get( this, "events" ) || Object.create( null ) + )[ event.type ] || [], special = jQuery.event.special[ event.type ] || {}; // Use the fix-ed jQuery.Event rather than the (read-only) native event @@ -5512,12 +5513,12 @@ jQuery.event = { get: isFunction( hook ) ? function() { if ( this.originalEvent ) { - return hook( this.originalEvent ); + return hook( this.originalEvent ); } } : function() { if ( this.originalEvent ) { - return this.originalEvent[ name ]; + return this.originalEvent[ name ]; } }, @@ -5656,7 +5657,13 @@ function leverageNative( el, type, expectSync ) { // Cancel the outer synthetic event event.stopImmediatePropagation(); event.preventDefault(); - return result.value; + + // Support: Chrome 86+ + // In Chrome, if an element having a focusout handler is blurred by + // clicking outside of it, it invokes the handler synchronously. If + // that handler calls `.remove()` on the element, the data is cleared, + // leaving `result` undefined. We need to guard against this. + return result && result.value; } // If this is an inner synthetic event for an event with a bubbling surrogate @@ -5821,34 +5828,7 @@ jQuery.each( { targetTouches: true, toElement: true, touches: true, - - which: function( event ) { - var button = event.button; - - // Add which for key events - if ( event.which == null && rkeyEvent.test( event.type ) ) { - return event.charCode != null ? event.charCode : event.keyCode; - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) { - if ( button & 1 ) { - return 1; - } - - if ( button & 2 ) { - return 3; - } - - if ( button & 4 ) { - return 2; - } - - return 0; - } - - return event.which; - } + which: true }, jQuery.event.addProp ); jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { @@ -5874,6 +5854,12 @@ jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateTyp return true; }, + // Suppress native focus or blur as it's already being fired + // in leverageNative. + _default: function() { + return true; + }, + delegateType: delegateType }; } ); @@ -6541,6 +6527,10 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); // set in CSS while `offset*` properties report correct values. // Behavior in IE 9 is more subtle than in newer versions & it passes // some versions of this test; make sure not to make it pass there! + // + // Support: Firefox 70+ + // Only Firefox includes border widths + // in computed dimensions. (gh-4529) reliableTrDimensions: function() { var table, tr, trChild, trStyle; if ( reliableTrDimensionsVal == null ) { @@ -6548,17 +6538,32 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); tr = document.createElement( "tr" ); trChild = document.createElement( "div" ); - table.style.cssText = "position:absolute;left:-11111px"; + table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; + tr.style.cssText = "border:1px solid"; + + // Support: Chrome 86+ + // Height set through cssText does not get applied. + // Computed height then comes back as 0. tr.style.height = "1px"; trChild.style.height = "9px"; + // Support: Android 8 Chrome 86+ + // In our bodyBackground.html iframe, + // display for all div elements is set to "inline", + // which causes a problem only in Android 8 Chrome 86. + // Ensuring the div is display: block + // gets around this issue. + trChild.style.display = "block"; + documentElement .appendChild( table ) .appendChild( tr ) .appendChild( trChild ); trStyle = window.getComputedStyle( tr ); - reliableTrDimensionsVal = parseInt( trStyle.height ) > 3; + reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + + parseInt( trStyle.borderTopWidth, 10 ) + + parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; documentElement.removeChild( table ); } @@ -7022,10 +7027,10 @@ jQuery.each( [ "height", "width" ], function( _i, dimension ) { // Running getBoundingClientRect on a disconnected node // in IE throws an error. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? - swap( elem, cssShow, function() { - return getWidthOrHeight( elem, dimension, extra ); - } ) : - getWidthOrHeight( elem, dimension, extra ); + swap( elem, cssShow, function() { + return getWidthOrHeight( elem, dimension, extra ); + } ) : + getWidthOrHeight( elem, dimension, extra ); } }, @@ -7084,7 +7089,7 @@ jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, swap( elem, { marginLeft: 0 }, function() { return elem.getBoundingClientRect().left; } ) - ) + "px"; + ) + "px"; } } ); @@ -7223,7 +7228,7 @@ Tween.propHooks = { if ( jQuery.fx.step[ tween.prop ] ) { jQuery.fx.step[ tween.prop ]( tween ); } else if ( tween.elem.nodeType === 1 && ( - jQuery.cssHooks[ tween.prop ] || + jQuery.cssHooks[ tween.prop ] || tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); } else { @@ -7468,7 +7473,7 @@ function defaultPrefilter( elem, props, opts ) { anim.done( function() { - /* eslint-enable no-loop-func */ + /* eslint-enable no-loop-func */ // The final step of a "hide" animation is actually hiding the element if ( !hidden ) { @@ -7588,7 +7593,7 @@ function Animation( elem, properties, options ) { tweens: [], createTween: function( prop, end ) { var tween = jQuery.Tween( elem, animation.opts, prop, end, - animation.opts.specialEasing[ prop ] || animation.opts.easing ); + animation.opts.specialEasing[ prop ] || animation.opts.easing ); animation.tweens.push( tween ); return tween; }, @@ -7761,7 +7766,8 @@ jQuery.fn.extend( { anim.stop( true ); } }; - doAnimation.finish = doAnimation; + + doAnimation.finish = doAnimation; return empty || optall.queue === false ? this.each( doAnimation ) : @@ -8401,8 +8407,8 @@ jQuery.fn.extend( { if ( this.setAttribute ) { this.setAttribute( "class", className || value === false ? - "" : - dataPriv.get( this, "__className__" ) || "" + "" : + dataPriv.get( this, "__className__" ) || "" ); } } @@ -8417,7 +8423,7 @@ jQuery.fn.extend( { while ( ( elem = this[ i++ ] ) ) { if ( elem.nodeType === 1 && ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { - return true; + return true; } } @@ -8707,9 +8713,7 @@ jQuery.extend( jQuery.event, { special.bindType || type; // jQuery handler - handle = ( - dataPriv.get( cur, "events" ) || Object.create( null ) - )[ event.type ] && + handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] && dataPriv.get( cur, "handle" ); if ( handle ) { handle.apply( cur, data ); @@ -8856,7 +8860,7 @@ var rquery = ( /\?/ ); // Cross-browser xml parsing jQuery.parseXML = function( data ) { - var xml; + var xml, parserErrorElem; if ( !data || typeof data !== "string" ) { return null; } @@ -8865,12 +8869,17 @@ jQuery.parseXML = function( data ) { // IE throws on parseFromString with invalid input. try { xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); - } catch ( e ) { - xml = undefined; - } + } catch ( e ) {} - if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { - jQuery.error( "Invalid XML: " + data ); + parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ]; + if ( !xml || parserErrorElem ) { + jQuery.error( "Invalid XML: " + ( + parserErrorElem ? + jQuery.map( parserErrorElem.childNodes, function( el ) { + return el.textContent; + } ).join( "\n" ) : + data + ) ); } return xml; }; @@ -8971,16 +8980,14 @@ jQuery.fn.extend( { // Can add propHook for "elements" to filter or add form elements var elements = jQuery.prop( this, "elements" ); return elements ? jQuery.makeArray( elements ) : this; - } ) - .filter( function() { + } ).filter( function() { var type = this.type; // Use .is( ":disabled" ) so that fieldset[disabled] works return this.name && !jQuery( this ).is( ":disabled" ) && rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && ( this.checked || !rcheckableType.test( type ) ); - } ) - .map( function( _i, elem ) { + } ).map( function( _i, elem ) { var val = jQuery( this ).val(); if ( val == null ) { @@ -9033,7 +9040,8 @@ var // Anchor tag for parsing the document origin originAnchor = document.createElement( "a" ); - originAnchor.href = location.href; + +originAnchor.href = location.href; // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport function addToPrefiltersOrTransports( structure ) { @@ -9414,8 +9422,8 @@ jQuery.extend( { // Context for global events is callbackContext if it is a DOM node or jQuery collection globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ? - jQuery( callbackContext ) : - jQuery.event, + jQuery( callbackContext ) : + jQuery.event, // Deferreds deferred = jQuery.Deferred(), @@ -9727,8 +9735,10 @@ jQuery.extend( { response = ajaxHandleResponses( s, jqXHR, responses ); } - // Use a noop converter for missing script - if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) { + // Use a noop converter for missing script but not if jsonp + if ( !isSuccess && + jQuery.inArray( "script", s.dataTypes ) > -1 && + jQuery.inArray( "json", s.dataTypes ) < 0 ) { s.converters[ "text script" ] = function() {}; } @@ -10466,12 +10476,6 @@ jQuery.offset = { options.using.call( elem, props ); } else { - if ( typeof props.top === "number" ) { - props.top += "px"; - } - if ( typeof props.left === "number" ) { - props.left += "px"; - } curElem.css( props ); } } @@ -10640,8 +10644,11 @@ jQuery.each( [ "top", "left" ], function( _i, prop ) { // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { - jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, - function( defaultExtra, funcName ) { + jQuery.each( { + padding: "inner" + name, + content: type, + "": "outer" + name + }, function( defaultExtra, funcName ) { // Margin is only for outerHeight, outerWidth jQuery.fn[ funcName ] = function( margin, value ) { @@ -10726,7 +10733,8 @@ jQuery.fn.extend( { } } ); -jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + +jQuery.each( + ( "blur focus focusin focusout resize scroll click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "change select submit keydown keypress keyup contextmenu" ).split( " " ), function( _i, name ) { @@ -10737,7 +10745,8 @@ jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + this.on( name, null, data, fn ) : this.trigger( name ); }; - } ); + } +); diff --git a/docs/build/html/_static/jquery.js b/docs/build/html/_static/jquery.js index b0614034ad3a95e4ae9f53c2b015eeb3e8d68bde..c4c6022f2982e8dae64cebd6b9a2b59f2547faad 100644 --- a/docs/build/html/_static/jquery.js +++ b/docs/build/html/_static/jquery.js @@ -1,2 +1,2 @@ -/*! jQuery v3.5.1 | (c) JS Foundation and other contributors | jquery.org/license */ -!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.5.1",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=S.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return S.each(this,e)},map:function(n){return this.pushStack(S.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(S.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(S.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:u,sort:t.sort,splice:t.splice},S.extend=S.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||m(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(S.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||S.isPlainObject(n)?n:{},i=!1,a[t]=S.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},S.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=v.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){b(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(p(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},makeArray:function(e,t){var n=t||[];return null!=e&&(p(Object(e))?S.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(p(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:y}),"function"==typeof Symbol&&(S.fn[Symbol.iterator]=t[Symbol.iterator]),S.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var d=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,v,s,c,y,S="sizzle"+1*new Date,p=n.document,k=0,r=0,m=ue(),x=ue(),A=ue(),N=ue(),D=function(e,t){return e===t&&(l=!0),0},j={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",F=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",B=new RegExp(M+"+","g"),$=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="<a id='"+S+"'></a><select id='"+S+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0<se(t,C,null,[e]).length},se.contains=function(e,t){return(e.ownerDocument||e)!=C&&T(e),y(e,t)},se.attr=function(e,t){(e.ownerDocument||e)!=C&&T(e);var n=b.attrHandle[t.toLowerCase()],r=n&&j.call(b.attrHandle,t.toLowerCase())?n(e,t,!E):void 0;return void 0!==r?r:d.attributes||!E?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},se.escape=function(e){return(e+"").replace(re,ie)},se.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},se.uniqueSort=function(e){var t,n=[],r=0,i=0;if(l=!d.detectDuplicates,u=!d.sortStable&&e.slice(0),e.sort(D),l){while(t=e[i++])t===e[i]&&(r=n.push(i));while(r--)e.splice(n[r],1)}return u=null,e},o=se.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else while(t=e[r++])n+=o(t);return n},(b=se.selectors={cacheLength:50,createPseudo:le,match:G,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1<t.indexOf(i):"$="===r?i&&t.slice(-i.length)===i:"~="===r?-1<(" "+t.replace(B," ")+" ").indexOf(i):"|="===r&&(t===i||t.slice(0,i.length+1)===i+"-"))}},CHILD:function(h,e,t,g,v){var y="nth"!==h.slice(0,3),m="last"!==h.slice(-4),x="of-type"===e;return 1===g&&0===v?function(e){return!!e.parentNode}:function(e,t,n){var r,i,o,a,s,u,l=y!==m?"nextSibling":"previousSibling",c=e.parentNode,f=x&&e.nodeName.toLowerCase(),p=!n&&!x,d=!1;if(c){if(y){while(l){a=e;while(a=a[l])if(x?a.nodeName.toLowerCase()===f:1===a.nodeType)return!1;u=l="only"===h&&!u&&"nextSibling"}return!0}if(u=[m?c.firstChild:c.lastChild],m&&p){d=(s=(r=(i=(o=(a=c)[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]||[])[0]===k&&r[1])&&r[2],a=s&&c.childNodes[s];while(a=++s&&a&&a[l]||(d=s=0)||u.pop())if(1===a.nodeType&&++d&&a===e){i[h]=[k,s,d];break}}else if(p&&(d=s=(r=(i=(o=(a=e)[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]||[])[0]===k&&r[1]),!1===d)while(a=++s&&a&&a[l]||(d=s=0)||u.pop())if((x?a.nodeName.toLowerCase()===f:1===a.nodeType)&&++d&&(p&&((i=(o=a[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]=[k,d]),a===e))break;return(d-=v)===g||d%g==0&&0<=d/g}}},PSEUDO:function(e,o){var t,a=b.pseudos[e]||b.setFilters[e.toLowerCase()]||se.error("unsupported pseudo: "+e);return a[S]?a(o):1<a.length?(t=[e,e,"",o],b.setFilters.hasOwnProperty(e.toLowerCase())?le(function(e,t){var n,r=a(e,o),i=r.length;while(i--)e[n=P(e,r[i])]=!(t[n]=r[i])}):function(e){return a(e,0,t)}):a}},pseudos:{not:le(function(e){var r=[],i=[],s=f(e.replace($,"$1"));return s[S]?le(function(e,t,n,r){var i,o=s(e,null,r,[]),a=e.length;while(a--)(i=o[a])&&(e[a]=!(t[a]=i))}):function(e,t,n){return r[0]=e,s(r,null,n,i),r[0]=null,!i.pop()}}),has:le(function(t){return function(e){return 0<se(t,e).length}}),contains:le(function(t){return t=t.replace(te,ne),function(e){return-1<(e.textContent||o(e)).indexOf(t)}}),lang:le(function(n){return V.test(n||"")||se.error("unsupported lang: "+n),n=n.replace(te,ne).toLowerCase(),function(e){var t;do{if(t=E?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(t=t.toLowerCase())===n||0===t.indexOf(n+"-")}while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var t=n.location&&n.location.hash;return t&&t.slice(1)===e.id},root:function(e){return e===a},focus:function(e){return e===C.activeElement&&(!C.hasFocus||C.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ge(!1),disabled:ge(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!b.pseudos.empty(e)},header:function(e){return J.test(e.nodeName)},input:function(e){return Q.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:ve(function(){return[0]}),last:ve(function(e,t){return[t-1]}),eq:ve(function(e,t,n){return[n<0?n+t:n]}),even:ve(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:ve(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:ve(function(e,t,n){for(var r=n<0?n+t:t<n?t:n;0<=--r;)e.push(r);return e}),gt:ve(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}}).pseudos.nth=b.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})b.pseudos[e]=de(e);for(e in{submit:!0,reset:!0})b.pseudos[e]=he(e);function me(){}function xe(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function be(s,e,t){var u=e.dir,l=e.next,c=l||u,f=t&&"parentNode"===c,p=r++;return e.first?function(e,t,n){while(e=e[u])if(1===e.nodeType||f)return s(e,t,n);return!1}:function(e,t,n){var r,i,o,a=[k,p];if(n){while(e=e[u])if((1===e.nodeType||f)&&s(e,t,n))return!0}else while(e=e[u])if(1===e.nodeType||f)if(i=(o=e[S]||(e[S]={}))[e.uniqueID]||(o[e.uniqueID]={}),l&&l===e.nodeName.toLowerCase())e=e[u]||e;else{if((r=i[c])&&r[0]===k&&r[1]===p)return a[2]=r[2];if((i[c]=a)[2]=s(e,t,n))return!0}return!1}}function we(i){return 1<i.length?function(e,t,n){var r=i.length;while(r--)if(!i[r](e,t,n))return!1;return!0}:i[0]}function Te(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function Ce(d,h,g,v,y,e){return v&&!v[S]&&(v=Ce(v)),y&&!y[S]&&(y=Ce(y,e)),le(function(e,t,n,r){var i,o,a,s=[],u=[],l=t.length,c=e||function(e,t,n){for(var r=0,i=t.length;r<i;r++)se(e,t[r],n);return n}(h||"*",n.nodeType?[n]:n,[]),f=!d||!e&&h?c:Te(c,s,d,n,r),p=g?y||(e?d:l||v)?[]:t:f;if(g&&g(f,p,n,r),v){i=Te(p,u),v(i,[],n,r),o=i.length;while(o--)(a=i[o])&&(p[u[o]]=!(f[u[o]]=a))}if(e){if(y||d){if(y){i=[],o=p.length;while(o--)(a=p[o])&&i.push(f[o]=a);y(null,p=[],i,r)}o=p.length;while(o--)(a=p[o])&&-1<(i=y?P(e,a):s[o])&&(e[i]=!(t[i]=a))}}else p=Te(p===t?p.splice(l,p.length):p),y?y(null,t,p,r):H.apply(t,p)})}function Ee(e){for(var i,t,n,r=e.length,o=b.relative[e[0].type],a=o||b.relative[" "],s=o?1:0,u=be(function(e){return e===i},a,!0),l=be(function(e){return-1<P(i,e)},a,!0),c=[function(e,t,n){var r=!o&&(n||t!==w)||((i=t).nodeType?u(e,t,n):l(e,t,n));return i=null,r}];s<r;s++)if(t=b.relative[e[s].type])c=[be(we(c),t)];else{if((t=b.filter[e[s].type].apply(null,e[s].matches))[S]){for(n=++s;n<r;n++)if(b.relative[e[n].type])break;return Ce(1<s&&we(c),1<s&&xe(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace($,"$1"),t,s<n&&Ee(e.slice(s,n)),n<r&&Ee(e=e.slice(n)),n<r&&xe(e))}c.push(t)}return we(c)}return me.prototype=b.filters=b.pseudos,b.setFilters=new me,h=se.tokenize=function(e,t){var n,r,i,o,a,s,u,l=x[e+" "];if(l)return t?0:l.slice(0);a=e,s=[],u=b.preFilter;while(a){for(o in n&&!(r=_.exec(a))||(r&&(a=a.slice(r[0].length)||a),s.push(i=[])),n=!1,(r=z.exec(a))&&(n=r.shift(),i.push({value:n,type:r[0].replace($," ")}),a=a.slice(n.length)),b.filter)!(r=G[o].exec(a))||u[o]&&!(r=u[o](r))||(n=r.shift(),i.push({value:n,type:o,matches:r}),a=a.slice(n.length));if(!n)break}return t?a.length:a?se.error(e):x(e,s).slice(0)},f=se.compile=function(e,t){var n,v,y,m,x,r,i=[],o=[],a=A[e+" "];if(!a){t||(t=h(e)),n=t.length;while(n--)(a=Ee(t[n]))[S]?i.push(a):o.push(a);(a=A(e,(v=o,m=0<(y=i).length,x=0<v.length,r=function(e,t,n,r,i){var o,a,s,u=0,l="0",c=e&&[],f=[],p=w,d=e||x&&b.find.TAG("*",i),h=k+=null==p?1:Math.random()||.1,g=d.length;for(i&&(w=t==C||t||i);l!==g&&null!=(o=d[l]);l++){if(x&&o){a=0,t||o.ownerDocument==C||(T(o),n=!E);while(s=v[a++])if(s(o,t||C,n)){r.push(o);break}i&&(k=h)}m&&((o=!s&&o)&&u--,e&&c.push(o))}if(u+=l,m&&l!==u){a=0;while(s=y[a++])s(c,f,t,n);if(e){if(0<u)while(l--)c[l]||f[l]||(f[l]=q.call(r));f=Te(f)}H.apply(r,f),i&&!e&&0<f.length&&1<u+y.length&&se.uniqueSort(r)}return i&&(k=h,w=p),c},m?le(r):r))).selector=e}return a},g=se.select=function(e,t,n,r){var i,o,a,s,u,l="function"==typeof e&&e,c=!r&&h(e=l.selector||e);if(n=n||[],1===c.length){if(2<(o=c[0]=c[0].slice(0)).length&&"ID"===(a=o[0]).type&&9===t.nodeType&&E&&b.relative[o[1].type]){if(!(t=(b.find.ID(a.matches[0].replace(te,ne),t)||[])[0]))return n;l&&(t=t.parentNode),e=e.slice(o.shift().value.length)}i=G.needsContext.test(e)?0:o.length;while(i--){if(a=o[i],b.relative[s=a.type])break;if((u=b.find[s])&&(r=u(a.matches[0].replace(te,ne),ee.test(o[0].type)&&ye(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&xe(o)))return H.apply(n,r),n;break}}}return(l||f(e,c))(r,t,!E,n,!t||ee.test(e)&&ye(t.parentNode)||t),n},d.sortStable=S.split("").sort(D).join("")===S,d.detectDuplicates=!!l,T(),d.sortDetached=ce(function(e){return 1&e.compareDocumentPosition(C.createElement("fieldset"))}),ce(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||fe("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),d.attributes&&ce(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||fe("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ce(function(e){return null==e.getAttribute("disabled")})||fe(R,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),se}(C);S.find=d,S.expr=d.selectors,S.expr[":"]=S.expr.pseudos,S.uniqueSort=S.unique=d.uniqueSort,S.text=d.getText,S.isXMLDoc=d.isXML,S.contains=d.contains,S.escapeSelector=d.escape;var h=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&S(e).is(n))break;r.push(e)}return r},T=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},k=S.expr.match.needsContext;function A(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var N=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function D(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1<i.call(n,e)!==r}):S.filter(n,e,r)}S.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?S.find.matchesSelector(r,e)?[r]:[]:S.find.matches(e,S.grep(t,function(e){return 1===e.nodeType}))},S.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(S(e).filter(function(){for(t=0;t<r;t++)if(S.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)S.find(e,i[t],n);return 1<r?S.uniqueSort(n):n},filter:function(e){return this.pushStack(D(this,e||[],!1))},not:function(e){return this.pushStack(D(this,e||[],!0))},is:function(e){return!!D(this,"string"==typeof e&&k.test(e)?S(e):e||[],!1).length}});var j,q=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||j,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,j=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(S.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&S(e);if(!k.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?-1<a.index(n):1===n.nodeType&&S.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(1<o.length?S.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?i.call(S(e),this[0]):i.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(S.uniqueSort(S.merge(this.get(),S(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),S.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return h(e,"parentNode")},parentsUntil:function(e,t,n){return h(e,"parentNode",n)},next:function(e){return O(e,"nextSibling")},prev:function(e){return O(e,"previousSibling")},nextAll:function(e){return h(e,"nextSibling")},prevAll:function(e){return h(e,"previousSibling")},nextUntil:function(e,t,n){return h(e,"nextSibling",n)},prevUntil:function(e,t,n){return h(e,"previousSibling",n)},siblings:function(e){return T((e.parentNode||{}).firstChild,e)},children:function(e){return T(e.firstChild)},contents:function(e){return null!=e.contentDocument&&r(e.contentDocument)?e.contentDocument:(A(e,"template")&&(e=e.content||e),S.merge([],e.childNodes))}},function(r,i){S.fn[r]=function(e,t){var n=S.map(this,i,e);return"Until"!==r.slice(-5)&&(t=e),t&&"string"==typeof t&&(n=S.filter(t,n)),1<this.length&&(H[r]||S.uniqueSort(n),L.test(r)&&n.reverse()),this.pushStack(n)}});var P=/[^\x20\t\r\n\f]+/g;function R(e){return e}function M(e){throw e}function I(e,t,n,r){var i;try{e&&m(i=e.promise)?i.call(e).done(t).fail(n):e&&m(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}S.Callbacks=function(r){var e,n;r="string"==typeof r?(e=r,n={},S.each(e.match(P)||[],function(e,t){n[t]=!0}),n):S.extend({},r);var i,t,o,a,s=[],u=[],l=-1,c=function(){for(a=a||r.once,o=i=!0;u.length;l=-1){t=u.shift();while(++l<s.length)!1===s[l].apply(t[0],t[1])&&r.stopOnFalse&&(l=s.length,t=!1)}r.memory||(t=!1),i=!1,a&&(s=t?[]:"")},f={add:function(){return s&&(t&&!i&&(l=s.length-1,u.push(t)),function n(e){S.each(e,function(e,t){m(t)?r.unique&&f.has(t)||s.push(t):t&&t.length&&"string"!==w(t)&&n(t)})}(arguments),t&&!i&&c()),this},remove:function(){return S.each(arguments,function(e,t){var n;while(-1<(n=S.inArray(t,s,n)))s.splice(n,1),n<=l&&l--}),this},has:function(e){return e?-1<S.inArray(e,s):0<s.length},empty:function(){return s&&(s=[]),this},disable:function(){return a=u=[],s=t="",this},disabled:function(){return!s},lock:function(){return a=u=[],t||i||(s=t=""),this},locked:function(){return!!a},fireWith:function(e,t){return a||(t=[e,(t=t||[]).slice?t.slice():t],u.push(t),i||c()),this},fire:function(){return f.fireWith(this,arguments),this},fired:function(){return!!o}};return f},S.extend({Deferred:function(e){var o=[["notify","progress",S.Callbacks("memory"),S.Callbacks("memory"),2],["resolve","done",S.Callbacks("once memory"),S.Callbacks("once memory"),0,"resolved"],["reject","fail",S.Callbacks("once memory"),S.Callbacks("once memory"),1,"rejected"]],i="pending",a={state:function(){return i},always:function(){return s.done(arguments).fail(arguments),this},"catch":function(e){return a.then(null,e)},pipe:function(){var i=arguments;return S.Deferred(function(r){S.each(o,function(e,t){var n=m(i[t[4]])&&i[t[4]];s[t[1]](function(){var e=n&&n.apply(this,arguments);e&&m(e.promise)?e.promise().progress(r.notify).done(r.resolve).fail(r.reject):r[t[0]+"With"](this,n?[e]:arguments)})}),i=null}).promise()},then:function(t,n,r){var u=0;function l(i,o,a,s){return function(){var n=this,r=arguments,e=function(){var e,t;if(!(i<u)){if((e=a.apply(n,r))===o.promise())throw new TypeError("Thenable self-resolution");t=e&&("object"==typeof e||"function"==typeof e)&&e.then,m(t)?s?t.call(e,l(u,o,R,s),l(u,o,M,s)):(u++,t.call(e,l(u,o,R,s),l(u,o,M,s),l(u,o,R,o.notifyWith))):(a!==R&&(n=void 0,r=[e]),(s||o.resolveWith)(n,r))}},t=s?e:function(){try{e()}catch(e){S.Deferred.exceptionHook&&S.Deferred.exceptionHook(e,t.stackTrace),u<=i+1&&(a!==M&&(n=void 0,r=[e]),o.rejectWith(n,r))}};i?t():(S.Deferred.getStackHook&&(t.stackTrace=S.Deferred.getStackHook()),C.setTimeout(t))}}return S.Deferred(function(e){o[0][3].add(l(0,e,m(r)?r:R,e.notifyWith)),o[1][3].add(l(0,e,m(t)?t:R)),o[2][3].add(l(0,e,m(n)?n:M))}).promise()},promise:function(e){return null!=e?S.extend(e,a):a}},s={};return S.each(o,function(e,t){var n=t[2],r=t[5];a[t[1]]=n.add,r&&n.add(function(){i=r},o[3-e][2].disable,o[3-e][3].disable,o[0][2].lock,o[0][3].lock),n.add(t[3].fire),s[t[0]]=function(){return s[t[0]+"With"](this===s?void 0:this,arguments),this},s[t[0]+"With"]=n.fireWith}),a.promise(s),e&&e.call(s,s),s},when:function(e){var n=arguments.length,t=n,r=Array(t),i=s.call(arguments),o=S.Deferred(),a=function(t){return function(e){r[t]=this,i[t]=1<arguments.length?s.call(arguments):e,--n||o.resolveWith(r,i)}};if(n<=1&&(I(e,o.done(a(t)).resolve,o.reject,!n),"pending"===o.state()||m(i[t]&&i[t].then)))return o.then();while(t--)I(i[t],a(t),o.reject);return o.promise()}});var W=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;S.Deferred.exceptionHook=function(e,t){C.console&&C.console.warn&&e&&W.test(e.name)&&C.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},S.readyException=function(e){C.setTimeout(function(){throw e})};var F=S.Deferred();function B(){E.removeEventListener("DOMContentLoaded",B),C.removeEventListener("load",B),S.ready()}S.fn.ready=function(e){return F.then(e)["catch"](function(e){S.readyException(e)}),this},S.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--S.readyWait:S.isReady)||(S.isReady=!0)!==e&&0<--S.readyWait||F.resolveWith(E,[S])}}),S.ready.then=F.then,"complete"===E.readyState||"loading"!==E.readyState&&!E.documentElement.doScroll?C.setTimeout(S.ready):(E.addEventListener("DOMContentLoaded",B),C.addEventListener("load",B));var $=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===w(n))for(s in i=!0,n)$(e,t,s,n[s],!0,o,a);else if(void 0!==r&&(i=!0,m(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(S(e),n)})),t))for(;s<u;s++)t(e[s],n,a?r:r.call(e[s],s,t(e[s],n)));return i?e:l?t.call(e):u?t(e[0],n):o},_=/^-ms-/,z=/-([a-z])/g;function U(e,t){return t.toUpperCase()}function X(e){return e.replace(_,"ms-").replace(z,U)}var V=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function G(){this.expando=S.expando+G.uid++}G.uid=1,G.prototype={cache:function(e){var t=e[this.expando];return t||(t={},V(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[X(t)]=n;else for(r in t)i[X(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][X(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){n=(t=Array.isArray(t)?t.map(X):(t=X(t))in r?[t]:t.match(P)||[]).length;while(n--)delete r[t[n]]}(void 0===t||S.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!S.isEmptyObject(t)}};var Y=new G,Q=new G,J=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,K=/[A-Z]/g;function Z(e,t,n){var r,i;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(K,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n="true"===(i=n)||"false"!==i&&("null"===i?null:i===+i+""?+i:J.test(i)?JSON.parse(i):i)}catch(e){}Q.set(e,t,n)}else n=void 0;return n}S.extend({hasData:function(e){return Q.hasData(e)||Y.hasData(e)},data:function(e,t,n){return Q.access(e,t,n)},removeData:function(e,t){Q.remove(e,t)},_data:function(e,t,n){return Y.access(e,t,n)},_removeData:function(e,t){Y.remove(e,t)}}),S.fn.extend({data:function(n,e){var t,r,i,o=this[0],a=o&&o.attributes;if(void 0===n){if(this.length&&(i=Q.get(o),1===o.nodeType&&!Y.get(o,"hasDataAttrs"))){t=a.length;while(t--)a[t]&&0===(r=a[t].name).indexOf("data-")&&(r=X(r.slice(5)),Z(o,r,i[r]));Y.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof n?this.each(function(){Q.set(this,n)}):$(this,function(e){var t;if(o&&void 0===e)return void 0!==(t=Q.get(o,n))?t:void 0!==(t=Z(o,n))?t:void 0;this.each(function(){Q.set(this,n,e)})},null,e,1<arguments.length,null,!0)},removeData:function(e){return this.each(function(){Q.remove(this,e)})}}),S.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=Y.get(e,t),n&&(!r||Array.isArray(n)?r=Y.access(e,t,S.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=S.queue(e,t),r=n.length,i=n.shift(),o=S._queueHooks(e,t);"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,function(){S.dequeue(e,t)},o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return Y.get(e,n)||Y.access(e,n,{empty:S.Callbacks("once memory").add(function(){Y.remove(e,[t+"queue",n])})})}}),S.fn.extend({queue:function(t,n){var e=2;return"string"!=typeof t&&(n=t,t="fx",e--),arguments.length<e?S.queue(this[0],t):void 0===n?this:this.each(function(){var e=S.queue(this,t,n);S._queueHooks(this,t),"fx"===t&&"inprogress"!==e[0]&&S.dequeue(this,t)})},dequeue:function(e){return this.each(function(){S.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=S.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=void 0),e=e||"fx";while(a--)(n=Y.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var ee=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,te=new RegExp("^(?:([+-])=|)("+ee+")([a-z%]*)$","i"),ne=["Top","Right","Bottom","Left"],re=E.documentElement,ie=function(e){return S.contains(e.ownerDocument,e)},oe={composed:!0};re.getRootNode&&(ie=function(e){return S.contains(e.ownerDocument,e)||e.getRootNode(oe)===e.ownerDocument});var ae=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&ie(e)&&"none"===S.css(e,"display")};function se(e,t,n,r){var i,o,a=20,s=r?function(){return r.cur()}:function(){return S.css(e,t,"")},u=s(),l=n&&n[3]||(S.cssNumber[t]?"":"px"),c=e.nodeType&&(S.cssNumber[t]||"px"!==l&&+u)&&te.exec(S.css(e,t));if(c&&c[3]!==l){u/=2,l=l||c[3],c=+u||1;while(a--)S.style(e,t,c+l),(1-o)*(1-(o=s()/u||.5))<=0&&(a=0),c/=o;c*=2,S.style(e,t,c+l),n=n||[]}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}var ue={};function le(e,t){for(var n,r,i,o,a,s,u,l=[],c=0,f=e.length;c<f;c++)(r=e[c]).style&&(n=r.style.display,t?("none"===n&&(l[c]=Y.get(r,"display")||null,l[c]||(r.style.display="")),""===r.style.display&&ae(r)&&(l[c]=(u=a=o=void 0,a=(i=r).ownerDocument,s=i.nodeName,(u=ue[s])||(o=a.body.appendChild(a.createElement(s)),u=S.css(o,"display"),o.parentNode.removeChild(o),"none"===u&&(u="block"),ue[s]=u)))):"none"!==n&&(l[c]="none",Y.set(r,"display",n)));for(c=0;c<f;c++)null!=l[c]&&(e[c].style.display=l[c]);return e}S.fn.extend({show:function(){return le(this,!0)},hide:function(){return le(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){ae(this)?S(this).show():S(this).hide()})}});var ce,fe,pe=/^(?:checkbox|radio)$/i,de=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="<textarea>x</textarea>",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="<option></option>",y.option=!!ce.lastChild;var ge={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n<r;n++)Y.set(e[n],"globalEval",!t||Y.get(t[n],"globalEval"))}ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td,y.option||(ge.optgroup=ge.option=[1,"<select multiple='multiple'>","</select>"]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d<h;d++)if((o=e[d])||0===o)if("object"===w(o))S.merge(p,o.nodeType?[o]:o);else if(me.test(o)){a=a||f.appendChild(t.createElement("div")),s=(de.exec(o)||["",""])[1].toLowerCase(),u=ge[s]||ge._default,a.innerHTML=u[1]+S.htmlPrefilter(o)+u[2],c=u[0];while(c--)a=a.lastChild;S.merge(p,a.childNodes),(a=f.firstChild).textContent=""}else p.push(t.createTextNode(o));f.textContent="",d=0;while(o=p[d++])if(r&&-1<S.inArray(o,r))i&&i.push(o);else if(l=ie(o),a=ve(f.appendChild(o),"script"),l&&ye(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}var be=/^key/,we=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Te=/^([^.]*)(?:\.(.+)|)/;function Ce(){return!0}function Ee(){return!1}function Se(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function ke(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)ke(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Ee;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return S().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=S.guid++)),e.each(function(){S.event.add(this,t,i,r,n)})}function Ae(e,i,o){o?(Y.set(e,i,!1),S.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Y.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(S.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Y.set(this,i,r),t=o(this,i),this[i](),r!==(n=Y.get(this,i))||t?Y.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else r.length&&(Y.set(this,i,{value:S.event.trigger(S.extend(r[0],S.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Y.get(e,i)&&S.event.add(e,i,Ce)}S.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Y.get(t);if(V(t)){n.handler&&(n=(o=n).handler,i=o.selector),i&&S.find.matchesSelector(re,i),n.guid||(n.guid=S.guid++),(u=v.events)||(u=v.events=Object.create(null)),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof S&&S.event.triggered!==e.type?S.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(P)||[""]).length;while(l--)d=g=(s=Te.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=S.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=S.event.special[d]||{},c=S.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&S.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),S.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Y.hasData(e)&&Y.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(P)||[""]).length;while(l--)if(d=g=(s=Te.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=S.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||S.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)S.event.remove(e,d+t[l],n,r,!0);S.isEmptyObject(u)&&Y.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=new Array(arguments.length),u=S.event.fix(e),l=(Y.get(this,"events")||Object.create(null))[u.type]||[],c=S.event.special[u.type]||{};for(s[0]=u,t=1;t<arguments.length;t++)s[t]=arguments[t];if(u.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,u)){a=S.event.handlers.call(this,u,l),t=0;while((i=a[t++])&&!u.isPropagationStopped()){u.currentTarget=i.elem,n=0;while((o=i.handlers[n++])&&!u.isImmediatePropagationStopped())u.rnamespace&&!1!==o.namespace&&!u.rnamespace.test(o.namespace)||(u.handleObj=o,u.data=o.data,void 0!==(r=((S.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,s))&&!1===(u.result=r)&&(u.preventDefault(),u.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,u),u.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&1<=e.button))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)void 0===a[i=(r=t[n]).selector+" "]&&(a[i]=r.needsContext?-1<S(i,this).index(l):S.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(t,e){Object.defineProperty(S.Event.prototype,t,{enumerable:!0,configurable:!0,get:m(e)?function(){if(this.originalEvent)return e(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[t]},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})},fix:function(e){return e[S.expando]?e:new S.Event(e)},special:{load:{noBubble:!0},click:{setup:function(e){var t=this||e;return pe.test(t.type)&&t.click&&A(t,"input")&&Ae(t,"click",Ce),!1},trigger:function(e){var t=this||e;return pe.test(t.type)&&t.click&&A(t,"input")&&Ae(t,"click"),!0},_default:function(e){var t=e.target;return pe.test(t.type)&&t.click&&A(t,"input")&&Y.get(t,"click")||A(t,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},S.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},S.Event=function(e,t){if(!(this instanceof S.Event))return new S.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?Ce:Ee,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&S.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[S.expando]=!0},S.Event.prototype={constructor:S.Event,isDefaultPrevented:Ee,isPropagationStopped:Ee,isImmediatePropagationStopped:Ee,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=Ce,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=Ce,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=Ce,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},S.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&be.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&we.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},S.event.addProp),S.each({focus:"focusin",blur:"focusout"},function(e,t){S.event.special[e]={setup:function(){return Ae(this,e,Se),!1},trigger:function(){return Ae(this,e),!0},delegateType:t}}),S.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,i){S.event.special[e]={delegateType:i,bindType:i,handle:function(e){var t,n=e.relatedTarget,r=e.handleObj;return n&&(n===this||S.contains(this,n))||(e.type=r.origType,t=r.handler.apply(this,arguments),e.type=i),t}}}),S.fn.extend({on:function(e,t,n,r){return ke(this,e,t,n,r)},one:function(e,t,n,r){return ke(this,e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,S(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=Ee),this.each(function(){S.event.remove(this,e,n,t)})}});var Ne=/<script|<style|<link/i,De=/checked\s*(?:[^=]|=\s*.checked.)/i,je=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function qe(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function Le(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function He(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Oe(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n<r;n++)S.event.add(t,i,s[i][n]);Q.hasData(e)&&(o=Q.access(e),a=S.extend({},o),Q.set(t,a))}}function Pe(n,r,i,o){r=g(r);var e,t,a,s,u,l,c=0,f=n.length,p=f-1,d=r[0],h=m(d);if(h||1<f&&"string"==typeof d&&!y.checkClone&&De.test(d))return n.each(function(e){var t=n.eq(e);h&&(r[0]=d.call(this,e,t.html())),Pe(t,r,i,o)});if(f&&(t=(e=xe(r,n[0].ownerDocument,!1,n,o)).firstChild,1===e.childNodes.length&&(e=t),t||o)){for(s=(a=S.map(ve(e,"script"),Le)).length;c<f;c++)u=e,c!==p&&(u=S.clone(u,!0,!0),s&&S.merge(a,ve(u,"script"))),i.call(n[c],u,c);if(s)for(l=a[a.length-1].ownerDocument,S.map(a,He),c=0;c<s;c++)u=a[c],he.test(u.type||"")&&!Y.access(u,"globalEval")&&S.contains(l,u)&&(u.src&&"module"!==(u.type||"").toLowerCase()?S._evalUrl&&!u.noModule&&S._evalUrl(u.src,{nonce:u.nonce||u.getAttribute("nonce")},l):b(u.textContent.replace(je,""),u,l))}return n}function Re(e,t,n){for(var r,i=t?S.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||S.cleanData(ve(r)),r.parentNode&&(n&&ie(r)&&ye(ve(r,"script")),r.parentNode.removeChild(r));return e}S.extend({htmlPrefilter:function(e){return e},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=ie(e);if(!(y.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||S.isXMLDoc(e)))for(a=ve(c),r=0,i=(o=ve(e)).length;r<i;r++)s=o[r],u=a[r],void 0,"input"===(l=u.nodeName.toLowerCase())&&pe.test(s.type)?u.checked=s.checked:"input"!==l&&"textarea"!==l||(u.defaultValue=s.defaultValue);if(t)if(n)for(o=o||ve(e),a=a||ve(c),r=0,i=o.length;r<i;r++)Oe(o[r],a[r]);else Oe(e,c);return 0<(a=ve(c,"script")).length&&ye(a,!f&&ve(e,"script")),c},cleanData:function(e){for(var t,n,r,i=S.event.special,o=0;void 0!==(n=e[o]);o++)if(V(n)){if(t=n[Y.expando]){if(t.events)for(r in t.events)i[r]?S.event.remove(n,r):S.removeEvent(n,r,t.handle);n[Y.expando]=void 0}n[Q.expando]&&(n[Q.expando]=void 0)}}}),S.fn.extend({detach:function(e){return Re(this,e,!0)},remove:function(e){return Re(this,e)},text:function(e){return $(this,function(e){return void 0===e?S.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Pe(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||qe(this,e).appendChild(e)})},prepend:function(){return Pe(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=qe(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Pe(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Pe(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(S.cleanData(ve(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return S.clone(this,e,t)})},html:function(e){return $(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ne.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=S.htmlPrefilter(e);try{for(;n<r;n++)1===(t=this[n]||{}).nodeType&&(S.cleanData(ve(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var n=[];return Pe(this,arguments,function(e){var t=this.parentNode;S.inArray(this,n)<0&&(S.cleanData(ve(this)),t&&t.replaceChild(e,this))},n)}}),S.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,a){S.fn[e]=function(e){for(var t,n=[],r=S(e),i=r.length-1,o=0;o<=i;o++)t=o===i?this:this.clone(!0),S(r[o])[a](t),u.apply(n,t.get());return this.pushStack(n)}});var Me=new RegExp("^("+ee+")(?!px)[a-z%]+$","i"),Ie=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=C),t.getComputedStyle(e)},We=function(e,t,n){var r,i,o={};for(i in t)o[i]=e.style[i],e.style[i]=t[i];for(i in r=n.call(e),t)e.style[i]=o[i];return r},Fe=new RegExp(ne.join("|"),"i");function Be(e,t,n){var r,i,o,a,s=e.style;return(n=n||Ie(e))&&(""!==(a=n.getPropertyValue(t)||n[t])||ie(e)||(a=S.style(e,t)),!y.pixelBoxStyles()&&Me.test(a)&&Fe.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function $e(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}!function(){function e(){if(l){u.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",l.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",re.appendChild(u).appendChild(l);var e=C.getComputedStyle(l);n="1%"!==e.top,s=12===t(e.marginLeft),l.style.right="60%",o=36===t(e.right),r=36===t(e.width),l.style.position="absolute",i=12===t(l.offsetWidth/3),re.removeChild(u),l=null}}function t(e){return Math.round(parseFloat(e))}var n,r,i,o,a,s,u=E.createElement("div"),l=E.createElement("div");l.style&&(l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",y.clearCloneStyle="content-box"===l.style.backgroundClip,S.extend(y,{boxSizingReliable:function(){return e(),r},pixelBoxStyles:function(){return e(),o},pixelPosition:function(){return e(),n},reliableMarginLeft:function(){return e(),s},scrollboxSize:function(){return e(),i},reliableTrDimensions:function(){var e,t,n,r;return null==a&&(e=E.createElement("table"),t=E.createElement("tr"),n=E.createElement("div"),e.style.cssText="position:absolute;left:-11111px",t.style.height="1px",n.style.height="9px",re.appendChild(e).appendChild(t).appendChild(n),r=C.getComputedStyle(t),a=3<parseInt(r.height),re.removeChild(e)),a}}))}();var _e=["Webkit","Moz","ms"],ze=E.createElement("div").style,Ue={};function Xe(e){var t=S.cssProps[e]||Ue[e];return t||(e in ze?e:Ue[e]=function(e){var t=e[0].toUpperCase()+e.slice(1),n=_e.length;while(n--)if((e=_e[n]+t)in ze)return e}(e)||e)}var Ve=/^(none|table(?!-c[ea]).+)/,Ge=/^--/,Ye={position:"absolute",visibility:"hidden",display:"block"},Qe={letterSpacing:"0",fontWeight:"400"};function Je(e,t,n){var r=te.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function Ke(e,t,n,r,i,o){var a="width"===t?1:0,s=0,u=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(u+=S.css(e,n+ne[a],!0,i)),r?("content"===n&&(u-=S.css(e,"padding"+ne[a],!0,i)),"margin"!==n&&(u-=S.css(e,"border"+ne[a]+"Width",!0,i))):(u+=S.css(e,"padding"+ne[a],!0,i),"padding"!==n?u+=S.css(e,"border"+ne[a]+"Width",!0,i):s+=S.css(e,"border"+ne[a]+"Width",!0,i));return!r&&0<=o&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))||0),u}function Ze(e,t,n){var r=Ie(e),i=(!y.boxSizingReliable()||n)&&"border-box"===S.css(e,"boxSizing",!1,r),o=i,a=Be(e,t,r),s="offset"+t[0].toUpperCase()+t.slice(1);if(Me.test(a)){if(!n)return a;a="auto"}return(!y.boxSizingReliable()&&i||!y.reliableTrDimensions()&&A(e,"tr")||"auto"===a||!parseFloat(a)&&"inline"===S.css(e,"display",!1,r))&&e.getClientRects().length&&(i="border-box"===S.css(e,"boxSizing",!1,r),(o=s in e)&&(a=e[s])),(a=parseFloat(a)||0)+Ke(e,t,n||(i?"border":"content"),o,r,a)+"px"}function et(e,t,n,r,i){return new et.prototype.init(e,t,n,r,i)}S.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Be(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=X(t),u=Ge.test(t),l=e.style;if(u||(t=Xe(s)),a=S.cssHooks[t]||S.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"===(o=typeof n)&&(i=te.exec(n))&&i[1]&&(n=se(e,t,i),o="number"),null!=n&&n==n&&("number"!==o||u||(n+=i&&i[3]||(S.cssNumber[s]?"":"px")),y.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=X(t);return Ge.test(t)||(t=Xe(s)),(a=S.cssHooks[t]||S.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Be(e,t,r)),"normal"===i&&t in Qe&&(i=Qe[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),S.each(["height","width"],function(e,u){S.cssHooks[u]={get:function(e,t,n){if(t)return!Ve.test(S.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?Ze(e,u,n):We(e,Ye,function(){return Ze(e,u,n)})},set:function(e,t,n){var r,i=Ie(e),o=!y.scrollboxSize()&&"absolute"===i.position,a=(o||n)&&"border-box"===S.css(e,"boxSizing",!1,i),s=n?Ke(e,u,n,a,i):0;return a&&o&&(s-=Math.ceil(e["offset"+u[0].toUpperCase()+u.slice(1)]-parseFloat(i[u])-Ke(e,u,"border",!1,i)-.5)),s&&(r=te.exec(t))&&"px"!==(r[3]||"px")&&(e.style[u]=t,t=S.css(e,u)),Je(0,t,s)}}}),S.cssHooks.marginLeft=$e(y.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Be(e,"marginLeft"))||e.getBoundingClientRect().left-We(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),S.each({margin:"",padding:"",border:"Width"},function(i,o){S.cssHooks[i+o]={expand:function(e){for(var t=0,n={},r="string"==typeof e?e.split(" "):[e];t<4;t++)n[i+ne[t]+o]=r[t]||r[t-2]||r[0];return n}},"margin"!==i&&(S.cssHooks[i+o].set=Je)}),S.fn.extend({css:function(e,t){return $(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=Ie(e),i=t.length;a<i;a++)o[t[a]]=S.css(e,t[a],!1,r);return o}return void 0!==n?S.style(e,t,n):S.css(e,t)},e,t,1<arguments.length)}}),((S.Tween=et).prototype={constructor:et,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||S.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(S.cssNumber[n]?"":"px")},cur:function(){var e=et.propHooks[this.prop];return e&&e.get?e.get(this):et.propHooks._default.get(this)},run:function(e){var t,n=et.propHooks[this.prop];return this.options.duration?this.pos=t=S.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):et.propHooks._default.set(this),this}}).init.prototype=et.prototype,(et.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=S.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){S.fx.step[e.prop]?S.fx.step[e.prop](e):1!==e.elem.nodeType||!S.cssHooks[e.prop]&&null==e.elem.style[Xe(e.prop)]?e.elem[e.prop]=e.now:S.style(e.elem,e.prop,e.now+e.unit)}}}).scrollTop=et.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},S.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},S.fx=et.prototype.init,S.fx.step={};var tt,nt,rt,it,ot=/^(?:toggle|show|hide)$/,at=/queueHooks$/;function st(){nt&&(!1===E.hidden&&C.requestAnimationFrame?C.requestAnimationFrame(st):C.setTimeout(st,S.fx.interval),S.fx.tick())}function ut(){return C.setTimeout(function(){tt=void 0}),tt=Date.now()}function lt(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=ne[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function ct(e,t,n){for(var r,i=(ft.tweeners[t]||[]).concat(ft.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function ft(o,e,t){var n,a,r=0,i=ft.prefilters.length,s=S.Deferred().always(function(){delete u.elem}),u=function(){if(a)return!1;for(var e=tt||ut(),t=Math.max(0,l.startTime+l.duration-e),n=1-(t/l.duration||0),r=0,i=l.tweens.length;r<i;r++)l.tweens[r].run(n);return s.notifyWith(o,[l,n,t]),n<1&&i?t:(i||s.notifyWith(o,[l,1,0]),s.resolveWith(o,[l]),!1)},l=s.promise({elem:o,props:S.extend({},e),opts:S.extend(!0,{specialEasing:{},easing:S.easing._default},t),originalProperties:e,originalOptions:t,startTime:tt||ut(),duration:t.duration,tweens:[],createTween:function(e,t){var n=S.Tween(o,l.opts,e,t,l.opts.specialEasing[e]||l.opts.easing);return l.tweens.push(n),n},stop:function(e){var t=0,n=e?l.tweens.length:0;if(a)return this;for(a=!0;t<n;t++)l.tweens[t].run(1);return e?(s.notifyWith(o,[l,1,0]),s.resolveWith(o,[l,e])):s.rejectWith(o,[l,e]),this}}),c=l.props;for(!function(e,t){var n,r,i,o,a;for(n in e)if(i=t[r=X(n)],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=S.cssHooks[r])&&"expand"in a)for(n in o=a.expand(o),delete e[r],o)n in e||(e[n]=o[n],t[n]=i);else t[r]=i}(c,l.opts.specialEasing);r<i;r++)if(n=ft.prefilters[r].call(l,o,c,l.opts))return m(n.stop)&&(S._queueHooks(l.elem,l.opts.queue).stop=n.stop.bind(n)),n;return S.map(c,ct,l),m(l.opts.start)&&l.opts.start.call(o,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),S.fx.timer(S.extend(u,{elem:o,anim:l,queue:l.opts.queue})),l}S.Animation=S.extend(ft,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return se(n.elem,e,te.exec(t),n),n}]},tweener:function(e,t){m(e)?(t=e,e=["*"]):e=e.match(P);for(var n,r=0,i=e.length;r<i;r++)n=e[r],ft.tweeners[n]=ft.tweeners[n]||[],ft.tweeners[n].unshift(t)},prefilters:[function(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,p=this,d={},h=e.style,g=e.nodeType&&ae(e),v=Y.get(e,"fxshow");for(r in n.queue||(null==(a=S._queueHooks(e,"fx")).unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,p.always(function(){p.always(function(){a.unqueued--,S.queue(e,"fx").length||a.empty.fire()})})),t)if(i=t[r],ot.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!v||void 0===v[r])continue;g=!0}d[r]=v&&v[r]||S.style(e,r)}if((u=!S.isEmptyObject(t))||!S.isEmptyObject(d))for(r in f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],null==(l=v&&v.display)&&(l=Y.get(e,"display")),"none"===(c=S.css(e,"display"))&&(l?c=l:(le([e],!0),l=e.style.display||l,c=S.css(e,"display"),le([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===S.css(e,"float")&&(u||(p.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",p.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1,d)u||(v?"hidden"in v&&(g=v.hidden):v=Y.access(e,"fxshow",{display:l}),o&&(v.hidden=!g),g&&le([e],!0),p.done(function(){for(r in g||le([e]),Y.remove(e,"fxshow"),d)S.style(e,r,d[r])})),u=ct(g?v[r]:0,r,p),r in v||(v[r]=u.start,g&&(u.end=u.start,u.start=0))}],prefilter:function(e,t){t?ft.prefilters.unshift(e):ft.prefilters.push(e)}}),S.speed=function(e,t,n){var r=e&&"object"==typeof e?S.extend({},e):{complete:n||!n&&t||m(e)&&e,duration:e,easing:n&&t||t&&!m(t)&&t};return S.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in S.fx.speeds?r.duration=S.fx.speeds[r.duration]:r.duration=S.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){m(r.old)&&r.old.call(this),r.queue&&S.dequeue(this,r.queue)},r},S.fn.extend({fadeTo:function(e,t,n,r){return this.filter(ae).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(t,e,n,r){var i=S.isEmptyObject(t),o=S.speed(e,n,r),a=function(){var e=ft(this,S.extend({},t),o);(i||Y.get(this,"finish"))&&e.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(i,e,o){var a=function(e){var t=e.stop;delete e.stop,t(o)};return"string"!=typeof i&&(o=e,e=i,i=void 0),e&&this.queue(i||"fx",[]),this.each(function(){var e=!0,t=null!=i&&i+"queueHooks",n=S.timers,r=Y.get(this);if(t)r[t]&&r[t].stop&&a(r[t]);else for(t in r)r[t]&&r[t].stop&&at.test(t)&&a(r[t]);for(t=n.length;t--;)n[t].elem!==this||null!=i&&n[t].queue!==i||(n[t].anim.stop(o),e=!1,n.splice(t,1));!e&&o||S.dequeue(this,i)})},finish:function(a){return!1!==a&&(a=a||"fx"),this.each(function(){var e,t=Y.get(this),n=t[a+"queue"],r=t[a+"queueHooks"],i=S.timers,o=n?n.length:0;for(t.finish=!0,S.queue(this,a,[]),r&&r.stop&&r.stop.call(this,!0),e=i.length;e--;)i[e].elem===this&&i[e].queue===a&&(i[e].anim.stop(!0),i.splice(e,1));for(e=0;e<o;e++)n[e]&&n[e].finish&&n[e].finish.call(this);delete t.finish})}}),S.each(["toggle","show","hide"],function(e,r){var i=S.fn[r];S.fn[r]=function(e,t,n){return null==e||"boolean"==typeof e?i.apply(this,arguments):this.animate(lt(r,!0),e,t,n)}}),S.each({slideDown:lt("show"),slideUp:lt("hide"),slideToggle:lt("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,r){S.fn[e]=function(e,t,n){return this.animate(r,e,t,n)}}),S.timers=[],S.fx.tick=function(){var e,t=0,n=S.timers;for(tt=Date.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||S.fx.stop(),tt=void 0},S.fx.timer=function(e){S.timers.push(e),S.fx.start()},S.fx.interval=13,S.fx.start=function(){nt||(nt=!0,st())},S.fx.stop=function(){nt=null},S.fx.speeds={slow:600,fast:200,_default:400},S.fn.delay=function(r,e){return r=S.fx&&S.fx.speeds[r]||r,e=e||"fx",this.queue(e,function(e,t){var n=C.setTimeout(e,r);t.stop=function(){C.clearTimeout(n)}})},rt=E.createElement("input"),it=E.createElement("select").appendChild(E.createElement("option")),rt.type="checkbox",y.checkOn=""!==rt.value,y.optSelected=it.selected,(rt=E.createElement("input")).value="t",rt.type="radio",y.radioValue="t"===rt.value;var pt,dt=S.expr.attrHandle;S.fn.extend({attr:function(e,t){return $(this,S.attr,e,t,1<arguments.length)},removeAttr:function(e){return this.each(function(){S.removeAttr(this,e)})}}),S.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?S.prop(e,t,n):(1===o&&S.isXMLDoc(e)||(i=S.attrHooks[t.toLowerCase()]||(S.expr.match.bool.test(t)?pt:void 0)),void 0!==n?null===n?void S.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=S.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!y.radioValue&&"radio"===t&&A(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(P);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),pt={set:function(e,t,n){return!1===t?S.removeAttr(e,n):e.setAttribute(n,n),n}},S.each(S.expr.match.bool.source.match(/\w+/g),function(e,t){var a=dt[t]||S.find.attr;dt[t]=function(e,t,n){var r,i,o=t.toLowerCase();return n||(i=dt[o],dt[o]=r,r=null!=a(e,t,n)?o:null,dt[o]=i),r}});var ht=/^(?:input|select|textarea|button)$/i,gt=/^(?:a|area)$/i;function vt(e){return(e.match(P)||[]).join(" ")}function yt(e){return e.getAttribute&&e.getAttribute("class")||""}function mt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(P)||[]}S.fn.extend({prop:function(e,t){return $(this,S.prop,e,t,1<arguments.length)},removeProp:function(e){return this.each(function(){delete this[S.propFix[e]||e]})}}),S.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&S.isXMLDoc(e)||(t=S.propFix[t]||t,i=S.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=S.find.attr(e,"tabindex");return t?parseInt(t,10):ht.test(e.nodeName)||gt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),y.optSelected||(S.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),S.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){S.propFix[this.toLowerCase()]=this}),S.fn.extend({addClass:function(t){var e,n,r,i,o,a,s,u=0;if(m(t))return this.each(function(e){S(this).addClass(t.call(this,e,yt(this)))});if((e=mt(t)).length)while(n=this[u++])if(i=yt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=e[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(t){var e,n,r,i,o,a,s,u=0;if(m(t))return this.each(function(e){S(this).removeClass(t.call(this,e,yt(this)))});if(!arguments.length)return this.attr("class","");if((e=mt(t)).length)while(n=this[u++])if(i=yt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=e[a++])while(-1<r.indexOf(" "+o+" "))r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(i,t){var o=typeof i,a="string"===o||Array.isArray(i);return"boolean"==typeof t&&a?t?this.addClass(i):this.removeClass(i):m(i)?this.each(function(e){S(this).toggleClass(i.call(this,e,yt(this),t),t)}):this.each(function(){var e,t,n,r;if(a){t=0,n=S(this),r=mt(i);while(e=r[t++])n.hasClass(e)?n.removeClass(e):n.addClass(e)}else void 0!==i&&"boolean"!==o||((e=yt(this))&&Y.set(this,"__className__",e),this.setAttribute&&this.setAttribute("class",e||!1===i?"":Y.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&-1<(" "+vt(yt(n))+" ").indexOf(t))return!0;return!1}});var xt=/\r/g;S.fn.extend({val:function(n){var r,e,i,t=this[0];return arguments.length?(i=m(n),this.each(function(e){var t;1===this.nodeType&&(null==(t=i?n.call(this,e,S(this).val()):n)?t="":"number"==typeof t?t+="":Array.isArray(t)&&(t=S.map(t,function(e){return null==e?"":e+""})),(r=S.valHooks[this.type]||S.valHooks[this.nodeName.toLowerCase()])&&"set"in r&&void 0!==r.set(this,t,"value")||(this.value=t))})):t?(r=S.valHooks[t.type]||S.valHooks[t.nodeName.toLowerCase()])&&"get"in r&&void 0!==(e=r.get(t,"value"))?e:"string"==typeof(e=t.value)?e.replace(xt,""):null==e?"":e:void 0}}),S.extend({valHooks:{option:{get:function(e){var t=S.find.attr(e,"value");return null!=t?t:vt(S.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(((n=i[r]).selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!A(n.parentNode,"optgroup"))){if(t=S(n).val(),a)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=S.makeArray(t),a=i.length;while(a--)((r=i[a]).selected=-1<S.inArray(S.valHooks.option.get(r),o))&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),S.each(["radio","checkbox"],function(){S.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=-1<S.inArray(S(e).val(),t)}},y.checkOn||(S.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),y.focusin="onfocusin"in C;var bt=/^(?:focusinfocus|focusoutblur)$/,wt=function(e){e.stopPropagation()};S.extend(S.event,{trigger:function(e,t,n,r){var i,o,a,s,u,l,c,f,p=[n||E],d=v.call(e,"type")?e.type:e,h=v.call(e,"namespace")?e.namespace.split("."):[];if(o=f=a=n=n||E,3!==n.nodeType&&8!==n.nodeType&&!bt.test(d+S.event.triggered)&&(-1<d.indexOf(".")&&(d=(h=d.split(".")).shift(),h.sort()),u=d.indexOf(":")<0&&"on"+d,(e=e[S.expando]?e:new S.Event(d,"object"==typeof e&&e)).isTrigger=r?2:3,e.namespace=h.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),t=null==t?[e]:S.makeArray(t,[e]),c=S.event.special[d]||{},r||!c.trigger||!1!==c.trigger.apply(n,t))){if(!r&&!c.noBubble&&!x(n)){for(s=c.delegateType||d,bt.test(s+d)||(o=o.parentNode);o;o=o.parentNode)p.push(o),a=o;a===(n.ownerDocument||E)&&p.push(a.defaultView||a.parentWindow||C)}i=0;while((o=p[i++])&&!e.isPropagationStopped())f=o,e.type=1<i?s:c.bindType||d,(l=(Y.get(o,"events")||Object.create(null))[e.type]&&Y.get(o,"handle"))&&l.apply(o,t),(l=u&&o[u])&&l.apply&&V(o)&&(e.result=l.apply(o,t),!1===e.result&&e.preventDefault());return e.type=d,r||e.isDefaultPrevented()||c._default&&!1!==c._default.apply(p.pop(),t)||!V(n)||u&&m(n[d])&&!x(n)&&((a=n[u])&&(n[u]=null),S.event.triggered=d,e.isPropagationStopped()&&f.addEventListener(d,wt),n[d](),e.isPropagationStopped()&&f.removeEventListener(d,wt),S.event.triggered=void 0,a&&(n[u]=a)),e.result}},simulate:function(e,t,n){var r=S.extend(new S.Event,n,{type:e,isSimulated:!0});S.event.trigger(r,null,t)}}),S.fn.extend({trigger:function(e,t){return this.each(function(){S.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return S.event.trigger(e,t,n,!0)}}),y.focusin||S.each({focus:"focusin",blur:"focusout"},function(n,r){var i=function(e){S.event.simulate(r,e.target,S.event.fix(e))};S.event.special[r]={setup:function(){var e=this.ownerDocument||this.document||this,t=Y.access(e,r);t||e.addEventListener(n,i,!0),Y.access(e,r,(t||0)+1)},teardown:function(){var e=this.ownerDocument||this.document||this,t=Y.access(e,r)-1;t?Y.access(e,r,t):(e.removeEventListener(n,i,!0),Y.remove(e,r))}}});var Tt=C.location,Ct={guid:Date.now()},Et=/\?/;S.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new C.DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||S.error("Invalid XML: "+e),t};var St=/\[\]$/,kt=/\r?\n/g,At=/^(?:submit|button|image|reset|file)$/i,Nt=/^(?:input|select|textarea|keygen)/i;function Dt(n,e,r,i){var t;if(Array.isArray(e))S.each(e,function(e,t){r||St.test(n)?i(n,t):Dt(n+"["+("object"==typeof t&&null!=t?e:"")+"]",t,r,i)});else if(r||"object"!==w(e))i(n,e);else for(t in e)Dt(n+"["+t+"]",e[t],r,i)}S.param=function(e,t){var n,r=[],i=function(e,t){var n=m(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!S.isPlainObject(e))S.each(e,function(){i(this.name,this.value)});else for(n in e)Dt(n,e[n],t,i);return r.join("&")},S.fn.extend({serialize:function(){return S.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=S.prop(this,"elements");return e?S.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!S(this).is(":disabled")&&Nt.test(this.nodeName)&&!At.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=S(this).val();return null==n?null:Array.isArray(n)?S.map(n,function(e){return{name:t.name,value:e.replace(kt,"\r\n")}}):{name:t.name,value:n.replace(kt,"\r\n")}}).get()}});var jt=/%20/g,qt=/#.*$/,Lt=/([?&])_=[^&]*/,Ht=/^(.*?):[ \t]*([^\r\n]*)$/gm,Ot=/^(?:GET|HEAD)$/,Pt=/^\/\//,Rt={},Mt={},It="*/".concat("*"),Wt=E.createElement("a");function Ft(o){return function(e,t){"string"!=typeof e&&(t=e,e="*");var n,r=0,i=e.toLowerCase().match(P)||[];if(m(t))while(n=i[r++])"+"===n[0]?(n=n.slice(1)||"*",(o[n]=o[n]||[]).unshift(t)):(o[n]=o[n]||[]).push(t)}}function Bt(t,i,o,a){var s={},u=t===Mt;function l(e){var r;return s[e]=!0,S.each(t[e]||[],function(e,t){var n=t(i,o,a);return"string"!=typeof n||u||s[n]?u?!(r=n):void 0:(i.dataTypes.unshift(n),l(n),!1)}),r}return l(i.dataTypes[0])||!s["*"]&&l("*")}function $t(e,t){var n,r,i=S.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&S.extend(!0,e,r),e}Wt.href=Tt.href,S.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Tt.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(Tt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":It,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":S.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?$t($t(e,S.ajaxSettings),t):$t(S.ajaxSettings,e)},ajaxPrefilter:Ft(Rt),ajaxTransport:Ft(Mt),ajax:function(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var c,f,p,n,d,r,h,g,i,o,v=S.ajaxSetup({},t),y=v.context||v,m=v.context&&(y.nodeType||y.jquery)?S(y):S.event,x=S.Deferred(),b=S.Callbacks("once memory"),w=v.statusCode||{},a={},s={},u="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(h){if(!n){n={};while(t=Ht.exec(p))n[t[1].toLowerCase()+" "]=(n[t[1].toLowerCase()+" "]||[]).concat(t[2])}t=n[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return h?p:null},setRequestHeader:function(e,t){return null==h&&(e=s[e.toLowerCase()]=s[e.toLowerCase()]||e,a[e]=t),this},overrideMimeType:function(e){return null==h&&(v.mimeType=e),this},statusCode:function(e){var t;if(e)if(h)T.always(e[T.status]);else for(t in e)w[t]=[w[t],e[t]];return this},abort:function(e){var t=e||u;return c&&c.abort(t),l(0,t),this}};if(x.promise(T),v.url=((e||v.url||Tt.href)+"").replace(Pt,Tt.protocol+"//"),v.type=t.method||t.type||v.method||v.type,v.dataTypes=(v.dataType||"*").toLowerCase().match(P)||[""],null==v.crossDomain){r=E.createElement("a");try{r.href=v.url,r.href=r.href,v.crossDomain=Wt.protocol+"//"+Wt.host!=r.protocol+"//"+r.host}catch(e){v.crossDomain=!0}}if(v.data&&v.processData&&"string"!=typeof v.data&&(v.data=S.param(v.data,v.traditional)),Bt(Rt,v,t,T),h)return T;for(i in(g=S.event&&v.global)&&0==S.active++&&S.event.trigger("ajaxStart"),v.type=v.type.toUpperCase(),v.hasContent=!Ot.test(v.type),f=v.url.replace(qt,""),v.hasContent?v.data&&v.processData&&0===(v.contentType||"").indexOf("application/x-www-form-urlencoded")&&(v.data=v.data.replace(jt,"+")):(o=v.url.slice(f.length),v.data&&(v.processData||"string"==typeof v.data)&&(f+=(Et.test(f)?"&":"?")+v.data,delete v.data),!1===v.cache&&(f=f.replace(Lt,"$1"),o=(Et.test(f)?"&":"?")+"_="+Ct.guid+++o),v.url=f+o),v.ifModified&&(S.lastModified[f]&&T.setRequestHeader("If-Modified-Since",S.lastModified[f]),S.etag[f]&&T.setRequestHeader("If-None-Match",S.etag[f])),(v.data&&v.hasContent&&!1!==v.contentType||t.contentType)&&T.setRequestHeader("Content-Type",v.contentType),T.setRequestHeader("Accept",v.dataTypes[0]&&v.accepts[v.dataTypes[0]]?v.accepts[v.dataTypes[0]]+("*"!==v.dataTypes[0]?", "+It+"; q=0.01":""):v.accepts["*"]),v.headers)T.setRequestHeader(i,v.headers[i]);if(v.beforeSend&&(!1===v.beforeSend.call(y,T,v)||h))return T.abort();if(u="abort",b.add(v.complete),T.done(v.success),T.fail(v.error),c=Bt(Mt,v,t,T)){if(T.readyState=1,g&&m.trigger("ajaxSend",[T,v]),h)return T;v.async&&0<v.timeout&&(d=C.setTimeout(function(){T.abort("timeout")},v.timeout));try{h=!1,c.send(a,l)}catch(e){if(h)throw e;l(-1,e)}}else l(-1,"No Transport");function l(e,t,n,r){var i,o,a,s,u,l=t;h||(h=!0,d&&C.clearTimeout(d),c=void 0,p=r||"",T.readyState=0<e?4:0,i=200<=e&&e<300||304===e,n&&(s=function(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}(v,T,n)),!i&&-1<S.inArray("script",v.dataTypes)&&(v.converters["text script"]=function(){}),s=function(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}(v,s,T,i),i?(v.ifModified&&((u=T.getResponseHeader("Last-Modified"))&&(S.lastModified[f]=u),(u=T.getResponseHeader("etag"))&&(S.etag[f]=u)),204===e||"HEAD"===v.type?l="nocontent":304===e?l="notmodified":(l=s.state,o=s.data,i=!(a=s.error))):(a=l,!e&&l||(l="error",e<0&&(e=0))),T.status=e,T.statusText=(t||l)+"",i?x.resolveWith(y,[o,l,T]):x.rejectWith(y,[T,l,a]),T.statusCode(w),w=void 0,g&&m.trigger(i?"ajaxSuccess":"ajaxError",[T,v,i?o:a]),b.fireWith(y,[T,l]),g&&(m.trigger("ajaxComplete",[T,v]),--S.active||S.event.trigger("ajaxStop")))}return T},getJSON:function(e,t,n){return S.get(e,t,n,"json")},getScript:function(e,t){return S.get(e,void 0,t,"script")}}),S.each(["get","post"],function(e,i){S[i]=function(e,t,n,r){return m(t)&&(r=r||n,n=t,t=void 0),S.ajax(S.extend({url:e,type:i,dataType:r,data:t,success:n},S.isPlainObject(e)&&e))}}),S.ajaxPrefilter(function(e){var t;for(t in e.headers)"content-type"===t.toLowerCase()&&(e.contentType=e.headers[t]||"")}),S._evalUrl=function(e,t,n){return S.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){S.globalEval(e,t,n)}})},S.fn.extend({wrapAll:function(e){var t;return this[0]&&(m(e)&&(e=e.call(this[0])),t=S(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(n){return m(n)?this.each(function(e){S(this).wrapInner(n.call(this,e))}):this.each(function(){var e=S(this),t=e.contents();t.length?t.wrapAll(n):e.append(n)})},wrap:function(t){var n=m(t);return this.each(function(e){S(this).wrapAll(n?t.call(this,e):t)})},unwrap:function(e){return this.parent(e).not("body").each(function(){S(this).replaceWith(this.childNodes)}),this}}),S.expr.pseudos.hidden=function(e){return!S.expr.pseudos.visible(e)},S.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},S.ajaxSettings.xhr=function(){try{return new C.XMLHttpRequest}catch(e){}};var _t={0:200,1223:204},zt=S.ajaxSettings.xhr();y.cors=!!zt&&"withCredentials"in zt,y.ajax=zt=!!zt,S.ajaxTransport(function(i){var o,a;if(y.cors||zt&&!i.crossDomain)return{send:function(e,t){var n,r=i.xhr();if(r.open(i.type,i.url,i.async,i.username,i.password),i.xhrFields)for(n in i.xhrFields)r[n]=i.xhrFields[n];for(n in i.mimeType&&r.overrideMimeType&&r.overrideMimeType(i.mimeType),i.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest"),e)r.setRequestHeader(n,e[n]);o=function(e){return function(){o&&(o=a=r.onload=r.onerror=r.onabort=r.ontimeout=r.onreadystatechange=null,"abort"===e?r.abort():"error"===e?"number"!=typeof r.status?t(0,"error"):t(r.status,r.statusText):t(_t[r.status]||r.status,r.statusText,"text"!==(r.responseType||"text")||"string"!=typeof r.responseText?{binary:r.response}:{text:r.responseText},r.getAllResponseHeaders()))}},r.onload=o(),a=r.onerror=r.ontimeout=o("error"),void 0!==r.onabort?r.onabort=a:r.onreadystatechange=function(){4===r.readyState&&C.setTimeout(function(){o&&a()})},o=o("abort");try{r.send(i.hasContent&&i.data||null)}catch(e){if(o)throw e}},abort:function(){o&&o()}}}),S.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),S.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return S.globalEval(e),e}}}),S.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),S.ajaxTransport("script",function(n){var r,i;if(n.crossDomain||n.scriptAttrs)return{send:function(e,t){r=S("<script>").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Ut,Xt=[],Vt=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Xt.pop()||S.expando+"_"+Ct.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Vt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Vt,"$1"+r):!1!==e.jsonp&&(e.url+=(Et.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Xt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((Ut=E.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===Ut.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1<s&&(r=vt(e.slice(s)),e=e.slice(0,s)),m(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),0<a.length&&S.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?S("<div>").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):("number"==typeof f.top&&(f.top+="px"),"number"==typeof f.left&&(f.left+="px"),c.css(f))}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=$e(y.pixelPosition,function(e,t){if(t)return t=Be(e,n),Me.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0<arguments.length?this.on(n,null,e,t):this.trigger(n)}});var Gt=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;S.proxy=function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),m(e))return r=s.call(arguments,2),(i=function(){return e.apply(t||this,r.concat(s.call(arguments)))}).guid=e.guid=e.guid||S.guid++,i},S.holdReady=function(e){e?S.readyWait++:S.ready(!0)},S.isArray=Array.isArray,S.parseJSON=JSON.parse,S.nodeName=A,S.isFunction=m,S.isWindow=x,S.camelCase=X,S.type=w,S.now=Date.now,S.isNumeric=function(e){var t=S.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},S.trim=function(e){return null==e?"":(e+"").replace(Gt,"")},"function"==typeof define&&define.amd&&define("jquery",[],function(){return S});var Yt=C.jQuery,Qt=C.$;return S.noConflict=function(e){return C.$===S&&(C.$=Qt),e&&C.jQuery===S&&(C.jQuery=Yt),S},"undefined"==typeof e&&(C.jQuery=C.$=S),S}); +/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=S.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return S.each(this,e)},map:function(n){return this.pushStack(S.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(S.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(S.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:u,sort:t.sort,splice:t.splice},S.extend=S.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||m(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(S.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||S.isPlainObject(n)?n:{},i=!1,a[t]=S.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},S.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=v.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){b(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(p(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},makeArray:function(e,t){var n=t||[];return null!=e&&(p(Object(e))?S.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(p(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:y}),"function"==typeof Symbol&&(S.fn[Symbol.iterator]=t[Symbol.iterator]),S.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var d=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,v,s,c,y,S="sizzle"+1*new Date,p=n.document,k=0,r=0,m=ue(),x=ue(),A=ue(),N=ue(),j=function(e,t){return e===t&&(l=!0),0},D={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",F=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",B=new RegExp(M+"+","g"),$=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="<a id='"+S+"'></a><select id='"+S+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0<se(t,C,null,[e]).length},se.contains=function(e,t){return(e.ownerDocument||e)!=C&&T(e),y(e,t)},se.attr=function(e,t){(e.ownerDocument||e)!=C&&T(e);var n=b.attrHandle[t.toLowerCase()],r=n&&D.call(b.attrHandle,t.toLowerCase())?n(e,t,!E):void 0;return void 0!==r?r:d.attributes||!E?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},se.escape=function(e){return(e+"").replace(re,ie)},se.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},se.uniqueSort=function(e){var t,n=[],r=0,i=0;if(l=!d.detectDuplicates,u=!d.sortStable&&e.slice(0),e.sort(j),l){while(t=e[i++])t===e[i]&&(r=n.push(i));while(r--)e.splice(n[r],1)}return u=null,e},o=se.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else while(t=e[r++])n+=o(t);return n},(b=se.selectors={cacheLength:50,createPseudo:le,match:G,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1<t.indexOf(i):"$="===r?i&&t.slice(-i.length)===i:"~="===r?-1<(" "+t.replace(B," ")+" ").indexOf(i):"|="===r&&(t===i||t.slice(0,i.length+1)===i+"-"))}},CHILD:function(h,e,t,g,v){var y="nth"!==h.slice(0,3),m="last"!==h.slice(-4),x="of-type"===e;return 1===g&&0===v?function(e){return!!e.parentNode}:function(e,t,n){var r,i,o,a,s,u,l=y!==m?"nextSibling":"previousSibling",c=e.parentNode,f=x&&e.nodeName.toLowerCase(),p=!n&&!x,d=!1;if(c){if(y){while(l){a=e;while(a=a[l])if(x?a.nodeName.toLowerCase()===f:1===a.nodeType)return!1;u=l="only"===h&&!u&&"nextSibling"}return!0}if(u=[m?c.firstChild:c.lastChild],m&&p){d=(s=(r=(i=(o=(a=c)[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]||[])[0]===k&&r[1])&&r[2],a=s&&c.childNodes[s];while(a=++s&&a&&a[l]||(d=s=0)||u.pop())if(1===a.nodeType&&++d&&a===e){i[h]=[k,s,d];break}}else if(p&&(d=s=(r=(i=(o=(a=e)[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]||[])[0]===k&&r[1]),!1===d)while(a=++s&&a&&a[l]||(d=s=0)||u.pop())if((x?a.nodeName.toLowerCase()===f:1===a.nodeType)&&++d&&(p&&((i=(o=a[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]=[k,d]),a===e))break;return(d-=v)===g||d%g==0&&0<=d/g}}},PSEUDO:function(e,o){var t,a=b.pseudos[e]||b.setFilters[e.toLowerCase()]||se.error("unsupported pseudo: "+e);return a[S]?a(o):1<a.length?(t=[e,e,"",o],b.setFilters.hasOwnProperty(e.toLowerCase())?le(function(e,t){var n,r=a(e,o),i=r.length;while(i--)e[n=P(e,r[i])]=!(t[n]=r[i])}):function(e){return a(e,0,t)}):a}},pseudos:{not:le(function(e){var r=[],i=[],s=f(e.replace($,"$1"));return s[S]?le(function(e,t,n,r){var i,o=s(e,null,r,[]),a=e.length;while(a--)(i=o[a])&&(e[a]=!(t[a]=i))}):function(e,t,n){return r[0]=e,s(r,null,n,i),r[0]=null,!i.pop()}}),has:le(function(t){return function(e){return 0<se(t,e).length}}),contains:le(function(t){return t=t.replace(te,ne),function(e){return-1<(e.textContent||o(e)).indexOf(t)}}),lang:le(function(n){return V.test(n||"")||se.error("unsupported lang: "+n),n=n.replace(te,ne).toLowerCase(),function(e){var t;do{if(t=E?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(t=t.toLowerCase())===n||0===t.indexOf(n+"-")}while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var t=n.location&&n.location.hash;return t&&t.slice(1)===e.id},root:function(e){return e===a},focus:function(e){return e===C.activeElement&&(!C.hasFocus||C.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ge(!1),disabled:ge(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!b.pseudos.empty(e)},header:function(e){return J.test(e.nodeName)},input:function(e){return Q.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:ve(function(){return[0]}),last:ve(function(e,t){return[t-1]}),eq:ve(function(e,t,n){return[n<0?n+t:n]}),even:ve(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:ve(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:ve(function(e,t,n){for(var r=n<0?n+t:t<n?t:n;0<=--r;)e.push(r);return e}),gt:ve(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}}).pseudos.nth=b.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})b.pseudos[e]=de(e);for(e in{submit:!0,reset:!0})b.pseudos[e]=he(e);function me(){}function xe(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function be(s,e,t){var u=e.dir,l=e.next,c=l||u,f=t&&"parentNode"===c,p=r++;return e.first?function(e,t,n){while(e=e[u])if(1===e.nodeType||f)return s(e,t,n);return!1}:function(e,t,n){var r,i,o,a=[k,p];if(n){while(e=e[u])if((1===e.nodeType||f)&&s(e,t,n))return!0}else while(e=e[u])if(1===e.nodeType||f)if(i=(o=e[S]||(e[S]={}))[e.uniqueID]||(o[e.uniqueID]={}),l&&l===e.nodeName.toLowerCase())e=e[u]||e;else{if((r=i[c])&&r[0]===k&&r[1]===p)return a[2]=r[2];if((i[c]=a)[2]=s(e,t,n))return!0}return!1}}function we(i){return 1<i.length?function(e,t,n){var r=i.length;while(r--)if(!i[r](e,t,n))return!1;return!0}:i[0]}function Te(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function Ce(d,h,g,v,y,e){return v&&!v[S]&&(v=Ce(v)),y&&!y[S]&&(y=Ce(y,e)),le(function(e,t,n,r){var i,o,a,s=[],u=[],l=t.length,c=e||function(e,t,n){for(var r=0,i=t.length;r<i;r++)se(e,t[r],n);return n}(h||"*",n.nodeType?[n]:n,[]),f=!d||!e&&h?c:Te(c,s,d,n,r),p=g?y||(e?d:l||v)?[]:t:f;if(g&&g(f,p,n,r),v){i=Te(p,u),v(i,[],n,r),o=i.length;while(o--)(a=i[o])&&(p[u[o]]=!(f[u[o]]=a))}if(e){if(y||d){if(y){i=[],o=p.length;while(o--)(a=p[o])&&i.push(f[o]=a);y(null,p=[],i,r)}o=p.length;while(o--)(a=p[o])&&-1<(i=y?P(e,a):s[o])&&(e[i]=!(t[i]=a))}}else p=Te(p===t?p.splice(l,p.length):p),y?y(null,t,p,r):H.apply(t,p)})}function Ee(e){for(var i,t,n,r=e.length,o=b.relative[e[0].type],a=o||b.relative[" "],s=o?1:0,u=be(function(e){return e===i},a,!0),l=be(function(e){return-1<P(i,e)},a,!0),c=[function(e,t,n){var r=!o&&(n||t!==w)||((i=t).nodeType?u(e,t,n):l(e,t,n));return i=null,r}];s<r;s++)if(t=b.relative[e[s].type])c=[be(we(c),t)];else{if((t=b.filter[e[s].type].apply(null,e[s].matches))[S]){for(n=++s;n<r;n++)if(b.relative[e[n].type])break;return Ce(1<s&&we(c),1<s&&xe(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace($,"$1"),t,s<n&&Ee(e.slice(s,n)),n<r&&Ee(e=e.slice(n)),n<r&&xe(e))}c.push(t)}return we(c)}return me.prototype=b.filters=b.pseudos,b.setFilters=new me,h=se.tokenize=function(e,t){var n,r,i,o,a,s,u,l=x[e+" "];if(l)return t?0:l.slice(0);a=e,s=[],u=b.preFilter;while(a){for(o in n&&!(r=_.exec(a))||(r&&(a=a.slice(r[0].length)||a),s.push(i=[])),n=!1,(r=z.exec(a))&&(n=r.shift(),i.push({value:n,type:r[0].replace($," ")}),a=a.slice(n.length)),b.filter)!(r=G[o].exec(a))||u[o]&&!(r=u[o](r))||(n=r.shift(),i.push({value:n,type:o,matches:r}),a=a.slice(n.length));if(!n)break}return t?a.length:a?se.error(e):x(e,s).slice(0)},f=se.compile=function(e,t){var n,v,y,m,x,r,i=[],o=[],a=A[e+" "];if(!a){t||(t=h(e)),n=t.length;while(n--)(a=Ee(t[n]))[S]?i.push(a):o.push(a);(a=A(e,(v=o,m=0<(y=i).length,x=0<v.length,r=function(e,t,n,r,i){var o,a,s,u=0,l="0",c=e&&[],f=[],p=w,d=e||x&&b.find.TAG("*",i),h=k+=null==p?1:Math.random()||.1,g=d.length;for(i&&(w=t==C||t||i);l!==g&&null!=(o=d[l]);l++){if(x&&o){a=0,t||o.ownerDocument==C||(T(o),n=!E);while(s=v[a++])if(s(o,t||C,n)){r.push(o);break}i&&(k=h)}m&&((o=!s&&o)&&u--,e&&c.push(o))}if(u+=l,m&&l!==u){a=0;while(s=y[a++])s(c,f,t,n);if(e){if(0<u)while(l--)c[l]||f[l]||(f[l]=q.call(r));f=Te(f)}H.apply(r,f),i&&!e&&0<f.length&&1<u+y.length&&se.uniqueSort(r)}return i&&(k=h,w=p),c},m?le(r):r))).selector=e}return a},g=se.select=function(e,t,n,r){var i,o,a,s,u,l="function"==typeof e&&e,c=!r&&h(e=l.selector||e);if(n=n||[],1===c.length){if(2<(o=c[0]=c[0].slice(0)).length&&"ID"===(a=o[0]).type&&9===t.nodeType&&E&&b.relative[o[1].type]){if(!(t=(b.find.ID(a.matches[0].replace(te,ne),t)||[])[0]))return n;l&&(t=t.parentNode),e=e.slice(o.shift().value.length)}i=G.needsContext.test(e)?0:o.length;while(i--){if(a=o[i],b.relative[s=a.type])break;if((u=b.find[s])&&(r=u(a.matches[0].replace(te,ne),ee.test(o[0].type)&&ye(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&xe(o)))return H.apply(n,r),n;break}}}return(l||f(e,c))(r,t,!E,n,!t||ee.test(e)&&ye(t.parentNode)||t),n},d.sortStable=S.split("").sort(j).join("")===S,d.detectDuplicates=!!l,T(),d.sortDetached=ce(function(e){return 1&e.compareDocumentPosition(C.createElement("fieldset"))}),ce(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||fe("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),d.attributes&&ce(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||fe("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ce(function(e){return null==e.getAttribute("disabled")})||fe(R,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),se}(C);S.find=d,S.expr=d.selectors,S.expr[":"]=S.expr.pseudos,S.uniqueSort=S.unique=d.uniqueSort,S.text=d.getText,S.isXMLDoc=d.isXML,S.contains=d.contains,S.escapeSelector=d.escape;var h=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&S(e).is(n))break;r.push(e)}return r},T=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},k=S.expr.match.needsContext;function A(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var N=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1<i.call(n,e)!==r}):S.filter(n,e,r)}S.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?S.find.matchesSelector(r,e)?[r]:[]:S.find.matches(e,S.grep(t,function(e){return 1===e.nodeType}))},S.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(S(e).filter(function(){for(t=0;t<r;t++)if(S.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)S.find(e,i[t],n);return 1<r?S.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&k.test(e)?S(e):e||[],!1).length}});var D,q=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(S.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&S(e);if(!k.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?-1<a.index(n):1===n.nodeType&&S.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(1<o.length?S.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?i.call(S(e),this[0]):i.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(S.uniqueSort(S.merge(this.get(),S(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),S.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return h(e,"parentNode")},parentsUntil:function(e,t,n){return h(e,"parentNode",n)},next:function(e){return O(e,"nextSibling")},prev:function(e){return O(e,"previousSibling")},nextAll:function(e){return h(e,"nextSibling")},prevAll:function(e){return h(e,"previousSibling")},nextUntil:function(e,t,n){return h(e,"nextSibling",n)},prevUntil:function(e,t,n){return h(e,"previousSibling",n)},siblings:function(e){return T((e.parentNode||{}).firstChild,e)},children:function(e){return T(e.firstChild)},contents:function(e){return null!=e.contentDocument&&r(e.contentDocument)?e.contentDocument:(A(e,"template")&&(e=e.content||e),S.merge([],e.childNodes))}},function(r,i){S.fn[r]=function(e,t){var n=S.map(this,i,e);return"Until"!==r.slice(-5)&&(t=e),t&&"string"==typeof t&&(n=S.filter(t,n)),1<this.length&&(H[r]||S.uniqueSort(n),L.test(r)&&n.reverse()),this.pushStack(n)}});var P=/[^\x20\t\r\n\f]+/g;function R(e){return e}function M(e){throw e}function I(e,t,n,r){var i;try{e&&m(i=e.promise)?i.call(e).done(t).fail(n):e&&m(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}S.Callbacks=function(r){var e,n;r="string"==typeof r?(e=r,n={},S.each(e.match(P)||[],function(e,t){n[t]=!0}),n):S.extend({},r);var i,t,o,a,s=[],u=[],l=-1,c=function(){for(a=a||r.once,o=i=!0;u.length;l=-1){t=u.shift();while(++l<s.length)!1===s[l].apply(t[0],t[1])&&r.stopOnFalse&&(l=s.length,t=!1)}r.memory||(t=!1),i=!1,a&&(s=t?[]:"")},f={add:function(){return s&&(t&&!i&&(l=s.length-1,u.push(t)),function n(e){S.each(e,function(e,t){m(t)?r.unique&&f.has(t)||s.push(t):t&&t.length&&"string"!==w(t)&&n(t)})}(arguments),t&&!i&&c()),this},remove:function(){return S.each(arguments,function(e,t){var n;while(-1<(n=S.inArray(t,s,n)))s.splice(n,1),n<=l&&l--}),this},has:function(e){return e?-1<S.inArray(e,s):0<s.length},empty:function(){return s&&(s=[]),this},disable:function(){return a=u=[],s=t="",this},disabled:function(){return!s},lock:function(){return a=u=[],t||i||(s=t=""),this},locked:function(){return!!a},fireWith:function(e,t){return a||(t=[e,(t=t||[]).slice?t.slice():t],u.push(t),i||c()),this},fire:function(){return f.fireWith(this,arguments),this},fired:function(){return!!o}};return f},S.extend({Deferred:function(e){var o=[["notify","progress",S.Callbacks("memory"),S.Callbacks("memory"),2],["resolve","done",S.Callbacks("once memory"),S.Callbacks("once memory"),0,"resolved"],["reject","fail",S.Callbacks("once memory"),S.Callbacks("once memory"),1,"rejected"]],i="pending",a={state:function(){return i},always:function(){return s.done(arguments).fail(arguments),this},"catch":function(e){return a.then(null,e)},pipe:function(){var i=arguments;return S.Deferred(function(r){S.each(o,function(e,t){var n=m(i[t[4]])&&i[t[4]];s[t[1]](function(){var e=n&&n.apply(this,arguments);e&&m(e.promise)?e.promise().progress(r.notify).done(r.resolve).fail(r.reject):r[t[0]+"With"](this,n?[e]:arguments)})}),i=null}).promise()},then:function(t,n,r){var u=0;function l(i,o,a,s){return function(){var n=this,r=arguments,e=function(){var e,t;if(!(i<u)){if((e=a.apply(n,r))===o.promise())throw new TypeError("Thenable self-resolution");t=e&&("object"==typeof e||"function"==typeof e)&&e.then,m(t)?s?t.call(e,l(u,o,R,s),l(u,o,M,s)):(u++,t.call(e,l(u,o,R,s),l(u,o,M,s),l(u,o,R,o.notifyWith))):(a!==R&&(n=void 0,r=[e]),(s||o.resolveWith)(n,r))}},t=s?e:function(){try{e()}catch(e){S.Deferred.exceptionHook&&S.Deferred.exceptionHook(e,t.stackTrace),u<=i+1&&(a!==M&&(n=void 0,r=[e]),o.rejectWith(n,r))}};i?t():(S.Deferred.getStackHook&&(t.stackTrace=S.Deferred.getStackHook()),C.setTimeout(t))}}return S.Deferred(function(e){o[0][3].add(l(0,e,m(r)?r:R,e.notifyWith)),o[1][3].add(l(0,e,m(t)?t:R)),o[2][3].add(l(0,e,m(n)?n:M))}).promise()},promise:function(e){return null!=e?S.extend(e,a):a}},s={};return S.each(o,function(e,t){var n=t[2],r=t[5];a[t[1]]=n.add,r&&n.add(function(){i=r},o[3-e][2].disable,o[3-e][3].disable,o[0][2].lock,o[0][3].lock),n.add(t[3].fire),s[t[0]]=function(){return s[t[0]+"With"](this===s?void 0:this,arguments),this},s[t[0]+"With"]=n.fireWith}),a.promise(s),e&&e.call(s,s),s},when:function(e){var n=arguments.length,t=n,r=Array(t),i=s.call(arguments),o=S.Deferred(),a=function(t){return function(e){r[t]=this,i[t]=1<arguments.length?s.call(arguments):e,--n||o.resolveWith(r,i)}};if(n<=1&&(I(e,o.done(a(t)).resolve,o.reject,!n),"pending"===o.state()||m(i[t]&&i[t].then)))return o.then();while(t--)I(i[t],a(t),o.reject);return o.promise()}});var W=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;S.Deferred.exceptionHook=function(e,t){C.console&&C.console.warn&&e&&W.test(e.name)&&C.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},S.readyException=function(e){C.setTimeout(function(){throw e})};var F=S.Deferred();function B(){E.removeEventListener("DOMContentLoaded",B),C.removeEventListener("load",B),S.ready()}S.fn.ready=function(e){return F.then(e)["catch"](function(e){S.readyException(e)}),this},S.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--S.readyWait:S.isReady)||(S.isReady=!0)!==e&&0<--S.readyWait||F.resolveWith(E,[S])}}),S.ready.then=F.then,"complete"===E.readyState||"loading"!==E.readyState&&!E.documentElement.doScroll?C.setTimeout(S.ready):(E.addEventListener("DOMContentLoaded",B),C.addEventListener("load",B));var $=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===w(n))for(s in i=!0,n)$(e,t,s,n[s],!0,o,a);else if(void 0!==r&&(i=!0,m(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(S(e),n)})),t))for(;s<u;s++)t(e[s],n,a?r:r.call(e[s],s,t(e[s],n)));return i?e:l?t.call(e):u?t(e[0],n):o},_=/^-ms-/,z=/-([a-z])/g;function U(e,t){return t.toUpperCase()}function X(e){return e.replace(_,"ms-").replace(z,U)}var V=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function G(){this.expando=S.expando+G.uid++}G.uid=1,G.prototype={cache:function(e){var t=e[this.expando];return t||(t={},V(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[X(t)]=n;else for(r in t)i[X(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][X(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){n=(t=Array.isArray(t)?t.map(X):(t=X(t))in r?[t]:t.match(P)||[]).length;while(n--)delete r[t[n]]}(void 0===t||S.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!S.isEmptyObject(t)}};var Y=new G,Q=new G,J=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,K=/[A-Z]/g;function Z(e,t,n){var r,i;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(K,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n="true"===(i=n)||"false"!==i&&("null"===i?null:i===+i+""?+i:J.test(i)?JSON.parse(i):i)}catch(e){}Q.set(e,t,n)}else n=void 0;return n}S.extend({hasData:function(e){return Q.hasData(e)||Y.hasData(e)},data:function(e,t,n){return Q.access(e,t,n)},removeData:function(e,t){Q.remove(e,t)},_data:function(e,t,n){return Y.access(e,t,n)},_removeData:function(e,t){Y.remove(e,t)}}),S.fn.extend({data:function(n,e){var t,r,i,o=this[0],a=o&&o.attributes;if(void 0===n){if(this.length&&(i=Q.get(o),1===o.nodeType&&!Y.get(o,"hasDataAttrs"))){t=a.length;while(t--)a[t]&&0===(r=a[t].name).indexOf("data-")&&(r=X(r.slice(5)),Z(o,r,i[r]));Y.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof n?this.each(function(){Q.set(this,n)}):$(this,function(e){var t;if(o&&void 0===e)return void 0!==(t=Q.get(o,n))?t:void 0!==(t=Z(o,n))?t:void 0;this.each(function(){Q.set(this,n,e)})},null,e,1<arguments.length,null,!0)},removeData:function(e){return this.each(function(){Q.remove(this,e)})}}),S.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=Y.get(e,t),n&&(!r||Array.isArray(n)?r=Y.access(e,t,S.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=S.queue(e,t),r=n.length,i=n.shift(),o=S._queueHooks(e,t);"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,function(){S.dequeue(e,t)},o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return Y.get(e,n)||Y.access(e,n,{empty:S.Callbacks("once memory").add(function(){Y.remove(e,[t+"queue",n])})})}}),S.fn.extend({queue:function(t,n){var e=2;return"string"!=typeof t&&(n=t,t="fx",e--),arguments.length<e?S.queue(this[0],t):void 0===n?this:this.each(function(){var e=S.queue(this,t,n);S._queueHooks(this,t),"fx"===t&&"inprogress"!==e[0]&&S.dequeue(this,t)})},dequeue:function(e){return this.each(function(){S.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=S.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=void 0),e=e||"fx";while(a--)(n=Y.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var ee=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,te=new RegExp("^(?:([+-])=|)("+ee+")([a-z%]*)$","i"),ne=["Top","Right","Bottom","Left"],re=E.documentElement,ie=function(e){return S.contains(e.ownerDocument,e)},oe={composed:!0};re.getRootNode&&(ie=function(e){return S.contains(e.ownerDocument,e)||e.getRootNode(oe)===e.ownerDocument});var ae=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&ie(e)&&"none"===S.css(e,"display")};function se(e,t,n,r){var i,o,a=20,s=r?function(){return r.cur()}:function(){return S.css(e,t,"")},u=s(),l=n&&n[3]||(S.cssNumber[t]?"":"px"),c=e.nodeType&&(S.cssNumber[t]||"px"!==l&&+u)&&te.exec(S.css(e,t));if(c&&c[3]!==l){u/=2,l=l||c[3],c=+u||1;while(a--)S.style(e,t,c+l),(1-o)*(1-(o=s()/u||.5))<=0&&(a=0),c/=o;c*=2,S.style(e,t,c+l),n=n||[]}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}var ue={};function le(e,t){for(var n,r,i,o,a,s,u,l=[],c=0,f=e.length;c<f;c++)(r=e[c]).style&&(n=r.style.display,t?("none"===n&&(l[c]=Y.get(r,"display")||null,l[c]||(r.style.display="")),""===r.style.display&&ae(r)&&(l[c]=(u=a=o=void 0,a=(i=r).ownerDocument,s=i.nodeName,(u=ue[s])||(o=a.body.appendChild(a.createElement(s)),u=S.css(o,"display"),o.parentNode.removeChild(o),"none"===u&&(u="block"),ue[s]=u)))):"none"!==n&&(l[c]="none",Y.set(r,"display",n)));for(c=0;c<f;c++)null!=l[c]&&(e[c].style.display=l[c]);return e}S.fn.extend({show:function(){return le(this,!0)},hide:function(){return le(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){ae(this)?S(this).show():S(this).hide()})}});var ce,fe,pe=/^(?:checkbox|radio)$/i,de=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="<textarea>x</textarea>",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="<option></option>",y.option=!!ce.lastChild;var ge={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n<r;n++)Y.set(e[n],"globalEval",!t||Y.get(t[n],"globalEval"))}ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td,y.option||(ge.optgroup=ge.option=[1,"<select multiple='multiple'>","</select>"]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d<h;d++)if((o=e[d])||0===o)if("object"===w(o))S.merge(p,o.nodeType?[o]:o);else if(me.test(o)){a=a||f.appendChild(t.createElement("div")),s=(de.exec(o)||["",""])[1].toLowerCase(),u=ge[s]||ge._default,a.innerHTML=u[1]+S.htmlPrefilter(o)+u[2],c=u[0];while(c--)a=a.lastChild;S.merge(p,a.childNodes),(a=f.firstChild).textContent=""}else p.push(t.createTextNode(o));f.textContent="",d=0;while(o=p[d++])if(r&&-1<S.inArray(o,r))i&&i.push(o);else if(l=ie(o),a=ve(f.appendChild(o),"script"),l&&ye(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}var be=/^([^.]*)(?:\.(.+)|)/;function we(){return!0}function Te(){return!1}function Ce(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ee(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Ee(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Te;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return S().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=S.guid++)),e.each(function(){S.event.add(this,t,i,r,n)})}function Se(e,i,o){o?(Y.set(e,i,!1),S.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Y.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(S.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Y.set(this,i,r),t=o(this,i),this[i](),r!==(n=Y.get(this,i))||t?Y.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n&&n.value}else r.length&&(Y.set(this,i,{value:S.event.trigger(S.extend(r[0],S.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Y.get(e,i)&&S.event.add(e,i,we)}S.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Y.get(t);if(V(t)){n.handler&&(n=(o=n).handler,i=o.selector),i&&S.find.matchesSelector(re,i),n.guid||(n.guid=S.guid++),(u=v.events)||(u=v.events=Object.create(null)),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof S&&S.event.triggered!==e.type?S.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(P)||[""]).length;while(l--)d=g=(s=be.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=S.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=S.event.special[d]||{},c=S.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&S.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),S.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Y.hasData(e)&&Y.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(P)||[""]).length;while(l--)if(d=g=(s=be.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=S.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||S.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)S.event.remove(e,d+t[l],n,r,!0);S.isEmptyObject(u)&&Y.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=new Array(arguments.length),u=S.event.fix(e),l=(Y.get(this,"events")||Object.create(null))[u.type]||[],c=S.event.special[u.type]||{};for(s[0]=u,t=1;t<arguments.length;t++)s[t]=arguments[t];if(u.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,u)){a=S.event.handlers.call(this,u,l),t=0;while((i=a[t++])&&!u.isPropagationStopped()){u.currentTarget=i.elem,n=0;while((o=i.handlers[n++])&&!u.isImmediatePropagationStopped())u.rnamespace&&!1!==o.namespace&&!u.rnamespace.test(o.namespace)||(u.handleObj=o,u.data=o.data,void 0!==(r=((S.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,s))&&!1===(u.result=r)&&(u.preventDefault(),u.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,u),u.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&1<=e.button))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)void 0===a[i=(r=t[n]).selector+" "]&&(a[i]=r.needsContext?-1<S(i,this).index(l):S.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(t,e){Object.defineProperty(S.Event.prototype,t,{enumerable:!0,configurable:!0,get:m(e)?function(){if(this.originalEvent)return e(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[t]},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})},fix:function(e){return e[S.expando]?e:new S.Event(e)},special:{load:{noBubble:!0},click:{setup:function(e){var t=this||e;return pe.test(t.type)&&t.click&&A(t,"input")&&Se(t,"click",we),!1},trigger:function(e){var t=this||e;return pe.test(t.type)&&t.click&&A(t,"input")&&Se(t,"click"),!0},_default:function(e){var t=e.target;return pe.test(t.type)&&t.click&&A(t,"input")&&Y.get(t,"click")||A(t,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},S.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},S.Event=function(e,t){if(!(this instanceof S.Event))return new S.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?we:Te,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&S.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[S.expando]=!0},S.Event.prototype={constructor:S.Event,isDefaultPrevented:Te,isPropagationStopped:Te,isImmediatePropagationStopped:Te,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=we,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=we,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=we,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},S.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},S.event.addProp),S.each({focus:"focusin",blur:"focusout"},function(e,t){S.event.special[e]={setup:function(){return Se(this,e,Ce),!1},trigger:function(){return Se(this,e),!0},_default:function(){return!0},delegateType:t}}),S.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,i){S.event.special[e]={delegateType:i,bindType:i,handle:function(e){var t,n=e.relatedTarget,r=e.handleObj;return n&&(n===this||S.contains(this,n))||(e.type=r.origType,t=r.handler.apply(this,arguments),e.type=i),t}}}),S.fn.extend({on:function(e,t,n,r){return Ee(this,e,t,n,r)},one:function(e,t,n,r){return Ee(this,e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,S(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=Te),this.each(function(){S.event.remove(this,e,n,t)})}});var ke=/<script|<style|<link/i,Ae=/checked\s*(?:[^=]|=\s*.checked.)/i,Ne=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n<r;n++)S.event.add(t,i,s[i][n]);Q.hasData(e)&&(o=Q.access(e),a=S.extend({},o),Q.set(t,a))}}function He(n,r,i,o){r=g(r);var e,t,a,s,u,l,c=0,f=n.length,p=f-1,d=r[0],h=m(d);if(h||1<f&&"string"==typeof d&&!y.checkClone&&Ae.test(d))return n.each(function(e){var t=n.eq(e);h&&(r[0]=d.call(this,e,t.html())),He(t,r,i,o)});if(f&&(t=(e=xe(r,n[0].ownerDocument,!1,n,o)).firstChild,1===e.childNodes.length&&(e=t),t||o)){for(s=(a=S.map(ve(e,"script"),De)).length;c<f;c++)u=e,c!==p&&(u=S.clone(u,!0,!0),s&&S.merge(a,ve(u,"script"))),i.call(n[c],u,c);if(s)for(l=a[a.length-1].ownerDocument,S.map(a,qe),c=0;c<s;c++)u=a[c],he.test(u.type||"")&&!Y.access(u,"globalEval")&&S.contains(l,u)&&(u.src&&"module"!==(u.type||"").toLowerCase()?S._evalUrl&&!u.noModule&&S._evalUrl(u.src,{nonce:u.nonce||u.getAttribute("nonce")},l):b(u.textContent.replace(Ne,""),u,l))}return n}function Oe(e,t,n){for(var r,i=t?S.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||S.cleanData(ve(r)),r.parentNode&&(n&&ie(r)&&ye(ve(r,"script")),r.parentNode.removeChild(r));return e}S.extend({htmlPrefilter:function(e){return e},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=ie(e);if(!(y.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||S.isXMLDoc(e)))for(a=ve(c),r=0,i=(o=ve(e)).length;r<i;r++)s=o[r],u=a[r],void 0,"input"===(l=u.nodeName.toLowerCase())&&pe.test(s.type)?u.checked=s.checked:"input"!==l&&"textarea"!==l||(u.defaultValue=s.defaultValue);if(t)if(n)for(o=o||ve(e),a=a||ve(c),r=0,i=o.length;r<i;r++)Le(o[r],a[r]);else Le(e,c);return 0<(a=ve(c,"script")).length&&ye(a,!f&&ve(e,"script")),c},cleanData:function(e){for(var t,n,r,i=S.event.special,o=0;void 0!==(n=e[o]);o++)if(V(n)){if(t=n[Y.expando]){if(t.events)for(r in t.events)i[r]?S.event.remove(n,r):S.removeEvent(n,r,t.handle);n[Y.expando]=void 0}n[Q.expando]&&(n[Q.expando]=void 0)}}}),S.fn.extend({detach:function(e){return Oe(this,e,!0)},remove:function(e){return Oe(this,e)},text:function(e){return $(this,function(e){return void 0===e?S.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return He(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||je(this,e).appendChild(e)})},prepend:function(){return He(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=je(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return He(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return He(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(S.cleanData(ve(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return S.clone(this,e,t)})},html:function(e){return $(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!ke.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=S.htmlPrefilter(e);try{for(;n<r;n++)1===(t=this[n]||{}).nodeType&&(S.cleanData(ve(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var n=[];return He(this,arguments,function(e){var t=this.parentNode;S.inArray(this,n)<0&&(S.cleanData(ve(this)),t&&t.replaceChild(e,this))},n)}}),S.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,a){S.fn[e]=function(e){for(var t,n=[],r=S(e),i=r.length-1,o=0;o<=i;o++)t=o===i?this:this.clone(!0),S(r[o])[a](t),u.apply(n,t.get());return this.pushStack(n)}});var Pe=new RegExp("^("+ee+")(?!px)[a-z%]+$","i"),Re=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=C),t.getComputedStyle(e)},Me=function(e,t,n){var r,i,o={};for(i in t)o[i]=e.style[i],e.style[i]=t[i];for(i in r=n.call(e),t)e.style[i]=o[i];return r},Ie=new RegExp(ne.join("|"),"i");function We(e,t,n){var r,i,o,a,s=e.style;return(n=n||Re(e))&&(""!==(a=n.getPropertyValue(t)||n[t])||ie(e)||(a=S.style(e,t)),!y.pixelBoxStyles()&&Pe.test(a)&&Ie.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function Fe(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}!function(){function e(){if(l){u.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",l.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",re.appendChild(u).appendChild(l);var e=C.getComputedStyle(l);n="1%"!==e.top,s=12===t(e.marginLeft),l.style.right="60%",o=36===t(e.right),r=36===t(e.width),l.style.position="absolute",i=12===t(l.offsetWidth/3),re.removeChild(u),l=null}}function t(e){return Math.round(parseFloat(e))}var n,r,i,o,a,s,u=E.createElement("div"),l=E.createElement("div");l.style&&(l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",y.clearCloneStyle="content-box"===l.style.backgroundClip,S.extend(y,{boxSizingReliable:function(){return e(),r},pixelBoxStyles:function(){return e(),o},pixelPosition:function(){return e(),n},reliableMarginLeft:function(){return e(),s},scrollboxSize:function(){return e(),i},reliableTrDimensions:function(){var e,t,n,r;return null==a&&(e=E.createElement("table"),t=E.createElement("tr"),n=E.createElement("div"),e.style.cssText="position:absolute;left:-11111px;border-collapse:separate",t.style.cssText="border:1px solid",t.style.height="1px",n.style.height="9px",n.style.display="block",re.appendChild(e).appendChild(t).appendChild(n),r=C.getComputedStyle(t),a=parseInt(r.height,10)+parseInt(r.borderTopWidth,10)+parseInt(r.borderBottomWidth,10)===t.offsetHeight,re.removeChild(e)),a}}))}();var Be=["Webkit","Moz","ms"],$e=E.createElement("div").style,_e={};function ze(e){var t=S.cssProps[e]||_e[e];return t||(e in $e?e:_e[e]=function(e){var t=e[0].toUpperCase()+e.slice(1),n=Be.length;while(n--)if((e=Be[n]+t)in $e)return e}(e)||e)}var Ue=/^(none|table(?!-c[ea]).+)/,Xe=/^--/,Ve={position:"absolute",visibility:"hidden",display:"block"},Ge={letterSpacing:"0",fontWeight:"400"};function Ye(e,t,n){var r=te.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function Qe(e,t,n,r,i,o){var a="width"===t?1:0,s=0,u=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(u+=S.css(e,n+ne[a],!0,i)),r?("content"===n&&(u-=S.css(e,"padding"+ne[a],!0,i)),"margin"!==n&&(u-=S.css(e,"border"+ne[a]+"Width",!0,i))):(u+=S.css(e,"padding"+ne[a],!0,i),"padding"!==n?u+=S.css(e,"border"+ne[a]+"Width",!0,i):s+=S.css(e,"border"+ne[a]+"Width",!0,i));return!r&&0<=o&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))||0),u}function Je(e,t,n){var r=Re(e),i=(!y.boxSizingReliable()||n)&&"border-box"===S.css(e,"boxSizing",!1,r),o=i,a=We(e,t,r),s="offset"+t[0].toUpperCase()+t.slice(1);if(Pe.test(a)){if(!n)return a;a="auto"}return(!y.boxSizingReliable()&&i||!y.reliableTrDimensions()&&A(e,"tr")||"auto"===a||!parseFloat(a)&&"inline"===S.css(e,"display",!1,r))&&e.getClientRects().length&&(i="border-box"===S.css(e,"boxSizing",!1,r),(o=s in e)&&(a=e[s])),(a=parseFloat(a)||0)+Qe(e,t,n||(i?"border":"content"),o,r,a)+"px"}function Ke(e,t,n,r,i){return new Ke.prototype.init(e,t,n,r,i)}S.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=We(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=X(t),u=Xe.test(t),l=e.style;if(u||(t=ze(s)),a=S.cssHooks[t]||S.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"===(o=typeof n)&&(i=te.exec(n))&&i[1]&&(n=se(e,t,i),o="number"),null!=n&&n==n&&("number"!==o||u||(n+=i&&i[3]||(S.cssNumber[s]?"":"px")),y.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=X(t);return Xe.test(t)||(t=ze(s)),(a=S.cssHooks[t]||S.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=We(e,t,r)),"normal"===i&&t in Ge&&(i=Ge[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),S.each(["height","width"],function(e,u){S.cssHooks[u]={get:function(e,t,n){if(t)return!Ue.test(S.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?Je(e,u,n):Me(e,Ve,function(){return Je(e,u,n)})},set:function(e,t,n){var r,i=Re(e),o=!y.scrollboxSize()&&"absolute"===i.position,a=(o||n)&&"border-box"===S.css(e,"boxSizing",!1,i),s=n?Qe(e,u,n,a,i):0;return a&&o&&(s-=Math.ceil(e["offset"+u[0].toUpperCase()+u.slice(1)]-parseFloat(i[u])-Qe(e,u,"border",!1,i)-.5)),s&&(r=te.exec(t))&&"px"!==(r[3]||"px")&&(e.style[u]=t,t=S.css(e,u)),Ye(0,t,s)}}}),S.cssHooks.marginLeft=Fe(y.reliableMarginLeft,function(e,t){if(t)return(parseFloat(We(e,"marginLeft"))||e.getBoundingClientRect().left-Me(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),S.each({margin:"",padding:"",border:"Width"},function(i,o){S.cssHooks[i+o]={expand:function(e){for(var t=0,n={},r="string"==typeof e?e.split(" "):[e];t<4;t++)n[i+ne[t]+o]=r[t]||r[t-2]||r[0];return n}},"margin"!==i&&(S.cssHooks[i+o].set=Ye)}),S.fn.extend({css:function(e,t){return $(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=Re(e),i=t.length;a<i;a++)o[t[a]]=S.css(e,t[a],!1,r);return o}return void 0!==n?S.style(e,t,n):S.css(e,t)},e,t,1<arguments.length)}}),((S.Tween=Ke).prototype={constructor:Ke,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||S.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(S.cssNumber[n]?"":"px")},cur:function(){var e=Ke.propHooks[this.prop];return e&&e.get?e.get(this):Ke.propHooks._default.get(this)},run:function(e){var t,n=Ke.propHooks[this.prop];return this.options.duration?this.pos=t=S.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Ke.propHooks._default.set(this),this}}).init.prototype=Ke.prototype,(Ke.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=S.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){S.fx.step[e.prop]?S.fx.step[e.prop](e):1!==e.elem.nodeType||!S.cssHooks[e.prop]&&null==e.elem.style[ze(e.prop)]?e.elem[e.prop]=e.now:S.style(e.elem,e.prop,e.now+e.unit)}}}).scrollTop=Ke.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},S.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},S.fx=Ke.prototype.init,S.fx.step={};var Ze,et,tt,nt,rt=/^(?:toggle|show|hide)$/,it=/queueHooks$/;function ot(){et&&(!1===E.hidden&&C.requestAnimationFrame?C.requestAnimationFrame(ot):C.setTimeout(ot,S.fx.interval),S.fx.tick())}function at(){return C.setTimeout(function(){Ze=void 0}),Ze=Date.now()}function st(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=ne[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function ut(e,t,n){for(var r,i=(lt.tweeners[t]||[]).concat(lt.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function lt(o,e,t){var n,a,r=0,i=lt.prefilters.length,s=S.Deferred().always(function(){delete u.elem}),u=function(){if(a)return!1;for(var e=Ze||at(),t=Math.max(0,l.startTime+l.duration-e),n=1-(t/l.duration||0),r=0,i=l.tweens.length;r<i;r++)l.tweens[r].run(n);return s.notifyWith(o,[l,n,t]),n<1&&i?t:(i||s.notifyWith(o,[l,1,0]),s.resolveWith(o,[l]),!1)},l=s.promise({elem:o,props:S.extend({},e),opts:S.extend(!0,{specialEasing:{},easing:S.easing._default},t),originalProperties:e,originalOptions:t,startTime:Ze||at(),duration:t.duration,tweens:[],createTween:function(e,t){var n=S.Tween(o,l.opts,e,t,l.opts.specialEasing[e]||l.opts.easing);return l.tweens.push(n),n},stop:function(e){var t=0,n=e?l.tweens.length:0;if(a)return this;for(a=!0;t<n;t++)l.tweens[t].run(1);return e?(s.notifyWith(o,[l,1,0]),s.resolveWith(o,[l,e])):s.rejectWith(o,[l,e]),this}}),c=l.props;for(!function(e,t){var n,r,i,o,a;for(n in e)if(i=t[r=X(n)],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=S.cssHooks[r])&&"expand"in a)for(n in o=a.expand(o),delete e[r],o)n in e||(e[n]=o[n],t[n]=i);else t[r]=i}(c,l.opts.specialEasing);r<i;r++)if(n=lt.prefilters[r].call(l,o,c,l.opts))return m(n.stop)&&(S._queueHooks(l.elem,l.opts.queue).stop=n.stop.bind(n)),n;return S.map(c,ut,l),m(l.opts.start)&&l.opts.start.call(o,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),S.fx.timer(S.extend(u,{elem:o,anim:l,queue:l.opts.queue})),l}S.Animation=S.extend(lt,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return se(n.elem,e,te.exec(t),n),n}]},tweener:function(e,t){m(e)?(t=e,e=["*"]):e=e.match(P);for(var n,r=0,i=e.length;r<i;r++)n=e[r],lt.tweeners[n]=lt.tweeners[n]||[],lt.tweeners[n].unshift(t)},prefilters:[function(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,p=this,d={},h=e.style,g=e.nodeType&&ae(e),v=Y.get(e,"fxshow");for(r in n.queue||(null==(a=S._queueHooks(e,"fx")).unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,p.always(function(){p.always(function(){a.unqueued--,S.queue(e,"fx").length||a.empty.fire()})})),t)if(i=t[r],rt.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!v||void 0===v[r])continue;g=!0}d[r]=v&&v[r]||S.style(e,r)}if((u=!S.isEmptyObject(t))||!S.isEmptyObject(d))for(r in f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],null==(l=v&&v.display)&&(l=Y.get(e,"display")),"none"===(c=S.css(e,"display"))&&(l?c=l:(le([e],!0),l=e.style.display||l,c=S.css(e,"display"),le([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===S.css(e,"float")&&(u||(p.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",p.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1,d)u||(v?"hidden"in v&&(g=v.hidden):v=Y.access(e,"fxshow",{display:l}),o&&(v.hidden=!g),g&&le([e],!0),p.done(function(){for(r in g||le([e]),Y.remove(e,"fxshow"),d)S.style(e,r,d[r])})),u=ut(g?v[r]:0,r,p),r in v||(v[r]=u.start,g&&(u.end=u.start,u.start=0))}],prefilter:function(e,t){t?lt.prefilters.unshift(e):lt.prefilters.push(e)}}),S.speed=function(e,t,n){var r=e&&"object"==typeof e?S.extend({},e):{complete:n||!n&&t||m(e)&&e,duration:e,easing:n&&t||t&&!m(t)&&t};return S.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in S.fx.speeds?r.duration=S.fx.speeds[r.duration]:r.duration=S.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){m(r.old)&&r.old.call(this),r.queue&&S.dequeue(this,r.queue)},r},S.fn.extend({fadeTo:function(e,t,n,r){return this.filter(ae).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(t,e,n,r){var i=S.isEmptyObject(t),o=S.speed(e,n,r),a=function(){var e=lt(this,S.extend({},t),o);(i||Y.get(this,"finish"))&&e.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(i,e,o){var a=function(e){var t=e.stop;delete e.stop,t(o)};return"string"!=typeof i&&(o=e,e=i,i=void 0),e&&this.queue(i||"fx",[]),this.each(function(){var e=!0,t=null!=i&&i+"queueHooks",n=S.timers,r=Y.get(this);if(t)r[t]&&r[t].stop&&a(r[t]);else for(t in r)r[t]&&r[t].stop&&it.test(t)&&a(r[t]);for(t=n.length;t--;)n[t].elem!==this||null!=i&&n[t].queue!==i||(n[t].anim.stop(o),e=!1,n.splice(t,1));!e&&o||S.dequeue(this,i)})},finish:function(a){return!1!==a&&(a=a||"fx"),this.each(function(){var e,t=Y.get(this),n=t[a+"queue"],r=t[a+"queueHooks"],i=S.timers,o=n?n.length:0;for(t.finish=!0,S.queue(this,a,[]),r&&r.stop&&r.stop.call(this,!0),e=i.length;e--;)i[e].elem===this&&i[e].queue===a&&(i[e].anim.stop(!0),i.splice(e,1));for(e=0;e<o;e++)n[e]&&n[e].finish&&n[e].finish.call(this);delete t.finish})}}),S.each(["toggle","show","hide"],function(e,r){var i=S.fn[r];S.fn[r]=function(e,t,n){return null==e||"boolean"==typeof e?i.apply(this,arguments):this.animate(st(r,!0),e,t,n)}}),S.each({slideDown:st("show"),slideUp:st("hide"),slideToggle:st("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,r){S.fn[e]=function(e,t,n){return this.animate(r,e,t,n)}}),S.timers=[],S.fx.tick=function(){var e,t=0,n=S.timers;for(Ze=Date.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||S.fx.stop(),Ze=void 0},S.fx.timer=function(e){S.timers.push(e),S.fx.start()},S.fx.interval=13,S.fx.start=function(){et||(et=!0,ot())},S.fx.stop=function(){et=null},S.fx.speeds={slow:600,fast:200,_default:400},S.fn.delay=function(r,e){return r=S.fx&&S.fx.speeds[r]||r,e=e||"fx",this.queue(e,function(e,t){var n=C.setTimeout(e,r);t.stop=function(){C.clearTimeout(n)}})},tt=E.createElement("input"),nt=E.createElement("select").appendChild(E.createElement("option")),tt.type="checkbox",y.checkOn=""!==tt.value,y.optSelected=nt.selected,(tt=E.createElement("input")).value="t",tt.type="radio",y.radioValue="t"===tt.value;var ct,ft=S.expr.attrHandle;S.fn.extend({attr:function(e,t){return $(this,S.attr,e,t,1<arguments.length)},removeAttr:function(e){return this.each(function(){S.removeAttr(this,e)})}}),S.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?S.prop(e,t,n):(1===o&&S.isXMLDoc(e)||(i=S.attrHooks[t.toLowerCase()]||(S.expr.match.bool.test(t)?ct:void 0)),void 0!==n?null===n?void S.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=S.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!y.radioValue&&"radio"===t&&A(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(P);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),ct={set:function(e,t,n){return!1===t?S.removeAttr(e,n):e.setAttribute(n,n),n}},S.each(S.expr.match.bool.source.match(/\w+/g),function(e,t){var a=ft[t]||S.find.attr;ft[t]=function(e,t,n){var r,i,o=t.toLowerCase();return n||(i=ft[o],ft[o]=r,r=null!=a(e,t,n)?o:null,ft[o]=i),r}});var pt=/^(?:input|select|textarea|button)$/i,dt=/^(?:a|area)$/i;function ht(e){return(e.match(P)||[]).join(" ")}function gt(e){return e.getAttribute&&e.getAttribute("class")||""}function vt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(P)||[]}S.fn.extend({prop:function(e,t){return $(this,S.prop,e,t,1<arguments.length)},removeProp:function(e){return this.each(function(){delete this[S.propFix[e]||e]})}}),S.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&S.isXMLDoc(e)||(t=S.propFix[t]||t,i=S.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=S.find.attr(e,"tabindex");return t?parseInt(t,10):pt.test(e.nodeName)||dt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),y.optSelected||(S.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),S.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){S.propFix[this.toLowerCase()]=this}),S.fn.extend({addClass:function(t){var e,n,r,i,o,a,s,u=0;if(m(t))return this.each(function(e){S(this).addClass(t.call(this,e,gt(this)))});if((e=vt(t)).length)while(n=this[u++])if(i=gt(n),r=1===n.nodeType&&" "+ht(i)+" "){a=0;while(o=e[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=ht(r))&&n.setAttribute("class",s)}return this},removeClass:function(t){var e,n,r,i,o,a,s,u=0;if(m(t))return this.each(function(e){S(this).removeClass(t.call(this,e,gt(this)))});if(!arguments.length)return this.attr("class","");if((e=vt(t)).length)while(n=this[u++])if(i=gt(n),r=1===n.nodeType&&" "+ht(i)+" "){a=0;while(o=e[a++])while(-1<r.indexOf(" "+o+" "))r=r.replace(" "+o+" "," ");i!==(s=ht(r))&&n.setAttribute("class",s)}return this},toggleClass:function(i,t){var o=typeof i,a="string"===o||Array.isArray(i);return"boolean"==typeof t&&a?t?this.addClass(i):this.removeClass(i):m(i)?this.each(function(e){S(this).toggleClass(i.call(this,e,gt(this),t),t)}):this.each(function(){var e,t,n,r;if(a){t=0,n=S(this),r=vt(i);while(e=r[t++])n.hasClass(e)?n.removeClass(e):n.addClass(e)}else void 0!==i&&"boolean"!==o||((e=gt(this))&&Y.set(this,"__className__",e),this.setAttribute&&this.setAttribute("class",e||!1===i?"":Y.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&-1<(" "+ht(gt(n))+" ").indexOf(t))return!0;return!1}});var yt=/\r/g;S.fn.extend({val:function(n){var r,e,i,t=this[0];return arguments.length?(i=m(n),this.each(function(e){var t;1===this.nodeType&&(null==(t=i?n.call(this,e,S(this).val()):n)?t="":"number"==typeof t?t+="":Array.isArray(t)&&(t=S.map(t,function(e){return null==e?"":e+""})),(r=S.valHooks[this.type]||S.valHooks[this.nodeName.toLowerCase()])&&"set"in r&&void 0!==r.set(this,t,"value")||(this.value=t))})):t?(r=S.valHooks[t.type]||S.valHooks[t.nodeName.toLowerCase()])&&"get"in r&&void 0!==(e=r.get(t,"value"))?e:"string"==typeof(e=t.value)?e.replace(yt,""):null==e?"":e:void 0}}),S.extend({valHooks:{option:{get:function(e){var t=S.find.attr(e,"value");return null!=t?t:ht(S.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(((n=i[r]).selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!A(n.parentNode,"optgroup"))){if(t=S(n).val(),a)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=S.makeArray(t),a=i.length;while(a--)((r=i[a]).selected=-1<S.inArray(S.valHooks.option.get(r),o))&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),S.each(["radio","checkbox"],function(){S.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=-1<S.inArray(S(e).val(),t)}},y.checkOn||(S.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),y.focusin="onfocusin"in C;var mt=/^(?:focusinfocus|focusoutblur)$/,xt=function(e){e.stopPropagation()};S.extend(S.event,{trigger:function(e,t,n,r){var i,o,a,s,u,l,c,f,p=[n||E],d=v.call(e,"type")?e.type:e,h=v.call(e,"namespace")?e.namespace.split("."):[];if(o=f=a=n=n||E,3!==n.nodeType&&8!==n.nodeType&&!mt.test(d+S.event.triggered)&&(-1<d.indexOf(".")&&(d=(h=d.split(".")).shift(),h.sort()),u=d.indexOf(":")<0&&"on"+d,(e=e[S.expando]?e:new S.Event(d,"object"==typeof e&&e)).isTrigger=r?2:3,e.namespace=h.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),t=null==t?[e]:S.makeArray(t,[e]),c=S.event.special[d]||{},r||!c.trigger||!1!==c.trigger.apply(n,t))){if(!r&&!c.noBubble&&!x(n)){for(s=c.delegateType||d,mt.test(s+d)||(o=o.parentNode);o;o=o.parentNode)p.push(o),a=o;a===(n.ownerDocument||E)&&p.push(a.defaultView||a.parentWindow||C)}i=0;while((o=p[i++])&&!e.isPropagationStopped())f=o,e.type=1<i?s:c.bindType||d,(l=(Y.get(o,"events")||Object.create(null))[e.type]&&Y.get(o,"handle"))&&l.apply(o,t),(l=u&&o[u])&&l.apply&&V(o)&&(e.result=l.apply(o,t),!1===e.result&&e.preventDefault());return e.type=d,r||e.isDefaultPrevented()||c._default&&!1!==c._default.apply(p.pop(),t)||!V(n)||u&&m(n[d])&&!x(n)&&((a=n[u])&&(n[u]=null),S.event.triggered=d,e.isPropagationStopped()&&f.addEventListener(d,xt),n[d](),e.isPropagationStopped()&&f.removeEventListener(d,xt),S.event.triggered=void 0,a&&(n[u]=a)),e.result}},simulate:function(e,t,n){var r=S.extend(new S.Event,n,{type:e,isSimulated:!0});S.event.trigger(r,null,t)}}),S.fn.extend({trigger:function(e,t){return this.each(function(){S.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return S.event.trigger(e,t,n,!0)}}),y.focusin||S.each({focus:"focusin",blur:"focusout"},function(n,r){var i=function(e){S.event.simulate(r,e.target,S.event.fix(e))};S.event.special[r]={setup:function(){var e=this.ownerDocument||this.document||this,t=Y.access(e,r);t||e.addEventListener(n,i,!0),Y.access(e,r,(t||0)+1)},teardown:function(){var e=this.ownerDocument||this.document||this,t=Y.access(e,r)-1;t?Y.access(e,r,t):(e.removeEventListener(n,i,!0),Y.remove(e,r))}}});var bt=C.location,wt={guid:Date.now()},Tt=/\?/;S.parseXML=function(e){var t,n;if(!e||"string"!=typeof e)return null;try{t=(new C.DOMParser).parseFromString(e,"text/xml")}catch(e){}return n=t&&t.getElementsByTagName("parsererror")[0],t&&!n||S.error("Invalid XML: "+(n?S.map(n.childNodes,function(e){return e.textContent}).join("\n"):e)),t};var Ct=/\[\]$/,Et=/\r?\n/g,St=/^(?:submit|button|image|reset|file)$/i,kt=/^(?:input|select|textarea|keygen)/i;function At(n,e,r,i){var t;if(Array.isArray(e))S.each(e,function(e,t){r||Ct.test(n)?i(n,t):At(n+"["+("object"==typeof t&&null!=t?e:"")+"]",t,r,i)});else if(r||"object"!==w(e))i(n,e);else for(t in e)At(n+"["+t+"]",e[t],r,i)}S.param=function(e,t){var n,r=[],i=function(e,t){var n=m(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!S.isPlainObject(e))S.each(e,function(){i(this.name,this.value)});else for(n in e)At(n,e[n],t,i);return r.join("&")},S.fn.extend({serialize:function(){return S.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=S.prop(this,"elements");return e?S.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!S(this).is(":disabled")&&kt.test(this.nodeName)&&!St.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=S(this).val();return null==n?null:Array.isArray(n)?S.map(n,function(e){return{name:t.name,value:e.replace(Et,"\r\n")}}):{name:t.name,value:n.replace(Et,"\r\n")}}).get()}});var Nt=/%20/g,jt=/#.*$/,Dt=/([?&])_=[^&]*/,qt=/^(.*?):[ \t]*([^\r\n]*)$/gm,Lt=/^(?:GET|HEAD)$/,Ht=/^\/\//,Ot={},Pt={},Rt="*/".concat("*"),Mt=E.createElement("a");function It(o){return function(e,t){"string"!=typeof e&&(t=e,e="*");var n,r=0,i=e.toLowerCase().match(P)||[];if(m(t))while(n=i[r++])"+"===n[0]?(n=n.slice(1)||"*",(o[n]=o[n]||[]).unshift(t)):(o[n]=o[n]||[]).push(t)}}function Wt(t,i,o,a){var s={},u=t===Pt;function l(e){var r;return s[e]=!0,S.each(t[e]||[],function(e,t){var n=t(i,o,a);return"string"!=typeof n||u||s[n]?u?!(r=n):void 0:(i.dataTypes.unshift(n),l(n),!1)}),r}return l(i.dataTypes[0])||!s["*"]&&l("*")}function Ft(e,t){var n,r,i=S.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&S.extend(!0,e,r),e}Mt.href=bt.href,S.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:bt.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(bt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Rt,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":S.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?Ft(Ft(e,S.ajaxSettings),t):Ft(S.ajaxSettings,e)},ajaxPrefilter:It(Ot),ajaxTransport:It(Pt),ajax:function(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var c,f,p,n,d,r,h,g,i,o,v=S.ajaxSetup({},t),y=v.context||v,m=v.context&&(y.nodeType||y.jquery)?S(y):S.event,x=S.Deferred(),b=S.Callbacks("once memory"),w=v.statusCode||{},a={},s={},u="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(h){if(!n){n={};while(t=qt.exec(p))n[t[1].toLowerCase()+" "]=(n[t[1].toLowerCase()+" "]||[]).concat(t[2])}t=n[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return h?p:null},setRequestHeader:function(e,t){return null==h&&(e=s[e.toLowerCase()]=s[e.toLowerCase()]||e,a[e]=t),this},overrideMimeType:function(e){return null==h&&(v.mimeType=e),this},statusCode:function(e){var t;if(e)if(h)T.always(e[T.status]);else for(t in e)w[t]=[w[t],e[t]];return this},abort:function(e){var t=e||u;return c&&c.abort(t),l(0,t),this}};if(x.promise(T),v.url=((e||v.url||bt.href)+"").replace(Ht,bt.protocol+"//"),v.type=t.method||t.type||v.method||v.type,v.dataTypes=(v.dataType||"*").toLowerCase().match(P)||[""],null==v.crossDomain){r=E.createElement("a");try{r.href=v.url,r.href=r.href,v.crossDomain=Mt.protocol+"//"+Mt.host!=r.protocol+"//"+r.host}catch(e){v.crossDomain=!0}}if(v.data&&v.processData&&"string"!=typeof v.data&&(v.data=S.param(v.data,v.traditional)),Wt(Ot,v,t,T),h)return T;for(i in(g=S.event&&v.global)&&0==S.active++&&S.event.trigger("ajaxStart"),v.type=v.type.toUpperCase(),v.hasContent=!Lt.test(v.type),f=v.url.replace(jt,""),v.hasContent?v.data&&v.processData&&0===(v.contentType||"").indexOf("application/x-www-form-urlencoded")&&(v.data=v.data.replace(Nt,"+")):(o=v.url.slice(f.length),v.data&&(v.processData||"string"==typeof v.data)&&(f+=(Tt.test(f)?"&":"?")+v.data,delete v.data),!1===v.cache&&(f=f.replace(Dt,"$1"),o=(Tt.test(f)?"&":"?")+"_="+wt.guid+++o),v.url=f+o),v.ifModified&&(S.lastModified[f]&&T.setRequestHeader("If-Modified-Since",S.lastModified[f]),S.etag[f]&&T.setRequestHeader("If-None-Match",S.etag[f])),(v.data&&v.hasContent&&!1!==v.contentType||t.contentType)&&T.setRequestHeader("Content-Type",v.contentType),T.setRequestHeader("Accept",v.dataTypes[0]&&v.accepts[v.dataTypes[0]]?v.accepts[v.dataTypes[0]]+("*"!==v.dataTypes[0]?", "+Rt+"; q=0.01":""):v.accepts["*"]),v.headers)T.setRequestHeader(i,v.headers[i]);if(v.beforeSend&&(!1===v.beforeSend.call(y,T,v)||h))return T.abort();if(u="abort",b.add(v.complete),T.done(v.success),T.fail(v.error),c=Wt(Pt,v,t,T)){if(T.readyState=1,g&&m.trigger("ajaxSend",[T,v]),h)return T;v.async&&0<v.timeout&&(d=C.setTimeout(function(){T.abort("timeout")},v.timeout));try{h=!1,c.send(a,l)}catch(e){if(h)throw e;l(-1,e)}}else l(-1,"No Transport");function l(e,t,n,r){var i,o,a,s,u,l=t;h||(h=!0,d&&C.clearTimeout(d),c=void 0,p=r||"",T.readyState=0<e?4:0,i=200<=e&&e<300||304===e,n&&(s=function(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}(v,T,n)),!i&&-1<S.inArray("script",v.dataTypes)&&S.inArray("json",v.dataTypes)<0&&(v.converters["text script"]=function(){}),s=function(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}(v,s,T,i),i?(v.ifModified&&((u=T.getResponseHeader("Last-Modified"))&&(S.lastModified[f]=u),(u=T.getResponseHeader("etag"))&&(S.etag[f]=u)),204===e||"HEAD"===v.type?l="nocontent":304===e?l="notmodified":(l=s.state,o=s.data,i=!(a=s.error))):(a=l,!e&&l||(l="error",e<0&&(e=0))),T.status=e,T.statusText=(t||l)+"",i?x.resolveWith(y,[o,l,T]):x.rejectWith(y,[T,l,a]),T.statusCode(w),w=void 0,g&&m.trigger(i?"ajaxSuccess":"ajaxError",[T,v,i?o:a]),b.fireWith(y,[T,l]),g&&(m.trigger("ajaxComplete",[T,v]),--S.active||S.event.trigger("ajaxStop")))}return T},getJSON:function(e,t,n){return S.get(e,t,n,"json")},getScript:function(e,t){return S.get(e,void 0,t,"script")}}),S.each(["get","post"],function(e,i){S[i]=function(e,t,n,r){return m(t)&&(r=r||n,n=t,t=void 0),S.ajax(S.extend({url:e,type:i,dataType:r,data:t,success:n},S.isPlainObject(e)&&e))}}),S.ajaxPrefilter(function(e){var t;for(t in e.headers)"content-type"===t.toLowerCase()&&(e.contentType=e.headers[t]||"")}),S._evalUrl=function(e,t,n){return S.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){S.globalEval(e,t,n)}})},S.fn.extend({wrapAll:function(e){var t;return this[0]&&(m(e)&&(e=e.call(this[0])),t=S(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(n){return m(n)?this.each(function(e){S(this).wrapInner(n.call(this,e))}):this.each(function(){var e=S(this),t=e.contents();t.length?t.wrapAll(n):e.append(n)})},wrap:function(t){var n=m(t);return this.each(function(e){S(this).wrapAll(n?t.call(this,e):t)})},unwrap:function(e){return this.parent(e).not("body").each(function(){S(this).replaceWith(this.childNodes)}),this}}),S.expr.pseudos.hidden=function(e){return!S.expr.pseudos.visible(e)},S.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},S.ajaxSettings.xhr=function(){try{return new C.XMLHttpRequest}catch(e){}};var Bt={0:200,1223:204},$t=S.ajaxSettings.xhr();y.cors=!!$t&&"withCredentials"in $t,y.ajax=$t=!!$t,S.ajaxTransport(function(i){var o,a;if(y.cors||$t&&!i.crossDomain)return{send:function(e,t){var n,r=i.xhr();if(r.open(i.type,i.url,i.async,i.username,i.password),i.xhrFields)for(n in i.xhrFields)r[n]=i.xhrFields[n];for(n in i.mimeType&&r.overrideMimeType&&r.overrideMimeType(i.mimeType),i.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest"),e)r.setRequestHeader(n,e[n]);o=function(e){return function(){o&&(o=a=r.onload=r.onerror=r.onabort=r.ontimeout=r.onreadystatechange=null,"abort"===e?r.abort():"error"===e?"number"!=typeof r.status?t(0,"error"):t(r.status,r.statusText):t(Bt[r.status]||r.status,r.statusText,"text"!==(r.responseType||"text")||"string"!=typeof r.responseText?{binary:r.response}:{text:r.responseText},r.getAllResponseHeaders()))}},r.onload=o(),a=r.onerror=r.ontimeout=o("error"),void 0!==r.onabort?r.onabort=a:r.onreadystatechange=function(){4===r.readyState&&C.setTimeout(function(){o&&a()})},o=o("abort");try{r.send(i.hasContent&&i.data||null)}catch(e){if(o)throw e}},abort:function(){o&&o()}}}),S.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),S.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return S.globalEval(e),e}}}),S.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),S.ajaxTransport("script",function(n){var r,i;if(n.crossDomain||n.scriptAttrs)return{send:function(e,t){r=S("<script>").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1<s&&(r=ht(e.slice(s)),e=e.slice(0,s)),m(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),0<a.length&&S.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?S("<div>").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0<arguments.length?this.on(n,null,e,t):this.trigger(n)}});var Xt=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;S.proxy=function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),m(e))return r=s.call(arguments,2),(i=function(){return e.apply(t||this,r.concat(s.call(arguments)))}).guid=e.guid=e.guid||S.guid++,i},S.holdReady=function(e){e?S.readyWait++:S.ready(!0)},S.isArray=Array.isArray,S.parseJSON=JSON.parse,S.nodeName=A,S.isFunction=m,S.isWindow=x,S.camelCase=X,S.type=w,S.now=Date.now,S.isNumeric=function(e){var t=S.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},S.trim=function(e){return null==e?"":(e+"").replace(Xt,"")},"function"==typeof define&&define.amd&&define("jquery",[],function(){return S});var Vt=C.jQuery,Gt=C.$;return S.noConflict=function(e){return C.$===S&&(C.$=Gt),e&&C.jQuery===S&&(C.jQuery=Vt),S},"undefined"==typeof e&&(C.jQuery=C.$=S),S}); diff --git a/docs/build/html/_static/js/badge_only.js b/docs/build/html/_static/js/badge_only.js new file mode 100644 index 0000000000000000000000000000000000000000..526d7234b6538603393d419ae2330b3fd6e57ee8 --- /dev/null +++ b/docs/build/html/_static/js/badge_only.js @@ -0,0 +1 @@ +!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}}); \ No newline at end of file diff --git a/docs/build/html/_static/js/html5shiv-printshiv.min.js b/docs/build/html/_static/js/html5shiv-printshiv.min.js new file mode 100644 index 0000000000000000000000000000000000000000..2b43bd062e9689f9f4016931d08e7143d555539d --- /dev/null +++ b/docs/build/html/_static/js/html5shiv-printshiv.min.js @@ -0,0 +1,4 @@ +/** +* @preserve HTML5 Shiv 3.7.3-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=y.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=y.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),y.elements=c+" "+a,j(b)}function f(a){var b=x[a[v]];return b||(b={},w++,a[v]=w,x[w]=b),b}function g(a,c,d){if(c||(c=b),q)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():u.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||t.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),q)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return y.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(y,b.frag)}function j(a){a||(a=b);var d=f(a);return!y.shivCSS||p||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),q||i(a,d),a}function k(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(l(b)));return g}function l(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(A+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function m(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+A+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function n(a){for(var b=a.length;b--;)a[b].removeNode()}function o(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,e,g=f(a),h=a.namespaces,i=a.parentWindow;return!B||a.printShived?a:("undefined"==typeof h[A]&&h.add(A),i.attachEvent("onbeforeprint",function(){b();for(var f,g,h,i=a.styleSheets,j=[],l=i.length,n=Array(l);l--;)n[l]=i[l];for(;h=n.pop();)if(!h.disabled&&z.test(h.media)){try{f=h.imports,g=f.length}catch(o){g=0}for(l=0;g>l;l++)n.push(f[l]);try{j.push(h.cssText)}catch(o){}}j=m(j.reverse().join("")),e=k(a),d=c(a,j)}),i.attachEvent("onafterprint",function(){n(e),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var p,q,r="3.7.3",s=a.html5||{},t=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,u=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",w=0,x={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",p="hidden"in a,q=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){p=!0,q=!0}}();var y={elements:s.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:r,shivCSS:s.shivCSS!==!1,supportsUnknownElements:q,shivMethods:s.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=y,j(b);var z=/^$|\b(?:all|print)\b/,A="html5shiv",B=!q&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();y.type+=" print",y.shivPrint=o,o(b),"object"==typeof module&&module.exports&&(module.exports=y)}("undefined"!=typeof window?window:this,document); \ No newline at end of file diff --git a/docs/build/html/_static/js/html5shiv.min.js b/docs/build/html/_static/js/html5shiv.min.js new file mode 100644 index 0000000000000000000000000000000000000000..cd1c674f5e3a290a12386156500df3c50903a46b --- /dev/null +++ b/docs/build/html/_static/js/html5shiv.min.js @@ -0,0 +1,4 @@ +/** +* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document); \ No newline at end of file diff --git a/docs/build/html/_static/js/modernizr.min.js b/docs/build/html/_static/js/modernizr.min.js deleted file mode 100644 index f65d47974786ee51c258f680bd9be621629244f5..0000000000000000000000000000000000000000 --- a/docs/build/html/_static/js/modernizr.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* Modernizr 2.6.2 (Custom Build) | MIT & BSD - * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load - */ -;window.Modernizr=function(a,b,c){function D(a){j.cssText=a}function E(a,b){return D(n.join(a+";")+(b||""))}function F(a,b){return typeof a===b}function G(a,b){return!!~(""+a).indexOf(b)}function H(a,b){for(var d in a){var e=a[d];if(!G(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function I(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:F(f,"function")?f.bind(d||b):f}return!1}function J(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return F(b,"string")||F(b,"undefined")?H(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),I(e,b,c))}function K(){e.input=function(c){for(var d=0,e=c.length;d<e;d++)u[c[d]]=c[d]in k;return u.list&&(u.list=!!b.createElement("datalist")&&!!a.HTMLDataListElement),u}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,f,h,i=a.length;d<i;d++)k.setAttribute("type",f=a[d]),e=k.type!=="text",e&&(k.value=l,k.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(f)&&k.style.WebkitAppearance!==c?(g.appendChild(k),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(k,null).WebkitAppearance!=="textfield"&&k.offsetHeight!==0,g.removeChild(k)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=k.checkValidity&&k.checkValidity()===!1:e=k.value!=l)),t[a[d]]=!!e;return t}("search tel url email datetime date month week time datetime-local number range color".split(" "))}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k=b.createElement("input"),l=":)",m={}.toString,n=" -webkit- -moz- -o- -ms- ".split(" "),o="Webkit Moz O ms",p=o.split(" "),q=o.toLowerCase().split(" "),r={svg:"http://www.w3.org/2000/svg"},s={},t={},u={},v=[],w=v.slice,x,y=function(a,c,d,e){var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);return f=["­",'<style id="s',h,'">',a,"</style>"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},z=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return y("@media "+b+" { #"+h+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},A=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=F(e[d],"function"),F(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),B={}.hasOwnProperty,C;!F(B,"undefined")&&!F(B.call,"undefined")?C=function(a,b){return B.call(a,b)}:C=function(a,b){return b in a&&F(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return J("flexWrap")},s.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},s.canvastext=function(){return!!e.canvas&&!!F(b.createElement("canvas").getContext("2d").fillText,"function")},s.webgl=function(){return!!a.WebGLRenderingContext},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!J("indexedDB",a)},s.hashchange=function(){return A("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return D("background-color:rgba(150,255,150,.5)"),G(j.backgroundColor,"rgba")},s.hsla=function(){return D("background-color:hsla(120,40%,100%,.5)"),G(j.backgroundColor,"rgba")||G(j.backgroundColor,"hsla")},s.multiplebgs=function(){return D("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return J("backgroundSize")},s.borderimage=function(){return J("borderImage")},s.borderradius=function(){return J("borderRadius")},s.boxshadow=function(){return J("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return E("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return J("animationName")},s.csscolumns=function(){return J("columnCount")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return D((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),G(j.backgroundImage,"gradient")},s.cssreflections=function(){return J("boxReflect")},s.csstransforms=function(){return!!J("transform")},s.csstransforms3d=function(){var a=!!J("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return J("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(["#",h,"{font:0/0 a}#",h,':after{content:"',l,'";visibility:hidden;font:3px/1 a}'].join(""),function(b){a=b.offsetHeight>=3}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},s.webworkers=function(){return!!a.Worker},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect},s.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML="<svg/>",(a.firstChild&&a.firstChild.namespaceURI)==r.svg},s.smil=function(){return!!b.createElementNS&&/SVGAnimate/.test(m.call(b.createElementNS(r.svg,"animate")))},s.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))};for(var L in s)C(s,L)&&(x=L.toLowerCase(),e[x]=s[L](),v.push((e[x]?"":"no-")+x));return e.input||K(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)C(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},D(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e<g;e++)d.createElement(f[e]);return d}function p(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return r.shivMethods?n(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+l().join().replace(/\w+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(r,b.frag)}function q(a){a||(a=b);var c=m(a);return r.shivCSS&&!f&&!c.hasCSS&&(c.hasCSS=!!k(a,"article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}")),j||p(a,c),a}var c=a.html5||{},d=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,e=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,f,g="_html5shiv",h=0,i={},j;(function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.mq=z,e.hasEvent=A,e.testProp=function(a){return H([a])},e.testAllProps=J,e.testStyles=y,e.prefixed=function(a,b,c){return b?J(a,b,c):J(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}}(this,document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))}; diff --git a/docs/build/html/_static/js/theme.js b/docs/build/html/_static/js/theme.js index 8555d79b71a1a347857e06b8a6223df1ccdd7859..1fddb6ee4a60f30b4a4c4b3ad1f1604043f77981 100644 --- a/docs/build/html/_static/js/theme.js +++ b/docs/build/html/_static/js/theme.js @@ -1,3 +1 @@ -/* sphinx_rtd_theme version 0.4.3 | MIT license */ -/* Built 20190212 16:02 */ -require=function r(s,a,l){function c(e,n){if(!a[e]){if(!s[e]){var i="function"==typeof require&&require;if(!n&&i)return i(e,!0);if(u)return u(e,!0);var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}var o=a[e]={exports:{}};s[e][0].call(o.exports,function(n){return c(s[e][1][n]||n)},o,o.exports,r,s,a,l)}return a[e].exports}for(var u="function"==typeof require&&require,n=0;n<l.length;n++)c(l[n]);return c}({"sphinx-rtd-theme":[function(n,e,i){var jQuery="undefined"!=typeof window?window.jQuery:n("jquery");e.exports.ThemeNav={navBar:null,win:null,winScroll:!1,winResize:!1,linkScroll:!1,winPosition:0,winHeight:null,docHeight:null,isRunning:!1,enable:function(e){var i=this;void 0===e&&(e=!0),i.isRunning||(i.isRunning=!0,jQuery(function(n){i.init(n),i.reset(),i.win.on("hashchange",i.reset),e&&i.win.on("scroll",function(){i.linkScroll||i.winScroll||(i.winScroll=!0,requestAnimationFrame(function(){i.onScroll()}))}),i.win.on("resize",function(){i.winResize||(i.winResize=!0,requestAnimationFrame(function(){i.onResize()}))}),i.onResize()}))},enableSticky:function(){this.enable(!0)},init:function(i){i(document);var t=this;this.navBar=i("div.wy-side-scroll:first"),this.win=i(window),i(document).on("click","[data-toggle='wy-nav-top']",function(){i("[data-toggle='wy-nav-shift']").toggleClass("shift"),i("[data-toggle='rst-versions']").toggleClass("shift")}).on("click",".wy-menu-vertical .current ul li a",function(){var n=i(this);i("[data-toggle='wy-nav-shift']").removeClass("shift"),i("[data-toggle='rst-versions']").toggleClass("shift"),t.toggleCurrent(n),t.hashChange()}).on("click","[data-toggle='rst-current-version']",function(){i("[data-toggle='rst-versions']").toggleClass("shift-up")}),i("table.docutils:not(.field-list,.footnote,.citation)").wrap("<div class='wy-table-responsive'></div>"),i("table.docutils.footnote").wrap("<div class='wy-table-responsive footnote'></div>"),i("table.docutils.citation").wrap("<div class='wy-table-responsive citation'></div>"),i(".wy-menu-vertical ul").not(".simple").siblings("a").each(function(){var e=i(this);expand=i('<span class="toctree-expand"></span>'),expand.on("click",function(n){return t.toggleCurrent(e),n.stopPropagation(),!1}),e.prepend(expand)})},reset:function(){var n=encodeURI(window.location.hash)||"#";try{var e=$(".wy-menu-vertical"),i=e.find('[href="'+n+'"]');if(0===i.length){var t=$('.document [id="'+n.substring(1)+'"]').closest("div.section");0===(i=e.find('[href="#'+t.attr("id")+'"]')).length&&(i=e.find('[href="#"]'))}0<i.length&&($(".wy-menu-vertical .current").removeClass("current"),i.addClass("current"),i.closest("li.toctree-l1").addClass("current"),i.closest("li.toctree-l1").parent().addClass("current"),i.closest("li.toctree-l1").addClass("current"),i.closest("li.toctree-l2").addClass("current"),i.closest("li.toctree-l3").addClass("current"),i.closest("li.toctree-l4").addClass("current"),i[0].scrollIntoView())}catch(o){console.log("Error expanding nav for anchor",o)}},onScroll:function(){this.winScroll=!1;var n=this.win.scrollTop(),e=n+this.winHeight,i=this.navBar.scrollTop()+(n-this.winPosition);n<0||e>this.docHeight||(this.navBar.scrollTop(i),this.winPosition=n)},onResize:function(){this.winResize=!1,this.winHeight=this.win.height(),this.docHeight=$(document).height()},hashChange:function(){this.linkScroll=!0,this.win.one("hashchange",function(){this.linkScroll=!1})},toggleCurrent:function(n){var e=n.closest("li");e.siblings("li.current").removeClass("current"),e.siblings().find("li.current").removeClass("current"),e.find("> ul li.current").removeClass("current"),e.toggleClass("current")}},"undefined"!=typeof window&&(window.SphinxRtdTheme={Navigation:e.exports.ThemeNav,StickyNav:e.exports.ThemeNav}),function(){for(var r=0,n=["ms","moz","webkit","o"],e=0;e<n.length&&!window.requestAnimationFrame;++e)window.requestAnimationFrame=window[n[e]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[n[e]+"CancelAnimationFrame"]||window[n[e]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(n,e){var i=(new Date).getTime(),t=Math.max(0,16-(i-r)),o=window.setTimeout(function(){n(i+t)},t);return r=i+t,o}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(n){clearTimeout(n)})}()},{jquery:"jquery"}]},{},["sphinx-rtd-theme"]); \ No newline at end of file +!function(n){var e={};function t(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return n[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,i){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:i})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(i,o,function(e){return n[e]}.bind(null,o));return i},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){t(1),n.exports=t(3)},function(n,e,t){(function(){var e="undefined"!=typeof window?window.jQuery:t(2);n.exports.ThemeNav={navBar:null,win:null,winScroll:!1,winResize:!1,linkScroll:!1,winPosition:0,winHeight:null,docHeight:null,isRunning:!1,enable:function(n){var t=this;void 0===n&&(n=!0),t.isRunning||(t.isRunning=!0,e((function(e){t.init(e),t.reset(),t.win.on("hashchange",t.reset),n&&t.win.on("scroll",(function(){t.linkScroll||t.winScroll||(t.winScroll=!0,requestAnimationFrame((function(){t.onScroll()})))})),t.win.on("resize",(function(){t.winResize||(t.winResize=!0,requestAnimationFrame((function(){t.onResize()})))})),t.onResize()})))},enableSticky:function(){this.enable(!0)},init:function(n){n(document);var e=this;this.navBar=n("div.wy-side-scroll:first"),this.win=n(window),n(document).on("click","[data-toggle='wy-nav-top']",(function(){n("[data-toggle='wy-nav-shift']").toggleClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift")})).on("click",".wy-menu-vertical .current ul li a",(function(){var t=n(this);n("[data-toggle='wy-nav-shift']").removeClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift"),e.toggleCurrent(t),e.hashChange()})).on("click","[data-toggle='rst-current-version']",(function(){n("[data-toggle='rst-versions']").toggleClass("shift-up")})),n("table.docutils:not(.field-list,.footnote,.citation)").wrap("<div class='wy-table-responsive'></div>"),n("table.docutils.footnote").wrap("<div class='wy-table-responsive footnote'></div>"),n("table.docutils.citation").wrap("<div class='wy-table-responsive citation'></div>"),n(".wy-menu-vertical ul").not(".simple").siblings("a").each((function(){var t=n(this);expand=n('<button class="toctree-expand" title="Open/close menu"></button>'),expand.on("click",(function(n){return e.toggleCurrent(t),n.stopPropagation(),!1})),t.prepend(expand)}))},reset:function(){var n=encodeURI(window.location.hash)||"#";try{var e=$(".wy-menu-vertical"),t=e.find('[href="'+n+'"]');if(0===t.length){var i=$('.document [id="'+n.substring(1)+'"]').closest("div.section");0===(t=e.find('[href="#'+i.attr("id")+'"]')).length&&(t=e.find('[href="#"]'))}if(t.length>0){$(".wy-menu-vertical .current").removeClass("current").attr("aria-expanded","false"),t.addClass("current").attr("aria-expanded","true"),t.closest("li.toctree-l1").parent().addClass("current").attr("aria-expanded","true");for(let n=1;n<=10;n++)t.closest("li.toctree-l"+n).addClass("current").attr("aria-expanded","true");t[0].scrollIntoView()}}catch(n){console.log("Error expanding nav for anchor",n)}},onScroll:function(){this.winScroll=!1;var n=this.win.scrollTop(),e=n+this.winHeight,t=this.navBar.scrollTop()+(n-this.winPosition);n<0||e>this.docHeight||(this.navBar.scrollTop(t),this.winPosition=n)},onResize:function(){this.winResize=!1,this.winHeight=this.win.height(),this.docHeight=$(document).height()},hashChange:function(){this.linkScroll=!0,this.win.one("hashchange",(function(){this.linkScroll=!1}))},toggleCurrent:function(n){var e=n.closest("li");e.siblings("li.current").removeClass("current").attr("aria-expanded","false"),e.siblings().find("li.current").removeClass("current").attr("aria-expanded","false");var t=e.find("> ul li");t.length&&(t.removeClass("current").attr("aria-expanded","false"),e.toggleClass("current").attr("aria-expanded",(function(n,e){return"true"==e?"false":"true"})))}},"undefined"!=typeof window&&(window.SphinxRtdTheme={Navigation:n.exports.ThemeNav,StickyNav:n.exports.ThemeNav}),function(){for(var n=0,e=["ms","moz","webkit","o"],t=0;t<e.length&&!window.requestAnimationFrame;++t)window.requestAnimationFrame=window[e[t]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e[t]+"CancelAnimationFrame"]||window[e[t]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e,t){var i=(new Date).getTime(),o=Math.max(0,16-(i-n)),r=window.setTimeout((function(){e(i+o)}),o);return n=i+o,r}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(n){clearTimeout(n)})}()}).call(window)},function(n,e){n.exports=jQuery},function(n,e,t){}]); \ No newline at end of file diff --git a/docs/build/html/_static/language_data.js b/docs/build/html/_static/language_data.js index 863704b310d1539241ef20e26ccce6af27f0ffce..2e22b06ab13bec689de4d1530b8b625bc6d69ae8 100644 --- a/docs/build/html/_static/language_data.js +++ b/docs/build/html/_static/language_data.js @@ -5,12 +5,12 @@ * This script contains the language-specific data used by searchtools.js, * namely the list of stopwords, stemmer, scorer and splitter. * - * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ -var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]; +var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"]; /* Non-minified version is copied as a separate JS file, is available */ @@ -197,101 +197,3 @@ var Stemmer = function() { } } - - - -var splitChars = (function() { - var result = {}; - var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648, - 1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702, - 2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971, - 2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345, - 3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761, - 3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823, - 4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125, - 8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695, - 11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587, - 43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141]; - var i, j, start, end; - for (i = 0; i < singles.length; i++) { - result[singles[i]] = true; - } - var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709], - [722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161], - [1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568], - [1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807], - [1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047], - [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383], - [2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450], - [2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547], - [2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673], - [2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820], - [2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946], - [2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023], - [3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173], - [3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332], - [3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481], - [3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718], - [3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791], - [3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095], - [4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205], - [4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687], - [4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968], - [4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869], - [5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102], - [6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271], - [6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592], - [6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822], - [6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167], - [7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959], - [7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143], - [8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318], - [8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483], - [8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101], - [10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567], - [11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292], - [12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444], - [12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783], - [12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311], - [19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511], - [42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774], - [42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071], - [43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263], - [43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519], - [43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647], - [43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967], - [44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295], - [57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274], - [64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007], - [65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381], - [65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]]; - for (i = 0; i < ranges.length; i++) { - start = ranges[i][0]; - end = ranges[i][1]; - for (j = start; j <= end; j++) { - result[j] = true; - } - } - return result; -})(); - -function splitQuery(query) { - var result = []; - var start = -1; - for (var i = 0; i < query.length; i++) { - if (splitChars[query.charCodeAt(i)]) { - if (start !== -1) { - result.push(query.slice(start, i)); - start = -1; - } - } else if (start === -1) { - start = i; - } - } - if (start !== -1) { - result.push(query.slice(start)); - } - return result; -} - - diff --git a/docs/build/html/_static/pygments.css b/docs/build/html/_static/pygments.css index 631bc92ffa57bc202c1dac78d96bbeaea624571e..08bec689d3306e6c13d1973f61a01bee9a307e87 100644 --- a/docs/build/html/_static/pygments.css +++ b/docs/build/html/_static/pygments.css @@ -1,21 +1,26 @@ +pre { line-height: 125%; } +td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } -.highlight { background: #f8f8f8; } -.highlight .c { color: #408080; font-style: italic } /* Comment */ +.highlight { background: #f8f8f8; } +.highlight .c { color: #3D7B7B; font-style: italic } /* Comment */ .highlight .err { border: 1px solid #FF0000 } /* Error */ .highlight .k { color: #008000; font-weight: bold } /* Keyword */ .highlight .o { color: #666666 } /* Operator */ -.highlight .ch { color: #408080; font-style: italic } /* Comment.Hashbang */ -.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #BC7A00 } /* Comment.Preproc */ -.highlight .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */ -.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ +.highlight .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */ +.highlight .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #9C6500 } /* Comment.Preproc */ +.highlight .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */ +.highlight .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */ .highlight .gd { color: #A00000 } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ +.highlight .gr { color: #E40000 } /* Generic.Error */ .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gi { color: #008400 } /* Generic.Inserted */ +.highlight .go { color: #717171 } /* Generic.Output */ .highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ @@ -28,15 +33,15 @@ .highlight .kt { color: #B00040 } /* Keyword.Type */ .highlight .m { color: #666666 } /* Literal.Number */ .highlight .s { color: #BA2121 } /* Literal.String */ -.highlight .na { color: #7D9029 } /* Name.Attribute */ +.highlight .na { color: #687822 } /* Name.Attribute */ .highlight .nb { color: #008000 } /* Name.Builtin */ .highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ .highlight .no { color: #880000 } /* Name.Constant */ .highlight .nd { color: #AA22FF } /* Name.Decorator */ -.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ +.highlight .ni { color: #717171; font-weight: bold } /* Name.Entity */ +.highlight .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0000FF } /* Name.Function */ -.highlight .nl { color: #A0A000 } /* Name.Label */ +.highlight .nl { color: #767600 } /* Name.Label */ .highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ .highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #19177C } /* Name.Variable */ @@ -53,11 +58,11 @@ .highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */ .highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ .highlight .s2 { color: #BA2121 } /* Literal.String.Double */ -.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ +.highlight .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */ .highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ -.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ +.highlight .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */ .highlight .sx { color: #008000 } /* Literal.String.Other */ -.highlight .sr { color: #BB6688 } /* Literal.String.Regex */ +.highlight .sr { color: #A45A77 } /* Literal.String.Regex */ .highlight .s1 { color: #BA2121 } /* Literal.String.Single */ .highlight .ss { color: #19177C } /* Literal.String.Symbol */ .highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ diff --git a/docs/build/html/_static/searchtools.js b/docs/build/html/_static/searchtools.js index 58ff35c4345d19830352048b89abc8e7c06e4f20..ac4d5861f95f5c6161b846522d572532725aa275 100644 --- a/docs/build/html/_static/searchtools.js +++ b/docs/build/html/_static/searchtools.js @@ -4,22 +4,24 @@ * * Sphinx JavaScript utilities for the full-text search. * - * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ +"use strict"; -if (!Scorer) { - /** - * Simple result scoring code. - */ +/** + * Simple result scoring code. + */ +if (typeof Scorer === "undefined") { var Scorer = { // Implement the following function to further tweak the score for each result - // The function takes a result array [filename, title, anchor, descr, score] + // The function takes a result array [docname, title, anchor, descr, score, filename] // and returns the new score. /* - score: function(result) { - return result[4]; + score: result => { + const [docname, title, anchor, descr, score, filename] = result + return score }, */ @@ -28,9 +30,11 @@ if (!Scorer) { // or matches in the last dotted part of the object name objPartialMatch: 6, // Additive scores depending on the priority of the object - objPrio: {0: 15, // used to be importantResults - 1: 5, // used to be objectResults - 2: -5}, // used to be unimportantResults + objPrio: { + 0: 15, // used to be importantResults + 1: 5, // used to be objectResults + 2: -5, // used to be unimportantResults + }, // Used when the priority is not in the mapping. objPrioDefault: 0, @@ -39,455 +43,455 @@ if (!Scorer) { partialTitle: 7, // query found in terms term: 5, - partialTerm: 2 + partialTerm: 2, }; } -if (!splitQuery) { - function splitQuery(query) { - return query.split(/\s+/); +const _removeChildren = (element) => { + while (element && element.lastChild) element.removeChild(element.lastChild); +}; + +/** + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping + */ +const _escapeRegExp = (string) => + string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string + +const _displayItem = (item, highlightTerms, searchTerms) => { + const docBuilder = DOCUMENTATION_OPTIONS.BUILDER; + const docUrlRoot = DOCUMENTATION_OPTIONS.URL_ROOT; + const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX; + const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX; + const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; + + const [docName, title, anchor, descr] = item; + + let listItem = document.createElement("li"); + let requestUrl; + let linkUrl; + if (docBuilder === "dirhtml") { + // dirhtml builder + let dirname = docName + "/"; + if (dirname.match(/\/index\/$/)) + dirname = dirname.substring(0, dirname.length - 6); + else if (dirname === "index/") dirname = ""; + requestUrl = docUrlRoot + dirname; + linkUrl = requestUrl; + } else { + // normal html builders + requestUrl = docUrlRoot + docName + docFileSuffix; + linkUrl = docName + docLinkSuffix; + } + const params = new URLSearchParams(); + params.set("highlight", [...highlightTerms].join(" ")); + let linkEl = listItem.appendChild(document.createElement("a")); + linkEl.href = linkUrl + "?" + params.toString() + anchor; + linkEl.innerHTML = title; + if (descr) + listItem.appendChild(document.createElement("span")).innerText = + " (" + descr + ")"; + else if (showSearchSummary) + fetch(requestUrl) + .then((responseData) => responseData.text()) + .then((data) => { + if (data) + listItem.appendChild( + Search.makeSearchSummary(data, searchTerms, highlightTerms) + ); + }); + Search.output.appendChild(listItem); +}; +const _finishSearch = (resultCount) => { + Search.stopPulse(); + Search.title.innerText = _("Search Results"); + if (!resultCount) + Search.status.innerText = Documentation.gettext( + "Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories." + ); + else + Search.status.innerText = _( + `Search finished, found ${resultCount} page(s) matching the search query.` + ); +}; +const _displayNextItem = ( + results, + resultCount, + highlightTerms, + searchTerms +) => { + // results left, load the summary and display it + // this is intended to be dynamic (don't sub resultsCount) + if (results.length) { + _displayItem(results.pop(), highlightTerms, searchTerms); + setTimeout( + () => _displayNextItem(results, resultCount, highlightTerms, searchTerms), + 5 + ); } + // search finished, update title and status message + else _finishSearch(resultCount); +}; + +/** + * Default splitQuery function. Can be overridden in ``sphinx.search`` with a + * custom function per language. + * + * The regular expression works by splitting the string on consecutive characters + * that are not Unicode letters, numbers, underscores, or emoji characters. + * This is the same as ``\W+`` in Python, preserving the surrogate pair area. + */ +if (typeof splitQuery === "undefined") { + var splitQuery = (query) => query + .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}]+/gu) + .filter(term => term) // remove remaining empty strings } /** * Search Module */ -var Search = { - - _index : null, - _queued_query : null, - _pulse_status : -1, - - htmlToText : function(htmlString) { - var virtualDocument = document.implementation.createHTMLDocument('virtual'); - var htmlElement = $(htmlString, virtualDocument); - htmlElement.find('.headerlink').remove(); - docContent = htmlElement.find('[role=main]')[0]; - if(docContent === undefined) { - console.warn("Content block not found. Sphinx search tries to obtain it " + - "via '[role=main]'. Could you check your theme or template."); - return ""; - } - return docContent.textContent || docContent.innerText; +const Search = { + _index: null, + _queued_query: null, + _pulse_status: -1, + + htmlToText: (htmlString) => { + const htmlElement = document + .createRange() + .createContextualFragment(htmlString); + _removeChildren(htmlElement.querySelectorAll(".headerlink")); + const docContent = htmlElement.querySelector('[role="main"]'); + if (docContent !== undefined) return docContent.textContent; + console.warn( + "Content block not found. Sphinx search tries to obtain it via '[role=main]'. Could you check your theme or template." + ); + return ""; }, - init : function() { - var params = $.getQueryParameters(); - if (params.q) { - var query = params.q[0]; - $('input[name="q"]')[0].value = query; - this.performSearch(query); - } + init: () => { + const query = new URLSearchParams(window.location.search).get("q"); + document + .querySelectorAll('input[name="q"]') + .forEach((el) => (el.value = query)); + if (query) Search.performSearch(query); }, - loadIndex : function(url) { - $.ajax({type: "GET", url: url, data: null, - dataType: "script", cache: true, - complete: function(jqxhr, textstatus) { - if (textstatus != "success") { - document.getElementById("searchindexloader").src = url; - } - }}); - }, + loadIndex: (url) => + (document.body.appendChild(document.createElement("script")).src = url), - setIndex : function(index) { - var q; - this._index = index; - if ((q = this._queued_query) !== null) { - this._queued_query = null; - Search.query(q); + setIndex: (index) => { + Search._index = index; + if (Search._queued_query !== null) { + const query = Search._queued_query; + Search._queued_query = null; + Search.query(query); } }, - hasIndex : function() { - return this._index !== null; - }, + hasIndex: () => Search._index !== null, - deferQuery : function(query) { - this._queued_query = query; - }, + deferQuery: (query) => (Search._queued_query = query), - stopPulse : function() { - this._pulse_status = 0; - }, + stopPulse: () => (Search._pulse_status = -1), - startPulse : function() { - if (this._pulse_status >= 0) - return; - function pulse() { - var i; + startPulse: () => { + if (Search._pulse_status >= 0) return; + + const pulse = () => { Search._pulse_status = (Search._pulse_status + 1) % 4; - var dotString = ''; - for (i = 0; i < Search._pulse_status; i++) - dotString += '.'; - Search.dots.text(dotString); - if (Search._pulse_status > -1) - window.setTimeout(pulse, 500); - } + Search.dots.innerText = ".".repeat(Search._pulse_status); + if (Search._pulse_status >= 0) window.setTimeout(pulse, 500); + }; pulse(); }, /** * perform a search for something (or wait until index is loaded) */ - performSearch : function(query) { + performSearch: (query) => { // create the required interface elements - this.out = $('#search-results'); - this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out); - this.dots = $('<span></span>').appendTo(this.title); - this.status = $('<p class="search-summary"> </p>').appendTo(this.out); - this.output = $('<ul class="search"/>').appendTo(this.out); - - $('#search-progress').text(_('Preparing search...')); - this.startPulse(); + const searchText = document.createElement("h2"); + searchText.textContent = _("Searching"); + const searchSummary = document.createElement("p"); + searchSummary.classList.add("search-summary"); + searchSummary.innerText = ""; + const searchList = document.createElement("ul"); + searchList.classList.add("search"); + + const out = document.getElementById("search-results"); + Search.title = out.appendChild(searchText); + Search.dots = Search.title.appendChild(document.createElement("span")); + Search.status = out.appendChild(searchSummary); + Search.output = out.appendChild(searchList); + + const searchProgress = document.getElementById("search-progress"); + // Some themes don't use the search progress node + if (searchProgress) { + searchProgress.innerText = _("Preparing search..."); + } + Search.startPulse(); // index already loaded, the browser was quick! - if (this.hasIndex()) - this.query(query); - else - this.deferQuery(query); + if (Search.hasIndex()) Search.query(query); + else Search.deferQuery(query); }, /** * execute search (requires search index to be loaded) */ - query : function(query) { - var i; - - // stem the searchterms and add them to the correct list - var stemmer = new Stemmer(); - var searchterms = []; - var excluded = []; - var hlterms = []; - var tmp = splitQuery(query); - var objectterms = []; - for (i = 0; i < tmp.length; i++) { - if (tmp[i] !== "") { - objectterms.push(tmp[i].toLowerCase()); - } + query: (query) => { + // stem the search terms and add them to the correct list + const stemmer = new Stemmer(); + const searchTerms = new Set(); + const excludedTerms = new Set(); + const highlightTerms = new Set(); + const objectTerms = new Set(splitQuery(query.toLowerCase().trim())); + splitQuery(query.trim()).forEach((queryTerm) => { + const queryTermLower = queryTerm.toLowerCase(); + + // maybe skip this "word" + // stopwords array is from language_data.js + if ( + stopwords.indexOf(queryTermLower) !== -1 || + queryTerm.match(/^\d+$/) + ) + return; - if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i] === "") { - // skip this "word" - continue; - } // stem the word - var word = stemmer.stemWord(tmp[i].toLowerCase()); - // prevent stemmer from cutting word smaller than two chars - if(word.length < 3 && tmp[i].length >= 3) { - word = tmp[i]; - } - var toAppend; + let word = stemmer.stemWord(queryTermLower); // select the correct list - if (word[0] == '-') { - toAppend = excluded; - word = word.substr(1); - } + if (word[0] === "-") excludedTerms.add(word.substr(1)); else { - toAppend = searchterms; - hlterms.push(tmp[i].toLowerCase()); + searchTerms.add(word); + highlightTerms.add(queryTermLower); } - // only add if not already in the list - if (!$u.contains(toAppend, word)) - toAppend.push(word); - } - var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" ")); - - // console.debug('SEARCH: searching for:'); - // console.info('required: ', searchterms); - // console.info('excluded: ', excluded); + }); - // prepare search - var terms = this._index.terms; - var titleterms = this._index.titleterms; + // console.debug("SEARCH: searching for:"); + // console.info("required: ", [...searchTerms]); + // console.info("excluded: ", [...excludedTerms]); - // array of [filename, title, anchor, descr, score] - var results = []; - $('#search-progress').empty(); + // array of [docname, title, anchor, descr, score, filename] + let results = []; + _removeChildren(document.getElementById("search-progress")); // lookup as object - for (i = 0; i < objectterms.length; i++) { - var others = [].concat(objectterms.slice(0, i), - objectterms.slice(i+1, objectterms.length)); - results = results.concat(this.performObjectSearch(objectterms[i], others)); - } + objectTerms.forEach((term) => + results.push(...Search.performObjectSearch(term, objectTerms)) + ); // lookup as search terms in fulltext - results = results.concat(this.performTermsSearch(searchterms, excluded, terms, titleterms)); + results.push(...Search.performTermsSearch(searchTerms, excludedTerms)); // let the scorer override scores with a custom scoring function - if (Scorer.score) { - for (i = 0; i < results.length; i++) - results[i][4] = Scorer.score(results[i]); - } + if (Scorer.score) results.forEach((item) => (item[4] = Scorer.score(item))); // now sort the results by score (in opposite order of appearance, since the // display function below uses pop() to retrieve items) and then // alphabetically - results.sort(function(a, b) { - var left = a[4]; - var right = b[4]; - if (left > right) { - return 1; - } else if (left < right) { - return -1; - } else { + results.sort((a, b) => { + const leftScore = a[4]; + const rightScore = b[4]; + if (leftScore === rightScore) { // same score: sort alphabetically - left = a[1].toLowerCase(); - right = b[1].toLowerCase(); - return (left > right) ? -1 : ((left < right) ? 1 : 0); + const leftTitle = a[1].toLowerCase(); + const rightTitle = b[1].toLowerCase(); + if (leftTitle === rightTitle) return 0; + return leftTitle > rightTitle ? -1 : 1; // inverted is intentional } + return leftScore > rightScore ? 1 : -1; }); + // remove duplicate search results + // note the reversing of results, so that in the case of duplicates, the highest-scoring entry is kept + let seen = new Set(); + results = results.reverse().reduce((acc, result) => { + let resultStr = result.slice(0, 4).concat([result[5]]).map(v => String(v)).join(','); + if (!seen.has(resultStr)) { + acc.push(result); + seen.add(resultStr); + } + return acc; + }, []); + + results = results.reverse(); + // for debugging //Search.lastresults = results.slice(); // a copy - //console.info('search results:', Search.lastresults); + // console.info("search results:", Search.lastresults); // print the results - var resultCount = results.length; - function displayNextItem() { - // results left, load the summary and display it - if (results.length) { - var item = results.pop(); - var listItem = $('<li></li>'); - var requestUrl = ""; - var linkUrl = ""; - if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') { - // dirhtml builder - var dirname = item[0] + '/'; - if (dirname.match(/\/index\/$/)) { - dirname = dirname.substring(0, dirname.length-6); - } else if (dirname == 'index/') { - dirname = ''; - } - requestUrl = DOCUMENTATION_OPTIONS.URL_ROOT + dirname; - linkUrl = requestUrl; - - } else { - // normal html builders - requestUrl = DOCUMENTATION_OPTIONS.URL_ROOT + item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX; - linkUrl = item[0] + DOCUMENTATION_OPTIONS.LINK_SUFFIX; - } - listItem.append($('<a/>').attr('href', - linkUrl + - highlightstring + item[2]).html(item[1])); - if (item[3]) { - listItem.append($('<span> (' + item[3] + ')</span>')); - Search.output.append(listItem); - setTimeout(function() { - displayNextItem(); - }, 5); - } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { - $.ajax({url: requestUrl, - dataType: "text", - complete: function(jqxhr, textstatus) { - var data = jqxhr.responseText; - if (data !== '' && data !== undefined) { - var summary = Search.makeSearchSummary(data, searchterms, hlterms); - if (summary) { - listItem.append(summary); - } - } - Search.output.append(listItem); - setTimeout(function() { - displayNextItem(); - }, 5); - }}); - } else { - // no source available, just display title - Search.output.append(listItem); - setTimeout(function() { - displayNextItem(); - }, 5); - } - } - // search finished, update title and status message - else { - Search.stopPulse(); - Search.title.text(_('Search Results')); - if (!resultCount) - Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.')); - else - Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount)); - Search.status.fadeIn(500); - } - } - displayNextItem(); + _displayNextItem(results, results.length, highlightTerms, searchTerms); }, /** * search for object names */ - performObjectSearch : function(object, otherterms) { - var filenames = this._index.filenames; - var docnames = this._index.docnames; - var objects = this._index.objects; - var objnames = this._index.objnames; - var titles = this._index.titles; - - var i; - var results = []; - - for (var prefix in objects) { - for (var name in objects[prefix]) { - var fullname = (prefix ? prefix + '.' : '') + name; - var fullnameLower = fullname.toLowerCase() - if (fullnameLower.indexOf(object) > -1) { - var score = 0; - var parts = fullnameLower.split('.'); - // check for different match types: exact matches of full name or - // "last name" (i.e. last dotted part) - if (fullnameLower == object || parts[parts.length - 1] == object) { - score += Scorer.objNameMatch; - // matches in last name - } else if (parts[parts.length - 1].indexOf(object) > -1) { - score += Scorer.objPartialMatch; - } - var match = objects[prefix][name]; - var objname = objnames[match[1]][2]; - var title = titles[match[0]]; - // If more than one term searched for, we require other words to be - // found in the name/title/description - if (otherterms.length > 0) { - var haystack = (prefix + ' ' + name + ' ' + - objname + ' ' + title).toLowerCase(); - var allfound = true; - for (i = 0; i < otherterms.length; i++) { - if (haystack.indexOf(otherterms[i]) == -1) { - allfound = false; - break; - } - } - if (!allfound) { - continue; - } - } - var descr = objname + _(', in ') + title; - - var anchor = match[3]; - if (anchor === '') - anchor = fullname; - else if (anchor == '-') - anchor = objnames[match[1]][1] + '-' + fullname; - // add custom score for some objects according to scorer - if (Scorer.objPrio.hasOwnProperty(match[2])) { - score += Scorer.objPrio[match[2]]; - } else { - score += Scorer.objPrioDefault; - } - results.push([docnames[match[0]], fullname, '#'+anchor, descr, score, filenames[match[0]]]); - } + performObjectSearch: (object, objectTerms) => { + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const objects = Search._index.objects; + const objNames = Search._index.objnames; + const titles = Search._index.titles; + + const results = []; + + const objectSearchCallback = (prefix, match) => { + const name = match[4] + const fullname = (prefix ? prefix + "." : "") + name; + const fullnameLower = fullname.toLowerCase(); + if (fullnameLower.indexOf(object) < 0) return; + + let score = 0; + const parts = fullnameLower.split("."); + + // check for different match types: exact matches of full name or + // "last name" (i.e. last dotted part) + if (fullnameLower === object || parts.slice(-1)[0] === object) + score += Scorer.objNameMatch; + else if (parts.slice(-1)[0].indexOf(object) > -1) + score += Scorer.objPartialMatch; // matches in last name + + const objName = objNames[match[1]][2]; + const title = titles[match[0]]; + + // If more than one term searched for, we require other words to be + // found in the name/title/description + const otherTerms = new Set(objectTerms); + otherTerms.delete(object); + if (otherTerms.size > 0) { + const haystack = `${prefix} ${name} ${objName} ${title}`.toLowerCase(); + if ( + [...otherTerms].some((otherTerm) => haystack.indexOf(otherTerm) < 0) + ) + return; } - } + let anchor = match[3]; + if (anchor === "") anchor = fullname; + else if (anchor === "-") anchor = objNames[match[1]][1] + "-" + fullname; + + const descr = objName + _(", in ") + title; + + // add custom score for some objects according to scorer + if (Scorer.objPrio.hasOwnProperty(match[2])) + score += Scorer.objPrio[match[2]]; + else score += Scorer.objPrioDefault; + + results.push([ + docNames[match[0]], + fullname, + "#" + anchor, + descr, + score, + filenames[match[0]], + ]); + }; + Object.keys(objects).forEach((prefix) => + objects[prefix].forEach((array) => + objectSearchCallback(prefix, array) + ) + ); return results; }, - /** - * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions - */ - escapeRegExp : function(string) { - return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string - }, - /** * search for full-text terms in the index */ - performTermsSearch : function(searchterms, excluded, terms, titleterms) { - var docnames = this._index.docnames; - var filenames = this._index.filenames; - var titles = this._index.titles; + performTermsSearch: (searchTerms, excludedTerms) => { + // prepare search + const terms = Search._index.terms; + const titleTerms = Search._index.titleterms; + const docNames = Search._index.docnames; + const filenames = Search._index.filenames; + const titles = Search._index.titles; - var i, j, file; - var fileMap = {}; - var scoreMap = {}; - var results = []; + const scoreMap = new Map(); + const fileMap = new Map(); // perform the search on the required terms - for (i = 0; i < searchterms.length; i++) { - var word = searchterms[i]; - var files = []; - var _o = [ - {files: terms[word], score: Scorer.term}, - {files: titleterms[word], score: Scorer.title} + searchTerms.forEach((word) => { + const files = []; + const arr = [ + { files: terms[word], score: Scorer.term }, + { files: titleTerms[word], score: Scorer.title }, ]; // add support for partial matches if (word.length > 2) { - var word_regex = this.escapeRegExp(word); - for (var w in terms) { - if (w.match(word_regex) && !terms[word]) { - _o.push({files: terms[w], score: Scorer.partialTerm}) - } - } - for (var w in titleterms) { - if (w.match(word_regex) && !titleterms[word]) { - _o.push({files: titleterms[w], score: Scorer.partialTitle}) - } - } + const escapedWord = _escapeRegExp(word); + Object.keys(terms).forEach((term) => { + if (term.match(escapedWord) && !terms[word]) + arr.push({ files: terms[term], score: Scorer.partialTerm }); + }); + Object.keys(titleTerms).forEach((term) => { + if (term.match(escapedWord) && !titleTerms[word]) + arr.push({ files: titleTerms[word], score: Scorer.partialTitle }); + }); } // no match but word was a required one - if ($u.every(_o, function(o){return o.files === undefined;})) { - break; - } + if (arr.every((record) => record.files === undefined)) return; + // found search word in contents - $u.each(_o, function(o) { - var _files = o.files; - if (_files === undefined) - return - - if (_files.length === undefined) - _files = [_files]; - files = files.concat(_files); - - // set score for the word in each file to Scorer.term - for (j = 0; j < _files.length; j++) { - file = _files[j]; - if (!(file in scoreMap)) - scoreMap[file] = {}; - scoreMap[file][word] = o.score; - } + arr.forEach((record) => { + if (record.files === undefined) return; + + let recordFiles = record.files; + if (recordFiles.length === undefined) recordFiles = [recordFiles]; + files.push(...recordFiles); + + // set score for the word in each file + recordFiles.forEach((file) => { + if (!scoreMap.has(file)) scoreMap.set(file, {}); + scoreMap.get(file)[word] = record.score; + }); }); // create the mapping - for (j = 0; j < files.length; j++) { - file = files[j]; - if (file in fileMap && fileMap[file].indexOf(word) === -1) - fileMap[file].push(word); - else - fileMap[file] = [word]; - } - } + files.forEach((file) => { + if (fileMap.has(file) && fileMap.get(file).indexOf(word) === -1) + fileMap.get(file).push(word); + else fileMap.set(file, [word]); + }); + }); // now check if the files don't contain excluded terms - for (file in fileMap) { - var valid = true; - + const results = []; + for (const [file, wordList] of fileMap) { // check if all requirements are matched - var filteredTermCount = // as search terms with length < 3 are discarded: ignore - searchterms.filter(function(term){return term.length > 2}).length + + // as search terms with length < 3 are discarded + const filteredTermCount = [...searchTerms].filter( + (term) => term.length > 2 + ).length; if ( - fileMap[file].length != searchterms.length && - fileMap[file].length != filteredTermCount - ) continue; + wordList.length !== searchTerms.size && + wordList.length !== filteredTermCount + ) + continue; // ensure that none of the excluded terms is in the search result - for (i = 0; i < excluded.length; i++) { - if (terms[excluded[i]] == file || - titleterms[excluded[i]] == file || - $u.contains(terms[excluded[i]] || [], file) || - $u.contains(titleterms[excluded[i]] || [], file)) { - valid = false; - break; - } - } + if ( + [...excludedTerms].some( + (term) => + terms[term] === file || + titleTerms[term] === file || + (terms[term] || []).includes(file) || + (titleTerms[term] || []).includes(file) + ) + ) + break; - // if we have still a valid result we can add it to the result list - if (valid) { - // select one (max) score for the file. - // for better ranking, we should calculate ranking by using words statistics like basic tf-idf... - var score = $u.max($u.map(fileMap[file], function(w){return scoreMap[file][w]})); - results.push([docnames[file], titles[file], '', null, score, filenames[file]]); - } + // select one (max) score for the file. + const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w])); + // add result to the result list + results.push([ + docNames[file], + titles[file], + "", + null, + score, + filenames[file], + ]); } return results; }, @@ -495,34 +499,33 @@ var Search = { /** * helper function to return a node containing the * search summary for a given text. keywords is a list - * of stemmed words, hlwords is the list of normal, unstemmed + * of stemmed words, highlightWords is the list of normal, unstemmed * words. the first one is used to find the occurrence, the * latter for highlighting it. */ - makeSearchSummary : function(htmlText, keywords, hlwords) { - var text = Search.htmlToText(htmlText); - if (text == "") { - return null; - } - var textLower = text.toLowerCase(); - var start = 0; - $.each(keywords, function() { - var i = textLower.indexOf(this.toLowerCase()); - if (i > -1) - start = i; - }); - start = Math.max(start - 120, 0); - var excerpt = ((start > 0) ? '...' : '') + - $.trim(text.substr(start, 240)) + - ((start + 240 - text.length) ? '...' : ''); - var rv = $('<p class="context"></p>').text(excerpt); - $.each(hlwords, function() { - rv = rv.highlightText(this, 'highlighted'); - }); - return rv; - } + makeSearchSummary: (htmlText, keywords, highlightWords) => { + const text = Search.htmlToText(htmlText).toLowerCase(); + if (text === "") return null; + + const actualStartPosition = [...keywords] + .map((k) => text.indexOf(k.toLowerCase())) + .filter((i) => i > -1) + .slice(-1)[0]; + const startWithContext = Math.max(actualStartPosition - 120, 0); + + const top = startWithContext === 0 ? "" : "..."; + const tail = startWithContext + 240 < text.length ? "..." : ""; + + let summary = document.createElement("div"); + summary.classList.add("context"); + summary.innerText = top + text.substr(startWithContext, 240).trim() + tail; + + highlightWords.forEach((highlightWord) => + _highlightText(summary, highlightWord, "highlighted") + ); + + return summary; + }, }; -$(document).ready(function() { - Search.init(); -}); +_ready(Search.init); diff --git a/docs/build/html/binary_c_parameters.html b/docs/build/html/binary_c_parameters.html index d336a5e5b9e15e9fb5c1a47c23311aed750cac81..c62242eec58f4894c7ed617cd56edc27bfdcd441 100644 --- a/docs/build/html/binary_c_parameters.html +++ b/docs/build/html/binary_c_parameters.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Binary_c parameters — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Binary_c parameters — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Population grid code options" href="grid_options_descriptions.html" /> <link rel="prev" title="Example use case: Solar system using the API functionality" href="examples/notebook_solar_system.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,17 +38,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> @@ -104,68 +60,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li>Binary_c parameters</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/binary_c_parameters.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -190,15 +108,15 @@ text-align: unset; } </style> -<div class="section" id="binary-c-parameters"> -<h1>Binary_c parameters<a class="headerlink" href="#binary-c-parameters" title="Permalink to this headline">¶</a></h1> +<section id="binary-c-parameters"> +<h1>Binary_c parameters<a class="headerlink" href="#binary-c-parameters" title="Permalink to this heading">ïƒ</a></h1> <p>The following chapter contains all the parameters that the current version of binary_c can handle, along with their descriptions and other properties.</p> <dl class="simple"> -<dt>This information was obtained by the following binary_c build:</dt><dd><p><strong>binary_c git branch</strong>: branch_david <strong>binary_c git revision</strong>: 5747:20211102:404ce27a0 <strong>Built on</strong>: Nov 2 2021 23:57:35</p> +<dt>This information was obtained by the following binary_c build:</dt><dd><p><strong>binary_c git branch</strong>: branch_david <strong>binary_c git revision</strong>: 6118:20220617:8463fa650 <strong>Built on</strong>: Jun 17 2022 23:20:34</p> </dd> </dl> -<div class="section" id="section-stars"> -<h2>Section: stars<a class="headerlink" href="#section-stars" title="Permalink to this headline">¶</a></h2> +<section id="section-stars"> +<h2>Section: stars<a class="headerlink" href="#section-stars" title="Permalink to this heading">ïƒ</a></h2> <div class="line-block"> <div class="line"><strong>Parameter</strong>: metallicity</div> <div class="line"><strong>Description</strong>: This sets the metallicity of the stars, i.e. the amount (by mass) of matter which is not hydrogen or helium. If you are using the BSE algorithm, this must be 1e-4 <= metallicity <= 0.03. See also nucsyn_metallicity and effective_metallicity.</div> @@ -485,6 +403,12 @@ <div class="line"><strong>Default value</strong>: False</div> </div> <div class="line-block"> +<div class="line"><strong>Parameter</strong>: custom_timeout_time</div> +<div class="line"><strong>Description</strong>: Custom timeout time. Requires compilation with DAVID_CUSTOM_TIMEOUT</div> +<div class="line"><strong>Parameter input type</strong>: Float</div> +<div class="line"><strong>Default value</strong>: 100</div> +</div> +<div class="line-block"> <div class="line"><strong>Parameter</strong>: evolution_splitting</div> <div class="line"><strong>Description</strong>: If True, turn on splitting of an evolutionary run if splitpoint (e.g. supernova) occurs.</div> <div class="line"><strong>Parameter input type</strong>: True|False</div> @@ -530,10 +454,10 @@ </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: wind_mass_loss</div> -<div class="line"><strong>Description</strong>: Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018).</div> +<div class="line"><strong>Description</strong>: Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018), 3 = Schneider + Sander and Wink (2020) for helium stars, 4 = Schneider + Hurley for LBV mass loss</div> <div class="line"><strong>Parameter input type</strong>: Unsigned integer</div> <div class="line"><strong>Default value</strong>: 3</div> -<div class="line"><strong>Macros</strong>: [‘WIND_ALGORITHM_NONE = 0’, ‘WIND_ALGORITHM_HURLEY2002 = 1’, ‘WIND_ALGORITHM_SCHNEIDER2018 = 2’, ‘WIND_ALGORITHM_BINARY_C_2020 = 3’]</div> +<div class="line"><strong>Macros</strong>: [‘WIND_ALGORITHM_NONE = 0’, ‘WIND_ALGORITHM_HURLEY2002 = 1’, ‘WIND_ALGORITHM_SCHNEIDER2018 = 2’, ‘WIND_ALGORITHM_BINARY_C_2020 = 3’, ‘WIND_ALGORITHM_HENDRIKS_2022 = 4’]</div> <div class="line"><strong>Extra</strong>: 0</div> </div> <div class="line-block"> @@ -765,6 +689,20 @@ <div class="line"><strong>Extra</strong>: Ignore</div> </div> <div class="line-block"> +<div class="line"><strong>Parameter</strong>: PPISN_core_mass_range_shift</div> +<div class="line"><strong>Description</strong>: (Pulsational) Pair-Instability Supernova CO core mass range shift: Value by which we shift the range of CO core mass values that undergo PPISN. This is taken into account in the fit that calculates the mass removal. Negative number is shifting the range to lower masses, positive to higher masses.</div> +<div class="line"><strong>Parameter input type</strong>: Float</div> +<div class="line"><strong>Default value</strong>: 0</div> +<div class="line"><strong>Extra</strong>: Ignore</div> +</div> +<div class="line-block"> +<div class="line"><strong>Parameter</strong>: PPISN_massloss_multiplier</div> +<div class="line"><strong>Description</strong>: (Pulsational) Pair-Instability Supernova CO massloss multiplier: Value by which the (P)PISN massloss is multiplied. Currently only works with the new prescription. THe additional mass loss is not affected multiplied by this.</div> +<div class="line"><strong>Parameter input type</strong>: Float</div> +<div class="line"><strong>Default value</strong>: 1</div> +<div class="line"><strong>Extra</strong>: Ignore</div> +</div> +<div class="line-block"> <div class="line"><strong>Parameter</strong>: use_LWN_fallback</div> <div class="line"><strong>Description</strong>: Flag whether to use the Nazehdin-Lovegrove-Woosley hydrogen envelope ejection at failed supernova.</div> <div class="line"><strong>Parameter input type</strong>: Integer</div> @@ -852,7 +790,7 @@ <div class="line"><strong>Parameter</strong>: sn_kick_distribution_PPISN</div> <div class="line"><strong>Description</strong>: Set the distribution of speeds applied to PPISN supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c).</div> <div class="line"><strong>Parameter input type</strong>: Integer</div> -<div class="line"><strong>Default value</strong>: 1</div> +<div class="line"><strong>Default value</strong>: 0</div> <div class="line"><strong>Macros</strong>: [‘KICK_VELOCITY_FIXED = 0’, ‘KICK_VELOCITY_MAXWELLIAN = 1’, ‘KICK_VELOCITY_CUSTOM = 2’]</div> </div> <div class="line-block"> @@ -939,7 +877,7 @@ <div class="line"><strong>Parameter</strong>: sn_kick_dispersion_PPISN</div> <div class="line"><strong>Description</strong>: Set the dispersion of speeds applied to the survivor of a PPISN supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c).</div> <div class="line"><strong>Parameter input type</strong>: Float</div> -<div class="line"><strong>Default value</strong>: 190</div> +<div class="line"><strong>Default value</strong>: 0</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: sn_kick_dispersion_PISN</div> @@ -1334,7 +1272,7 @@ <div class="line"><strong>Parameter</strong>: MINT_metallicity</div> <div class="line"><strong>Description</strong>: This sets the metallicity for MINT. It is ignored if set to -1.0, the default, in which case the normal metallicity parameter is used.</div> <div class="line"><strong>Parameter input type</strong>: Float</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: -1</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: gaia_Teff_binwidth</div> @@ -1554,9 +1492,27 @@ <div class="line"><strong>Parameter input type</strong>: True|False</div> <div class="line"><strong>Default value</strong>: False</div> </div> +<div class="line-block"> +<div class="line"><strong>Parameter</strong>: degenerate_core_merger_nucsyn</div> +<div class="line"><strong>Description</strong>: If TRUE, assume that in a degnerate core merger, energy is generated from nucleosynthesis of the whole core, and that this can disrupt the core. The BSE algorithm (Hurley et al. 2002) assumes this to be TRUE, but binary_c assumes FALSE by default. (FALSE)</div> +<div class="line"><strong>Parameter input type</strong>: True|False</div> +<div class="line"><strong>Default value</strong>: False</div> +</div> +<div class="line-block"> +<div class="line"><strong>Parameter</strong>: degenerate_core_helium_merger_ignition</div> +<div class="line"><strong>Description</strong>: If TRUE, assume that when there is a degenerate helium core merger, the star reignites helium. This is required to make R-type carbon stars. (TRUE)</div> +<div class="line"><strong>Parameter input type</strong>: True|False</div> +<div class="line"><strong>Default value</strong>: True</div> +</div> +<div class="line-block"> +<div class="line"><strong>Parameter</strong>: degenerate_core_merger_dredgeup_fraction</div> +<div class="line"><strong>Description</strong>: If non-zero, mix this fraction of the degenerate core during a merger.(0.0).</div> +<div class="line"><strong>Parameter input type</strong>: Float</div> +<div class="line"><strong>Default value</strong>: NULL</div> </div> -<div class="section" id="section-binary"> -<h2>Section: binary<a class="headerlink" href="#section-binary" title="Permalink to this headline">¶</a></h2> +</section> +<section id="section-binary"> +<h2>Section: binary<a class="headerlink" href="#section-binary" title="Permalink to this heading">ïƒ</a></h2> <div class="line-block"> <div class="line"><strong>Parameter</strong>: separation</div> <div class="line"><strong>Description</strong>: Set the orbital separation (actually the semi-major axis) of the binary (internal index 0, stellar indices 0 and 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0).</div> @@ -1759,7 +1715,7 @@ <div class="line"><strong>Parameter</strong>: post_ce_objects_have_envelopes</div> <div class="line"><strong>Description</strong>: If TRUE then post-common-envelope objects have thin envelopes. You need this if you are to have post-CE post-AGB stars. Note that this <em>may</em> be unstable, i.e. you may end up having many CEEs. The mass in the envelope is controlled by post_ce_adaptive_menv. TRUE by default.</div> <div class="line"><strong>Parameter input type</strong>: True|False</div> -<div class="line"><strong>Default value</strong>: True</div> +<div class="line"><strong>Default value</strong>: False</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: PN_comenv_transition_time</div> @@ -2316,7 +2272,7 @@ </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: lambda_ce</div> -<div class="line"><strong>Description</strong>: Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to -1 binary_c uses the Dewi and Tauris fits instead, -2 uses the formalism of Wang, Jia and Li (2016) and if -3 then a polytropic formalism is used (see also comenv_splitmass).</div> +<div class="line"><strong>Description</strong>: Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to LAMBDA_CE_DEWI_TAURIS == -1 binary_c uses the Dewi and Tauris fits instead, LAMBDA_CE_WANG_2016 == -2 uses the formalism of Wang, Jia and Li (2016), if LAMBDA_CE_POLYTROPE == -3 then a polytropic formalism is used (see also comenv_splitmass) and if LAMBDA_CE_KLENCKI_2020 == -4 use Klencki et al. (2020).</div> <div class="line"><strong>Parameter input type</strong>: Float</div> <div class="line"><strong>Default value</strong>: 0.5</div> <div class="line"><strong>Macros</strong>: [‘LAMBDA_CE_DEWI_TAURIS = -1’, ‘LAMBDA_CE_WANG_2016 = -2’, ‘LAMBDA_CE_POLYTROPE = -3’, ‘LAMBDA_CE_KLENCKI_2020 = -4’]</div> @@ -2527,7 +2483,7 @@ </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: cbdisc_minimum_fRing</div> -<div class="line"><strong>Description</strong>: Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = <a href="#id1"><span class="problematic" id="id2">|Rout/Rin-1|</span></a> < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS.</div> +<div class="line"><strong>Description</strong>: Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = abs(Rout/Rin-1) < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS.</div> <div class="line"><strong>Parameter input type</strong>: Float</div> <div class="line"><strong>Default value</strong>: 0.2</div> </div> @@ -2716,9 +2672,9 @@ <div class="line"><strong>Parameter input type</strong>: Float</div> <div class="line"><strong>Default value</strong>: 0.05</div> </div> -</div> -<div class="section" id="section-nucsyn"> -<h2>Section: nucsyn<a class="headerlink" href="#section-nucsyn" title="Permalink to this headline">¶</a></h2> +</section> +<section id="section-nucsyn"> +<h2>Section: nucsyn<a class="headerlink" href="#section-nucsyn" title="Permalink to this heading">ïƒ</a></h2> <div class="line-block"> <div class="line"><strong>Parameter</strong>: third_dup</div> <div class="line"><strong>Description</strong>: If True, enables third dredge up. Requires NUCSYN and NUCSYN_THIRD_DREDGE_UP.</div> @@ -2979,13 +2935,48 @@ <div class="line"><strong>Parameter input type</strong>: Float</div> <div class="line"><strong>Default value</strong>: NULL</div> </div> -</div> -<div class="section" id="section-output"> -<h2>Section: output<a class="headerlink" href="#section-output" title="Permalink to this headline">¶</a></h2> +</section> +<section id="section-output"> +<h2>Section: output<a class="headerlink" href="#section-output" title="Permalink to this heading">ïƒ</a></h2> <div class="line-block"> <div class="line"><strong>Parameter</strong>: david_logging_function</div> <div class="line"><strong>Description</strong>: Function to choose which kind of information gets logged Requires DAVID. Choices are: 0= None, >0 for custom logging functions</div> <div class="line"><strong>Parameter input type</strong>: Integer</div> +<div class="line"><strong>Default value</strong>: -1</div> +<div class="line"><strong>Extra</strong>: Ignore</div> +</div> +<div class="line-block"> +<div class="line"><strong>Parameter</strong>: david_tzo_logging</div> +<div class="line"><strong>Description</strong>: Flag to enable logging for TZO project</div> +<div class="line"><strong>Parameter input type</strong>: Integer</div> +<div class="line"><strong>Default value</strong>: 0</div> +<div class="line"><strong>Extra</strong>: Ignore</div> +</div> +<div class="line-block"> +<div class="line"><strong>Parameter</strong>: david_ppisn_logging</div> +<div class="line"><strong>Description</strong>: Flag to enable logging for PPISN project</div> +<div class="line"><strong>Parameter input type</strong>: Integer</div> +<div class="line"><strong>Default value</strong>: 0</div> +<div class="line"><strong>Extra</strong>: Ignore</div> +</div> +<div class="line-block"> +<div class="line"><strong>Parameter</strong>: david_ppisn_single_logging</div> +<div class="line"><strong>Description</strong>: Flag to enable logging for PPISN project capturing single star systems that underwent SN</div> +<div class="line"><strong>Parameter input type</strong>: Integer</div> +<div class="line"><strong>Default value</strong>: 0</div> +<div class="line"><strong>Extra</strong>: Ignore</div> +</div> +<div class="line-block"> +<div class="line"><strong>Parameter</strong>: david_rlof_episode_logging</div> +<div class="line"><strong>Description</strong>: Flag to enable the RLOF episode logging</div> +<div class="line"><strong>Parameter input type</strong>: Integer</div> +<div class="line"><strong>Default value</strong>: 0</div> +<div class="line"><strong>Extra</strong>: Ignore</div> +</div> +<div class="line-block"> +<div class="line"><strong>Parameter</strong>: david_rlof_ensemble_logging</div> +<div class="line"><strong>Description</strong>: Flag to enable the RLOF ensemble logging</div> +<div class="line"><strong>Parameter input type</strong>: Integer</div> <div class="line"><strong>Default value</strong>: 0</div> <div class="line"><strong>Extra</strong>: Ignore</div> </div> @@ -3266,91 +3257,98 @@ <div class="line"><strong>Default value</strong>: NULL</div> <div class="line"><strong>Extra</strong>: Ignore</div> </div> +<div class="line-block"> +<div class="line"><strong>Parameter</strong>: tides_diagnosis_log</div> +<div class="line"><strong>Description</strong>: Enable logging to test MINT tides. Requires MINT. Choices are: 0 disabled, 1 enable lambda test.</div> +<div class="line"><strong>Parameter input type</strong>: Integer</div> +<div class="line"><strong>Default value</strong>: 0</div> +<div class="line"><strong>Extra</strong>: Ignore</div> </div> -<div class="section" id="section-input"> -<h2>Section: input<a class="headerlink" href="#section-input" title="Permalink to this headline">¶</a></h2> +</section> +<section id="section-input"> +<h2>Section: input<a class="headerlink" href="#section-input" title="Permalink to this heading">ïƒ</a></h2> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_dir</div> <div class="line"><strong>Description</strong>: Location of MINT algorithm data.</div> <div class="line"><strong>Parameter input type</strong>: String</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>:</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_data_cleanup</div> <div class="line"><strong>Description</strong>: Activate checks on incoming data to try to account for problems. Will make data-loading slower, but may fix a few things.</div> <div class="line"><strong>Parameter input type</strong>: True|False</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: False</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_MS_rejuvenation</div> <div class="line"><strong>Description</strong>: Turn on or off (hydrogen) main-sequence rejuvenation.</div> <div class="line"><strong>Parameter input type</strong>: True|False</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: True</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_remesh</div> <div class="line"><strong>Description</strong>: Turn on or off MINT’s remeshing.</div> <div class="line"><strong>Parameter input type</strong>: True|False</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: True</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_use_ZAMS_profiles</div> <div class="line"><strong>Description</strong>: Use chemical profiles at the ZAMS if MINT_use_ZAMS_profiles is TRUE, otherwise set homogeneous abundances. (Default is TRUE, so we use the profiles if they are available.)</div> <div class="line"><strong>Parameter input type</strong>: True|False</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: True</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_fallback_to_test_data</div> <div class="line"><strong>Description</strong>: If TRUE, use the MINT test_data directory as a fallback when data is unavailable. (FALSE)</div> <div class="line"><strong>Parameter input type</strong>: True|False</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: False</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_disable_grid_load_warnings</div> <div class="line"><strong>Description</strong>: Use this to explicitly disable MINT’s warnings when loading a grid with, e.g., missing or too much data.</div> <div class="line"><strong>Parameter input type</strong>: True|False</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: False</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_Kippenhahn</div> <div class="line"><strong>Description</strong>: Turn on or off MINT’s Kippenhahn diagrams. If 0, off, if 1, output star 1 (index 0), if 2 output star 2 (index 1). Default 0.</div> <div class="line"><strong>Parameter input type</strong>: Integer</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: 0</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_nshells</div> <div class="line"><strong>Description</strong>: Set the initial number of shells MINT uses in each star when doing nuclear burning. Note: remeshing can change this. If MINT_nshells is 0, shellular burning and other routines that require shells will not be available. (200)</div> <div class="line"><strong>Parameter input type</strong>: Integer</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: 200</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_maximum_nshells</div> <div class="line"><strong>Description</strong>: Set the maximum number of shells MINT uses in each star when doing nuclear burning. Note that this will be limited to MINT_HARD_MAX_NSHELLS. (1000)</div> <div class="line"><strong>Parameter input type</strong>: Integer</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: 1000</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_minimum_nshells</div> <div class="line"><strong>Description</strong>: Set the minimum number of shells MINT uses in each star when doing nuclear burning. Note that this will be greater than or equal to MINT_HARD_MIN_NSHELLS, which is 0 by default. (0)</div> <div class="line"><strong>Parameter input type</strong>: Integer</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: 10</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_Kippenhahn_stellar_type</div> <div class="line"><strong>Description</strong>: Stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for which Kippenhahn plot data should be output.</div> <div class="line"><strong>Parameter input type</strong>: Integer</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: -1</div> <div class="line"><strong>Macros</strong>: [‘LOW_MASS_MS = 0’, ‘MS = 1’, ‘HG = 2’, ‘GIANT_BRANCH = 3’, ‘CHeB = 4’, ‘EAGB = 5’, ‘TPAGB = 6’, ‘HeMS = 7’, ‘HeHG = 8’, ‘HeGB = 9’, ‘HeWD = 10’, ‘COWD = 11’, ‘ONeWD = 12’, ‘NS = 13’, ‘BH = 14’, ‘MASSLESS_REMNANT = 15’]</div> <div class="line"><strong>Extra</strong>:</div> </div> @@ -3358,7 +3356,7 @@ <div class="line"><strong>Parameter</strong>: MINT_Kippenhahn_companion_stellar_type</div> <div class="line"><strong>Description</strong>: Companion stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for the companion for which Kippenhahn plot data should be output.</div> <div class="line"><strong>Parameter input type</strong>: Integer</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: -1</div> <div class="line"><strong>Macros</strong>: [‘LOW_MASS_MS = 0’, ‘MS = 1’, ‘HG = 2’, ‘GIANT_BRANCH = 3’, ‘CHeB = 4’, ‘EAGB = 5’, ‘TPAGB = 6’, ‘HeMS = 7’, ‘HeHG = 8’, ‘HeGB = 9’, ‘HeWD = 10’, ‘COWD = 11’, ‘ONeWD = 12’, ‘NS = 13’, ‘BH = 14’, ‘MASSLESS_REMNANT = 15’]</div> <div class="line"><strong>Extra</strong>:</div> </div> @@ -3366,26 +3364,26 @@ <div class="line"><strong>Parameter</strong>: MINT_nuclear_burning</div> <div class="line"><strong>Description</strong>: Turn on or off MINT’s nuclear burning algorithm.</div> <div class="line"><strong>Parameter input type</strong>: True|False</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: False</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_minimum_shell_mass</div> <div class="line"><strong>Description</strong>: Minimum shell mass in MINT’s nuclear burning routines.</div> <div class="line"><strong>Parameter input type</strong>: Float</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: 1e-06</div> <div class="line"><strong>Extra</strong>:</div> </div> <div class="line-block"> <div class="line"><strong>Parameter</strong>: MINT_maximum_shell_mass</div> <div class="line"><strong>Description</strong>: Maximum shell mass in MINT’s nuclear burning routines. :</div> <div class="line"><strong>Parameter input type</strong>: Float</div> -<div class="line"><strong>Default value</strong>: NULL</div> +<div class="line"><strong>Default value</strong>: 0.1</div> <div class="line"><strong>Extra</strong>:</div> </div> -</div> -<div class="section" id="section-i-o"> -<h2>Section: i/o<a class="headerlink" href="#section-i-o" title="Permalink to this headline">¶</a></h2> +</section> +<section id="section-i-o"> +<h2>Section: i/o<a class="headerlink" href="#section-i-o" title="Permalink to this heading">ïƒ</a></h2> <div class="line-block"> <div class="line"><strong>Parameter</strong>: go</div> <div class="line"><strong>Description</strong>: batchmode control command</div> @@ -3446,9 +3444,9 @@ <div class="line"><strong>Description</strong>: Output batchmode status information.</div> <div class="line"><strong>Extra</strong>: Ignore</div> </div> -</div> -<div class="section" id="section-algorithms"> -<h2>Section: algorithms<a class="headerlink" href="#section-algorithms" title="Permalink to this headline">¶</a></h2> +</section> +<section id="section-algorithms"> +<h2>Section: algorithms<a class="headerlink" href="#section-algorithms" title="Permalink to this heading">ïƒ</a></h2> <div class="line-block"> <div class="line"><strong>Parameter</strong>: repeat</div> <div class="line"><strong>Description</strong>: If > 1, repeats the system as many times as required. Handy if you’re using Monte-Carlo kicks and want to sample the parameter space well. Also, if you are running speed tests this is good to give a statistically more reasonable result. (See e.g. ‘tbse pgo’).</div> @@ -3461,9 +3459,9 @@ <div class="line"><strong>Parameter input type</strong>: Integer</div> <div class="line"><strong>Default value</strong>: 0</div> </div> -</div> -<div class="section" id="section-misc"> -<h2>Section: misc<a class="headerlink" href="#section-misc" title="Permalink to this headline">¶</a></h2> +</section> +<section id="section-misc"> +<h2>Section: misc<a class="headerlink" href="#section-misc" title="Permalink to this heading">ïƒ</a></h2> <div class="line-block"> <div class="line"><strong>Parameter</strong>: random_seed</div> <div class="line"><strong>Description</strong>: Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process).</div> @@ -3535,62 +3533,44 @@ <div class="line"><strong>Default value</strong>: NULL</div> <div class="line"><strong>Extra</strong>: Ignore</div> </div> -</div> -</div> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="grid_options_descriptions.html" class="btn btn-neutral float-right" title="Population grid code options" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="examples/notebook_solar_system.html" class="btn btn-neutral float-left" title="Example use case: Solar system using the API functionality" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="examples/notebook_solar_system.html" class="btn btn-neutral float-left" title="Example use case: Solar system using the API functionality" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="grid_options_descriptions.html" class="btn btn-neutral float-right" title="Population grid code options" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/custom_logging_functions.html b/docs/build/html/custom_logging_functions.html index 631018bef7205da5db1b256b52e81ad0509984d7..9ab5b016c80436e34600a0f96e0042fdd49f24c6 100644 --- a/docs/build/html/custom_logging_functions.html +++ b/docs/build/html/custom_logging_functions.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>custom_logging_functions module — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>custom_logging_functions module — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> - <link rel="next" title="distribution_functions module" href="distribution_functions.html" /> + <link rel="next" title="dicts module" href="dicts.html" /> <link rel="prev" title="Binarycpython code" href="modules.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,30 +38,32 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> <li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> <li class="toctree-l2 current"><a class="current reference internal" href="#">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="ensemble.html">ensemble module</a></li> <li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid.html">Population class module</a></li> <li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> <li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> <li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> <li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> </ul> @@ -107,70 +75,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li><a href="modules.html">Binarycpython code</a> »</li> - <li>custom_logging_functions module</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/custom_logging_functions.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -195,13 +124,13 @@ text-align: unset; } </style> -<div class="section" id="module-binarycpython.utils.custom_logging_functions"> -<span id="custom-logging-functions-module"></span><h1>custom_logging_functions module<a class="headerlink" href="#module-binarycpython.utils.custom_logging_functions" title="Permalink to this headline">¶</a></h1> +<section id="module-binarycpython.utils.custom_logging_functions"> +<span id="custom-logging-functions-module"></span><h1>custom_logging_functions module<a class="headerlink" href="#module-binarycpython.utils.custom_logging_functions" title="Permalink to this heading">ïƒ</a></h1> <p>Module containing functions for the custom logging functionality. The functions here make it possible for the user to define binaryc output logs on runtime</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.custom_logging_functions.autogen_C_logging_code"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">autogen_C_logging_code</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">logging_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#autogen_C_logging_code"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.autogen_C_logging_code" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">autogen_C_logging_code</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">logging_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#autogen_C_logging_code"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.autogen_C_logging_code" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that auto-generates PRINTF statements for binaryc. Input is a dictionary where the key is the header of that logging line and items which are lists of parameters that will be put in that logging line</p> @@ -236,7 +165,7 @@ and items which are lists of parameters that will be put in that logging line</p <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.custom_logging_functions.binary_c_log_code"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">binary_c_log_code</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#binary_c_log_code"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.binary_c_log_code" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">binary_c_log_code</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#binary_c_log_code"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.binary_c_log_code" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to construct the code to construct the custom logging function</p> <p class="rubric">Example</p> <p>Code to log and terminate evolution when the primary star becomes a NS:</p> @@ -281,7 +210,7 @@ and items which are lists of parameters that will be put in that logging line</p <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.custom_logging_functions.binary_c_write_log_code"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">binary_c_write_log_code</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#binary_c_write_log_code"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.binary_c_write_log_code" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">binary_c_write_log_code</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#binary_c_write_log_code"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.binary_c_write_log_code" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to write the generated logging code to a file</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -299,10 +228,9 @@ and items which are lists of parameters that will be put in that logging line</p <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.custom_logging_functions.compile_shared_lib"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">compile_shared_lib</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sourcefile_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">outfile_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#compile_shared_lib"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.compile_shared_lib" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">compile_shared_lib</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sourcefile_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">outfile_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#compile_shared_lib"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.compile_shared_lib" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to write the custom logging code to a file and then compile it.</p> -<p>TODO: nicely put in the -fPIC -TODO: consider returning a status</p> +<p>TODO: consider returning a status</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> @@ -320,7 +248,7 @@ TODO: consider returning a status</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.custom_logging_functions.create_and_load_logging_function"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">create_and_load_logging_function</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">custom_logging_code</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">custom_tmp_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#create_and_load_logging_function"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.create_and_load_logging_function" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">create_and_load_logging_function</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">custom_logging_code</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">custom_tmp_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#create_and_load_logging_function"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.create_and_load_logging_function" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to automatically compile the shared library with the given custom logging code and load it with ctypes.</p> <p>This function is more or less the main function of this module and unless you know what you’re doing with the other functions @@ -343,27 +271,27 @@ I recommend using this in function in combination with a function that generates <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.custom_logging_functions.from_binary_c_config"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">from_binary_c_config</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">config_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flag</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#from_binary_c_config"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.from_binary_c_config" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to run the binaryc_config command with flags</p> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">from_binary_c_config</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">config_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flag</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#from_binary_c_config"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.from_binary_c_config" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to run the <code class="docutils literal notranslate"><span class="pre">binaryc_config</span></code> command with flags</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> -<li><p><strong>config_file</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – binary_c-config filepath TODO: change the name of this</p></li> -<li><p><strong>flag</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – flag used in the binary_c-config call.</p></li> +<li><p><strong>config_file</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <code class="docutils literal notranslate"><span class="pre">binary_c-config</span></code> filepath. TODO: change the name of this</p></li> +<li><p><strong>flag</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – flag used in the <code class="docutils literal notranslate"><span class="pre">binary_c-config</span></code> call.</p></li> </ul> </dd> <dt class="field-even">Return type</dt> <dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></p> </dd> <dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>returns the result of <binary_c-config> <flag></p> +<dd class="field-odd"><p>returns the result of <code class="docutils literal notranslate"><span class="pre"><binary_c-config></span> <span class="pre"><flag></span></code></p> </dd> </dl> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.custom_logging_functions.return_compilation_dict"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">return_compilation_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#return_compilation_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.return_compilation_dict" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.custom_logging_functions.</span></span><span class="sig-name descname"><span class="pre">return_compilation_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/custom_logging_functions.html#return_compilation_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.custom_logging_functions.return_compilation_dict" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to build the compile command for the shared library</p> <p>Inspired by binary_c_inline_config command in Perl</p> <p>TODO: this function still has some cleaning up to do w.r.t. default values for the compile command @@ -381,61 +309,43 @@ I recommend using this in function in combination with a function that generates </dl> </dd></dl> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="distribution_functions.html" class="btn btn-neutral float-right" title="distribution_functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="modules.html" class="btn btn-neutral float-left" title="Binarycpython code" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="modules.html" class="btn btn-neutral float-left" title="Binarycpython code" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="dicts.html" class="btn btn-neutral float-right" title="dicts module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/dicts.html b/docs/build/html/dicts.html new file mode 100644 index 0000000000000000000000000000000000000000..e4c86f81d4ce42a838d3c7b829ba66326d7c5360 --- /dev/null +++ b/docs/build/html/dicts.html @@ -0,0 +1,547 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>dicts module — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> + <script src="_static/jquery.js"></script> + <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="_static/js/theme.js"></script> + <link rel="index" title="Index" href="genindex.html" /> + <link rel="search" title="Search" href="search.html" /> + <link rel="next" title="ensemble module" href="ensemble.html" /> + <link rel="prev" title="custom_logging_functions module" href="custom_logging_functions.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="index.html" class="icon icon-home"></a> »</li> + <li><a href="modules.html">Binarycpython code</a> »</li> + <li>dicts module</li> + <li class="wy-breadcrumbs-aside"> + <a href="_sources/dicts.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.dicts"> +<span id="dicts-module"></span><h1>dicts module<a class="headerlink" href="#module-binarycpython.utils.dicts" title="Permalink to this heading">ïƒ</a></h1> +<p>Module containing functions that binary_c-python uses to modify dictionaries.</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.AutoVivificationDict"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">AutoVivificationDict</span></span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#AutoVivificationDict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.AutoVivificationDict" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +<p>Implementation of perl’s autovivification feature, by overriding the +get item and the __iadd__ operator (<a class="reference external" href="https://docs.python.org/3/reference/datamodel.html?highlight=iadd#object.__iadd__">https://docs.python.org/3/reference/datamodel.html?highlight=iadd#object.__iadd__</a>)</p> +<p>This allows to set values within a subdict that might not exist yet:</p> +<p class="rubric">Example</p> +<p>newdict = {} +newdict[‘example’][‘mass’] += 10 +print(newdict) +>>> {‘example’: {‘mass’: 10}}</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.AutoVivificationDict.__getitem__"> +<span class="sig-name descname"><span class="pre">__getitem__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#AutoVivificationDict.__getitem__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.AutoVivificationDict.__getitem__" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Getitem function for the autovivication dict</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.AutoVivificationDict.__iadd__"> +<span class="sig-name descname"><span class="pre">__iadd__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#AutoVivificationDict.__iadd__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.AutoVivificationDict.__iadd__" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>iadd function (handling the +=) for the autovivication dict.</p> +</dd></dl> + +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.count_keys_recursive"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">count_keys_recursive</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#count_keys_recursive"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.count_keys_recursive" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to recursively count the total number of keys in a dictionary.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>input_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary that we want to know the total amount of keys from.</p> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>total amount of keys within the input_dict.</p> +</dd> +<dt class="field-odd">Return type</dt> +<dd class="field-odd"><p>local_count</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.custom_sort_dict"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">custom_sort_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#custom_sort_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.custom_sort_dict" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Returns a dictionary that is ordered, but can handle numbers better than normal OrderedDict</p> +<p>When the keys of the current dictionary are of mixed type, we first find all the unique types. +Sort that list of type names. Then find the values that fit that type. +Sort those and append them to the sorted keys list. +This is done until all the keys are sorted.</p> +<p>All objects other than dictionary types are directly return as they are</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>input_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – object which will be sorted (and returned as a new object) if its a dictionary, otherwise it will be returned without change.</p> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.filter_dict"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">filter_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">arg_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filter_list</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#filter_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.filter_dict" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to filter out keys that are contains in filter_list</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>arg_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary containing the argument + default key pairs of binary_c</p></li> +<li><p><strong>filter_list</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code>) – lists of keys to be filtered out</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>filtered dictionary</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.filter_dict_through_values"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">filter_dict_through_values</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">arg_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filter_list</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#filter_dict_through_values"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.filter_dict_through_values" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to filter out keys that contain values included in filter_list</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>arg_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary containing the argument + default key pairs of binary_c</p></li> +<li><p><strong>filter_list</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code>) – lists of values to be filtered out</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>filtered dictionary</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.inspect_dict"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">inspect_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">print_structure</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#inspect_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.inspect_dict" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to (recursively) inspect a (nested) dictionary. +The object that is returned is a dictionary containing the key of the input_dict, but as value +it will return the type of what the value would be in the input_dict</p> +<p>In this way we inspect the structure of these dictionaries, rather than the exact contents.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>input_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary you want to inspect</p></li> +<li><p><strong>print_structure</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = True)</p></li> +<li><p><strong>indent</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – (optional, default = 0) indent of the first output</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p><dl class="simple"> +<dt>Dictionary that has the same structure as the input_dict, but as values it has the</dt><dd><p>type(input_dict[key]) (except if the value is a dict)</p> +</dd> +</dl> +</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.keys_to_floats"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">keys_to_floats</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#keys_to_floats"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.keys_to_floats" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to convert all the keys of the dictionary to float to float</p> +<dl class="simple"> +<dt>we need to convert keys to floats:</dt><dd><p>this is ~ a factor 10 faster than David’s <code class="docutils literal notranslate"><span class="pre">recursive_change_key_to_float</span></code> routine, probably because this version only does the float conversion, nothing else.</p> +</dd> +</dl> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>input_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dict of which we want to turn all the keys to float types if possible</p> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>dict of which the keys have been turned to float types where possible</p> +</dd> +<dt class="field-odd">Return type</dt> +<dd class="field-odd"><p>new_dict</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.merge_dicts"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">merge_dicts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dict_1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dict_2</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#merge_dicts"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.merge_dicts" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to merge two dictionaries in a custom way.</p> +<p>Behaviour:</p> +<dl class="simple"> +<dt>When dict keys are only present in one of either:</dt><dd><ul class="simple"> +<li><p>we just add the content to the new dict</p></li> +</ul> +</dd> +<dt>When dict keys are present in both, we decide based on the value types how to combine them:</dt><dd><ul class="simple"> +<li><p>dictionaries will be merged by calling recursively calling this function again</p></li> +<li><p>numbers will be added</p></li> +<li><p>(opt) lists will be appended</p></li> +<li><p>booleans are merged with logical OR</p></li> +<li><p>identical strings are just set to the string</p></li> +<li><p>non-identical strings are concatenated</p></li> +<li><p>NoneTypes are set to None</p></li> +<li><p>In the case that the instances do not match: for now I will raise an error</p></li> +</ul> +</dd> +</dl> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>dict_1</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – first dictionary</p></li> +<li><p><strong>dict_2</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – second dictionary</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>Merged dictionary</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.multiply_float_values"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">multiply_float_values</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">factor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ignore</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#multiply_float_values"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.multiply_float_values" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>A function to recursively multiply values of a (nested) dictionary that are floats by a constant. Nested dictionaries call this function recursively.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>input_dict</strong> – the dictionary</p></li> +<li><p><strong>factor</strong> – the constant that multiplies float values</p></li> +</ul> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.multiply_values_dict"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">multiply_values_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">factor</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#multiply_values_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.multiply_values_dict" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that goes over dictionary recursively and multiplies the value if possible by a factor</p> +<p>If the key equals “general_infoâ€, the multiplication gets skipped.</p> +<p>This function changes the values in-place, so the original dict is modified</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>input_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary of which we want to multiply the values by <factor></p></li> +<li><p><strong>factor</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">complex</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">number</span></code>]) – factor that we want to multiply the values with</p></li> +</ul> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>dict containing the multiplied keys. This is the same object as we passed as input.</p> +</dd> +<dt class="field-odd">Return type</dt> +<dd class="field-odd"><p>multiplied_dict</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.normalize_dict"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">normalize_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">result_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#normalize_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.normalize_dict" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to normalise a dictionary by summing all the values and dividing each term by the total. Designed for dictionary containing only positive values.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>result_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary where values should be positive number objects</p> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>dictionary where the values are normalised to sum to 1</p> +</dd> +<dt class="field-odd">Return type</dt> +<dd class="field-odd"><p>normalized_dict</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.prepare_dict"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">prepare_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">global_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">list_of_sub_keys</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#prepare_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.prepare_dict" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that makes sure that the global dict is prepared to have a value set there. +This dictionary will store values and factors for the distribution functions, +so that they don’t have to be calculated each time.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>global_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – globally accessible dictionary where factors are stored in</p></li> +<li><p><strong>list_of_sub_keys</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code>) – List of keys that must become be(come) present in the global_dict</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.recursive_change_key_to_float"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">recursive_change_key_to_float</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#recursive_change_key_to_float"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.recursive_change_key_to_float" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to recursively change the key to float</p> +<p>This only works if the dict contains just sub-dicts or numbers/strings.</p> +<p>Does not work with lists as values</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>input_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dict of which we want to turn all the keys to float types if possible</p> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>dict of which the keys have been turned to float types where possible</p> +</dd> +<dt class="field-odd">Return type</dt> +<dd class="field-odd"><p>new_dict</p> +</dd> +</dl> +<p>If input_dict is None or empty, returns an empty dict</p> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.recursive_change_key_to_string"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">recursive_change_key_to_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">custom_format</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'{:g}'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#recursive_change_key_to_string"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.recursive_change_key_to_string" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to recursively change the key back to a string but this time in a format that we decide. We’ll try to turn a string key into a float key before formatting the key</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>input_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dict of which we want to turn all the keys to string types (with a custom format)</p></li> +<li><p><strong>custom_format</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – custom format used when turning the key to strings</p></li> +</ul> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>dict of which the keys have been turned to string types where possible</p> +</dd> +<dt class="field-odd">Return type</dt> +<dd class="field-odd"><p>new_dict</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.set_opts"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">set_opts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">opts</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newopts</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#set_opts"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.set_opts" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to take a default dict and override it with newer values.</p> +<p># TODO: consider changing this to just a dict.update</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>opts</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary with default values</p></li> +<li><p><strong>newopts</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary with new values</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>returns an updated dictionary</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.subtract_dicts"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">subtract_dicts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dict_1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dict_2</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#subtract_dicts"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.subtract_dicts" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to subtract two dictionaries, i.e. <code class="docutils literal notranslate"><span class="pre">dict_1</span> <span class="pre">-</span> <span class="pre">dict_2</span></code></p> +<p>Only allows values to be either a dict or a numerical type</p> +<dl> +<dt>For the overlapping keys (key name present in both dicts):</dt><dd><p>When the keys are of the same type: If the types are of numerical type we subtract the value at dict 2 from dict 1. If the types are both dictionaries: call this function with the subdicts</p> +<p>When the keys are not of the same type: If the keys are all of numerical types we do the subtraction. If they are not numerical we raise an error.</p> +</dd> +<dt>For the unique keys:</dt><dd><p>If the key is from dict 1: adds the value to the new dict (be it numerical value or dict)</p> +<p>If the key is from dict 2: Adds the negative of its value in case of numerical type. If the type is a dict, the result of <code class="docutils literal notranslate"><span class="pre">subtract_dicts({},</span> <span class="pre">dict_2[key])</span></code> will be set</p> +</dd> +</dl> +<p>If the result is 0, the key will be removed from the resulting dict.</p> +<p>If that results in an empty dict, the dict will be removed too.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>dict_1</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – first dictionary</p></li> +<li><p><strong>dict_2</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – second dictionary</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>Subtracted dictionary, i.e. <code class="docutils literal notranslate"><span class="pre">dict_1</span> <span class="pre">-</span> <span class="pre">dict_2</span></code></p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.dicts.update_dicts"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.dicts.</span></span><span class="sig-name descname"><span class="pre">update_dicts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dict_1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dict_2</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/dicts.html#update_dicts"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.dicts.update_dicts" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to update dict_1 with values of dict_2 in a recursive way.</p> +<dl> +<dt>Behaviour:</dt><dd><p>When dict keys are only present in one of either: we just add the content to the new dict</p> +<p>When dict keys are present in both, we decide based on the value types how to combine them: value of dict2 will be taken</p> +</dd> +</dl> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>dict_1</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – first dictionary</p></li> +<li><p><strong>dict_2</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – second dictionary</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>New dictionary with Updated values</p> +</dd> +</dl> +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="custom_logging_functions.html" class="btn btn-neutral float-left" title="custom_logging_functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="ensemble.html" class="btn btn-neutral float-right" title="ensemble module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/ensemble.html b/docs/build/html/ensemble.html new file mode 100644 index 0000000000000000000000000000000000000000..1d9b7aa39c565961b786cab7facf7e3e8b0f2bd1 --- /dev/null +++ b/docs/build/html/ensemble.html @@ -0,0 +1,297 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>ensemble module — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> + <script src="_static/jquery.js"></script> + <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="_static/js/theme.js"></script> + <link rel="index" title="Index" href="genindex.html" /> + <link rel="search" title="Search" href="search.html" /> + <link rel="next" title="functions module" href="functions.html" /> + <link rel="prev" title="dicts module" href="dicts.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="index.html" class="icon icon-home"></a> »</li> + <li><a href="modules.html">Binarycpython code</a> »</li> + <li>ensemble module</li> + <li class="wy-breadcrumbs-aside"> + <a href="_sources/ensemble.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.ensemble"> +<span id="ensemble-module"></span><h1>ensemble module<a class="headerlink" href="#module-binarycpython.utils.ensemble" title="Permalink to this heading">ïƒ</a></h1> +<p>Module containing functions to interact with binary_c’s +population ensemble using the binarycpython package</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.BinarycDecoder"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">BinarycDecoder</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">object_hook</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parse_float</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parse_int</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parse_constant</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">strict</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">object_pairs_hook</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#BinarycDecoder"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.BinarycDecoder" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">JSONDecoder</span></code></p> +<p>Custom decoder to transform the numbers that are strings to actual floats</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.BinarycDecoder.decode"> +<span class="sig-name descname"><span class="pre">decode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#BinarycDecoder.decode"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.BinarycDecoder.decode" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Entry point function for decoding</p> +</dd></dl> + +</dd></dl> + +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.BinarycEncoder"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">BinarycEncoder</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">skipkeys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ensure_ascii</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">check_circular</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allow_nan</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sort_keys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">separators</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#BinarycEncoder"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.BinarycEncoder" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">JSONEncoder</span></code></p> +<p>Encoding class function to attempt to convert things to strings.</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.BinarycEncoder.default"> +<span class="sig-name descname"><span class="pre">default</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">o</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#BinarycEncoder.default"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.BinarycEncoder.default" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Converting function. Well, could be more precise. look at the JSON module</p> +</dd></dl> + +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.binaryc_json_serializer"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">binaryc_json_serializer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">obj</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#binaryc_json_serializer"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.binaryc_json_serializer" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Custom serialiser for binary_c to use when functions are present in the dictionary +that we want to export.</p> +<p>Function objects will be turned into str representations of themselves</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>obj</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Any</span></code>) – The object that might not be serialisable</p> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Any</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>Either string representation of object if the object is a function, or the object itself</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.ensemble_compression"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">ensemble_compression</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#ensemble_compression"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.ensemble_compression" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return the compression type of the ensemble file, based on its filename extension.</p> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.ensemble_file_type"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">ensemble_file_type</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#ensemble_file_type"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.ensemble_file_type" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Returns the file type of an ensemble file.</p> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.ensemble_setting"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">ensemble_setting</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ensemble</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parameter_name</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#ensemble_setting"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.ensemble_setting" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to get the setting of parameter_name in the given ensemble, or return the default value.</p> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.extract_ensemble_json_from_string"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">extract_ensemble_json_from_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">binary_c_output</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#extract_ensemble_json_from_string"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.extract_ensemble_json_from_string" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to extract the ensemble_json information from a raw binary_c output string</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>binary_c_output</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – raw binary_c output string</p> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>JSON dictionary with the parsed ENSEMBLE_JSON data</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.format_ensemble_results"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">format_ensemble_results</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ensemble_dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#format_ensemble_results"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.format_ensemble_results" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to handle all the steps of formatting the ensemble output again.</p> +<dl class="simple"> +<dt>Input:</dt><dd><p>ensemble_dictionary: dictionary containing all the ensemble results</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.handle_ensemble_string_to_json"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">handle_ensemble_string_to_json</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">raw_output</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#handle_ensemble_string_to_json"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.handle_ensemble_string_to_json" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that deals with the raw output of the ensemble and +creates a working JSON dictionary out of it.</p> +<p>Having this wrapper makes it easy to</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>raw_output</strong> – raw output of the ensemble dump by binary_c</p> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>json.loads(raw_output, cls=BinarycDecoder)</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.load_ensemble"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">load_ensemble</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">convert_float_keys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">select_keys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timing</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flush</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#load_ensemble"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.load_ensemble" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to load an ensemeble file, even if it is compressed, +and return its contents to as a Python dictionary.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>convert_float_keys</strong> – if True, converts strings to floats.</p></li> +<li><p><strong>select_keys</strong> – a list of keys to be selected from the ensemble.</p></li> +</ul> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.ensemble.open_ensemble"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.ensemble.</span></span><span class="sig-name descname"><span class="pre">open_ensemble</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'utf-8'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/ensemble.html#open_ensemble"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.ensemble.open_ensemble" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to open an ensemble at filename for reading and decompression if required.</p> +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="dicts.html" class="btn btn-neutral float-left" title="dicts module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="functions.html" class="btn btn-neutral float-right" title="functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/example_notebooks.html b/docs/build/html/example_notebooks.html index 39503c396365d7c08558bc56a9f9e802b037db30..1ec5baea297934c8ff05249628fbf92e44a0dc75 100644 --- a/docs/build/html/example_notebooks.html +++ b/docs/build/html/example_notebooks.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Example notebooks — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Example notebooks — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Tutorial: Running individual systems with binary_c-python" href="examples/notebook_individual_systems.html" /> <link rel="prev" title="useful_funcs module" href="useful_funcs.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,17 +38,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> @@ -93,6 +49,7 @@ <li class="toctree-l2"><a class="reference internal" href="examples/notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="examples/notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -108,68 +65,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li>Example notebooks</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/example_notebooks.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -194,8 +113,8 @@ text-align: unset; } </style> -<div class="section" id="example-notebooks"> -<h1>Example notebooks<a class="headerlink" href="#example-notebooks" title="Permalink to this headline">¶</a></h1> +<section id="example-notebooks"> +<h1>Example notebooks<a class="headerlink" href="#example-notebooks" title="Permalink to this heading">ïƒ</a></h1> <p>We have a set of notebooks that explain and show the usage of the binarycpython features. The notebooks are also stored in the examples/ directory in the <a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/master/examples">repository</a></p> <p>The order of the notebooks below is more or less the recommended order to read. The last couple of notebooks are example usecases</p> <div class="toctree-wrapper compound"> @@ -226,13 +145,13 @@ <li class="toctree-l2"><a class="reference internal" href="examples/notebook_extra_features.html#Build-information-of-binary_c">Build information of binary_c</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_extra_features.html#Example-parse-function">Example parse function</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_extra_features.html#Dictionary-modification">Dictionary modification</a></li> -<li class="toctree-l2"><a class="reference internal" href="examples/notebook_extra_features.html#Getting-help">Getting help</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="examples/notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a><ul> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_api_functionality.html#Example-usage:">Example usage:</a></li> </ul> </li> +<li class="toctree-l1"><a class="reference internal" href="examples/notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l1"><a class="reference internal" href="examples/notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a><ul> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_luminosity_function_single.html#Setting-up-the-Population-object">Setting up the Population object</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_luminosity_function_single.html#Adding-grid-variables">Adding grid variables</a></li> @@ -277,61 +196,43 @@ <li class="toctree-l1"><a class="reference internal" href="examples/notebook_solar_system.html">Example use case: Solar system using the API functionality</a></li> </ul> </div> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="examples/notebook_individual_systems.html" class="btn btn-neutral float-right" title="Tutorial: Running individual systems with binary_c-python" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="useful_funcs.html" class="btn btn-neutral float-left" title="useful_funcs module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="useful_funcs.html" class="btn btn-neutral float-left" title="useful_funcs module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="examples/notebook_individual_systems.html" class="btn btn-neutral float-right" title="Tutorial: Running individual systems with binary_c-python" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_BHBH.html b/docs/build/html/examples/notebook_BHBH.html index ae2b99d65a130837840e92fb926954441a92e75f..1c4970d05dd94ba4a088c6f221dcd86586ec25cc 100644 --- a/docs/build/html/examples/notebook_BHBH.html +++ b/docs/build/html/examples/notebook_BHBH.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Example use case: Binary black hole systems — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Example use case: Binary black hole systems — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Example use case: Massive star luminosity" href="notebook_massive_remnants.html" /> <link rel="prev" title="Example use case: Common-envelope evolution" href="notebook_common_envelope_evolution.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -95,6 +51,7 @@ <li class="toctree-l2"><a class="reference internal" href="notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -110,70 +67,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Example use case: Binary black hole systems</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_BHBH.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -384,11 +302,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -397,10 +316,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -412,12 +335,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -444,17 +370,16 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Example-use-case:-Binary-black-hole-systems"> -<h1>Example use case: Binary black hole systems<a class="headerlink" href="#Example-use-case:-Binary-black-hole-systems" title="Permalink to this headline">¶</a></h1> +<section id="Example-use-case:-Binary-black-hole-systems"> +<h1>Example use case: Binary black hole systems<a class="headerlink" href="#Example-use-case:-Binary-black-hole-systems" title="Permalink to this heading">ïƒ</a></h1> <p>TODO: introduce the notebook</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">os</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">temp_dir</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.run_system_wrapper</span> <span class="k">import</span> <span class="n">run_system</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">temp_dir</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.run_system_wrapper</span> <span class="kn">import</span> <span class="n">run_system</span> <span class="n">TMP_DIR</span> <span class="o">=</span> <span class="n">temp_dir</span><span class="p">(</span><span class="s2">"notebooks"</span><span class="p">,</span> <span class="s2">"notebook_BHBH"</span><span class="p">)</span> </pre></div> </div> @@ -463,8 +388,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">log_filename</span> <span class="o">=</span> <span class="s2">"log_file"</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">log_filename</span> <span class="o">=</span> <span class="s2">"log_file"</span> <span class="n">output</span> <span class="o">=</span> <span class="n">run_system</span><span class="p">(</span><span class="n">M_1</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> <span class="n">BH_prescription</span><span class="o">=</span><span class="s1">'BH_BELCZYNSKI'</span><span class="p">,</span> <span class="n">log_filename</span><span class="o">=</span><span class="n">log_filename</span><span class="p">,</span> @@ -501,8 +425,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">output</span> <span class="o">=</span> <span class="n">run_system</span><span class="p">(</span><span class="n">M_1</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">output</span> <span class="o">=</span> <span class="n">run_system</span><span class="p">(</span><span class="n">M_1</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> <span class="n">M_2</span><span class="o">=</span><span class="mi">40</span><span class="p">,</span> <span class="n">orbital_period</span><span class="o">=</span><span class="mi">2000</span><span class="p">,</span> <span class="c1"># days</span> <span class="n">BH_prescription</span><span class="o">=</span><span class="s1">'BH_BELCZYNSKI'</span><span class="p">,</span> @@ -719,9 +642,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> - -<span></span><span class="c1"># BHBH detector : returns BHBH system data, or None if not found</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><br/><span></span><span class="c1"># BHBH detector : returns BHBH system data, or None if not found</span> <span class="k">def</span> <span class="nf">BHBH</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span> <span class="n">vb</span> <span class="o">=</span> <span class="kc">False</span> <span class="c1"># set to True for debugging</span> <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">'r'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> @@ -771,8 +692,7 @@ BHBH system is unbound <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="k">def</span> <span class="nf">search_for_BHBH</span><span class="p">(</span><span class="n">maxcount</span><span class="p">,</span><span class="o">**</span><span class="n">opts</span><span class="p">):</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">search_for_BHBH</span><span class="p">(</span><span class="n">maxcount</span><span class="p">,</span><span class="o">**</span><span class="n">opts</span><span class="p">):</span> <span class="nb">print</span><span class="p">(</span><span class="n">opts</span><span class="p">)</span> <span class="n">found</span> <span class="o">=</span> <span class="kc">False</span> <span class="n">count</span> <span class="o">=</span> <span class="mi">0</span> @@ -808,8 +728,7 @@ BHBH system is unbound <span class="n">wind_mass_loss</span><span class="o">=</span><span class="s1">'WIND_ALGORITHM_BINARY_C_2020'</span><span class="p">,</span> <span class="p">)</span> <span class="n">search_for_BHBH</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span><span class="o">**</span><span class="n">args</span><span class="p">)</span> - -</pre></div> +<br/></pre></div> </div> </div> <div class="nboutput nblast docutils container"> @@ -1124,8 +1043,7 @@ System 100 has separation -154.61 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">args</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">args</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span> <span class="n">M_1</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> <span class="n">M_2</span><span class="o">=</span><span class="mi">40</span><span class="p">,</span> <span class="n">orbital_period</span><span class="o">=</span><span class="mi">2000</span><span class="p">,</span> <span class="c1"># days</span> @@ -1350,8 +1268,7 @@ Found bound BHBH system <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">args</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">args</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span> <span class="n">M_1</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> <span class="n">M_2</span><span class="o">=</span><span class="mi">40</span><span class="p">,</span> <span class="n">metallicity</span><span class="o">=</span><span class="mf">0.001</span><span class="p">,</span> @@ -1423,8 +1340,7 @@ closer, more grvitationally-bound systems).</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[8]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">args</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">args</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span> <span class="n">M_1</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> <span class="n">M_2</span><span class="o">=</span><span class="mi">40</span><span class="p">,</span> <span class="n">metallicity</span><span class="o">=</span><span class="mf">0.0001</span><span class="p">,</span> @@ -1454,8 +1370,7 @@ System 1 has separation -3069.7 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">args</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">args</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span> <span class="n">M_1</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> <span class="n">M_2</span><span class="o">=</span><span class="mi">40</span><span class="p">,</span> <span class="n">metallicity</span><span class="o">=</span><span class="mf">0.001</span><span class="p">,</span> @@ -1470,8 +1385,7 @@ System 1 has separation -3069.7 <span class="n">d</span> <span class="o">=</span> <span class="n">search_for_BHBH</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span><span class="o">**</span><span class="n">args</span><span class="p">)</span> <span class="k">if</span> <span class="n">d</span> <span class="o">!=</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">d</span><span class="p">[</span><span class="s1">'separation'</span><span class="p">]</span> <span class="o"><</span> <span class="mf">10.0</span><span class="p">:</span> <span class="n">found</span> <span class="o">=</span> <span class="kc">True</span> - -</pre></div> +<br/></pre></div> </div> </div> <div class="nboutput nblast docutils container"> @@ -5632,66 +5546,47 @@ system 2 / 100 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> </pre></div> </div> </div> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_massive_remnants.html" class="btn btn-neutral float-right" title="Example use case: Massive star luminosity" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_common_envelope_evolution.html" class="btn btn-neutral float-left" title="Example use case: Common-envelope evolution" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_common_envelope_evolution.html" class="btn btn-neutral float-left" title="Example use case: Common-envelope evolution" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_massive_remnants.html" class="btn btn-neutral float-right" title="Example use case: Massive star luminosity" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_HRD.html b/docs/build/html/examples/notebook_HRD.html index f04d187e2afec3f004c9d4674deb0bde077a19f9..c2c505aa0cdc0e85aa93fa526caeb0b4b6a8ab6a 100644 --- a/docs/build/html/examples/notebook_HRD.html +++ b/docs/build/html/examples/notebook_HRD.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Example use case: Hertzsprung-Russell diagrams — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Example use case: Hertzsprung-Russell diagrams — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Example use case: Common-envelope evolution" href="notebook_common_envelope_evolution.html" /> <link rel="prev" title="Example use case: Zero-age stellar luminosity function in binaries" href="notebook_luminosity_function_binaries.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -95,6 +51,7 @@ <li class="toctree-l2"><a class="reference internal" href="notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">Example use case: Hertzsprung-Russell diagrams</a><ul> @@ -117,70 +74,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Example use case: Hertzsprung-Russell diagrams</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_HRD.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -391,11 +309,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -404,10 +323,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -419,12 +342,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -451,36 +377,33 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Example-use-case:-Hertzsprung-Russell-diagrams"> -<h1>Example use case: Hertzsprung-Russell diagrams<a class="headerlink" href="#Example-use-case:-Hertzsprung-Russell-diagrams" title="Permalink to this headline">¶</a></h1> +<section id="Example-use-case:-Hertzsprung-Russell-diagrams"> +<h1>Example use case: Hertzsprung-Russell diagrams<a class="headerlink" href="#Example-use-case:-Hertzsprung-Russell-diagrams" title="Permalink to this heading">ïƒ</a></h1> <p>In this notebook we compute Hertzsprung-Russell diagrams (HRDs) of single and binary stars.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">os</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span> <span class="kn">import</span> <span class="nn">math</span> <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">temp_dir</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="k">import</span> <span class="n">Population</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">temp_dir</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="kn">import</span> <span class="n">Population</span> <span class="n">TMP_DIR</span> <span class="o">=</span> <span class="n">temp_dir</span><span class="p">(</span><span class="s2">"notebooks"</span><span class="p">,</span> <span class="s2">"notebook_HRD"</span><span class="p">)</span> - -</pre></div> +<br/></pre></div> </div> </div> -<div class="section" id="Setting-up-the-Population-object"> -<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this headline">¶</a></h2> +<section id="Setting-up-the-Population-object"> +<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this heading">ïƒ</a></h2> <p>First we set up a new population object. Our stars evolve to <span class="math notranslate nohighlight">\(13.7\mathrm{Gyr}\)</span>, the age of the Universe, and we assume the metallicity <span class="math notranslate nohighlight">\(Z=0.02\)</span>. These are rough approximations: a real population was born some finite time ago, so cannot possibly evolve to <span class="math notranslate nohighlight">\(13.7\mathrm{Gyr}\)</span>, and stars are not really born with a metallicity of <span class="math notranslate nohighlight">\(0.02\)</span>. These approximations only affect very low mass stars, so we assume all our stars have mass <span class="math notranslate nohighlight">\(M\geq 1 \mathrm{M}_\odot\)</span>, and metallicity does not change evolution too much except in massive stars through the dependence of their winds on metallicity, so we limit our study to <span class="math notranslate nohighlight">\(M\leq 10 \mathrm{M}_\odot\)</span>.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create population object</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create population object</span> <span class="n">population</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> <span class="c1"># Setting values can be done via .set(<parameter_name>=<value>)</span> @@ -494,20 +417,18 @@ does not change evolution too much except in massive stars through the dependenc <span class="n">tmp_dir</span><span class="o">=</span><span class="n">TMP_DIR</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">1</span> <span class="p">)</span> - -</pre></div> -</div> +<br/></pre></div> </div> </div> -<div class="section" id="Stellar-Grid"> -<h2>Stellar Grid<a class="headerlink" href="#Stellar-Grid" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Stellar-Grid"> +<h2>Stellar Grid<a class="headerlink" href="#Stellar-Grid" title="Permalink to this heading">ïƒ</a></h2> <p>We now construct a grid of stars, varying the mass from <span class="math notranslate nohighlight">\(1\)</span> to <span class="math notranslate nohighlight">\(10\mathrm{M}_\odot\)</span> in nine steps (so the masses are integers).</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">binarycpython.utils.distribution_functions</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">binarycpython.utils.distribution_functions</span> <span class="c1"># Set resolution and mass range that we simulate</span> <span class="n">resolution</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"M_1"</span><span class="p">:</span> <span class="mi">10</span><span class="p">}</span> <span class="n">massrange</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">11</span><span class="p">)</span> @@ -554,17 +475,16 @@ Added grid variable: { } </pre></div></div> </div> -</div> -<div class="section" id="Setting-logging-and-handling-the-output"> -<h2>Setting logging and handling the output<a class="headerlink" href="#Setting-logging-and-handling-the-output" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Setting-logging-and-handling-the-output"> +<h2>Setting logging and handling the output<a class="headerlink" href="#Setting-logging-and-handling-the-output" title="Permalink to this heading">ïƒ</a></h2> <p>We now construct the HRD output.</p> <p>We choose stars prior to and including the thermally-pulsing asymptotic giant branch (TPAGB) phase that have <span class="math notranslate nohighlight">\(>0.1\mathrm{M}_\odot\)</span> of material in their outer hydrogen envelope (remember the core of an evolved star is made of helium or carbon/oxygen/neon). This prevents us showing the post-AGB phase which is a bit messy and we avoid the white-dwarf cooling track.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">custom_logging_statement</span> <span class="o">=</span> <span class="s2">"""</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">custom_logging_statement</span> <span class="o">=</span> <span class="s2">"""</span> <span class="s2">Foreach_star(star)</span> <span class="s2">{</span> <span class="s2"> if(star->stellar_type <= TPAGB &&</span> @@ -589,8 +509,7 @@ Added grid variable: { <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">C_logging_code</span><span class="o">=</span><span class="n">custom_logging_statement</span> <span class="p">)</span> - -</pre></div> +<br/></pre></div> </div> </div> <div class="nboutput nblast docutils container"> @@ -626,8 +545,7 @@ Foreach_star(star) <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">datalinedict</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">datalinedict</span> <span class="kn">import</span> <span class="nn">re</span> <span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> @@ -673,9 +591,9 @@ Foreach_star(star) adding: parse_function=<function parse_function at 0x14bf2250fdc0> to grid_options </pre></div></div> </div> -</div> -<div class="section" id="Evolving-the-grid"> -<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Evolving-the-grid"> +<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this heading">ïƒ</a></h2> <p>Now that we configured all the main parts of the population object, we can actually run the population! Doing this is straightforward: <code class="docutils literal notranslate"><span class="pre">population.evolve()</span></code></p> <p>This will start up the processing of all the systems. We can control how many cores are used by settings <code class="docutils literal notranslate"><span class="pre">num_cores</span></code>. By setting the <code class="docutils literal notranslate"><span class="pre">verbosity</span></code> of the population object to a higher value we can get a lot of verbose information about the run, but for now we will set it to 0.</p> <p>There are many grid_options that can lead to different behaviour of the evolution of the grid. Please do have a look at the [grid options docs] (<a class="reference external" href="https://ri0005.pages.surrey.ac.uk/binary_c-python/grid_options_descriptions.html">https://ri0005.pages.surrey.ac.uk/binary_c-python/grid_options_descriptions.html</a>) for more details.</p> @@ -683,8 +601,7 @@ adding: parse_function=<function parse_function at 0x14bf2250fdc0> to grid <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># set number of threads</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># set number of threads</span> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="c1"># verbose output at level 1 is sufficient</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> @@ -825,8 +742,7 @@ dict_keys([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]) <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> </pre></div> </div> </div> @@ -842,12 +758,11 @@ dict_keys([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]) <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[8]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># make an HRD using Seaborn and Pandas</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># make an HRD using Seaborn and Pandas</span> <span class="kn">import</span> <span class="nn">seaborn</span> <span class="k">as</span> <span class="nn">sns</span> <span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> <span class="n">pd</span><span class="o">.</span><span class="n">set_option</span><span class="p">(</span><span class="s2">"display.max_rows"</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="s2">"display.max_columns"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">pad_output_distribution</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">pad_output_distribution</span> <span class="c1"># set up seaborn for use in the notebook</span> <span class="n">sns</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">rc</span><span class="o">=</span><span class="p">{</span><span class="s1">'figure.figsize'</span><span class="p">:(</span><span class="mi">20</span><span class="p">,</span><span class="mi">10</span><span class="p">)})</span> @@ -883,8 +798,7 @@ dict_keys([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]) <span class="n">p</span><span class="o">.</span><span class="n">invert_xaxis</span><span class="p">()</span> <span class="n">p</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s2">"$\log_</span><span class="si">{10}</span><span class="s2"> (T_\mathrm</span><span class="si">{eff}</span><span class="s2"> / \mathrm</span><span class="si">{K}</span><span class="s2">)$"</span><span class="p">)</span> <span class="n">p</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s2">"$\log_</span><span class="si">{10}</span><span class="s2"> (L/$L$_{☉})$"</span><span class="p">)</span> - -</pre></div> +<br/></pre></div> </div> </div> <div class="nboutput docutils container"> @@ -921,16 +835,15 @@ Text(0, 0.5, '$\\log_{10} (L/$L$_{☉})$') </div> </div> <p>We now have an HRD. It took longer to make the plot than to run the stars with <em>binary_c</em>!</p> -</div> -<div class="section" id="Binary-stars"> -<h2>Binary stars<a class="headerlink" href="#Binary-stars" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Binary-stars"> +<h2>Binary stars<a class="headerlink" href="#Binary-stars" title="Permalink to this heading">ïƒ</a></h2> <p>Now we put a secondary star of mass <span class="math notranslate nohighlight">\(0.5\mathrm{M}_\odot\)</span> at a distance of <span class="math notranslate nohighlight">\(10\mathrm{R}_\odot\)</span> to see how this changes things. Then we rerun the population. At such short separations, we expect mass transfer to begin on or shortly after the main sequence.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[9]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">M_2</span> <span class="o">=</span> <span class="mf">0.5</span><span class="p">,</span> <span class="c1"># Msun</span> <span class="n">separation</span> <span class="o">=</span> <span class="mi">10</span><span class="p">,</span> <span class="c1"># Rsun</span> <span class="n">multiplicity</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> <span class="c1"># binaries</span> @@ -1064,9 +977,7 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[10]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> - -<span></span><span class="n">hrd</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'HRD'</span><span class="p">]</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><br/><span></span><span class="n">hrd</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'HRD'</span><span class="p">]</span> <span class="k">for</span> <span class="n">nstar</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">hrd</span><span class="p">):</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"star "</span><span class="p">,</span><span class="n">nstar</span><span class="p">)</span> @@ -1139,8 +1050,7 @@ Text(0, 0.5, '$\\log_{10} (L/$L$_{☉})$') <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[11]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">M_2</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="c1"># Msun</span> <span class="n">separation</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span> <span class="c1"># Rsun</span> <span class="n">multiplicity</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> <span class="c1"># binaries</span> @@ -1276,8 +1186,7 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[12]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">hrd</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'HRD'</span><span class="p">]</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">hrd</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'HRD'</span><span class="p">]</span> <span class="k">for</span> <span class="n">nstar</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">hrd</span><span class="p">):</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"star "</span><span class="p">,</span><span class="n">nstar</span><span class="p">)</span> @@ -1350,8 +1259,7 @@ Text(0, 0.5, '$\\log_{10} (L/$L$_{☉})$') <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[13]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">hrd</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'HRD'</span><span class="p">]</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">hrd</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'HRD'</span><span class="p">]</span> <span class="k">for</span> <span class="n">nstar</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">hrd</span><span class="p">):</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"star "</span><span class="p">,</span><span class="n">nstar</span><span class="p">)</span> @@ -1423,67 +1331,48 @@ very start.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> </pre></div> </div> </div> -</div> -</div> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_common_envelope_evolution.html" class="btn btn-neutral float-right" title="Example use case: Common-envelope evolution" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_luminosity_function_binaries.html" class="btn btn-neutral float-left" title="Example use case: Zero-age stellar luminosity function in binaries" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_luminosity_function_binaries.html" class="btn btn-neutral float-left" title="Example use case: Zero-age stellar luminosity function in binaries" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_common_envelope_evolution.html" class="btn btn-neutral float-right" title="Example use case: Common-envelope evolution" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_api_functionality.html b/docs/build/html/examples/notebook_api_functionality.html index a770dc79965fc814eac81adfabf16e89a9a1e0d9..bd7d9766c5f40124783d0d1786144012172bb4d2 100644 --- a/docs/build/html/examples/notebook_api_functionality.html +++ b/docs/build/html/examples/notebook_api_functionality.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Tutorial: Using the API functionality of binary_c-python — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Tutorial: Using the API functionality of binary_c-python — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> - <link rel="next" title="Example use case: Zero-age stellar luminosity function" href="notebook_luminosity_function_single.html" /> + <link rel="next" title="Tutorial: Generating and handling ensemble data" href="notebook_ensembles.html" /> <link rel="prev" title="Tutorial: Extra features and functionality of binary_c-python" href="notebook_extra_features.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -102,6 +58,7 @@ </li> </ul> </li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -117,70 +74,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Tutorial: Using the API functionality of binary_c-python</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_api_functionality.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -391,11 +309,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -404,10 +323,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -419,12 +342,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -451,8 +377,8 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Tutorial:-Using-the-API-functionality-of-binary_c-python"> -<h1>Tutorial: Using the API functionality of binary_c-python<a class="headerlink" href="#Tutorial:-Using-the-API-functionality-of-binary_c-python" title="Permalink to this headline">¶</a></h1> +<section id="Tutorial:-Using-the-API-functionality-of-binary_c-python"> +<h1>Tutorial: Using the API functionality of binary_c-python<a class="headerlink" href="#Tutorial:-Using-the-API-functionality-of-binary_c-python" title="Permalink to this heading">ïƒ</a></h1> <p>This notebook shows how to use the API functions that interface with binary_c. It usually is better to use wrapper functions that internally use these API functions, because most of the output here is very raw</p> <p>Binarycpython uses the Python-C extension framework to interface Python with C. The sourcecode for this is contained in <code class="docutils literal notranslate"><span class="pre">src/binary_c_python.c</span></code>, and the functions are available via <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">binarycpython</span> <span class="pre">import</span> <span class="pre">_binary_c_bindings</span></code>.</p> <p>The following functions are available through the API: (run cell below)</p> @@ -460,8 +386,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython</span> <span class="k">import</span> <span class="n">_binary_c_bindings</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">_binary_c_bindings</span> <span class="n">help</span><span class="p">(</span><span class="n">_binary_c_bindings</span><span class="p">)</span> </pre></div> </div> @@ -553,7 +478,7 @@ FUNCTIONS Function that contains random snippets. Do not expect this to remain available, or reliable. i.e. dont use it. FILE - /home/izzard/.local/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so + /home/david/.pyenv/versions/binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so </pre></div></div> @@ -583,16 +508,15 @@ FILE </ul> </li> </ul> -<div class="section" id="Example-usage:"> -<h2>Example usage:<a class="headerlink" href="#Example-usage:" title="Permalink to this headline">¶</a></h2> -<div class="section" id="Setting-up,-using-and-freeing-store"> -<h3>Setting up, using and freeing store<a class="headerlink" href="#Setting-up,-using-and-freeing-store" title="Permalink to this headline">¶</a></h3> +<section id="Example-usage:"> +<h2>Example usage:<a class="headerlink" href="#Example-usage:" title="Permalink to this heading">ïƒ</a></h2> +<section id="Setting-up,-using-and-freeing-store"> +<h3>Setting up, using and freeing store<a class="headerlink" href="#Setting-up,-using-and-freeing-store" title="Permalink to this heading">ïƒ</a></h3> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># allocating store memory</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># allocating store memory</span> <span class="n">store_memaddr</span> <span class="o">=</span> <span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">return_store_memaddr</span><span class="p">()</span> <span class="nb">print</span><span class="p">(</span><span class="n">store_memaddr</span><span class="p">)</span> @@ -621,21 +545,20 @@ FILE </div> <div class="output_area docutils container"> <div class="highlight"><pre> -<capsule object "STORE" at 0x146f912dbc60> +<capsule object "STORE" at 0x7fc1f0c3ff00> SINGLE_STAR_LIFETIME 10 28.4838 </pre></div></div> </div> -</div> -<div class="section" id="Getting-information-from-binary_c"> -<h3>Getting information from binary_c<a class="headerlink" href="#Getting-information-from-binary_c" title="Permalink to this headline">¶</a></h3> +</section> +<section id="Getting-information-from-binary_c"> +<h3>Getting information from binary_c<a class="headerlink" href="#Getting-information-from-binary_c" title="Permalink to this heading">ïƒ</a></h3> <p>We can get information for a parameter via return_help(parameter_name): This will return an unparsed output</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="nb">print</span><span class="p">(</span><span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">return_help</span><span class="p">(</span><span class="s1">'M_1'</span><span class="p">))</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">return_help</span><span class="p">(</span><span class="s1">'M_1'</span><span class="p">))</span> </pre></div> </div> </div> @@ -660,8 +583,8 @@ Default : 0 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="nb">print</span><span class="p">(</span><span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">return_help_all</span><span class="p">())</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">return_help_all</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[:</span><span class="mi">10</span><span class="p">]))</span> +<span class="nb">print</span><span class="p">(</span><span class="s2">"(abridged)"</span><span class="p">)</span> </pre></div> </div> </div> @@ -680,581 +603,7 @@ M_1 : The initial mass of star one (in solar units, internally this is star inde M_2 : The initial mass of star two (in solar units, internally this is star index 1). : (null) M_3 : The initial mass of star three (in solar units, internally this is star index 2). : (null) M_4 : The initial mass of star four (in solar units, internally this is star index 3). : (null) -vrot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot2,3,4. : (null) -vrot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,3,4. : (null) -vrot3 : The initial equatorial rotational velocity of star three (in km/s, internally this is star index 2). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,4. : (null) -vrot4 : The initial equatorial rotational velocity of star four (in km/s, internally this is star index 3). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,3. : (null) -Prot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). See also Prot2,3,4. : (null) -Prot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). See also Prot1,3,4. : (null) -Prot3 : The initial equatorial rotational period of star three (in days, internally this is star index 2). See also Prot1,2,4. : (null) -Prot4 : The initial equatorial rotational period of star four (in days, internally this is star index 3). See also Prot1,2,3. : (null) -inclination1 : The initial inclination of star one (in degrees). : (null) -inclination2 : The initial inclination of star two (in degrees). : (null) -inclination3 : The initial inclination of star three (in degrees). : (null) -inclination4 : The initial inclination of star four (in degrees). : (null) -B_1 : The initial magnetic field of star one (in Gauss, internally this is star index 0). : (null) -B_2 : The initial magnetic field of star two (in Gauss, internally this is star index 1). : (null) -B_3 : The initial magnetic field of star three (in Gauss, internally this is star index 2). : (null) -B_4 : The initial magnetic field of star four (in Gauss, internally this is star index 3). : (null) -B_inclination1 : The initial inclination of the magnetic field of star one (in degrees). : (null) -B_inclination2 : The initial inclination of the magnetic field of star two (in degrees). : (null) -B_inclination3 : The initial inclination of the magnetic field of star three (in degrees). : (null) -B_inclination4 : The initial inclination of the magnetic field of star four (in degrees). : (null) -stellar_type_1 : Set the stellar type of star 1 (internal index 0), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null) -stellar_type_2 : Set the stellar type of star 2 (internal index 1), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null) -stellar_type_3 : Set the stellar type of star 3 (internal index 2), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null) -stellar_type_4 : Set the stellar type of star 4 (internal index 3), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null) -max_stellar_type_1 : The maximum stellar type of star 1 (internal index 0). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value. - : (null) -max_stellar_type_2 : The maximum stellar type of star 2 (internal index 1). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value. - : (null) -max_stellar_type_3 : The maximum stellar type of star 3 (internal index 2). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value. - : (null) -max_stellar_type_4 : The maximum stellar type of star 4 (internal index 3). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value. - : (null) -probability : The probability is a weighting applied to the star based on, say, the initial mass function. When running a grid of stars to simulate *all* stars, the summed probability of all the stars should be 1.0. : (null) -phasevol : The system's phase volume, used by binary_grid. : (null) -stellar_structure_algorithm : Set the stellar structure algorithm. 0=modified BSE (default), 1=none, 2=external function (must be defined by the calling code), 3=binary_c (not yet implemented). : (null) -solver : The type of solver. Default is the Forward-Euler (0), but could be RK2 (1), RK4 (2) or a predictor-corretor (3). : (null) -max_evolution_time : Set the maximum age for the stars (Myr). : (null) -max_model_number : Set the maximum number of models, ignored if 0 (default is 0). : (null) -monte_carlo_kicks : Turn on Monte-Carlo SN kicks. On (True) by default, and indeed other algorithms are probably broken. : (null) -disable_debug : Disables debug output. Only has an effect when DEBUG is 1, which probably requires a rebuild. Default FALSE. : (null) -timestep_logging : Turn on timestep logging (default is False). : (null) -rejects_in_log : Show timestep rejections in the main log (default is False). : (null) -vandenHeuvel_logging : Turn on van den Heuvel logging (default is False). : (null) -evolution_splitting : If True, turn on splitting of an evolutionary run if splitpoint (e.g. supernova) occurs. : (null) -disable_events : Whether to disable the new events code (defaults to False, so we use events by default) - : (null) -evolution_splitting_sn_eccentricity_threshold : Threshold eccentricity above which evolution splitting happens in a system with no SN kick. (0.01) : (null) -evolution_splitting_sn_n : Number of runs to split into when a SN occurs. : (null) -evolution_splitting_maxdepth : Max number of splits in an evolutionary run. : (null) -equation_of_state_algorithm : Set the equation of state algorithm. 0 = Paczynski. : (null) -opacity_algorithm : Set the opacity algorithm. 0 = Paczynski, 1 = Ferguson/Opal. : (null) -wind_mass_loss : Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018). : 0 -gbwind : Wind prescription for first red giant branch stars. 0=Reimers (Hurley et al 2000/2002; choose gb_reimers_eta=0.5 for their mass loss rate), 1=Schroeder+Cuntz 2005 (set gb_reimers_eta=1.0 for their mass loss rate). : (null) -postagbwind : Apply special post-(A)GB prescription. Default is POSTAGB_WIND_USE_GIANT which means we just use whatever is prescribed on the giant branch. Other options include: POSTAGB_WIND_NONE = 1 (no wind on the post (A)GB), POSTAGB_WIND_KRTICKA2020 = 2 which uses Krticka, Kubát and Krticková (2020, A&A 635, A173). : (null) -Teff_postAGB_min : The minimum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_max. (6000 K) : (null) -Teff_postAGB_max : The maximum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_min. (120000 K) : (null) -mattsson_Orich_tpagbwind : Experimental : turns on Mattsson's TPAGB wind when the star is oxygen rich. Requires MATTSSON_MASS_LOSS. : (null) -magnetic_braking_factor : Multiplier for the magnetic braking angular momentum loss rate. : (null) -magnetic_braking_gamma : gamma factor in Rappaport style magnetic braking expression. : (null) -magnetic_braking_algorithm : Algorithm for the magnetic braking angular momentum loss rate. 0 = Hurley et al. 2002, 1 = Andronov, Pinnsonneault and Sills 2003, 2 = Barnes and Kim 2010 : (null) -helium_flash_mass_loss : Mass to be lost at the helium flash. : (null) -gb_reimers_eta : First red giant branch wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) : (null) -gbwindfac : Multiplier for the giant branch wind mass loss rate : (null) -tpagbwindfac : Multiplier for the TPAGB wind mass loss rate : (null) -eagbwindfac : Multiplier for the EAGB wind mass loss rate : (null) -nieuwenhuijzen_windfac : Multiplier for the Nieuwenhuijzen & de Jager wind mass loss rate : (null) -tpagbwind : Wind prescription during the TPAGB. 0=Karakas 2002 (a modified Vassiliadis and Wood 1993), 1=Hurley et al 2000/2002 (Vassiliadis and Wood 1993), 2=Reimers, 3=Bloecker, 4=Van Loon, 5=Rob's C-wind (broken?), 6,7=Vassiliadis and Wood 1993 (Karakas,Hurley variants respectively) when C/O>1, 8=Mattsson, 9 = Goldman et al. (2017), 10 = Beasor et al. (2020). : (null) -eagbwind : Wind prescription during the EAGB. 0=BSE (Hurley+2002, based on VW93), 1 = Goldman et al. (2017), 2 = Beasor et al. (2020). : (null) -wind_gas_to_dust_ratio : Gas to dust ratio used in wind calculations (e.g. Goldman et al. 2017). Typically 200 (Milky Way)-500 (Magellanic Clouds). Default is 200, approximately as in MW stars. : (null) -vwind_multiplier : Multiplier for the stellar wind velocity. : (null) -vwind_beta : Beta for stellar wind speed calculations, where vwind=sqrt(beta) * escape velocity. Default 0.125 (from BSE, Hurley et al. 2002). : (null) -superwind_mira_switchon : In the Vassiliadis and Wood (1993) AGB wind prescription, the superwind is turned on at a given Mira period, usually 500 days. You can vary when this switch-on happens with this parameter. : (null) -vw93_mira_shift : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate depends on the Mira period plus this offset. Requires VW93_MIRA_SHIFT. : (null) -vw93_multiplier : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate is multiplied by this factor. Requires VW93_MULTIPLIER. : (null) -tpagb_reimers_eta : TPAGB Reimers wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) Note that Reimers is not the default TPAGB wind prescription. See also tpagbwind. : (null) -Tout_Pringle_1992_multiplier : Multiplier for the Tout & Pringle (1992) magnetic wind. (0.0) : (null) -artificial_mass_accretion_rate%d : Constant mass accretion rate for star <n>. : (null) -artificial_mass_accretion_rate_by_stellar_type%d : Constant mass accretion rate for stellar type <n>. : (null) -artificial_angular_momentum_accretion_rate%d : Constant angular momentum accretion for star <n>. : (null) -artificial_orbital_angular_momentum_accretion_rate : Constant angular momentum accretion rate on the orbit. : (null) -artificial_accretion_start_time : Time at which artificial accretion stars. Ignored if <0 (default is -1). : (null) -artificial_accretion_end_time : Time at which artificial accretion ends. Ignored if <0 (default is -1). : (null) -wr_wind : Massive-star (WR) wind prescription. 0 = Hurley et al 2000/2002, 1=Maeder and Meynet, 2=Nugis and Lamers, 3=John Eldridge's version of Vink's early-2000s wind (See Lynnette Dray's thesis, or John Eldridge's thesis) : (null) -wr_wind_fac : Massive-star (WR) wind multiplication factor. : (null) -wrwindfac : Massive-star (WR) wind multiplication factor. Synonymous with wr_wind_fac (which you should use instead). : (null) -BH_prescription : Black hole mass prescrition: relates the mass of a newly formed black hole to its progenitor's (CO) core mass. BH_HURLEY2002 = 0 = Hurley et al 2000/2002, BH_BELCZYNSKI = 1 = Belczynski (early 2000s), BH_SPERA2015 = Spera+ 2015, BH_FRYER12_DELAYED = 3 = Fryer et al. (2012) delayed prescription, BH_FRYER12_RAPID = 4 = Fryer et al. (2012) rapid prescription, BH_FRYER12_STARTRACK = 5 = Fryer et al. (2012) startrack prescription. : (null) -sn_kick_distribution_II : Set the distribution of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_distribution_ECAP : Set the distribution of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_distribution_NS_NS : Set the distribution of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_distribution_IBC : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_distribution_GRB_COLLAPSAR : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_distribution_TZ : Set the distribution of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_distribution_AIC_BH : Set the distribution of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_distribution_BH_BH : Set the distribution of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_distribution_BH_NS : Set the distribution of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_distribution_IA_Hybrid_HeCOWD : Set the distribution of speeds applied to any survivor of a hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_distribution_IA_Hybrid_HeCOWD_subluminous : Set the distribution of speeds applied to any survivor of a subluminous hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_II : Set the dispersion of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_ECAP : Set the dispersion of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_NS_NS : Set the dispersion of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_IBC : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_GRB_COLLAPSAR : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_TZ : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_AIC_BH : Set the dispersion of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_BH_BH : Set the dispersion of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_BH_NS : Set the dispersion of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_IA_Hybrid_HeCOWD : Set the dispersion of speeds applied to the survivor of a SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_dispersion_IA_Hybrid_HeCOWD_subluminous : Set the dispersion of speeds applied to the survivor of a subluminous SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null) -sn_kick_companion_IA_He : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia He supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_IA_ELD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia ELD (sub-Mch) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_IA_CHAND : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_AIC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an accretion induced collapse (supernova) occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_ECAP : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an electron capture supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_IA_He_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia helium merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_IA_CHAND_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_NS_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron-star neutron-star merger. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_GRB_COLLAPSAR : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a GRB Collapsar (rapidly rotating SN Ibc) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_HeStarIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a He-star Ia supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_IBC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type Ib/c supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_II : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type II supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_IIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type IIa supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_WDKICK : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a WD is kicked. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_TZ : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Thorne-Zytkow object is formed. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_AIC_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron star collapses to a black hole. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_BH_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when two black holes merge. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_BH_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a black hole merges with a neutron star. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_IA_Hybrid_HeCOWD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -sn_kick_companion_IA_Hybrid_HeCOWD_subluminous : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a subluminous hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null) -wd_sigma : Set the speed at which white dwarfs are kicked when they form, in km/s. Default is zero (i.e. no kick). Requires WD_KICKS. : (null) -wd_kick_direction : Set the direction of white dwarf kicks. 0 = random, 1 = up, 2 = forward, 3 = backward, 4 = inward, 5 = outward. Requires WD_KICKS. : (null) -wd_kick_when : Decide when to kick a white dwarf. 0=at birth, 1=at first RLOF, 2=at given pulse number (see wd_kick_pulse_number), 3 at every pulse Requires WD_KICKS. : (null) -wd_kick_pulse_number : Apply a kick to a star at a desired pulse number on the TPAGB (i.e. pre-WD). Requires WD_KICKS. : (null) -minimum_helium_ignition_core_mass : Minimum helium core mass required to ignite helium in the case that the hydrogen envelope is stripped on the giant branch, e.g. to make an sdB or sdO star. Typically 0.4, if 0.0 then the BSE algorithm (based on the total mass) is used. : (null) -minimum_CO_core_mass_for_carbon_ignition : Minimum CO core mass for carbon ignition, assuming Mc,bagb>1.6Msun. Typically around 1.08Msun (Pols+1998). : (null) -minimum_CO_core_mass_for_neon_ignition : Minimum CO core mass for neon ignition. Typically around 1.42Msun. Stars that have cores that ignite carbon, but not neon explode in electon-capture supernovae. : (null) -minimum_mcbagb_for_nondegenerate_carbon_ignition : Minimum Mc,bagb (core mass at the base of the AGB) for non-degenerate carbon ignition. Typically around 2.25Msun (Pols+1998). : (null) -maximum_mcbagb_for_degenerate_carbon_ignition : Maximum Mc,bagb (core mass at the base of the AGB) for degenerate carbon ignition. Typically around 1.6Msun (Pols+1998). : (null) -max_neutron_star_mass : Maximum mass of a neutron star before it collapses to a black hole. Typically around 2Msun. : (null) -chandrasekhar_mass : The Chandrasekhar mass, usually 1.44Msun : (null) -delta_mcmin : A parameter to reduce the minimum core mass for third dredge up to occur on the TPAGB. As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null) -lambda_min : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. See also lambda_multiplier. : (null) -lambda_multiplier : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null) -minimum_envelope_mass_for_third_dredgeup : The minimum envelope mass for third dredge up on the TPAGB. Early, solar metallicity models by Straniero et al suggested 0.5Msun is typical. However, circumstantial evidence (Izzard et al 2009) as well as newer models by Stancliffe and Karakas suggest that at low metallicity a value nearer zero is more appropriate. : (null) -mass_of_pmz : The mass in the partial mixing zone of a TPAGB star, using the Karakas 2012 tables. Ask Carlo Abate for more details, or see the series of papers Abate et al 2012, 2013, 2014. Requires NUCSYN and USE_TABULAR_INTERSHELL_ABUNDANCES_KARAKAS_2012. : (null) -c13_eff : The "efficiency" of partial mixing in a TPAGB star intershell region, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null) -mc13_pocket_multiplier : Multiplies the mass in the partial mixing zone of a TPAGB star, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null) -tides_convective_damping : Tidal convective damping algorithm. 0=TIDES_HURLEY2002 Zahn 197x timescales + Hut, as in Hurley et al (2002), 1 = TIDES_ZAHN1989 : Zahn 1989 lambdas + Hut. : (null) -E2_prescription : Choose how to calculate the E2 structural parameter (used in tidal timescale calculations). 0=Hurley 1=Izzard (see Siess et al 2013). : (null) -dtfac : A parameter to decrease the timestep ONLY during the TPAGB phase. : (null) -hbbtfac : A parameter to modulate the temperature at the base of the hot-bottom burning zone in TPAGB stars. (Works only if NUCSYN is defined) : (null) -wind_multiplier_%d : Wind multiplier for the stellar type specified by the intger %d. By default these are all 1.0. : (null) -wind_type_multiplier_%d : Wind multiplier for different types of wind (MS, GB, AGB, WR, LBV, OTHER), given by the integer %d. By default these are all 1.0. : (null) -pre_main_sequence : Set to True to turn on pre-main sequence evolution. Currently this is not a special stellar type, rather the first (small) fraction of the main sequence has increased radii to match the Railton et al 2014 fits to Tout's pre-main sequence stars. Requires PRE_MAIN_SEQUENCE. See also pre_main_sequence_fit_lobes. : (null) -pre_main_sequence_fit_lobes : Set to True force a pre-main sequence star into its Roche lobe. This is done by artificially aging it. Requires PRE_MAIN_SEQUENCE : (null) -small_envelope_method : Choose the method used to determine the stellar radius when the envelope mass is very thin. 0 = Hurley et al. (2002), 1 = Miller Bertolami et al. (2016+) for GB and AGB stars only. : (null) -timestep_modulator : Multiplier applied to the global timestep. Requires TIMESTEP_MODULATION. : (null) -timestep_multiplier%d : Multiplier applied to timestep limit <n>. : (null) -maximum_timestep : The maximum timestep (MYr). : (null) -zoomfac_multiplier_decrease : When a timestep is rejected, decrease the timestep by this factor (0.5). : (null) -zoomfac_multiplier_increase : When a timestep is rejected, zooms, then succeeds, increase the timestep by this factor (1.2). : (null) -maximum_timestep_factor : The maximum factor between two subsequent timesteps (1.2). : (null) -maximum_nuclear_burning_timestep : The maximum timestep (MYr) in any nuclear burning phase. : (null) -nova_retention_method : Algorithm used to calculate the amount of mass retained during a nova explosion. 0=use nova_retention_fraction. (other methods pending) : (null) -MINT_metallicity : This sets the metallicity for MINT. It is ignored if set to -1.0, the default, in which case the normal metallicity parameter is used. : (null) -gaia_Teff_binwidth : log10(Effective temperature) bin width used to make Gaia-like HRDs - : (null) -gaia_L_binwidth : log10(luminosity) bin width used to make Gaia-like HRDs - : (null) -gaia_colour_transform_method : Use this to select the method used to transform to Gaia colours from other colour schemes. GAIA_CONVERSION_UBVRI_UNIVARIATE_JORDI2010 = 0 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_UBVRI_BIVARIATE_JORDI2010 = 1 Jordi et al.'s bivariate UBVRI fits, GAIA_CONVERSION_ugriz_UNIVARIATE_JORDI2010 = 2 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_ugriz_BIVARIATE_JORDI2010 = 3 Jordi et al.'s univariate ugriv fits, GAIA_CONVERSION_UBVRI_UNIVARIATE_EVANS2018 = 4 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_ugriz_UNIVARIATE_EVANS2018 = 5 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_UBVRI_RIELLO2020 = 6 Riello et al. (2020, DR3) fits, GAIA_CONVERSION_ugriz_RIELLO2020 = 7 Riello et al. (2020, DR3) fits. : (null) -rotationally_enhanced_mass_loss : Set to 1 to enable rotationally enhanced mass loss rate algorithms: 0= none, 1=formula cf. Langer models (=ROTATIONALLY_ENHANCED_MASSLOSS_LANGER_FORMULA), 2=limit accretion rate before wind loss is applied, 3 = both 1 and 2. See also rotationally_enhanced_exponent : (null) -AGB_core_algorithm : Algorithm to use for calculating AGB core masses. 0=Hurley et al. 2002 if no NUCSYN, Karakas 2002 if NUCSYN is defined; 1=Hurley et al. 2002 (overshooting models); 1=Karakas 2002 (non-overshooting models). : (null) -AGB_radius_algorithm : Algorithm to use for calculating radii on the TPAGB. : (null) -AGB_luminosity_algorithm : Algorithm to use for calculating luminosities on the TPAGB. : (null) -AGB_3dup_algorithm : Algorithm to use for calculating third dredge up efficiency on the TPAGB. : (null) -overspin_algorithm : Algorithm to determine what we do when a star is rotating at its breakup velocity. OVERSPIN_BSE (0) conservatively transfers the angular momentum back to the orbit. OVERSPIN_MASSLOSS uses the rotationally_enhanced_massloss parameter to lose mass which carries away the angular momentum. : (null) -rotationally_enhanced_exponent : The exponent (power) by which rotationally enhanced mass loss is raised. Requires ROTATIONALLY_ENHANCED_MASS_LOSS. See also rotationally_enhanced_mass_loss. : (null) -batchmode : Set the batchmode control variable. Use only if you know what you are doing! : (null) -speedtests : If True, turns on speedtests during version information (off by default). : (null) -use_fixed_timestep_%d : Set to True to use fixed timestep <n>, False to turn off. Fixed timesteps are on (this is True) by default. : (null) -task%d : Control tasks to be performed by binary_c. By default, these are all TRUE. For more information see binary_c_macros.h, particularly the BINARY_C_TASK_* macros. : (null) -orbiting_object : Usage: --orbiting_object mass,spinrate,central_object,period. : 1.0 -orbiting_objects_log : If True, turn on orbiting-object log. : (null) -orbiting_objects_log : If True, turn on orbiting-object log. : (null) -orbiting_objects_wind_accretion_multiplier : Multiplier for wind accretion on orbiting objects. Hurley et al 2002 use 1.5, which is the default. : (null) -orbiting_objects_close_pc_threshold : How close are orbiting objects allowed to be? Set this to be the absolute percentage difference minimum. : (null) -orbiting_objects_tides_multiplier : Multiplier for tidal torques on orbiting objects. : (null) -evaporate_escaped_orbiting_objects : If True, evaporate orbiting objects that have escaped the system. : (null) -RLOF_transition_objects_escape : If True, objects that escape their Roche lobe are ejected from the system, otherwise they are placed just outside the minimum stable orbit. : (null) -PN_resolve : If True, the timestep will be shortened to resolve better the PN phase (FALSE). : (null) -PN_resolve_minimum_luminosity : The luminosity above which extra time resolution for PNe is applied (see PN_resolve). : (null) -PN_resolve_maximum_envelope_mass : The envelope mass below which extra time resolution for PNe is applied (see PN_resolve). : (null) -PN_resolve_minimum_effective_temperature : The minimum effective temperature above which extra time resolution for PNe is applied (see PN_resolve). : (null) -PN_fast_wind : If True, thin-envelope PNe will have fast winds (FALSE). : (null) -PN_fast_wind_dm_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null) -PN_fast_wind_mdot_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null) -PN_fast_wind_dm_AGB : The envelope mass below which fast wind used during the AGB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null) -PN_fast_wind_mdot_AGB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null) -HeWD_HeWD_ignition_mass : HeWD-HeWD mergers above this mass reignite helium. (0.3) : (null) -wind_Nieuwenhuijzen_luminosity_lower_limit : Above this luminosity we activate the Nieuwenhuijzen and de Jager wind (4e3 Lsun). : (null) -wind_LBV_luminosity_lower_limit : Above this luminosity we activate the LBV wind (6e5 Lsun). : (null) -colour%d : Sets colour %d (0 to NUM_ANSI_COLOURS-1) to the extended ANSI set colour you choose (1-255, 0 means ignore). The colour numbers are defined in src/logging/ansi_colours.h : (null) -apply_Darwin_Radau_correction : Apply Darwin-Radau correction to the moment of inertia to take rotation into account? : (null) -degenerate_core_merger_nucsyn : If TRUE, assume that in a degnerate core merger, energy is generated from nucleosynthesis of the whole core, and that this can disrupt the core. The BSE algorithm (Hurley et al. 2002) assumes this to be TRUE, but binary_c assumes FALSE by default. (FALSE) : (null) -degenerate_core_helium_merger_ignition : If TRUE, assume that when there is a degenerate helium core merger, the star reignites helium. This is required to make R-type carbon stars. (TRUE) : (null) -degenerate_core_merger_dredgeup_fraction : If non-zero, mix this fraction of the degenerate core during a merger.(0.0). : (null) - -############################################################ -##### Section Binary -############################################################ -separation : Set the orbital separation (actually the semi-major axis) of the binary (internal index 0, stellar indices 0 and 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null) -separation_triple : Set the orbital separation (actually the semi-major axis) of the triple (internal index 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null) -separation_quadruple : Set the orbital separation (actually the semi-major axis) of the quadruple (internal index 2) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null) -orbital_period : Set the initial orbital period of the binary, stars 1 and 2 (internal indices 0 and 1) in days. See also separation. : (null) -orbital_period_triple : Set the initial orbital period of the triple in days. See also separation. : (null) -orbital_period_quadruple : Set the orbital period of the outer binary in a quadrulple (stars 3 and 4, internal indices 2 and 3) in days. See also separation. : (null) -eccentricity : Set the initial eccentricity of the binary orbit (stars 1 and 2, internal indices 0 and 1). : (null) -eccentricity_triple : Set the initial eccentricity of the triple orbit. : (null) -eccentricity_quadruple : Set the initial eccentricity of the outer binary of a quadruple (stars 3 and 4, internal indices 2 and 3). : (null) -incliniation : Set the initial orbital_inclination of the binary relative to zero. : (null) -incliniation_triple : Set the initial orbital_inclination of the triple orbit relative to zero. : (null) -incliniation_quadruple : Set the initial orbital_inclinationy of the quadruple orbit relative to zero. : (null) -orbital_phase : Set the initial orbital phase of the binary orbit. : (null) -orbital_phase_triple : Set the initial orbital phase of the triple orbit. : (null) -orbital_phase_quadruple : Set the initial orbital phase of the quadruple orbit. : (null) -argument_of_periastron : Set the initial argument of periastron of the binary orbit. : (null) -argument_of_periastron_triple : Set the initial argument of periastron of the triple orbit. : (null) -argument_of_periastron_quadruple : Set the initial argument of periastron of the quadruple orbit. : (null) -disc_timestep_factor : Factor that multiplies the natural timestep of a disc. : (null) -white_dwarf_cooling_model : White dwarf cooling model, relates age to luminosity. WHITE_DWARF_COOLING_MESTEL = 0 is Mestel's model, WHITE_DWARF_COOLING_MESTEL_MODIFIED = 1 is Hurley's modified Mestel model, WHITE_DWARF_COOLING_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null) -white_dwarf_radius_model : White dwarf radius model, radius to mass (and perhaps age). WHITE_DWARF_RADIUS_NAUENBERG1972 = 0 Nauenberg (1972), WHITE_DWARF_RADIUS_MU = 1 mu-dependent variant, WHITE_DWARF_RADIUS_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null) -cbdisc_mass_loss_inner_viscous_accretion_method : Chooses where the mass that is accreted from the inner edge of a circumbinary disc goes, i.e. to which star. 0 = Young and Clarke 2015, 1 = Gerosa et al 2015, 2 = 50:50 (i.e. not dependence on mass). : (null) -cbdisc_inner_edge_stripping : If True, allow inner edge mass stripping. : (null) -cbdisc_end_evolution_after_disc : If True, stop evolution when a disc evaporates. : (null) -cbdisc_no_wind_if_cbdisc : If True, disable stellar winds when there is a circumbinary disc. : (null) -cbdisc_outer_edge_stripping : If True, allow outer edge mass stripping. : (null) -disc_n_monte_carlo_guesses : Number of monte carlo guesses to try in the disc solver if the normal list of guesses fails (0). : (null) -disc_log : If 1, turn on the disc log. Requires DISC_LOG to be defined on build. : (null) -disc_log2d : If 1, turn on the 2d disc log. Requires DISC_LOG to be defined on build. : (null) -disc_log_dt : If non-zero, only allows disc log output every disc_log_dt Myr. : (null) -disc_log_directory : Directory into which disc logging is sent (must exist!). : /tmp/ -post_ce_adaptive_menv : If TRUE, and if post_ce_objects_have_envelopes is TRUE, then the envelope mass of a post-CE star is such that it sits just inside its Roche lobe. If FALSE then a fixed (thin) envelope mass is applied that depends on the stellar type (see macros POST_CE_ENVELOPE_DM_GB, POST_CE_ENVELOPE_DM_EAGB and POST_CE_ENVELOPE_DM_TPAGB). : (null) -post_ce_objects_have_envelopes : If TRUE then post-common-envelope objects have thin envelopes. You need this if you are to have post-CE post-AGB stars. Note that this *may* be unstable, i.e. you may end up having many CEEs. The mass in the envelope is controlled by post_ce_adaptive_menv. TRUE by default. : (null) -PN_comenv_transition_time : post-common envelope transition time in years (1e2). This is the time taken to move from CEE ejection to Teff > 30e4 K. Hall et al. (2013) suggest ~100 years. : (null) -minimum_time_between_PNe : The minimum time (Myr) between planetary nebula detections. This prevents multiple, fast common envelopes triggering two PNe (0.1). : (null) -PN_Hall_fading_time_algorithm : In stars with low mass (<0.45Msun) cores, you can choose to set the PN fading time to either the minimum (PN_HALL_FADING_TIME_ALGORITHM_MINIMUM) or maximum (PN_HALL_FADING_TIME_ALGORITHM_MAXIMUM) as shown in Fig. 6 of Hall et al. (2013). : (null) -PPN_envelope_mass : Desired pre-planetary nebula (post-AGB) envelope mass. : (null) -cbdisc_eccentricity_pumping_method : Select from various eccentricity-pumping methods when there is a circumbinary disc. Requires DISCS. 0 = off. : (null) -cbdisc_viscous_photoevaporative_coupling : Set to 1 to turn on viscous-photoevaporative coupling in circumbinary discs. Requires DISCS. 0 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_NONE = off, 1 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_INSTANT instant, 2 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_VISCOUS slow, viscous wind. : (null) -cbdisc_inner_edge_stripping_timescale : Defines the timescale for mass loss from by inner edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_in. : (null) -cbdisc_outer_edge_stripping_timescale : Defines the timescale for mass loss from by outer edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_out. : (null) -cbdisc_viscous_L2_coupling : Set to 1 to turn on viscous-L2-loss coupling in circumbinary discs. Requires DISCS. 0 = off. : (null) -gravitational_radiation_model : Model for gravitational radiation from the system. 0=Hurley et al 2002 (Landau and Lifshitz 1951). 1 = as 0 but only when there is no RLOF. 2 = none. : (null) -nova_irradiation_multiplier : Multiplier for nova-radiative induced mass loss. (Shara+1986) : (null) -gravitational_radiation_modulator_J : Modulator for gravitational wave radiation angular momentum loss rate (1.0). : (null) -gravitational_radiation_modulator_e : Modulator for gravitational wave radiation eccentricity pumping rate (1.0). : (null) -nova_faml_multiplier : Nova friction-induced angular momentum loss multiplier. (Shara+1986) : (null) -RLOF_angular_momentum_transfer_model : Choose angular momentum transfer model in RLOF. 0=BSE (with discs), 1=conservative : (null) -post_SN_orbit_method : Method by which the post-SN orbit is calculated. 0=BSE, 1=Tauris&Taken 1998. : (null) -multiplicity : Multiplicity: 1=single star, 2=binary, 3=triple, 4=quadruple. : (null) -accretion_limit_eddington_steady_multiplier : Steady accretion is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_steady_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null) -accretion_limit_eddington_LMMS_multiplier : Accretion from a low-mass, convective, main_sequence star is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_LMMS_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null) -accretion_limit_eddington_WD_to_remnant_multiplier : Accretion from a WD onto a remnant star (e.g. another white dwarf, neutron star or black hole) is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_WD_to_remnant_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null) -accretion_limit_thermal_multiplier : Mass transfer onto a MS, HG or CHeB star is limited by the accretor's thermal rate times this multiplier. : (null) -accretion_limit_dynamical_multiplier : Mass transfer is limited by the accretor's dynamical rate times this multiplier. : (null) -donor_limit_envelope_multiplier : Mass transfer by RLOF is limited by this fraction of the donor's envelope mass per timestep : (null) -donor_limit_thermal_multiplier : Mass transfer by RLOF is limited by the accretor's thermal rate times this multiplier. : (null) -donor_limit_dynamical_multiplier : Mass transfer by RLOF is limited by the donor's dynamical rate times this multiplier. : (null) -Bondi_Hoyle_accretion_factor : Wind accretion rate, as calculated by the Bondi-Hoyle-Littleton formula, multiplcation factor. Hurley et al 2002 use 1.5, which is the default. : (null) -tidal_strength_factor : A modulator for the tidal strength. If this factor > 1 then tides are stronger, i.e. tidal timescales are reduced. : (null) -hachisu_qcrit : Critical q=Maccretor/Mdonor above which Hachisu's disk wind turns on. : (null) -hachisu_disk_wind : Set to True to turn on Hachisu's disk wind when material accretes too fast onto a white dwarf. This helps to make more SNeIa. See also hachisu_qcrit. : (null) -mass_accretion_for_eld : The mass that must be accreted onto a COWD for it to ignite as an edge-lit detonation SNIa. : (null) -WDWD_merger_algorithm : Algorithm to be used when merging two white dwarfs. 0 = Hurley et al. (2002), 1 = Perets+ (2019), 2 = Chen+ (2016, todo) : (null) -type_Ia_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from Chandrasekhar-mass exploders. 0 = DD7 (Iwamoto 1999), 1 = Seitenzahl 2013 3D hydro yields (you must also set Seitenzahl2013_model) : (null) -Seitenzahl2013_model : Which of Seitenzahl et al. 2013's models to use? One of N1,N3,N5,N10,N20,N40,N100L,N100,N100H,N150,N200,N300C,N1600,N1600C,N100_Z0.5,N100_Z0.1,N100_Z0.01 (defaults to N100). : N1 -type_Ia_sub_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from sub-Chandrasekhar-mass exploders. (Currently unused.) : (null) -max_HeWD_mass : The maximum mass a HeWD can have before it ignites helium (0.7). : (null) -merger_mass_loss_fraction : Fraction of the total mass which is lost when stars merge. : (null) -merger_angular_momentum_factor : When two stars merge the resulting single star retains a fraction of the total system angular momentum (or the critical spin angular momentum, if it is smaller) multiplied by this factor. : (null) -wind_angular_momentum_loss : Prescription for losing angular momentum in a stellar wind. 0=Hurley et al 2002 ('Tout') prescription, 1=lw i.e. a factor multiplying the specific orbital angular momentum, 2=lw hybrid for fast winds. Set wind_djorb_fac to the desired factor.. : (null) -wind_djorb_fac : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=0 (the Tout/Hurley et al 2002 prescription). See wind_angular_momentum_loss. : (null) -lw : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=1,2 (the 'lw' prescription). See wind_angular_momentum_loss. : (null) -VW93_EAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null) -VW93_TPAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null) -use_periastron_Roche_radius : Set this to True to use the Roche lobe radius at periastron, rather than (the default to) assume a circular orbit. This will be useful one day when we treat RLOF in eccentric orbits properly, hopefully. : (null) -qcrit_LMMS : Apply critical q=Mdonor/Maccretor value for low-mass main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_LMMS : Apply critical q=Mdonor/Maccretor value for (low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -qcrit_degenerate_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null) -mass_for_Hestar_Ia_upper : Only helium stars below this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_lower. : (null) -mass_for_Hestar_Ia_lower : Only helium stars above this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_upper. : (null) -alphaCB : Circumbinary disk viscosity parameter, alpha. : (null) -minimum_donor_menv_for_comenv : Minimum donor envelope mass for common envelope evolution to be triggered (Msun). Default 0. : (null) -comenv_prescription : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null) -comenv_prescription%d : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null) -comenv_ejection_spin_method : When a common envelope is ejected, we need to decide how fast the stars are left spinning. COMENV_EJECTION_SPIN_METHOD_DO_NOTHING (0) is the default, this just leaves the stars/stellar cores spinning with the same spin rate (omega = angular velocity) with which they entered the common envelope phase. COMENV_EJECTION_SPIN_METHOD_SYCHRONIZE instead tidally synchronizes the stars with their new orbital angular velocity. : (null) -comenv_merger_spin_method : When a common envelope binary merges, we need to decide how fast the resulting single star is left spinning. COMENV_MERGER_SPIN_METHOD_SPECIFIC (0) is the default, this preserves angular momentum but limits the specific angular momentum of the merged star to the specific angular momentum of the system at the onset of common envelope evolution. COMENV_MERGER_SPIN_METHOD_CONSERVE_ANGMOM (1) sets the merger's angular momentum to be that of the system at the onset of common envelope evolution (which means the star may be rotating supercritically). COMENV_MERGER_SPIN_METHOD_CONSERVE_OMEGA (2) sets the spin rate (angular frequency = omega) of the merged star to be that of the orbit just at the onset of common envelope evolution. : (null) -comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null) -comenv_ms_accretion_fraction : Experimental. During common envelope evolution, a main sequence may accrete a fraction of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_mass. : (null) -comenv_ns_accretion_mass : Experimental. During common envelope evolution, a neutron star may accrete some of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_fraction. : (null) -comenv_ns_accretion_fraction : Experimental. During common envelope evolution, a neutron star may accrete a fraction of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_mass. : (null) -alpha_ce : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null) -alpha_ce%d : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null) -lambda_ce : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to LAMBDA_CE_DEWI_TAURIS == -1 binary_c uses the Dewi and Tauris fits instead, LAMBDA_CE_WANG_2016 == -2 uses the formalism of Wang, Jia and Li (2016), if LAMBDA_CE_POLYTROPE == -3 then a polytropic formalism is used (see also comenv_splitmass) and if LAMBDA_CE_KLENCKI_2020 == -4 use Klencki et al. (2020). : (null) -lambda_ce%d : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to -1 binary_c uses the Dewi and Tauris fits instead, -2 uses the formalism of Wang, Jia and Li (2016) and if -3 then a polytropic formalism is used (see also comenv_splitmass). : (null) -comenv_splitmass : When lambda_ce=-2, the envelope binding energy, lambda, is calculated using a polytropic formalism. The comenv_splitmass defines the point, in the units of the core mass, above which material is ejected. : (null) -nelemans_recalc_eccentricity : If True, recalculate the eccentricity after angular momentum is removed. : (null) -comenv_post_eccentricity : Eccentricity remaining after common envelope ejection. : (null) -nelemans_gamma : Set the fraction of the orbital specific angular momentum that is used to eject the common envelope according to the Nelemans and Tout prescription. See also nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null) -nelemans_minq : Only activate the Nelemans and Tout common envelope prescription for q>nelemans_minq. See also nelemans_gamma, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null) -nelemans_max_frac_j_change : Maximum fractional angular momentum change in the Nelemans and Tout common envelope prescription. See also nelemans_gamma, nelemans_minq, nelemans_n_comenvs. : (null) -nelemans_n_comenvs : Set the maximum number of common envelope ejections allowed to follow the Nelemans and Tout prescription, after which the standard alpha prescription is used. : (null) -lambda_ionisation : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null) -lambda_ionisation%d : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null) -lambda_enthalpy : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null) -lambda_enthalpy%d : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null) -cbdisc_albedo : Circumbinary-disc albedo. Requires DISCS. : (null) -cbdisc_gamma : Circumbinary disc gamma (equation of state) parameter. Requires DISCS. : (null) -cbdisc_alpha : Circumbinary disc alpha (viscosity) parameter. Requires DISCS. : (null) -cbdisc_kappa : Circumbinary disc kappa (opacity) parameter. Requires DISCS. : (null) -cbdisc_minimum_evaporation_timescale : Circumbinary disc minimum evaporation timescale (years). If (slow, not edge stripped) mass loss would evaporate the disc on a timescale less than this, simply evaporate the disc immediated. Usually set to 1y, ignore if zero. Requires DISCS. : (null) -cbdisc_torquef : Circumbinary disc binary torque multiplier. Requires DISCS. : (null) -cbdisc_max_lifetime : Circumbinary disc maximum lifetime (years, ignored if 0). Requires DISCS. : (null) -cbdisc_init_dM : On cbdisc start, reduce mass by a fraction dM if it won't converge. Requires DISCS. : (null) -cbdisc_init_dJdM : On cbdisc start, reduce angular momentum by a fraction dJ/dM*dM if it won't converge. Requires DISCS. : (null) -cbdisc_mass_loss_constant_rate : Circumbinary disc constant mass loss rate (Msun/year). Requires DISCS. : (null) -cbdisc_mass_loss_FUV_multiplier : Circumbinary disc FUV mass loss rate multiplier (no units). Requires DISCS. : (null) -cbdisc_mass_loss_Xray_multiplier : Circumbinary disc X-ray mass loss rate multiplier (no units). Requires DISCS. : (null) -cbdisc_mass_loss_ISM_ram_pressure_multiplier : Circumbinary disc interstellar medium ram pressure stripping mass loss rate multiplier (no units). Requires DISCS. : (null) -cbdisc_mass_loss_ISM_pressure : Circumbinary disc interstellar medium ram pressure in units of Boltzmann constant per Kelvin (I think...). Requires DISCS. Typically 3000.0. See e.g. http://www.astronomy.ohio-state.edu/~pogge/Ast871/Notes/Intro.pdf page 15 or https://arxiv.org/pdf/0902.0820.pdf Fig. 1 (left panel). : (null) -cbdisc_mass_loss_inner_viscous_multiplier : Circumbinary disc inner edge viscous mass loss rate multiplier (no units). Requires DISCS. : (null) -cbdisc_mass_loss_inner_viscous_angular_momentum_multiplier : Circumbinary disc inner edge viscous angular momentum multiplier (no units). The inner edge angular momentum Requires DISCS. : (null) -cbdisc_resonance_multiplier : Circumbinary disc resonant interaction multiplier, affects eccentricity pumping and angular momentum rates. Requires DISCS. : (null) -cbdisc_resonance_damping : Circumbinary disc resonant interaction damping: should be on (True) to damp the l=1, m=2 resonance when the disc inner edge lies outside the resonance location. Requires DISCS. : (null) -cbdisc_fail_ring_inside_separation : If True, while converging on a structure, circumbinary discs with Rring < the binary separation are immediately failed. : (null) -cbdisc_mass_loss_inner_L2_cross_multiplier : Circumbinary disc inner edge L2-crossing mass loss rate multiplier (no units). Requires DISCS. : (null) -cbdisc_minimum_luminosity : Circumbinary disc minimum luminosity. If the disc becomes dimmer than this, the disc is evaporated instantly. Requires DISCS. : (null) -cbdisc_minimum_mass : Circumbinary disc minimum mass. If the disc becomes less massive than this, the disc is evaporated instantly. Requires DISCS. : (null) -cbdisc_minimum_fRing : Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = |Rout/Rin-1| < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS. : (null) -comenv_disc_angmom_fraction : If >0 Fraction of the common envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the moments of inertia to calculate (deprecated), if -2 use the common envelope's specific angular momentum, if -3 uses the L2 point at the end of the common envelope to set the angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null) -comenv_disc_mass_fraction : Fraction of the common envelope's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null) -wind_disc_angmom_fraction : If >0 Fraction of the wind envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the L2 point's specific angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null) -wind_disc_mass_fraction : Fraction of the stellar wind's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null) -WRLOF_method : Choose whether and how to apply wind-Roche-lobe-overflow. 0=none, 1=q-dependent, 2=quadratic See Abate et al 2013/14 for details. Requires WRLOF_MASS_TRANSFER. : (null) -minimum_timestep : The minimum timestep (Myr). : (null) -timestep_solver_factor : Factor applied in timestep_limits, e.g. to prevent X changing too fast by comparing to X/dX/dt, which is usually 1 but can be higher to lengthen timesteps when using an alternative solver. : (null) -RLOF_mdot_factor : Multiplier applied to the mass transfer rate during Roche-lobe overflow. Requires RLOF_MDOT_MODULATION. : (null) -RLOF_f : Factor to enlarge a Roche lobe, nominally because of radiation pressure (see Dermine et al paper). Requires RLOF_RADIATION_CORRECTION. : (null) -minimum_separation_for_instant_RLOF : If True, instead of evolving the system just report the minimum separation (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_orbital_period_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null) -minimum_orbital_period_for_instant_RLOF : If True, instead of evolving the system just report the minimum orbital period (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_separation_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null) -maximum_mass_ratio_for_instant_RLOF : If True, instead of evolving the system just report the maximum mass ratio (on the zero-age main sequence) that would lead to instant RLOF, given M1 and orbital period. Used by binary_grid. See also minimum_separation_for_instant_RLOF and minimum_orbital_period_for_instant_RLOF. : (null) -RLOF_method : Use RLOF_method to choose the algorithm you use for Roche-lobe overflow mass loss rate calculations. 0=Hurley et al 2002, 1=Adaptive (for radiative stars) R=RL method, 2=Ritter (probably broken), 3=Claeys etal 2014 variant on Hurley et al 2002. : (null) -RLOF_interpolation_method : When a star overflows its Roche lobe, it always has R>RL because of the limited time resolution of the simulation. Binary_c then uses an algorithm to get back to when R~RL (within a desired tolerance, set in RLOF_ENTRY_THRESHOLD which is usually 1.02, i.e. overflow of 2%). You can choose algorithm 0, the Hurley et al 2002 method which reverses time (i.e. uses a Newton-like scheme), or 1 to use the binary_c method which rejects a timestep (and hence does no logging on that timestep) and repeats with half the timestep until R~RL. The latter is now the default, because this means there are no negative timesteps which break various other algorithms (e.g. nucleosynthesis). : (null) -nova_retention_fraction : The mass accreted during a nova as fraction of mass transferred : (null) -beta_reverse_nova : The fraction of mass ejected in a nova explosion which is accreted back onto the companion star. Set to -1 to automatically calculate based on a geometric argument, or 0 or positive to set the value. : (null) -WD_accretion_rate_novae_upper_limit_hydrogen_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is hydrogen rich : above this rate the mass transfer leads to stable burning. : (null) -WD_accretion_rate_novae_upper_limit_helium_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is helium rich : above this rate the mass transfer leads to stable burning. : (null) -WD_accretion_rate_novae_upper_limit_other_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is neither hydrogen nor helium rich : above this rate the mass transfer leads to stable burning. : (null) -WD_accretion_rate_new_giant_envelope_lower_limit_hydrogen_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a hydrogen-rich donor. Below this mass transfer leads to stable burning. : (null) -WD_accretion_rate_new_giant_envelope_lower_limit_helium_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a helium-rich donor. Below this mass transfer leads to stable burning. : (null) -WD_accretion_rate_new_giant_envelope_lower_limit_other_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope when the donor is neither hydrogen nor helium rich. Below this mass transfer leads to stable burning. : (null) -CRAP_parameter : Tidally enhanced mass loss parameter. See Tout and Eggleton's paper on the subject. (Was the parameter bb). : (null) -individual_novae : If individual_novae is True, novae are resolved such that each explosion is performed separtaely. : (null) -nova_timestep_accelerator_num : The nova timestep is accelerated if the nova number exceeds nova_timestep_accelerator_num. If zero or negative, acceleration is off. See also nova_timestep_accelerator_index and nova_timestep_accelerator_max. Only used if individual_novae is on. - : (null) -nova_timestep_accelerator_index : The index at which the nova timestep is accelerated. A larger value gives longer timesteps. See also nova_timestep_accelerator_num and nova_timestep_accelerator_max. Only used if individual_novae is on. - : (null) -nova_timestep_accelerator_max : The nova timestep is accelerated by a factor that is capped at nova_timestep_accelerator_max. This parameter is ignored if it is zero or negative. See also nova_timestep_accelerator_num and nova_timestep_accelerator_index. Only used if individual_novae is on. - : (null) -nonconservative_angmom_gamma : Mass lost from the system (but NOT from a stellar wind) takes a fraction gamma of the orbital angular momentum with it. Set to -1 to take the specific angular momentum of the donor star. Set to -2 to take super-Eddington, nova and disk-wind angular momenta as if a wind from the accretor. : (null) -max_stellar_angmom_change : Maxmimum fractional change in stellar angular momentum allowed before a timestep is rejected (0.05). : (null) -comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null) - -############################################################ -##### Section Nucsyn -############################################################ -third_dup : If True, enables third dredge up. Requires NUCSYN and NUCSYN_THIRD_DREDGE_UP. : (null) -third_dup_multiplier : Usage: --third_dup_multiplier <i> <f>. Multiplies the abundance of element <i> by <f> during third dredge up. : 1.0 -NeNaMgAl : Enables NeNaMgAl reaction network. Requires NUCSYN and NUCSYN_HBB. : Ignore -nucsyn_network%d : Usage: --nucsyn_network%d <boolean>. Turn a nuclear network on or off. : (null) -nucsyn_network_error%d : Usage: --nucsyn_network_error%d <f>. Threshold error in nuclear network solver for network %d. : (null) -nucreacmult%d : Usage: --nucreacmult%d <f>. Multiply nuclear reaction given by the integer %d (integer) by f (float). : (null) -nucsyn_metallicity : This sets the metallicity of the nucleosynthesis algorithms, i.e. the amount (by mass) of matter which is not hydrogen or helium. Usually you'd just set this with the metallicity parameter, but if you want the nucleosynthesis to be outside the range of the stellar evolution algorithm (e.g. Z=0 or Z=0.04) then you need to use nucsyn_metallicity. That said, it's also outside the range of some of the nucleosynthesis algorithms as well, so you have been warned! : (null) -nucsyn_solver : Choose the solver used in nuclear burning. 0 = KAPS_RENTROP is a Kaps-Rentrop scheme (fast, not great for stiff problems), 1 = LSODA (Adams/BSF switcher), 2 = CVODE library (https://computing.llnl.gov/projects/sundials. Default 0. : 0 -initial_abundance_mix : initial abundance mixture: 0=AG89, 1=Karakas 2002, 2=Lodders 2003, 3=Asplund 2005 (not available?), 4=Garcia Berro, 5=Grevesse Noels 1993 : 0 -init_abund : Usage: --init_abund <i> <X>. Sets the initial abundance of isotope number <i> to mass fraction <X>. : 0.02 -init_abund_mult : Usage: --init_abund_mult <i> <f>. Multiplies the initial abundance of isotope number <i> by <f>. : 1.0 -init_abund_dex : Usage: --init_abund_dex <i> <f>. Changes the initial abundance of isotope number <i> by <f> dex. : 0.0 -init_abunds_only : If True, outputs only the initial abundances, then exits. : (null) -initial_abunds_only : If True, outputs only the initial abundances, then exits. : (null) -no_thermohaline_mixing : If True, disables thermohaline mixing. : (null) -lithium_GB_post_Heflash : Sets the lithium abundances after the helium flash. Requires NUCSYN and LITHIUM_TABLES. : (null) -lithium_GB_post_1DUP : Sets the lithium abundance after first dredge up. Requires NUCSYN and LITHIUM_TABLES. : (null) -lithium_hbb_multiplier : Multiplies the lithium abundances on the AGB during HBB (based on Karakas/Fishlock et al models).Requires NUCSYN and LITHIUM_TABLES. : (null) -angelou_lithium_decay_function : Functional form which describes Li7 decay. Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Choices are : 0 expoential (see angelou_lithium_decay_time). : (null) -angelou_lithium_LMMS_time : Time at which lithium manufacture is triggered in a low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_MS_time : Time at which lithium manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_HG_time : Time at which lithium manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_GB_time : Time at which lithium manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_CHeB_time : Time at which lithium manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_EAGB_time : Time at which lithium manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_TPAGB_time : Time at which lithium manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_LMMS_decay_time : Decay time for surface lithium abundance during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_MS_decay_time : Decay time for surface lithium abundance on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_HG_decay_time : Decay time for surface lithium abundance on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_GB_decay_time : Decay time for surface lithium abundance on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_CHeB_decay_time : Decay time for surface lithium abundance during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_EAGB_decay_time : Decay time for surface lithium abundance on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_TPAGB_decay_time : Decay time for surface lithium abundance on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_LMMS_massfrac : Lithium mass fraction when its manufacture is triggered during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_MS_massfrac : Lithium mass fraction when its manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_HG_massfrac : Lithium mass fraction when its manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_GB_massfrac : Lithium mass fraction when its manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_CHeB_massfrac : Lithium mass fraction when its manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_EAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_TPAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6). - : (null) -angelou_lithium_vrot_trigger : Equatorial rotational velocity at which lithium manufacture is triggered (km/s). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0. - : (null) -angelou_lithium_vrotfrac_trigger : Fraction of Keplerian (breakup) equatorial rotational velocity at which lithium manufacture is triggered (must be <1, ignored if 0). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0. - : (null) - -############################################################ -##### Section Output -############################################################ -cf_amanda_log : Enable logging to compare to Amanda's models. : (null) -float_overflow_checks : Turn on to enable floating-point overflow checks at the end of each timestep, if they are available. 0=off, 1=warn (stderr) on failure, 2=exit on failure (0) : (null) -save_pre_events_stardata : Enable this to save a copy of stardata to stardata->pre_events_stardata just before an event. : (null) -disable_end_logging : Disable the logging that happens at the end of the evolution. : (null) -ensemble : Turn on ensemble calculations and output. : (null) -ensemble_filters_off : Sets all ensemble filters to be off (FALSE) - these can then be enabled one-by-one with --ensemble_filter_[...] TRUE. : (null) -ensemble_filter_%d : Turn on or off ensemble filter <n>. For a list of filters, see ensemble_macros.h. : (null) -ensemble_legacy_ensemble : Turn on ensemble legacy population output. : (null) -legacy_yields : Turn on ensemble legacy yield output. : (null) -ensemble_defer : Defer ensemble output. : (null) -ensemble_dt : When doing ensemble calculations, data are stored and/or output every ensemble_dt Myr. See also ensemble, ensemble_logdt, ensemble_startlogtime. : (null) -ensemble_logdt : When doing ensemble calculations, and when logensembletimes is set, the ensemble is stored/output every ensemble_logdt Myr. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null) -ensemble_startlogtime : Start log ensemble data storage/calculations/output at ensemble_startlogtime. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null) -ensemble_logtimes : When doing ensemble calculations/output, set this to act at log times rather than linear times. : (null) -postagb_legacy_logging : Turn on post-AGB legacy logging. : (null) -disc_legacy_logging : Turn on disc legacy logging. : (null) -EMP_logg_maximum : Maximum logg that EMP stars are allowed to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_minimum_age. : (null) -EMP_minimum_age : Minimum age that EMP stars are required to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum. : (null) -EMP_feh_maximum : Maximum [Fe/H] that an EMP stars may have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default -2.0. : (null) -CEMP_cfe_minimum : Minimum [C/Fe] that CEMP stars are required to have. See Izzard et al 2009. See also NEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 0.7. : (null) -NEMP_cfe_minimum : Minimum [N/Fe] that NEMP stars are required to have. See Izzard et al 2009, Pols et al. 2012. See also CEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 1.0. : (null) -thick_disc_start_age : Lookback time for the start of the thick disc star formation, e.g. 13e3 Myr. Units = Myr. : (null) -thick_disc_end_age : Lookback time for the end of the thick disc star formation, e.g. 4e3 Myr. Units = Myr. : (null) -thick_disc_logg_min : Minimum logg for thick disc giants to be logged. : (null) -thick_disc_logg_max : Maximum logg for thick disc giants to be logged. : (null) -escape_velocity : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 1e9 km/s. See also escape_fraction. : (null) -escape_fraction : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 0.0. See also escape_velocity. : (null) -colour_log : If set to True, thelog is coloured with ANSI colour formatting. Requires FILE_LOG to be defined. : -log_filename : Location of the output logging filename. If set to "/dev/null" then there is no logging. : -log_arrows : Add arrows to the output log to show whether values are increasing or decreasing. : -stopfile : File which, when it exists, will stop the current binary_c repeat run. : -stardata_dump_filename : Location of the stardata dump file. : -stardata_load_filename : Location of the stardata file to load. : -api_log_filename_prefix : Location of the output logging filename prefix for the API. If set to "/dev/null" then there is no logging. : 0 -hrdiag_output : Set to True to output high time-resolution Hertzstrpung-Russell diagram information. Requires HRDIAG. : (null) -internal_buffering : Experimental. Set to non-zero values to implement internal buffering prior to output. For use with binary_grid, you shouldn't really be playing with this. : (null) -eccentric_RLOF_model : Chooses which model is used to handle eccentric RLOF. Default is RLOF_ECCENTRIC_AS_CIRCULAR, i.e. ignore the eccentricity. Note: requires force_corotation_of_primary_and_orbit to be FALSE. - : (null) -force_circularization_on_RLOF : If True forces circularization of stars and orbit when RLOF starts, this is as in the BSE algorithm. (True) : (null) -wtts_log : If True, enables log file output for WTTS2. : (null) -fabian_imf_log_time : Time at which to output for Fabian Schneider's IMF project. Requires FABIAN_IMF_LOG : Ignore -fabian_imf_log_timestep : Timestep for Fabian Schneider's IMF project logging. Requires FABIAN_IMF_LOG : Ignore -version : Display binary_c version and build information. Also performs timing tests. : Ignore -dumpversion : Display binary_c version number (short format). : Ignore -version_only : Display binary_c version number and build information, but do not perform timing tests or anything that requires stardata to be non-NULL. : Ignore -tides_diagnosis_log : Enable logging to test MINT tides. Requires MINT. Choices are: 0 disabled, 1 enable lambda test. : Ignore - -############################################################ -##### Section Input -############################################################ -MINT_dir : Location of MINT algorithm data. : -MINT_data_cleanup : Activate checks on incoming data to try to account for problems. Will make data-loading slower, but may fix a few things. : -MINT_MS_rejuvenation : Turn on or off (hydrogen) main-sequence rejuvenation. : -MINT_remesh : Turn on or off MINT's remeshing. : -MINT_use_ZAMS_profiles : Use chemical profiles at the ZAMS if MINT_use_ZAMS_profiles is TRUE, otherwise set homogeneous abundances. (Default is TRUE, so we use the profiles if they are available.) : -MINT_fallback_to_test_data : If TRUE, use the MINT test_data directory as a fallback when data is unavailable. (FALSE) : -MINT_disable_grid_load_warnings : Use this to explicitly disable MINT's warnings when loading a grid with, e.g., missing or too much data. : -MINT_Kippenhahn : Turn on or off MINT's Kippenhahn diagrams. If 0, off, if 1, output star 1 (index 0), if 2 output star 2 (index 1). Default 0. : -MINT_nshells : Set the initial number of shells MINT uses in each star when doing nuclear burning. Note: remeshing can change this. If MINT_nshells is 0, shellular burning and other routines that require shells will not be available. (200) : -MINT_maximum_nshells : Set the maximum number of shells MINT uses in each star when doing nuclear burning. Note that this will be limited to MINT_HARD_MAX_NSHELLS. (1000) : -MINT_minimum_nshells : Set the minimum number of shells MINT uses in each star when doing nuclear burning. Note that this will be greater than or equal to MINT_HARD_MIN_NSHELLS, which is 0 by default. (0) : -MINT_Kippenhahn_stellar_type : Stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for which Kippenhahn plot data should be output. : -MINT_Kippenhahn_companion_stellar_type : Companion stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for the companion for which Kippenhahn plot data should be output. : -MINT_nuclear_burning : Turn on or off MINT's nuclear burning algorithm. : -MINT_minimum_shell_mass : Minimum shell mass in MINT's nuclear burning routines. : -MINT_maximum_shell_mass : Maximum shell mass in MINT's nuclear burning routines. : - -############################################################ -##### Section I/O -############################################################ -go : batchmode control command : Ignore -gogo : batchmode control command : Ignore -reset_stars : Reset the star structures. Used in batchmode : Ignore -reset_stars_defaults : Reset the star structures and set defaults. Used in batchmode : Ignore -defaults : Reset all defaults. Used in batchmode : Ignore -echo : Activate batchmode command echoing, i.e. when you enter a command, binary_c repeats the command then executes it. : Ignore -noecho : Deactivate batchmode command echoing. See 'echo'. : Ignore -noechonow : Deactivate batchmode command echoing. See 'echo'. : Ignore -bye : Quit binary_c. Used in batchmode. : Ignore -fin : batchmode control command : Ignore -reset_prefs : Reset preferences struct. Used in batchmode : Ignore -status : Output batchmode status information. : Ignore - -############################################################ -##### Section Algorithms -############################################################ -repeat : If > 1, repeats the system as many times as required. Handy if you're using Monte-Carlo kicks and want to sample the parameter space well. Also, if you are running speed tests this is good to give a statistically more reasonable result. (See e.g. 'tbse pgo'). : (null) -random_systems : Experimental. Use this to apply random initial system parameters (masses, separations, etc.). Useful for testing only. : (null) - -############################################################ -##### Section Misc -############################################################ -random_seed : Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null) -random_systems_seed : Random number seed for the generation of random systems. See random_systems and random_seed. : (null) -random_skip : Skip the first <random_seed> random numbers that are generated. Usually this is 0 so they are all used. : (null) -idum : [NB: deprecated, please use 'random_seed' instead.] Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null) -reverse_time : Make time go backwards. To be considered very experimental! : (null) -start_time : Start time for the simulation. : (null) -warmup_cpu : Uses the CPU at maximum power the given number of seconds, prior to running normal stellar evolution. : Ignore -help : Display help pages. Usage: --help <help topic>. : Ignore -argopts : Display argument options. Usage: --argopts <argument>. : Ignore -help_all : Display all help pages. : Ignore -list_args : Display list of arguments with their default values. Useful for batchmode. : Ignore - +(abridged) </pre></div></div> </div> <p>We can get all the parameter names and their default values with return_arglines(): (abridged output)</p> @@ -1262,8 +611,8 @@ list_args : Display list of arguments with their default values. Useful for batc <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="nb">print</span><span class="p">(</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">return_arglines</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[:</span><span class="mi">4</span><span class="p">]))</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">return_arglines</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[:</span><span class="mi">4</span><span class="p">]))</span> +<span class="nb">print</span><span class="p">(</span><span class="s2">"(abridged)"</span><span class="p">)</span> </pre></div> </div> </div> @@ -1276,6 +625,7 @@ __ARG_BEGIN metallicity = 0.02 effective_metallicity = -1 M_1 = 0 +(abridged) </pre></div></div> </div> <p>Lastly, we can ask binary_c to determine the minimum period or maximum mass for RLOF at the ZAMS: Both of them need an argstring as input</p> @@ -1283,8 +633,7 @@ M_1 = 0 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Here we set up the argument string that is passed to the bindings</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Here we set up the argument string that is passed to the bindings</span> <span class="n">argstring</span> <span class="o">=</span> <span class="s2">"""</span> <span class="s2">binary_c M_1 </span><span class="si">{M_1}</span><span class="s2"> orbital_period </span><span class="si">{orbital_period}</span><span class="s2"> eccentricity </span><span class="si">{eccentricity}</span><span class="s2"> metallicity </span><span class="si">{metallicity}</span><span class="s2"> max_evolution_time </span><span class="si">{max_evolution_time}</span><span class="s2"></span> <span class="s2">"""</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> @@ -1315,8 +664,7 @@ MINIMUM PERIOD 0.00632092 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Here we set up the argument string that is passed to the bindings</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Here we set up the argument string that is passed to the bindings</span> <span class="n">argstring</span> <span class="o">=</span> <span class="s2">"""</span> <span class="s2">binary_c M_1 </span><span class="si">{M_1}</span><span class="s2"> orbital_period </span><span class="si">{orbital_period}</span><span class="s2"> eccentricity </span><span class="si">{eccentricity}</span><span class="s2"> metallicity </span><span class="si">{metallicity}</span><span class="s2"> max_evolution_time </span><span class="si">{max_evolution_time}</span><span class="s2"></span> <span class="s2">"""</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> @@ -1347,68 +695,49 @@ MAXIMUM MASS RATIO 0.0141 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> </pre></div> </div> </div> -</div> -</div> -</div> +</section> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_luminosity_function_single.html" class="btn btn-neutral float-right" title="Example use case: Zero-age stellar luminosity function" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_extra_features.html" class="btn btn-neutral float-left" title="Tutorial: Extra features and functionality of binary_c-python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_extra_features.html" class="btn btn-neutral float-left" title="Tutorial: Extra features and functionality of binary_c-python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_ensembles.html" class="btn btn-neutral float-right" title="Tutorial: Generating and handling ensemble data" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_api_functionality.ipynb b/docs/build/html/examples/notebook_api_functionality.ipynb index 504ae4b16880946428716c496c81cbf82eea63a8..49d6f8d3db7beacc8770e2b86b21b4636bbf8e7a 100644 --- a/docs/build/html/examples/notebook_api_functionality.ipynb +++ b/docs/build/html/examples/notebook_api_functionality.ipynb @@ -105,7 +105,7 @@ " Function that contains random snippets. Do not expect this to remain available, or reliable. i.e. dont use it.\n", "\n", "FILE\n", - " /home/izzard/.local/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so\n", + " /home/david/.pyenv/versions/binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so\n", "\n", "\n" ] @@ -166,7 +166,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "<capsule object \"STORE\" at 0x146f912dbc60>\n", + "<capsule object \"STORE\" at 0x7fc1f0c3ff00>\n", "SINGLE_STAR_LIFETIME 10 28.4838\n", "\n" ] @@ -270,586 +270,13 @@ "M_2 : The initial mass of star two (in solar units, internally this is star index 1). : (null)\n", "M_3 : The initial mass of star three (in solar units, internally this is star index 2). : (null)\n", "M_4 : The initial mass of star four (in solar units, internally this is star index 3). : (null)\n", - "vrot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot2,3,4. : (null)\n", - "vrot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,3,4. : (null)\n", - "vrot3 : The initial equatorial rotational velocity of star three (in km/s, internally this is star index 2). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,4. : (null)\n", - "vrot4 : The initial equatorial rotational velocity of star four (in km/s, internally this is star index 3). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,3. : (null)\n", - "Prot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). See also Prot2,3,4. : (null)\n", - "Prot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). See also Prot1,3,4. : (null)\n", - "Prot3 : The initial equatorial rotational period of star three (in days, internally this is star index 2). See also Prot1,2,4. : (null)\n", - "Prot4 : The initial equatorial rotational period of star four (in days, internally this is star index 3). See also Prot1,2,3. : (null)\n", - "inclination1 : The initial inclination of star one (in degrees). : (null)\n", - "inclination2 : The initial inclination of star two (in degrees). : (null)\n", - "inclination3 : The initial inclination of star three (in degrees). : (null)\n", - "inclination4 : The initial inclination of star four (in degrees). : (null)\n", - "B_1 : The initial magnetic field of star one (in Gauss, internally this is star index 0). : (null)\n", - "B_2 : The initial magnetic field of star two (in Gauss, internally this is star index 1). : (null)\n", - "B_3 : The initial magnetic field of star three (in Gauss, internally this is star index 2). : (null)\n", - "B_4 : The initial magnetic field of star four (in Gauss, internally this is star index 3). : (null)\n", - "B_inclination1 : The initial inclination of the magnetic field of star one (in degrees). : (null)\n", - "B_inclination2 : The initial inclination of the magnetic field of star two (in degrees). : (null)\n", - "B_inclination3 : The initial inclination of the magnetic field of star three (in degrees). : (null)\n", - "B_inclination4 : The initial inclination of the magnetic field of star four (in degrees). : (null)\n", - "stellar_type_1 : Set the stellar type of star 1 (internal index 0), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_2 : Set the stellar type of star 2 (internal index 1), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_3 : Set the stellar type of star 3 (internal index 2), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_4 : Set the stellar type of star 4 (internal index 3), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "max_stellar_type_1 : The maximum stellar type of star 1 (internal index 0). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value. \n", - " : (null)\n", - "max_stellar_type_2 : The maximum stellar type of star 2 (internal index 1). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "max_stellar_type_3 : The maximum stellar type of star 3 (internal index 2). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "max_stellar_type_4 : The maximum stellar type of star 4 (internal index 3). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "probability : The probability is a weighting applied to the star based on, say, the initial mass function. When running a grid of stars to simulate *all* stars, the summed probability of all the stars should be 1.0. : (null)\n", - "phasevol : The system's phase volume, used by binary_grid. : (null)\n", - "stellar_structure_algorithm : Set the stellar structure algorithm. 0=modified BSE (default), 1=none, 2=external function (must be defined by the calling code), 3=binary_c (not yet implemented). : (null)\n", - "solver : The type of solver. Default is the Forward-Euler (0), but could be RK2 (1), RK4 (2) or a predictor-corretor (3). : (null)\n", - "max_evolution_time : Set the maximum age for the stars (Myr). : (null)\n", - "max_model_number : Set the maximum number of models, ignored if 0 (default is 0). : (null)\n", - "monte_carlo_kicks : Turn on Monte-Carlo SN kicks. On (True) by default, and indeed other algorithms are probably broken. : (null)\n", - "disable_debug : Disables debug output. Only has an effect when DEBUG is 1, which probably requires a rebuild. Default FALSE. : (null)\n", - "timestep_logging : Turn on timestep logging (default is False). : (null)\n", - "rejects_in_log : Show timestep rejections in the main log (default is False). : (null)\n", - "vandenHeuvel_logging : Turn on van den Heuvel logging (default is False). : (null)\n", - "evolution_splitting : If True, turn on splitting of an evolutionary run if splitpoint (e.g. supernova) occurs. : (null)\n", - "disable_events : Whether to disable the new events code (defaults to False, so we use events by default)\n", - " : (null)\n", - "evolution_splitting_sn_eccentricity_threshold : Threshold eccentricity above which evolution splitting happens in a system with no SN kick. (0.01) : (null)\n", - "evolution_splitting_sn_n : Number of runs to split into when a SN occurs. : (null)\n", - "evolution_splitting_maxdepth : Max number of splits in an evolutionary run. : (null)\n", - "equation_of_state_algorithm : Set the equation of state algorithm. 0 = Paczynski. : (null)\n", - "opacity_algorithm : Set the opacity algorithm. 0 = Paczynski, 1 = Ferguson/Opal. : (null)\n", - "wind_mass_loss : Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018). : 0\n", - "gbwind : Wind prescription for first red giant branch stars. 0=Reimers (Hurley et al 2000/2002; choose gb_reimers_eta=0.5 for their mass loss rate), 1=Schroeder+Cuntz 2005 (set gb_reimers_eta=1.0 for their mass loss rate). : (null)\n", - "postagbwind : Apply special post-(A)GB prescription. Default is POSTAGB_WIND_USE_GIANT which means we just use whatever is prescribed on the giant branch. Other options include: POSTAGB_WIND_NONE = 1 (no wind on the post (A)GB), POSTAGB_WIND_KRTICKA2020 = 2 which uses Krticka, Kubát and Krticková (2020, A&A 635, A173). : (null)\n", - "Teff_postAGB_min : The minimum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_max. (6000 K) : (null)\n", - "Teff_postAGB_max : The maximum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_min. (120000 K) : (null)\n", - "mattsson_Orich_tpagbwind : Experimental : turns on Mattsson's TPAGB wind when the star is oxygen rich. Requires MATTSSON_MASS_LOSS. : (null)\n", - "magnetic_braking_factor : Multiplier for the magnetic braking angular momentum loss rate. : (null)\n", - "magnetic_braking_gamma : gamma factor in Rappaport style magnetic braking expression. : (null)\n", - "magnetic_braking_algorithm : Algorithm for the magnetic braking angular momentum loss rate. 0 = Hurley et al. 2002, 1 = Andronov, Pinnsonneault and Sills 2003, 2 = Barnes and Kim 2010 : (null)\n", - "helium_flash_mass_loss : Mass to be lost at the helium flash. : (null)\n", - "gb_reimers_eta : First red giant branch wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) : (null)\n", - "gbwindfac : Multiplier for the giant branch wind mass loss rate : (null)\n", - "tpagbwindfac : Multiplier for the TPAGB wind mass loss rate : (null)\n", - "eagbwindfac : Multiplier for the EAGB wind mass loss rate : (null)\n", - "nieuwenhuijzen_windfac : Multiplier for the Nieuwenhuijzen & de Jager wind mass loss rate : (null)\n", - "tpagbwind : Wind prescription during the TPAGB. 0=Karakas 2002 (a modified Vassiliadis and Wood 1993), 1=Hurley et al 2000/2002 (Vassiliadis and Wood 1993), 2=Reimers, 3=Bloecker, 4=Van Loon, 5=Rob's C-wind (broken?), 6,7=Vassiliadis and Wood 1993 (Karakas,Hurley variants respectively) when C/O>1, 8=Mattsson, 9 = Goldman et al. (2017), 10 = Beasor et al. (2020). : (null)\n", - "eagbwind : Wind prescription during the EAGB. 0=BSE (Hurley+2002, based on VW93), 1 = Goldman et al. (2017), 2 = Beasor et al. (2020). : (null)\n", - "wind_gas_to_dust_ratio : Gas to dust ratio used in wind calculations (e.g. Goldman et al. 2017). Typically 200 (Milky Way)-500 (Magellanic Clouds). Default is 200, approximately as in MW stars. : (null)\n", - "vwind_multiplier : Multiplier for the stellar wind velocity. : (null)\n", - "vwind_beta : Beta for stellar wind speed calculations, where vwind=sqrt(beta) * escape velocity. Default 0.125 (from BSE, Hurley et al. 2002). : (null)\n", - "superwind_mira_switchon : In the Vassiliadis and Wood (1993) AGB wind prescription, the superwind is turned on at a given Mira period, usually 500 days. You can vary when this switch-on happens with this parameter. : (null)\n", - "vw93_mira_shift : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate depends on the Mira period plus this offset. Requires VW93_MIRA_SHIFT. : (null)\n", - "vw93_multiplier : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate is multiplied by this factor. Requires VW93_MULTIPLIER. : (null)\n", - "tpagb_reimers_eta : TPAGB Reimers wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) Note that Reimers is not the default TPAGB wind prescription. See also tpagbwind. : (null)\n", - "Tout_Pringle_1992_multiplier : Multiplier for the Tout & Pringle (1992) magnetic wind. (0.0) : (null)\n", - "artificial_mass_accretion_rate%d : Constant mass accretion rate for star <n>. : (null)\n", - "artificial_mass_accretion_rate_by_stellar_type%d : Constant mass accretion rate for stellar type <n>. : (null)\n", - "artificial_angular_momentum_accretion_rate%d : Constant angular momentum accretion for star <n>. : (null)\n", - "artificial_orbital_angular_momentum_accretion_rate : Constant angular momentum accretion rate on the orbit. : (null)\n", - "artificial_accretion_start_time : Time at which artificial accretion stars. Ignored if <0 (default is -1). : (null)\n", - "artificial_accretion_end_time : Time at which artificial accretion ends. Ignored if <0 (default is -1). : (null)\n", - "wr_wind : Massive-star (WR) wind prescription. 0 = Hurley et al 2000/2002, 1=Maeder and Meynet, 2=Nugis and Lamers, 3=John Eldridge's version of Vink's early-2000s wind (See Lynnette Dray's thesis, or John Eldridge's thesis) : (null)\n", - "wr_wind_fac : Massive-star (WR) wind multiplication factor. : (null)\n", - "wrwindfac : Massive-star (WR) wind multiplication factor. Synonymous with wr_wind_fac (which you should use instead). : (null)\n", - "BH_prescription : Black hole mass prescrition: relates the mass of a newly formed black hole to its progenitor's (CO) core mass. BH_HURLEY2002 = 0 = Hurley et al 2000/2002, BH_BELCZYNSKI = 1 = Belczynski (early 2000s), BH_SPERA2015 = Spera+ 2015, BH_FRYER12_DELAYED = 3 = Fryer et al. (2012) delayed prescription, BH_FRYER12_RAPID = 4 = Fryer et al. (2012) rapid prescription, BH_FRYER12_STARTRACK = 5 = Fryer et al. (2012) startrack prescription. : (null)\n", - "sn_kick_distribution_II : Set the distribution of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_ECAP : Set the distribution of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_NS_NS : Set the distribution of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IBC : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_GRB_COLLAPSAR : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_TZ : Set the distribution of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_AIC_BH : Set the distribution of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_BH_BH : Set the distribution of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_BH_NS : Set the distribution of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD : Set the distribution of speeds applied to any survivor of a hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD_subluminous : Set the distribution of speeds applied to any survivor of a subluminous hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_II : Set the dispersion of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_ECAP : Set the dispersion of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_NS_NS : Set the dispersion of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IBC : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_GRB_COLLAPSAR : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_TZ : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_AIC_BH : Set the dispersion of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_BH_BH : Set the dispersion of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_BH_NS : Set the dispersion of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD : Set the dispersion of speeds applied to the survivor of a SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD_subluminous : Set the dispersion of speeds applied to the survivor of a subluminous SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_companion_IA_He : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia He supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_ELD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia ELD (sub-Mch) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_CHAND : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_AIC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an accretion induced collapse (supernova) occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_ECAP : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an electron capture supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_He_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia helium merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_CHAND_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_NS_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron-star neutron-star merger. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_GRB_COLLAPSAR : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a GRB Collapsar (rapidly rotating SN Ibc) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_HeStarIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a He-star Ia supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IBC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type Ib/c supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_II : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type II supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type IIa supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_WDKICK : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a WD is kicked. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_TZ : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Thorne-Zytkow object is formed. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_AIC_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron star collapses to a black hole. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_BH_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when two black holes merge. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_BH_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a black hole merges with a neutron star. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_Hybrid_HeCOWD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_Hybrid_HeCOWD_subluminous : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a subluminous hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "wd_sigma : Set the speed at which white dwarfs are kicked when they form, in km/s. Default is zero (i.e. no kick). Requires WD_KICKS. : (null)\n", - "wd_kick_direction : Set the direction of white dwarf kicks. 0 = random, 1 = up, 2 = forward, 3 = backward, 4 = inward, 5 = outward. Requires WD_KICKS. : (null)\n", - "wd_kick_when : Decide when to kick a white dwarf. 0=at birth, 1=at first RLOF, 2=at given pulse number (see wd_kick_pulse_number), 3 at every pulse Requires WD_KICKS. : (null)\n", - "wd_kick_pulse_number : Apply a kick to a star at a desired pulse number on the TPAGB (i.e. pre-WD). Requires WD_KICKS. : (null)\n", - "minimum_helium_ignition_core_mass : Minimum helium core mass required to ignite helium in the case that the hydrogen envelope is stripped on the giant branch, e.g. to make an sdB or sdO star. Typically 0.4, if 0.0 then the BSE algorithm (based on the total mass) is used. : (null)\n", - "minimum_CO_core_mass_for_carbon_ignition : Minimum CO core mass for carbon ignition, assuming Mc,bagb>1.6Msun. Typically around 1.08Msun (Pols+1998). : (null)\n", - "minimum_CO_core_mass_for_neon_ignition : Minimum CO core mass for neon ignition. Typically around 1.42Msun. Stars that have cores that ignite carbon, but not neon explode in electon-capture supernovae. : (null)\n", - "minimum_mcbagb_for_nondegenerate_carbon_ignition : Minimum Mc,bagb (core mass at the base of the AGB) for non-degenerate carbon ignition. Typically around 2.25Msun (Pols+1998). : (null)\n", - "maximum_mcbagb_for_degenerate_carbon_ignition : Maximum Mc,bagb (core mass at the base of the AGB) for degenerate carbon ignition. Typically around 1.6Msun (Pols+1998). : (null)\n", - "max_neutron_star_mass : Maximum mass of a neutron star before it collapses to a black hole. Typically around 2Msun. : (null)\n", - "chandrasekhar_mass : The Chandrasekhar mass, usually 1.44Msun : (null)\n", - "delta_mcmin : A parameter to reduce the minimum core mass for third dredge up to occur on the TPAGB. As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null)\n", - "lambda_min : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. See also lambda_multiplier. : (null)\n", - "lambda_multiplier : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null)\n", - "minimum_envelope_mass_for_third_dredgeup : The minimum envelope mass for third dredge up on the TPAGB. Early, solar metallicity models by Straniero et al suggested 0.5Msun is typical. However, circumstantial evidence (Izzard et al 2009) as well as newer models by Stancliffe and Karakas suggest that at low metallicity a value nearer zero is more appropriate. : (null)\n", - "mass_of_pmz : The mass in the partial mixing zone of a TPAGB star, using the Karakas 2012 tables. Ask Carlo Abate for more details, or see the series of papers Abate et al 2012, 2013, 2014. Requires NUCSYN and USE_TABULAR_INTERSHELL_ABUNDANCES_KARAKAS_2012. : (null)\n", - "c13_eff : The \"efficiency\" of partial mixing in a TPAGB star intershell region, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null)\n", - "mc13_pocket_multiplier : Multiplies the mass in the partial mixing zone of a TPAGB star, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null)\n", - "tides_convective_damping : Tidal convective damping algorithm. 0=TIDES_HURLEY2002 Zahn 197x timescales + Hut, as in Hurley et al (2002), 1 = TIDES_ZAHN1989 : Zahn 1989 lambdas + Hut. : (null)\n", - "E2_prescription : Choose how to calculate the E2 structural parameter (used in tidal timescale calculations). 0=Hurley 1=Izzard (see Siess et al 2013). : (null)\n", - "dtfac : A parameter to decrease the timestep ONLY during the TPAGB phase. : (null)\n", - "hbbtfac : A parameter to modulate the temperature at the base of the hot-bottom burning zone in TPAGB stars. (Works only if NUCSYN is defined) : (null)\n", - "wind_multiplier_%d : Wind multiplier for the stellar type specified by the intger %d. By default these are all 1.0. : (null)\n", - "wind_type_multiplier_%d : Wind multiplier for different types of wind (MS, GB, AGB, WR, LBV, OTHER), given by the integer %d. By default these are all 1.0. : (null)\n", - "pre_main_sequence : Set to True to turn on pre-main sequence evolution. Currently this is not a special stellar type, rather the first (small) fraction of the main sequence has increased radii to match the Railton et al 2014 fits to Tout's pre-main sequence stars. Requires PRE_MAIN_SEQUENCE. See also pre_main_sequence_fit_lobes. : (null)\n", - "pre_main_sequence_fit_lobes : Set to True force a pre-main sequence star into its Roche lobe. This is done by artificially aging it. Requires PRE_MAIN_SEQUENCE : (null)\n", - "small_envelope_method : Choose the method used to determine the stellar radius when the envelope mass is very thin. 0 = Hurley et al. (2002), 1 = Miller Bertolami et al. (2016+) for GB and AGB stars only. : (null)\n", - "timestep_modulator : Multiplier applied to the global timestep. Requires TIMESTEP_MODULATION. : (null)\n", - "timestep_multiplier%d : Multiplier applied to timestep limit <n>. : (null)\n", - "maximum_timestep : The maximum timestep (MYr). : (null)\n", - "zoomfac_multiplier_decrease : When a timestep is rejected, decrease the timestep by this factor (0.5). : (null)\n", - "zoomfac_multiplier_increase : When a timestep is rejected, zooms, then succeeds, increase the timestep by this factor (1.2). : (null)\n", - "maximum_timestep_factor : The maximum factor between two subsequent timesteps (1.2). : (null)\n", - "maximum_nuclear_burning_timestep : The maximum timestep (MYr) in any nuclear burning phase. : (null)\n", - "nova_retention_method : Algorithm used to calculate the amount of mass retained during a nova explosion. 0=use nova_retention_fraction. (other methods pending) : (null)\n", - "MINT_metallicity : This sets the metallicity for MINT. It is ignored if set to -1.0, the default, in which case the normal metallicity parameter is used. : (null)\n", - "gaia_Teff_binwidth : log10(Effective temperature) bin width used to make Gaia-like HRDs\n", - " : (null)\n", - "gaia_L_binwidth : log10(luminosity) bin width used to make Gaia-like HRDs\n", - " : (null)\n", - "gaia_colour_transform_method : Use this to select the method used to transform to Gaia colours from other colour schemes. GAIA_CONVERSION_UBVRI_UNIVARIATE_JORDI2010 = 0 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_UBVRI_BIVARIATE_JORDI2010 = 1 Jordi et al.'s bivariate UBVRI fits, GAIA_CONVERSION_ugriz_UNIVARIATE_JORDI2010 = 2 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_ugriz_BIVARIATE_JORDI2010 = 3 Jordi et al.'s univariate ugriv fits, GAIA_CONVERSION_UBVRI_UNIVARIATE_EVANS2018 = 4 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_ugriz_UNIVARIATE_EVANS2018 = 5 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_UBVRI_RIELLO2020 = 6 Riello et al. (2020, DR3) fits, GAIA_CONVERSION_ugriz_RIELLO2020 = 7 Riello et al. (2020, DR3) fits. : (null)\n", - "rotationally_enhanced_mass_loss : Set to 1 to enable rotationally enhanced mass loss rate algorithms: 0= none, 1=formula cf. Langer models (=ROTATIONALLY_ENHANCED_MASSLOSS_LANGER_FORMULA), 2=limit accretion rate before wind loss is applied, 3 = both 1 and 2. See also rotationally_enhanced_exponent : (null)\n", - "AGB_core_algorithm : Algorithm to use for calculating AGB core masses. 0=Hurley et al. 2002 if no NUCSYN, Karakas 2002 if NUCSYN is defined; 1=Hurley et al. 2002 (overshooting models); 1=Karakas 2002 (non-overshooting models). : (null)\n", - "AGB_radius_algorithm : Algorithm to use for calculating radii on the TPAGB. : (null)\n", - "AGB_luminosity_algorithm : Algorithm to use for calculating luminosities on the TPAGB. : (null)\n", - "AGB_3dup_algorithm : Algorithm to use for calculating third dredge up efficiency on the TPAGB. : (null)\n", - "overspin_algorithm : Algorithm to determine what we do when a star is rotating at its breakup velocity. OVERSPIN_BSE (0) conservatively transfers the angular momentum back to the orbit. OVERSPIN_MASSLOSS uses the rotationally_enhanced_massloss parameter to lose mass which carries away the angular momentum. : (null)\n", - "rotationally_enhanced_exponent : The exponent (power) by which rotationally enhanced mass loss is raised. Requires ROTATIONALLY_ENHANCED_MASS_LOSS. See also rotationally_enhanced_mass_loss. : (null)\n", - "batchmode : Set the batchmode control variable. Use only if you know what you are doing! : (null)\n", - "speedtests : If True, turns on speedtests during version information (off by default). : (null)\n", - "use_fixed_timestep_%d : Set to True to use fixed timestep <n>, False to turn off. Fixed timesteps are on (this is True) by default. : (null)\n", - "task%d : Control tasks to be performed by binary_c. By default, these are all TRUE. For more information see binary_c_macros.h, particularly the BINARY_C_TASK_* macros. : (null)\n", - "orbiting_object : Usage: --orbiting_object mass,spinrate,central_object,period. : 1.0\n", - "orbiting_objects_log : If True, turn on orbiting-object log. : (null)\n", - "orbiting_objects_log : If True, turn on orbiting-object log. : (null)\n", - "orbiting_objects_wind_accretion_multiplier : Multiplier for wind accretion on orbiting objects. Hurley et al 2002 use 1.5, which is the default. : (null)\n", - "orbiting_objects_close_pc_threshold : How close are orbiting objects allowed to be? Set this to be the absolute percentage difference minimum. : (null)\n", - "orbiting_objects_tides_multiplier : Multiplier for tidal torques on orbiting objects. : (null)\n", - "evaporate_escaped_orbiting_objects : If True, evaporate orbiting objects that have escaped the system. : (null)\n", - "RLOF_transition_objects_escape : If True, objects that escape their Roche lobe are ejected from the system, otherwise they are placed just outside the minimum stable orbit. : (null)\n", - "PN_resolve : If True, the timestep will be shortened to resolve better the PN phase (FALSE). : (null)\n", - "PN_resolve_minimum_luminosity : The luminosity above which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_resolve_maximum_envelope_mass : The envelope mass below which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_resolve_minimum_effective_temperature : The minimum effective temperature above which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_fast_wind : If True, thin-envelope PNe will have fast winds (FALSE). : (null)\n", - "PN_fast_wind_dm_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null)\n", - "PN_fast_wind_mdot_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null)\n", - "PN_fast_wind_dm_AGB : The envelope mass below which fast wind used during the AGB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null)\n", - "PN_fast_wind_mdot_AGB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null)\n", - "HeWD_HeWD_ignition_mass : HeWD-HeWD mergers above this mass reignite helium. (0.3) : (null)\n", - "wind_Nieuwenhuijzen_luminosity_lower_limit : Above this luminosity we activate the Nieuwenhuijzen and de Jager wind (4e3 Lsun). : (null)\n", - "wind_LBV_luminosity_lower_limit : Above this luminosity we activate the LBV wind (6e5 Lsun). : (null)\n", - "colour%d : Sets colour %d (0 to NUM_ANSI_COLOURS-1) to the extended ANSI set colour you choose (1-255, 0 means ignore). The colour numbers are defined in src/logging/ansi_colours.h : (null)\n", - "apply_Darwin_Radau_correction : Apply Darwin-Radau correction to the moment of inertia to take rotation into account? : (null)\n", - "degenerate_core_merger_nucsyn : If TRUE, assume that in a degnerate core merger, energy is generated from nucleosynthesis of the whole core, and that this can disrupt the core. The BSE algorithm (Hurley et al. 2002) assumes this to be TRUE, but binary_c assumes FALSE by default. (FALSE) : (null)\n", - "degenerate_core_helium_merger_ignition : If TRUE, assume that when there is a degenerate helium core merger, the star reignites helium. This is required to make R-type carbon stars. (TRUE) : (null)\n", - "degenerate_core_merger_dredgeup_fraction : If non-zero, mix this fraction of the degenerate core during a merger.(0.0). : (null)\n", - "\n", - "############################################################\n", - "##### Section Binary\n", - "############################################################\n", - "separation : Set the orbital separation (actually the semi-major axis) of the binary (internal index 0, stellar indices 0 and 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "separation_triple : Set the orbital separation (actually the semi-major axis) of the triple (internal index 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "separation_quadruple : Set the orbital separation (actually the semi-major axis) of the quadruple (internal index 2) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "orbital_period : Set the initial orbital period of the binary, stars 1 and 2 (internal indices 0 and 1) in days. See also separation. : (null)\n", - "orbital_period_triple : Set the initial orbital period of the triple in days. See also separation. : (null)\n", - "orbital_period_quadruple : Set the orbital period of the outer binary in a quadrulple (stars 3 and 4, internal indices 2 and 3) in days. See also separation. : (null)\n", - "eccentricity : Set the initial eccentricity of the binary orbit (stars 1 and 2, internal indices 0 and 1). : (null)\n", - "eccentricity_triple : Set the initial eccentricity of the triple orbit. : (null)\n", - "eccentricity_quadruple : Set the initial eccentricity of the outer binary of a quadruple (stars 3 and 4, internal indices 2 and 3). : (null)\n", - "incliniation : Set the initial orbital_inclination of the binary relative to zero. : (null)\n", - "incliniation_triple : Set the initial orbital_inclination of the triple orbit relative to zero. : (null)\n", - "incliniation_quadruple : Set the initial orbital_inclinationy of the quadruple orbit relative to zero. : (null)\n", - "orbital_phase : Set the initial orbital phase of the binary orbit. : (null)\n", - "orbital_phase_triple : Set the initial orbital phase of the triple orbit. : (null)\n", - "orbital_phase_quadruple : Set the initial orbital phase of the quadruple orbit. : (null)\n", - "argument_of_periastron : Set the initial argument of periastron of the binary orbit. : (null)\n", - "argument_of_periastron_triple : Set the initial argument of periastron of the triple orbit. : (null)\n", - "argument_of_periastron_quadruple : Set the initial argument of periastron of the quadruple orbit. : (null)\n", - "disc_timestep_factor : Factor that multiplies the natural timestep of a disc. : (null)\n", - "white_dwarf_cooling_model : White dwarf cooling model, relates age to luminosity. WHITE_DWARF_COOLING_MESTEL = 0 is Mestel's model, WHITE_DWARF_COOLING_MESTEL_MODIFIED = 1 is Hurley's modified Mestel model, WHITE_DWARF_COOLING_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null)\n", - "white_dwarf_radius_model : White dwarf radius model, radius to mass (and perhaps age). WHITE_DWARF_RADIUS_NAUENBERG1972 = 0 Nauenberg (1972), WHITE_DWARF_RADIUS_MU = 1 mu-dependent variant, WHITE_DWARF_RADIUS_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null)\n", - "cbdisc_mass_loss_inner_viscous_accretion_method : Chooses where the mass that is accreted from the inner edge of a circumbinary disc goes, i.e. to which star. 0 = Young and Clarke 2015, 1 = Gerosa et al 2015, 2 = 50:50 (i.e. not dependence on mass). : (null)\n", - "cbdisc_inner_edge_stripping : If True, allow inner edge mass stripping. : (null)\n", - "cbdisc_end_evolution_after_disc : If True, stop evolution when a disc evaporates. : (null)\n", - "cbdisc_no_wind_if_cbdisc : If True, disable stellar winds when there is a circumbinary disc. : (null)\n", - "cbdisc_outer_edge_stripping : If True, allow outer edge mass stripping. : (null)\n", - "disc_n_monte_carlo_guesses : Number of monte carlo guesses to try in the disc solver if the normal list of guesses fails (0). : (null)\n", - "disc_log : If 1, turn on the disc log. Requires DISC_LOG to be defined on build. : (null)\n", - "disc_log2d : If 1, turn on the 2d disc log. Requires DISC_LOG to be defined on build. : (null)\n", - "disc_log_dt : If non-zero, only allows disc log output every disc_log_dt Myr. : (null)\n", - "disc_log_directory : Directory into which disc logging is sent (must exist!). : /tmp/\n", - "post_ce_adaptive_menv : If TRUE, and if post_ce_objects_have_envelopes is TRUE, then the envelope mass of a post-CE star is such that it sits just inside its Roche lobe. If FALSE then a fixed (thin) envelope mass is applied that depends on the stellar type (see macros POST_CE_ENVELOPE_DM_GB, POST_CE_ENVELOPE_DM_EAGB and POST_CE_ENVELOPE_DM_TPAGB). : (null)\n", - "post_ce_objects_have_envelopes : If TRUE then post-common-envelope objects have thin envelopes. You need this if you are to have post-CE post-AGB stars. Note that this *may* be unstable, i.e. you may end up having many CEEs. The mass in the envelope is controlled by post_ce_adaptive_menv. TRUE by default. : (null)\n", - "PN_comenv_transition_time : post-common envelope transition time in years (1e2). This is the time taken to move from CEE ejection to Teff > 30e4 K. Hall et al. (2013) suggest ~100 years. : (null)\n", - "minimum_time_between_PNe : The minimum time (Myr) between planetary nebula detections. This prevents multiple, fast common envelopes triggering two PNe (0.1). : (null)\n", - "PN_Hall_fading_time_algorithm : In stars with low mass (<0.45Msun) cores, you can choose to set the PN fading time to either the minimum (PN_HALL_FADING_TIME_ALGORITHM_MINIMUM) or maximum (PN_HALL_FADING_TIME_ALGORITHM_MAXIMUM) as shown in Fig. 6 of Hall et al. (2013). : (null)\n", - "PPN_envelope_mass : Desired pre-planetary nebula (post-AGB) envelope mass. : (null)\n", - "cbdisc_eccentricity_pumping_method : Select from various eccentricity-pumping methods when there is a circumbinary disc. Requires DISCS. 0 = off. : (null)\n", - "cbdisc_viscous_photoevaporative_coupling : Set to 1 to turn on viscous-photoevaporative coupling in circumbinary discs. Requires DISCS. 0 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_NONE = off, 1 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_INSTANT instant, 2 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_VISCOUS slow, viscous wind. : (null)\n", - "cbdisc_inner_edge_stripping_timescale : Defines the timescale for mass loss from by inner edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_in. : (null)\n", - "cbdisc_outer_edge_stripping_timescale : Defines the timescale for mass loss from by outer edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_out. : (null)\n", - "cbdisc_viscous_L2_coupling : Set to 1 to turn on viscous-L2-loss coupling in circumbinary discs. Requires DISCS. 0 = off. : (null)\n", - "gravitational_radiation_model : Model for gravitational radiation from the system. 0=Hurley et al 2002 (Landau and Lifshitz 1951). 1 = as 0 but only when there is no RLOF. 2 = none. : (null)\n", - "nova_irradiation_multiplier : Multiplier for nova-radiative induced mass loss. (Shara+1986) : (null)\n", - "gravitational_radiation_modulator_J : Modulator for gravitational wave radiation angular momentum loss rate (1.0). : (null)\n", - "gravitational_radiation_modulator_e : Modulator for gravitational wave radiation eccentricity pumping rate (1.0). : (null)\n", - "nova_faml_multiplier : Nova friction-induced angular momentum loss multiplier. (Shara+1986) : (null)\n", - "RLOF_angular_momentum_transfer_model : Choose angular momentum transfer model in RLOF. 0=BSE (with discs), 1=conservative : (null)\n", - "post_SN_orbit_method : Method by which the post-SN orbit is calculated. 0=BSE, 1=Tauris&Taken 1998. : (null)\n", - "multiplicity : Multiplicity: 1=single star, 2=binary, 3=triple, 4=quadruple. : (null)\n", - "accretion_limit_eddington_steady_multiplier : Steady accretion is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_steady_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_eddington_LMMS_multiplier : Accretion from a low-mass, convective, main_sequence star is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_LMMS_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_eddington_WD_to_remnant_multiplier : Accretion from a WD onto a remnant star (e.g. another white dwarf, neutron star or black hole) is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_WD_to_remnant_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_thermal_multiplier : Mass transfer onto a MS, HG or CHeB star is limited by the accretor's thermal rate times this multiplier. : (null)\n", - "accretion_limit_dynamical_multiplier : Mass transfer is limited by the accretor's dynamical rate times this multiplier. : (null)\n", - "donor_limit_envelope_multiplier : Mass transfer by RLOF is limited by this fraction of the donor's envelope mass per timestep : (null)\n", - "donor_limit_thermal_multiplier : Mass transfer by RLOF is limited by the accretor's thermal rate times this multiplier. : (null)\n", - "donor_limit_dynamical_multiplier : Mass transfer by RLOF is limited by the donor's dynamical rate times this multiplier. : (null)\n", - "Bondi_Hoyle_accretion_factor : Wind accretion rate, as calculated by the Bondi-Hoyle-Littleton formula, multiplcation factor. Hurley et al 2002 use 1.5, which is the default. : (null)\n", - "tidal_strength_factor : A modulator for the tidal strength. If this factor > 1 then tides are stronger, i.e. tidal timescales are reduced. : (null)\n", - "hachisu_qcrit : Critical q=Maccretor/Mdonor above which Hachisu's disk wind turns on. : (null)\n", - "hachisu_disk_wind : Set to True to turn on Hachisu's disk wind when material accretes too fast onto a white dwarf. This helps to make more SNeIa. See also hachisu_qcrit. : (null)\n", - "mass_accretion_for_eld : The mass that must be accreted onto a COWD for it to ignite as an edge-lit detonation SNIa. : (null)\n", - "WDWD_merger_algorithm : Algorithm to be used when merging two white dwarfs. 0 = Hurley et al. (2002), 1 = Perets+ (2019), 2 = Chen+ (2016, todo) : (null)\n", - "type_Ia_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from Chandrasekhar-mass exploders. 0 = DD7 (Iwamoto 1999), 1 = Seitenzahl 2013 3D hydro yields (you must also set Seitenzahl2013_model) : (null)\n", - "Seitenzahl2013_model : Which of Seitenzahl et al. 2013's models to use? One of N1,N3,N5,N10,N20,N40,N100L,N100,N100H,N150,N200,N300C,N1600,N1600C,N100_Z0.5,N100_Z0.1,N100_Z0.01 (defaults to N100). : N1\n", - "type_Ia_sub_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from sub-Chandrasekhar-mass exploders. (Currently unused.) : (null)\n", - "max_HeWD_mass : The maximum mass a HeWD can have before it ignites helium (0.7). : (null)\n", - "merger_mass_loss_fraction : Fraction of the total mass which is lost when stars merge. : (null)\n", - "merger_angular_momentum_factor : When two stars merge the resulting single star retains a fraction of the total system angular momentum (or the critical spin angular momentum, if it is smaller) multiplied by this factor. : (null)\n", - "wind_angular_momentum_loss : Prescription for losing angular momentum in a stellar wind. 0=Hurley et al 2002 ('Tout') prescription, 1=lw i.e. a factor multiplying the specific orbital angular momentum, 2=lw hybrid for fast winds. Set wind_djorb_fac to the desired factor.. : (null)\n", - "wind_djorb_fac : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=0 (the Tout/Hurley et al 2002 prescription). See wind_angular_momentum_loss. : (null)\n", - "lw : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=1,2 (the 'lw' prescription). See wind_angular_momentum_loss. : (null)\n", - "VW93_EAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null)\n", - "VW93_TPAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null)\n", - "use_periastron_Roche_radius : Set this to True to use the Roche lobe radius at periastron, rather than (the default to) assume a circular orbit. This will be useful one day when we treat RLOF in eccentric orbits properly, hopefully. : (null)\n", - "qcrit_LMMS : Apply critical q=Mdonor/Maccretor value for low-mass main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_LMMS : Apply critical q=Mdonor/Maccretor value for (low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "mass_for_Hestar_Ia_upper : Only helium stars below this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_lower. : (null)\n", - "mass_for_Hestar_Ia_lower : Only helium stars above this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_upper. : (null)\n", - "alphaCB : Circumbinary disk viscosity parameter, alpha. : (null)\n", - "minimum_donor_menv_for_comenv : Minimum donor envelope mass for common envelope evolution to be triggered (Msun). Default 0. : (null)\n", - "comenv_prescription : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null)\n", - "comenv_prescription%d : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null)\n", - "comenv_ejection_spin_method : When a common envelope is ejected, we need to decide how fast the stars are left spinning. COMENV_EJECTION_SPIN_METHOD_DO_NOTHING (0) is the default, this just leaves the stars/stellar cores spinning with the same spin rate (omega = angular velocity) with which they entered the common envelope phase. COMENV_EJECTION_SPIN_METHOD_SYCHRONIZE instead tidally synchronizes the stars with their new orbital angular velocity. : (null)\n", - "comenv_merger_spin_method : When a common envelope binary merges, we need to decide how fast the resulting single star is left spinning. COMENV_MERGER_SPIN_METHOD_SPECIFIC (0) is the default, this preserves angular momentum but limits the specific angular momentum of the merged star to the specific angular momentum of the system at the onset of common envelope evolution. COMENV_MERGER_SPIN_METHOD_CONSERVE_ANGMOM (1) sets the merger's angular momentum to be that of the system at the onset of common envelope evolution (which means the star may be rotating supercritically). COMENV_MERGER_SPIN_METHOD_CONSERVE_OMEGA (2) sets the spin rate (angular frequency = omega) of the merged star to be that of the orbit just at the onset of common envelope evolution. : (null)\n", - "comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null)\n", - "comenv_ms_accretion_fraction : Experimental. During common envelope evolution, a main sequence may accrete a fraction of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_mass. : (null)\n", - "comenv_ns_accretion_mass : Experimental. During common envelope evolution, a neutron star may accrete some of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_fraction. : (null)\n", - "comenv_ns_accretion_fraction : Experimental. During common envelope evolution, a neutron star may accrete a fraction of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_mass. : (null)\n", - "alpha_ce : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null)\n", - "alpha_ce%d : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null)\n", - "lambda_ce : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to LAMBDA_CE_DEWI_TAURIS == -1 binary_c uses the Dewi and Tauris fits instead, LAMBDA_CE_WANG_2016 == -2 uses the formalism of Wang, Jia and Li (2016), if LAMBDA_CE_POLYTROPE == -3 then a polytropic formalism is used (see also comenv_splitmass) and if LAMBDA_CE_KLENCKI_2020 == -4 use Klencki et al. (2020). : (null)\n", - "lambda_ce%d : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to -1 binary_c uses the Dewi and Tauris fits instead, -2 uses the formalism of Wang, Jia and Li (2016) and if -3 then a polytropic formalism is used (see also comenv_splitmass). : (null)\n", - "comenv_splitmass : When lambda_ce=-2, the envelope binding energy, lambda, is calculated using a polytropic formalism. The comenv_splitmass defines the point, in the units of the core mass, above which material is ejected. : (null)\n", - "nelemans_recalc_eccentricity : If True, recalculate the eccentricity after angular momentum is removed. : (null)\n", - "comenv_post_eccentricity : Eccentricity remaining after common envelope ejection. : (null)\n", - "nelemans_gamma : Set the fraction of the orbital specific angular momentum that is used to eject the common envelope according to the Nelemans and Tout prescription. See also nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null)\n", - "nelemans_minq : Only activate the Nelemans and Tout common envelope prescription for q>nelemans_minq. See also nelemans_gamma, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null)\n", - "nelemans_max_frac_j_change : Maximum fractional angular momentum change in the Nelemans and Tout common envelope prescription. See also nelemans_gamma, nelemans_minq, nelemans_n_comenvs. : (null)\n", - "nelemans_n_comenvs : Set the maximum number of common envelope ejections allowed to follow the Nelemans and Tout prescription, after which the standard alpha prescription is used. : (null)\n", - "lambda_ionisation : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null)\n", - "lambda_ionisation%d : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null)\n", - "lambda_enthalpy : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null)\n", - "lambda_enthalpy%d : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null)\n", - "cbdisc_albedo : Circumbinary-disc albedo. Requires DISCS. : (null)\n", - "cbdisc_gamma : Circumbinary disc gamma (equation of state) parameter. Requires DISCS. : (null)\n", - "cbdisc_alpha : Circumbinary disc alpha (viscosity) parameter. Requires DISCS. : (null)\n", - "cbdisc_kappa : Circumbinary disc kappa (opacity) parameter. Requires DISCS. : (null)\n", - "cbdisc_minimum_evaporation_timescale : Circumbinary disc minimum evaporation timescale (years). If (slow, not edge stripped) mass loss would evaporate the disc on a timescale less than this, simply evaporate the disc immediated. Usually set to 1y, ignore if zero. Requires DISCS. : (null)\n", - "cbdisc_torquef : Circumbinary disc binary torque multiplier. Requires DISCS. : (null)\n", - "cbdisc_max_lifetime : Circumbinary disc maximum lifetime (years, ignored if 0). Requires DISCS. : (null)\n", - "cbdisc_init_dM : On cbdisc start, reduce mass by a fraction dM if it won't converge. Requires DISCS. : (null)\n", - "cbdisc_init_dJdM : On cbdisc start, reduce angular momentum by a fraction dJ/dM*dM if it won't converge. Requires DISCS. : (null)\n", - "cbdisc_mass_loss_constant_rate : Circumbinary disc constant mass loss rate (Msun/year). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_FUV_multiplier : Circumbinary disc FUV mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_Xray_multiplier : Circumbinary disc X-ray mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_ISM_ram_pressure_multiplier : Circumbinary disc interstellar medium ram pressure stripping mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_ISM_pressure : Circumbinary disc interstellar medium ram pressure in units of Boltzmann constant per Kelvin (I think...). Requires DISCS. Typically 3000.0. See e.g. http://www.astronomy.ohio-state.edu/~pogge/Ast871/Notes/Intro.pdf page 15 or https://arxiv.org/pdf/0902.0820.pdf Fig. 1 (left panel). : (null)\n", - "cbdisc_mass_loss_inner_viscous_multiplier : Circumbinary disc inner edge viscous mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_inner_viscous_angular_momentum_multiplier : Circumbinary disc inner edge viscous angular momentum multiplier (no units). The inner edge angular momentum Requires DISCS. : (null)\n", - "cbdisc_resonance_multiplier : Circumbinary disc resonant interaction multiplier, affects eccentricity pumping and angular momentum rates. Requires DISCS. : (null)\n", - "cbdisc_resonance_damping : Circumbinary disc resonant interaction damping: should be on (True) to damp the l=1, m=2 resonance when the disc inner edge lies outside the resonance location. Requires DISCS. : (null)\n", - "cbdisc_fail_ring_inside_separation : If True, while converging on a structure, circumbinary discs with Rring < the binary separation are immediately failed. : (null)\n", - "cbdisc_mass_loss_inner_L2_cross_multiplier : Circumbinary disc inner edge L2-crossing mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_minimum_luminosity : Circumbinary disc minimum luminosity. If the disc becomes dimmer than this, the disc is evaporated instantly. Requires DISCS. : (null)\n", - "cbdisc_minimum_mass : Circumbinary disc minimum mass. If the disc becomes less massive than this, the disc is evaporated instantly. Requires DISCS. : (null)\n", - "cbdisc_minimum_fRing : Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = |Rout/Rin-1| < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS. : (null)\n", - "comenv_disc_angmom_fraction : If >0 Fraction of the common envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the moments of inertia to calculate (deprecated), if -2 use the common envelope's specific angular momentum, if -3 uses the L2 point at the end of the common envelope to set the angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null)\n", - "comenv_disc_mass_fraction : Fraction of the common envelope's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null)\n", - "wind_disc_angmom_fraction : If >0 Fraction of the wind envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the L2 point's specific angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null)\n", - "wind_disc_mass_fraction : Fraction of the stellar wind's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null)\n", - "WRLOF_method : Choose whether and how to apply wind-Roche-lobe-overflow. 0=none, 1=q-dependent, 2=quadratic See Abate et al 2013/14 for details. Requires WRLOF_MASS_TRANSFER. : (null)\n", - "minimum_timestep : The minimum timestep (Myr). : (null)\n", - "timestep_solver_factor : Factor applied in timestep_limits, e.g. to prevent X changing too fast by comparing to X/dX/dt, which is usually 1 but can be higher to lengthen timesteps when using an alternative solver. : (null)\n", - "RLOF_mdot_factor : Multiplier applied to the mass transfer rate during Roche-lobe overflow. Requires RLOF_MDOT_MODULATION. : (null)\n", - "RLOF_f : Factor to enlarge a Roche lobe, nominally because of radiation pressure (see Dermine et al paper). Requires RLOF_RADIATION_CORRECTION. : (null)\n", - "minimum_separation_for_instant_RLOF : If True, instead of evolving the system just report the minimum separation (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_orbital_period_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null)\n", - "minimum_orbital_period_for_instant_RLOF : If True, instead of evolving the system just report the minimum orbital period (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_separation_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null)\n", - "maximum_mass_ratio_for_instant_RLOF : If True, instead of evolving the system just report the maximum mass ratio (on the zero-age main sequence) that would lead to instant RLOF, given M1 and orbital period. Used by binary_grid. See also minimum_separation_for_instant_RLOF and minimum_orbital_period_for_instant_RLOF. : (null)\n", - "RLOF_method : Use RLOF_method to choose the algorithm you use for Roche-lobe overflow mass loss rate calculations. 0=Hurley et al 2002, 1=Adaptive (for radiative stars) R=RL method, 2=Ritter (probably broken), 3=Claeys etal 2014 variant on Hurley et al 2002. : (null)\n", - "RLOF_interpolation_method : When a star overflows its Roche lobe, it always has R>RL because of the limited time resolution of the simulation. Binary_c then uses an algorithm to get back to when R~RL (within a desired tolerance, set in RLOF_ENTRY_THRESHOLD which is usually 1.02, i.e. overflow of 2%). You can choose algorithm 0, the Hurley et al 2002 method which reverses time (i.e. uses a Newton-like scheme), or 1 to use the binary_c method which rejects a timestep (and hence does no logging on that timestep) and repeats with half the timestep until R~RL. The latter is now the default, because this means there are no negative timesteps which break various other algorithms (e.g. nucleosynthesis). : (null)\n", - "nova_retention_fraction : The mass accreted during a nova as fraction of mass transferred : (null)\n", - "beta_reverse_nova : The fraction of mass ejected in a nova explosion which is accreted back onto the companion star. Set to -1 to automatically calculate based on a geometric argument, or 0 or positive to set the value. : (null)\n", - "WD_accretion_rate_novae_upper_limit_hydrogen_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is hydrogen rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_novae_upper_limit_helium_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is helium rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_novae_upper_limit_other_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is neither hydrogen nor helium rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_hydrogen_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a hydrogen-rich donor. Below this mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_helium_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a helium-rich donor. Below this mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_other_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope when the donor is neither hydrogen nor helium rich. Below this mass transfer leads to stable burning. : (null)\n", - "CRAP_parameter : Tidally enhanced mass loss parameter. See Tout and Eggleton's paper on the subject. (Was the parameter bb). : (null)\n", - "individual_novae : If individual_novae is True, novae are resolved such that each explosion is performed separtaely. : (null)\n", - "nova_timestep_accelerator_num : The nova timestep is accelerated if the nova number exceeds nova_timestep_accelerator_num. If zero or negative, acceleration is off. See also nova_timestep_accelerator_index and nova_timestep_accelerator_max. Only used if individual_novae is on.\n", - " : (null)\n", - "nova_timestep_accelerator_index : The index at which the nova timestep is accelerated. A larger value gives longer timesteps. See also nova_timestep_accelerator_num and nova_timestep_accelerator_max. Only used if individual_novae is on.\n", - " : (null)\n", - "nova_timestep_accelerator_max : The nova timestep is accelerated by a factor that is capped at nova_timestep_accelerator_max. This parameter is ignored if it is zero or negative. See also nova_timestep_accelerator_num and nova_timestep_accelerator_index. Only used if individual_novae is on.\n", - " : (null)\n", - "nonconservative_angmom_gamma : Mass lost from the system (but NOT from a stellar wind) takes a fraction gamma of the orbital angular momentum with it. Set to -1 to take the specific angular momentum of the donor star. Set to -2 to take super-Eddington, nova and disk-wind angular momenta as if a wind from the accretor. : (null)\n", - "max_stellar_angmom_change : Maxmimum fractional change in stellar angular momentum allowed before a timestep is rejected (0.05). : (null)\n", - "comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null)\n", - "\n", - "############################################################\n", - "##### Section Nucsyn\n", - "############################################################\n", - "third_dup : If True, enables third dredge up. Requires NUCSYN and NUCSYN_THIRD_DREDGE_UP. : (null)\n", - "third_dup_multiplier : Usage: --third_dup_multiplier <i> <f>. Multiplies the abundance of element <i> by <f> during third dredge up. : 1.0\n", - "NeNaMgAl : Enables NeNaMgAl reaction network. Requires NUCSYN and NUCSYN_HBB. : Ignore\n", - "nucsyn_network%d : Usage: --nucsyn_network%d <boolean>. Turn a nuclear network on or off. : (null)\n", - "nucsyn_network_error%d : Usage: --nucsyn_network_error%d <f>. Threshold error in nuclear network solver for network %d. : (null)\n", - "nucreacmult%d : Usage: --nucreacmult%d <f>. Multiply nuclear reaction given by the integer %d (integer) by f (float). : (null)\n", - "nucsyn_metallicity : This sets the metallicity of the nucleosynthesis algorithms, i.e. the amount (by mass) of matter which is not hydrogen or helium. Usually you'd just set this with the metallicity parameter, but if you want the nucleosynthesis to be outside the range of the stellar evolution algorithm (e.g. Z=0 or Z=0.04) then you need to use nucsyn_metallicity. That said, it's also outside the range of some of the nucleosynthesis algorithms as well, so you have been warned! : (null)\n", - "nucsyn_solver : Choose the solver used in nuclear burning. 0 = KAPS_RENTROP is a Kaps-Rentrop scheme (fast, not great for stiff problems), 1 = LSODA (Adams/BSF switcher), 2 = CVODE library (https://computing.llnl.gov/projects/sundials. Default 0. : 0\n", - "initial_abundance_mix : initial abundance mixture: 0=AG89, 1=Karakas 2002, 2=Lodders 2003, 3=Asplund 2005 (not available?), 4=Garcia Berro, 5=Grevesse Noels 1993 : 0\n", - "init_abund : Usage: --init_abund <i> <X>. Sets the initial abundance of isotope number <i> to mass fraction <X>. : 0.02\n", - "init_abund_mult : Usage: --init_abund_mult <i> <f>. Multiplies the initial abundance of isotope number <i> by <f>. : 1.0\n", - "init_abund_dex : Usage: --init_abund_dex <i> <f>. Changes the initial abundance of isotope number <i> by <f> dex. : 0.0\n", - "init_abunds_only : If True, outputs only the initial abundances, then exits. : (null)\n", - "initial_abunds_only : If True, outputs only the initial abundances, then exits. : (null)\n", - "no_thermohaline_mixing : If True, disables thermohaline mixing. : (null)\n", - "lithium_GB_post_Heflash : Sets the lithium abundances after the helium flash. Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "lithium_GB_post_1DUP : Sets the lithium abundance after first dredge up. Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "lithium_hbb_multiplier : Multiplies the lithium abundances on the AGB during HBB (based on Karakas/Fishlock et al models).Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "angelou_lithium_decay_function : Functional form which describes Li7 decay. Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Choices are : 0 expoential (see angelou_lithium_decay_time). : (null)\n", - "angelou_lithium_LMMS_time : Time at which lithium manufacture is triggered in a low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_time : Time at which lithium manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_time : Time at which lithium manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_time : Time at which lithium manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_time : Time at which lithium manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_time : Time at which lithium manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_time : Time at which lithium manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_LMMS_decay_time : Decay time for surface lithium abundance during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_decay_time : Decay time for surface lithium abundance on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_decay_time : Decay time for surface lithium abundance on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_decay_time : Decay time for surface lithium abundance on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_decay_time : Decay time for surface lithium abundance during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_decay_time : Decay time for surface lithium abundance on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_decay_time : Decay time for surface lithium abundance on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_LMMS_massfrac : Lithium mass fraction when its manufacture is triggered during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_massfrac : Lithium mass fraction when its manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_massfrac : Lithium mass fraction when its manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_massfrac : Lithium mass fraction when its manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_massfrac : Lithium mass fraction when its manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_vrot_trigger : Equatorial rotational velocity at which lithium manufacture is triggered (km/s). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0.\n", - " : (null)\n", - "angelou_lithium_vrotfrac_trigger : Fraction of Keplerian (breakup) equatorial rotational velocity at which lithium manufacture is triggered (must be <1, ignored if 0). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0.\n", - " : (null)\n", - "\n", - "############################################################\n", - "##### Section Output\n", - "############################################################\n", - "cf_amanda_log : Enable logging to compare to Amanda's models. : (null)\n", - "float_overflow_checks : Turn on to enable floating-point overflow checks at the end of each timestep, if they are available. 0=off, 1=warn (stderr) on failure, 2=exit on failure (0) : (null)\n", - "save_pre_events_stardata : Enable this to save a copy of stardata to stardata->pre_events_stardata just before an event. : (null)\n", - "disable_end_logging : Disable the logging that happens at the end of the evolution. : (null)\n", - "ensemble : Turn on ensemble calculations and output. : (null)\n", - "ensemble_filters_off : Sets all ensemble filters to be off (FALSE) - these can then be enabled one-by-one with --ensemble_filter_[...] TRUE. : (null)\n", - "ensemble_filter_%d : Turn on or off ensemble filter <n>. For a list of filters, see ensemble_macros.h. : (null)\n", - "ensemble_legacy_ensemble : Turn on ensemble legacy population output. : (null)\n", - "legacy_yields : Turn on ensemble legacy yield output. : (null)\n", - "ensemble_defer : Defer ensemble output. : (null)\n", - "ensemble_dt : When doing ensemble calculations, data are stored and/or output every ensemble_dt Myr. See also ensemble, ensemble_logdt, ensemble_startlogtime. : (null)\n", - "ensemble_logdt : When doing ensemble calculations, and when logensembletimes is set, the ensemble is stored/output every ensemble_logdt Myr. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null)\n", - "ensemble_startlogtime : Start log ensemble data storage/calculations/output at ensemble_startlogtime. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null)\n", - "ensemble_logtimes : When doing ensemble calculations/output, set this to act at log times rather than linear times. : (null)\n", - "postagb_legacy_logging : Turn on post-AGB legacy logging. : (null)\n", - "disc_legacy_logging : Turn on disc legacy logging. : (null)\n", - "EMP_logg_maximum : Maximum logg that EMP stars are allowed to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_minimum_age. : (null)\n", - "EMP_minimum_age : Minimum age that EMP stars are required to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum. : (null)\n", - "EMP_feh_maximum : Maximum [Fe/H] that an EMP stars may have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default -2.0. : (null)\n", - "CEMP_cfe_minimum : Minimum [C/Fe] that CEMP stars are required to have. See Izzard et al 2009. See also NEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 0.7. : (null)\n", - "NEMP_cfe_minimum : Minimum [N/Fe] that NEMP stars are required to have. See Izzard et al 2009, Pols et al. 2012. See also CEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 1.0. : (null)\n", - "thick_disc_start_age : Lookback time for the start of the thick disc star formation, e.g. 13e3 Myr. Units = Myr. : (null)\n", - "thick_disc_end_age : Lookback time for the end of the thick disc star formation, e.g. 4e3 Myr. Units = Myr. : (null)\n", - "thick_disc_logg_min : Minimum logg for thick disc giants to be logged. : (null)\n", - "thick_disc_logg_max : Maximum logg for thick disc giants to be logged. : (null)\n", - "escape_velocity : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 1e9 km/s. See also escape_fraction. : (null)\n", - "escape_fraction : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 0.0. See also escape_velocity. : (null)\n", - "colour_log : If set to True, thelog is coloured with ANSI colour formatting. Requires FILE_LOG to be defined. : \n", - "log_filename : Location of the output logging filename. If set to \"/dev/null\" then there is no logging. : \n", - "log_arrows : Add arrows to the output log to show whether values are increasing or decreasing. : \n", - "stopfile : File which, when it exists, will stop the current binary_c repeat run. : \n", - "stardata_dump_filename : Location of the stardata dump file. : \n", - "stardata_load_filename : Location of the stardata file to load. : \n", - "api_log_filename_prefix : Location of the output logging filename prefix for the API. If set to \"/dev/null\" then there is no logging. : 0\n", - "hrdiag_output : Set to True to output high time-resolution Hertzstrpung-Russell diagram information. Requires HRDIAG. : (null)\n", - "internal_buffering : Experimental. Set to non-zero values to implement internal buffering prior to output. For use with binary_grid, you shouldn't really be playing with this. : (null)\n", - "eccentric_RLOF_model : Chooses which model is used to handle eccentric RLOF. Default is RLOF_ECCENTRIC_AS_CIRCULAR, i.e. ignore the eccentricity. Note: requires force_corotation_of_primary_and_orbit to be FALSE.\n", - " : (null)\n", - "force_circularization_on_RLOF : If True forces circularization of stars and orbit when RLOF starts, this is as in the BSE algorithm. (True) : (null)\n", - "wtts_log : If True, enables log file output for WTTS2. : (null)\n", - "fabian_imf_log_time : Time at which to output for Fabian Schneider's IMF project. Requires FABIAN_IMF_LOG : Ignore\n", - "fabian_imf_log_timestep : Timestep for Fabian Schneider's IMF project logging. Requires FABIAN_IMF_LOG : Ignore\n", - "version : Display binary_c version and build information. Also performs timing tests. : Ignore\n", - "dumpversion : Display binary_c version number (short format). : Ignore\n", - "version_only : Display binary_c version number and build information, but do not perform timing tests or anything that requires stardata to be non-NULL. : Ignore\n", - "tides_diagnosis_log : Enable logging to test MINT tides. Requires MINT. Choices are: 0 disabled, 1 enable lambda test. : Ignore\n", - "\n", - "############################################################\n", - "##### Section Input\n", - "############################################################\n", - "MINT_dir : Location of MINT algorithm data. : \n", - "MINT_data_cleanup : Activate checks on incoming data to try to account for problems. Will make data-loading slower, but may fix a few things. : \n", - "MINT_MS_rejuvenation : Turn on or off (hydrogen) main-sequence rejuvenation. : \n", - "MINT_remesh : Turn on or off MINT's remeshing. : \n", - "MINT_use_ZAMS_profiles : Use chemical profiles at the ZAMS if MINT_use_ZAMS_profiles is TRUE, otherwise set homogeneous abundances. (Default is TRUE, so we use the profiles if they are available.) : \n", - "MINT_fallback_to_test_data : If TRUE, use the MINT test_data directory as a fallback when data is unavailable. (FALSE) : \n", - "MINT_disable_grid_load_warnings : Use this to explicitly disable MINT's warnings when loading a grid with, e.g., missing or too much data. : \n", - "MINT_Kippenhahn : Turn on or off MINT's Kippenhahn diagrams. If 0, off, if 1, output star 1 (index 0), if 2 output star 2 (index 1). Default 0. : \n", - "MINT_nshells : Set the initial number of shells MINT uses in each star when doing nuclear burning. Note: remeshing can change this. If MINT_nshells is 0, shellular burning and other routines that require shells will not be available. (200) : \n", - "MINT_maximum_nshells : Set the maximum number of shells MINT uses in each star when doing nuclear burning. Note that this will be limited to MINT_HARD_MAX_NSHELLS. (1000) : \n", - "MINT_minimum_nshells : Set the minimum number of shells MINT uses in each star when doing nuclear burning. Note that this will be greater than or equal to MINT_HARD_MIN_NSHELLS, which is 0 by default. (0) : \n", - "MINT_Kippenhahn_stellar_type : Stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for which Kippenhahn plot data should be output. : \n", - "MINT_Kippenhahn_companion_stellar_type : Companion stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for the companion for which Kippenhahn plot data should be output. : \n", - "MINT_nuclear_burning : Turn on or off MINT's nuclear burning algorithm. : \n", - "MINT_minimum_shell_mass : Minimum shell mass in MINT's nuclear burning routines. : \n", - "MINT_maximum_shell_mass : Maximum shell mass in MINT's nuclear burning routines. : \n", - "\n", - "############################################################\n", - "##### Section I/O\n", - "############################################################\n", - "go : batchmode control command : Ignore\n", - "gogo : batchmode control command : Ignore\n", - "reset_stars : Reset the star structures. Used in batchmode : Ignore\n", - "reset_stars_defaults : Reset the star structures and set defaults. Used in batchmode : Ignore\n", - "defaults : Reset all defaults. Used in batchmode : Ignore\n", - "echo : Activate batchmode command echoing, i.e. when you enter a command, binary_c repeats the command then executes it. : Ignore\n", - "noecho : Deactivate batchmode command echoing. See 'echo'. : Ignore\n", - "noechonow : Deactivate batchmode command echoing. See 'echo'. : Ignore\n", - "bye : Quit binary_c. Used in batchmode. : Ignore\n", - "fin : batchmode control command : Ignore\n", - "reset_prefs : Reset preferences struct. Used in batchmode : Ignore\n", - "status : Output batchmode status information. : Ignore\n", - "\n", - "############################################################\n", - "##### Section Algorithms\n", - "############################################################\n", - "repeat : If > 1, repeats the system as many times as required. Handy if you're using Monte-Carlo kicks and want to sample the parameter space well. Also, if you are running speed tests this is good to give a statistically more reasonable result. (See e.g. 'tbse pgo'). : (null)\n", - "random_systems : Experimental. Use this to apply random initial system parameters (masses, separations, etc.). Useful for testing only. : (null)\n", - "\n", - "############################################################\n", - "##### Section Misc\n", - "############################################################\n", - "random_seed : Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null)\n", - "random_systems_seed : Random number seed for the generation of random systems. See random_systems and random_seed. : (null)\n", - "random_skip : Skip the first <random_seed> random numbers that are generated. Usually this is 0 so they are all used. : (null)\n", - "idum : [NB: deprecated, please use 'random_seed' instead.] Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null)\n", - "reverse_time : Make time go backwards. To be considered very experimental! : (null)\n", - "start_time : Start time for the simulation. : (null)\n", - "warmup_cpu : Uses the CPU at maximum power the given number of seconds, prior to running normal stellar evolution. : Ignore\n", - "help : Display help pages. Usage: --help <help topic>. : Ignore\n", - "argopts : Display argument options. Usage: --argopts <argument>. : Ignore\n", - "help_all : Display all help pages. : Ignore\n", - "list_args : Display list of arguments with their default values. Useful for batchmode. : Ignore\n", - "\n" + "(abridged)\n" ] } ], "source": [ - "print(_binary_c_bindings.return_help_all())" + "print('\\n'.join(_binary_c_bindings.return_help_all().splitlines()[:10]))\n", + "print(\"(abridged)\")" ] }, { @@ -873,12 +300,14 @@ "__ARG_BEGIN\n", "metallicity = 0.02\n", "effective_metallicity = -1\n", - "M_1 = 0\n" + "M_1 = 0\n", + "(abridged)\n" ] } ], "source": [ - "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))" + "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))\n", + "print(\"(abridged)\")" ] }, { @@ -966,7 +395,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -980,7 +409,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/examples/notebook_common_envelope_evolution.html b/docs/build/html/examples/notebook_common_envelope_evolution.html index 3f1b7781b00198dac1300d61598d41076bffd22a..e2fc4ac53fa3eb0c4d4b252b73cc23bbcbb894a4 100644 --- a/docs/build/html/examples/notebook_common_envelope_evolution.html +++ b/docs/build/html/examples/notebook_common_envelope_evolution.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Example use case: Common-envelope evolution — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Example use case: Common-envelope evolution — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Example use case: Binary black hole systems" href="notebook_BHBH.html" /> <link rel="prev" title="Example use case: Hertzsprung-Russell diagrams" href="notebook_HRD.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -95,6 +51,7 @@ <li class="toctree-l2"><a class="reference internal" href="notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -116,70 +73,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Example use case: Common-envelope evolution</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_common_envelope_evolution.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -390,11 +308,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -403,10 +322,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -418,12 +341,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -450,33 +376,31 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Example-use-case:-Common-envelope-evolution"> -<h1>Example use case: Common-envelope evolution<a class="headerlink" href="#Example-use-case:-Common-envelope-evolution" title="Permalink to this headline">¶</a></h1> +<section id="Example-use-case:-Common-envelope-evolution"> +<h1>Example use case: Common-envelope evolution<a class="headerlink" href="#Example-use-case:-Common-envelope-evolution" title="Permalink to this heading">ïƒ</a></h1> <p>In this notebook we look at how common-envelope evolution (CEE) alters binary-star orbits. We construct a population of low- and intermediate-mass binaries and compare their orbital periods before and after CEE. Not all stars evolve into this phase, so we have to run a whole population to find those that do. We then have to construct the pre- and post-CEE distributions and plot them.</p> <p>First, we import a few required Python modules.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">os</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span> <span class="kn">import</span> <span class="nn">math</span> <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">temp_dir</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="k">import</span> <span class="n">Population</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">temp_dir</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="kn">import</span> <span class="n">Population</span> <span class="n">TMP_DIR</span> <span class="o">=</span> <span class="n">temp_dir</span><span class="p">(</span><span class="s2">"notebooks"</span><span class="p">,</span> <span class="s2">"notebook_comenv"</span><span class="p">)</span> </pre></div> </div> </div> -<div class="section" id="Setting-up-the-Population-object"> -<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this headline">¶</a></h2> +<section id="Setting-up-the-Population-object"> +<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this heading">ïƒ</a></h2> <p>We set up a new population object. Our stars evolve to <span class="math notranslate nohighlight">\(13.7\text{ }\mathrm{Gyr}\)</span>, the age of the Universe, and we assume the metallicity <span class="math notranslate nohighlight">\(Z=0.02\)</span>. We also set the common-envelope ejection efficiency <span class="math notranslate nohighlight">\(\alpha_\mathrm{CE}=1\)</span> and the envelope structure parameter <span class="math notranslate nohighlight">\(\lambda=0.5\)</span>. More complex options are available in <em>binary_c</em>, such as <span class="math notranslate nohighlight">\(\lambda\)</span> based on stellar mass, but this is just a demonstration example so let’s keep things simple.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create population object</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create population object</span> <span class="n">population</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="c1"># grid options</span> @@ -505,16 +429,15 @@ adding: alpha_ce=1.0 to BSE_options adding: lambda_ce=0.5 to BSE_options </pre></div></div> </div> -</div> -<div class="section" id="Stellar-Grid"> -<h2>Stellar Grid<a class="headerlink" href="#Stellar-Grid" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Stellar-Grid"> +<h2>Stellar Grid<a class="headerlink" href="#Stellar-Grid" title="Permalink to this heading">ïƒ</a></h2> <p>We now construct a grid of stars, varying the mass from <span class="math notranslate nohighlight">\(1\)</span> to <span class="math notranslate nohighlight">\(6\text{ }\mathrm{M}_\odot\)</span>. We avoid massive stars for now, and focus on the (more common) low- and intermediate-mass stars. We also limit the period range to <span class="math notranslate nohighlight">\(10^4\text{ }\mathrm{d}\)</span> because systems with longer orbital periods will probably not undergo Roche-lobe overflow and hence common-envelope evolution is impossible.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">binarycpython.utils.distribution_functions</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">binarycpython.utils.distribution_functions</span> <span class="c1"># Set resolution and mass range that we simulate</span> <span class="n">resolution</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"M_1"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"q"</span> <span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"per"</span><span class="p">:</span> <span class="mi">10</span><span class="p">}</span> <span class="n">massrange</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">6</span><span class="p">]</span> @@ -632,16 +555,15 @@ Added grid variable: { } </pre></div></div> </div> -</div> -<div class="section" id="Logging-and-handling-the-output"> -<h2>Logging and handling the output<a class="headerlink" href="#Logging-and-handling-the-output" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Logging-and-handling-the-output"> +<h2>Logging and handling the output<a class="headerlink" href="#Logging-and-handling-the-output" title="Permalink to this heading">ïƒ</a></h2> <p>We now construct the pre- and post-common envelope evolution data for the first common envelope that forms in each binary. We look at the comenv_count variable, we can see that when it increases from 0 to 1 we have found our object. If this happens, we stop evolution of the system to save CPU time.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">custom_logging_statement</span> <span class="o">=</span> <span class="s2">"""</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">custom_logging_statement</span> <span class="o">=</span> <span class="s2">"""</span> <span class="s2">/*</span> <span class="s2"> * Detect when the comenv_count increased</span> @@ -673,8 +595,7 @@ Added grid variable: { <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">C_logging_code</span><span class="o">=</span><span class="n">custom_logging_statement</span> <span class="p">)</span> - -</pre></div> +<br/></pre></div> </div> </div> <div class="nboutput nblast docutils container"> @@ -717,8 +638,7 @@ if(stardata->model.comenv_count == 1 && <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">bin_data</span><span class="p">,</span><span class="n">datalinedict</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">bin_data</span><span class="p">,</span><span class="n">datalinedict</span> <span class="kn">import</span> <span class="nn">re</span> <span class="c1"># log-period distribution bin width (dex)</span> @@ -773,16 +693,15 @@ if(stardata->model.comenv_count == 1 && adding: parse_function=<function parse_function at 0x149c95c56c10> to grid_options </pre></div></div> </div> -</div> -<div class="section" id="Evolving-the-grid"> -<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Evolving-the-grid"> +<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this heading">ïƒ</a></h2> <p>Now we actually run the population. This may take a little while. You can set num_cores higher if you have a powerful machine.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># set number of threads</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># set number of threads</span> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="c1"># set number of threads (i.e. number of CPU cores we use)</span> <span class="n">num_cores</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> @@ -1089,8 +1008,7 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> </pre></div> </div> </div> @@ -1106,13 +1024,12 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[8]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># make a plot of the distributions</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># make a plot of the distributions</span> <span class="kn">import</span> <span class="nn">seaborn</span> <span class="k">as</span> <span class="nn">sns</span> <span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> <span class="kn">import</span> <span class="nn">copy</span> <span class="n">pd</span><span class="o">.</span><span class="n">set_option</span><span class="p">(</span><span class="s2">"display.max_rows"</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="s2">"display.max_columns"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">pad_output_distribution</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">pad_output_distribution</span> <span class="c1"># set up seaborn for use in the notebook</span> <span class="n">sns</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">rc</span><span class="o">=</span><span class="p">{</span><span class="s1">'figure.figsize'</span><span class="p">:(</span><span class="mi">20</span><span class="p">,</span><span class="mi">10</span><span class="p">)})</span> @@ -1153,8 +1070,7 @@ There were no errors found in this run. <span class="n">p</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s2">"$\log_</span><span class="si">{10}</span><span class="s2"> (P_\mathrm</span><span class="si">{orb}</span><span class="s2"> / \mathrm</span><span class="si">{day}</span><span class="s2">)$"</span><span class="p">)</span> <span class="n">p</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s2">"Number of stars"</span><span class="p">)</span> <span class="c1">#p.set(xlim=(-5,5)) # might be necessary?</span> - -</pre></div> +<br/></pre></div> </div> </div> <div class="nboutput docutils container"> @@ -1193,62 +1109,44 @@ Text(0, 0.5, 'Number of stars') <li><p>… and perhaps increased resolution to obtain smoother curves.</p></li> <li><p>Why do long-period systems not reach common envelope evolution?</p></li> </ul> -</div> -</div> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_BHBH.html" class="btn btn-neutral float-right" title="Example use case: Binary black hole systems" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_HRD.html" class="btn btn-neutral float-left" title="Example use case: Hertzsprung-Russell diagrams" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_HRD.html" class="btn btn-neutral float-left" title="Example use case: Hertzsprung-Russell diagrams" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_BHBH.html" class="btn btn-neutral float-right" title="Example use case: Binary black hole systems" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_custom_logging.html b/docs/build/html/examples/notebook_custom_logging.html index b04c7f50973bca0f2fb76660dee0fbbed9ec261e..f9198e2c4bc4689efa790602c395a5d5f6a78f4d 100644 --- a/docs/build/html/examples/notebook_custom_logging.html +++ b/docs/build/html/examples/notebook_custom_logging.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Tutorial: Using custom logging routines with binary_c-python — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Tutorial: Using custom logging routines with binary_c-python — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Tutorial: Running populations with binary_c-python" href="notebook_population.html" /> <link rel="prev" title="Tutorial: Running individual systems with binary_c-python" href="notebook_individual_systems.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -107,6 +63,7 @@ <li class="toctree-l2"><a class="reference internal" href="notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -122,70 +79,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Tutorial: Using custom logging routines with binary_c-python</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_custom_logging.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -396,11 +314,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -409,10 +328,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -424,12 +347,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -456,22 +382,21 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Tutorial:-Using-custom-logging-routines-with-binary_c-python"> -<h1>Tutorial: Using custom logging routines with binary_c-python<a class="headerlink" href="#Tutorial:-Using-custom-logging-routines-with-binary_c-python" title="Permalink to this headline">¶</a></h1> +<section id="Tutorial:-Using-custom-logging-routines-with-binary_c-python"> +<h1>Tutorial: Using custom logging routines with binary_c-python<a class="headerlink" href="#Tutorial:-Using-custom-logging-routines-with-binary_c-python" title="Permalink to this heading">ïƒ</a></h1> <p>In this notebook you’ll learn how to use the custom logging functionality</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython</span> <span class="k">import</span> <span class="n">_binary_c_bindings</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="k">import</span> <span class="p">(</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">_binary_c_bindings</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="kn">import</span> <span class="p">(</span> <span class="n">autogen_C_logging_code</span><span class="p">,</span> <span class="n">binary_c_log_code</span><span class="p">,</span> <span class="n">create_and_load_logging_function</span><span class="p">,</span> <span class="p">)</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.run_system_wrapper</span> <span class="k">import</span> <span class="n">run_system</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="k">import</span> <span class="n">Population</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.run_system_wrapper</span> <span class="kn">import</span> <span class="n">run_system</span> +<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">Population</span> </pre></div> </div> </div> @@ -486,15 +411,14 @@ div.rendered_html tbody tr:hover { </ul> <p>The custom logging functionality can be used when running systems via <code class="docutils literal notranslate"><span class="pre">run_system()</span></code>, via <code class="docutils literal notranslate"><span class="pre">Population.evolve()</span></code> and <code class="docutils literal notranslate"><span class="pre">Population.evolve_single()</span></code>, and directly via the API</p> <p>Within the logging statement we can access information from the stardata object, as well as use logical statements to determine when to log information. What we cannot do, however, is access functions that are not <em>publicly available</em>. For very elaborate printing routines it is still advised to actually hardcode the print statement into binary_c itself.</p> -<div class="section" id="Usage"> -<h2>Usage<a class="headerlink" href="#Usage" title="Permalink to this headline">¶</a></h2> +<section id="Usage"> +<h2>Usage<a class="headerlink" href="#Usage" title="Permalink to this heading">ïƒ</a></h2> <p>There are two methods to create the C-code that will be compiled: - Automatically generate the print statement and use the wrapper to generate the full function string, by using <code class="docutils literal notranslate"><span class="pre">autogen_C_logging_code</span></code> - Create your custom print statement and use the wrapper to generate the full function string, by writing out the print statement. Here the logging statement obviously has to be valid C code</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># generate logging lines. Here you can choose whatever you want to have logged, and with what header</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># generate logging lines. Here you can choose whatever you want to have logged, and with what header</span> <span class="c1"># this generates working print statements</span> <span class="n">logging_line</span> <span class="o">=</span> <span class="n">autogen_C_logging_code</span><span class="p">(</span> <span class="p">{</span> @@ -517,8 +441,7 @@ Printf("MY_STELLAR_DATA %g %g\n",((double)stardata->model.time),((dou <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># You can also decide to `write` your own logging_line, which allows you to write a more complex logging statement with conditionals.</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># You can also decide to `write` your own logging_line, which allows you to write a more complex logging statement with conditionals.</span> <span class="n">logging_line</span> <span class="o">=</span> <span class="s1">'Printf("MY_STELLAR_DATA time=</span><span class="si">%g</span><span class="s1"> mass=</span><span class="si">%g</span><span class="se">\\</span><span class="s1">n", stardata->model.time, stardata->star[0].mass)'</span> <span class="nb">print</span><span class="p">(</span><span class="n">logging_line</span><span class="p">)</span> </pre></div> @@ -536,8 +459,7 @@ Printf("MY_STELLAR_DATA time=%g mass=%g\n", stardata->model.time, sta <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Generate the entire 'script' by wrapping the logging line</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Generate the entire 'script' by wrapping the logging line</span> <span class="n">custom_logging_code</span> <span class="o">=</span> <span class="n">binary_c_log_code</span><span class="p">(</span><span class="n">logging_line</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">custom_logging_code</span><span class="p">)</span> </pre></div> @@ -573,8 +495,7 @@ void binary_c_API_function custom_output_function(struct stardata_t * stardata) <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># logging statement</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># logging statement</span> <span class="n">logging_line</span> <span class="o">=</span> <span class="s1">'Printf("MY_STELLAR_DATA time=</span><span class="si">%g</span><span class="s1"> mass=</span><span class="si">%g</span><span class="se">\\</span><span class="s1">n", stardata->model.time, stardata->star[0].mass)'</span> <span class="c1"># Entire script</span> @@ -599,15 +520,14 @@ MY_STELLAR_DATA time=1e-06 mass=2 MY_STELLAR_DATA time=2e-06 mass=2 </pre></div></div> </div> -<div class="section" id="Using-custom-logging-with-the-population-object"> -<h3>Using custom logging with the population object<a class="headerlink" href="#Using-custom-logging-with-the-population-object" title="Permalink to this headline">¶</a></h3> +<section id="Using-custom-logging-with-the-population-object"> +<h3>Using custom logging with the population object<a class="headerlink" href="#Using-custom-logging-with-the-population-object" title="Permalink to this heading">ïƒ</a></h3> <p>Custom logging can be used for a whole population by setting the print statement (so not the entire logging script) in <code class="docutils literal notranslate"><span class="pre">C_logging_code</span></code></p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Set up population</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Set up population</span> <span class="n">pop</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> <span class="c1"># Set some BSE parameters</span> @@ -657,16 +577,15 @@ EXAMPLE_POST_MS 1.044654032097e+02 4.99192 4.99192 7.81395 7.51803 2 EXAMPLE_POST_MS 1.045084306856e+02 4.99191 4.99192 9.57443 7.81395 2 2 </pre></div></div> </div> -</div> -<div class="section" id="Using-custom-logging-when-running-directly-from-the-API"> -<h3>Using custom logging when running directly from the API<a class="headerlink" href="#Using-custom-logging-when-running-directly-from-the-API" title="Permalink to this headline">¶</a></h3> +</section> +<section id="Using-custom-logging-when-running-directly-from-the-API"> +<h3>Using custom logging when running directly from the API<a class="headerlink" href="#Using-custom-logging-when-running-directly-from-the-API" title="Permalink to this heading">ïƒ</a></h3> <p>When running a system directly with the API we need to manually load the custom logging into memory (via <code class="docutils literal notranslate"><span class="pre">create_and_load_logging_function</span></code>) and pass the memory address to the binary_c binding via <code class="docutils literal notranslate"><span class="pre">_binary_c_bindings.run_system(argstring,</span> <span class="pre">custom_logging_func_memaddr=custom_logging_memaddr)</span></code></p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># generate logging lines</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># generate logging lines</span> <span class="n">logging_line</span> <span class="o">=</span> <span class="n">autogen_C_logging_code</span><span class="p">(</span> <span class="p">{</span> <span class="s2">"MY_STELLAR_DATA"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"model.time"</span><span class="p">,</span> <span class="s2">"star[0].mass"</span><span class="p">],</span> @@ -718,20 +637,19 @@ MY_STELLAR_DATA 1e-06 15 MY_STELLAR_DATA 2e-06 15 </pre></div></div> </div> -</div> -</div> -<div class="section" id="Examples-of-logging-strings"> -<h2>Examples of logging strings<a class="headerlink" href="#Examples-of-logging-strings" title="Permalink to this headline">¶</a></h2> +</section> +</section> +<section id="Examples-of-logging-strings"> +<h2>Examples of logging strings<a class="headerlink" href="#Examples-of-logging-strings" title="Permalink to this heading">ïƒ</a></h2> <p>Below are some examples of logging strings</p> -<div class="section" id="Compact-object"> -<h3>Compact object<a class="headerlink" href="#Compact-object" title="Permalink to this headline">¶</a></h3> +<section id="Compact-object"> +<h3>Compact object<a class="headerlink" href="#Compact-object" title="Permalink to this heading">ïƒ</a></h3> <p>This logging will print the timestep when the star becomes a compact object. After it does, we change the maximum time to be the current time, effectively terminating the evolution</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[8]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">example_logging_string_CO</span> <span class="o">=</span> <span class="s2">"""</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">example_logging_string_CO</span> <span class="o">=</span> <span class="s2">"""</span> <span class="s2">if(stardata->star[0].stellar_type>=NS)</span> <span class="s2">{</span> <span class="s2"> if (stardata->model.time < stardata->model.max_evolution_time)</span> @@ -775,16 +693,15 @@ SINGLE_STAR_LIFETIME 10 28.4838 EXAMPLE_LOG_CO 2.848380621869e+01 1.33469 9.1865 1.72498e-05 724.338 13 5 </pre></div></div> </div> -</div> -<div class="section" id="Logging-mass-evolution-and-the-supernova"> -<h3>Logging mass evolution and the supernova<a class="headerlink" href="#Logging-mass-evolution-and-the-supernova" title="Permalink to this headline">¶</a></h3> +</section> +<section id="Logging-mass-evolution-and-the-supernova"> +<h3>Logging mass evolution and the supernova<a class="headerlink" href="#Logging-mass-evolution-and-the-supernova" title="Permalink to this heading">ïƒ</a></h3> <p>This logging code prints the mass evolution and the moment the star goes supernova</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[9]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">example_logging_string_CO</span> <span class="o">=</span> <span class="s2">"""</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">example_logging_string_CO</span> <span class="o">=</span> <span class="s2">"""</span> <span class="s2">Printf("EXAMPLE_MASSLOSS </span><span class="si">%30.12e</span><span class="s2"> </span><span class="si">%g</span><span class="s2"> </span><span class="si">%g</span><span class="s2"> </span><span class="si">%g</span><span class="s2"> </span><span class="si">%d</span><span class="s2"> </span><span class="si">%g</span><span class="se">\\</span><span class="s2">n",</span> <span class="s2"> //</span> <span class="s2"> stardata->model.time, // 1</span> @@ -846,63 +763,53 @@ EXAMPLE_MASSLOSS 1.050651207308e+01 1.59452 9.34213 20 13 1 EXAMPLE_SN 1.050651207308e+01 1.59452 9.34213 20 12 13 5 1 6.55458 4.71662 6.55458 </pre></div></div> </div> +<div class="nbinput nblast docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +</pre></div> </div> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> +</pre></div> </div> </div> +</section> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_population.html" class="btn btn-neutral float-right" title="Tutorial: Running populations with binary_c-python" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_individual_systems.html" class="btn btn-neutral float-left" title="Tutorial: Running individual systems with binary_c-python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_individual_systems.html" class="btn btn-neutral float-left" title="Tutorial: Running individual systems with binary_c-python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_population.html" class="btn btn-neutral float-right" title="Tutorial: Running populations with binary_c-python" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_custom_logging.ipynb b/docs/build/html/examples/notebook_custom_logging.ipynb index 8dfb85034dd77e1b0ae790c475a1e52bd70d0227..8627ffb4751bfea37ebfc00c67e763a79463eba0 100644 --- a/docs/build/html/examples/notebook_custom_logging.ipynb +++ b/docs/build/html/examples/notebook_custom_logging.ipynb @@ -23,7 +23,7 @@ " create_and_load_logging_function,\n", ")\n", "from binarycpython.utils.run_system_wrapper import run_system\n", - "from binarycpython.utils.grid import Population" + "from binarycpython import Population" ] }, { @@ -461,11 +461,19 @@ "# print (abridged) output\n", "print(\"\\n\".join(output.splitlines()[-2:]))" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c708268f-0b0c-48ea-9155-ec632a0acc3a", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -479,7 +487,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/examples/notebook_ensembles.html b/docs/build/html/examples/notebook_ensembles.html new file mode 100644 index 0000000000000000000000000000000000000000..7103580ad9306afd94cba04326ad22e173e37687 --- /dev/null +++ b/docs/build/html/examples/notebook_ensembles.html @@ -0,0 +1,423 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Tutorial: Generating and handling ensemble data — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Example use case: Zero-age stellar luminosity function" href="notebook_luminosity_function_single.html" /> + <link rel="prev" title="Tutorial: Using the API functionality of binary_c-python" href="notebook_api_functionality.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1"><a class="reference internal" href="../modules.html">Binarycpython code</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="notebook_individual_systems.html">Tutorial: Running individual systems with binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_custom_logging.html">Tutorial: Using custom logging routines with binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Tutorial: Generating and handling ensemble data</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_common_envelope_evolution.html">Example use case: Common-envelope evolution</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_BHBH.html">Example use case: Binary black hole systems</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_massive_remnants.html">Example use case: Massive star luminosity</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_solar_system.html">Example use case: Solar system using the API functionality</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../example_notebooks.html">Example notebooks</a> »</li> + <li>Tutorial: Generating and handling ensemble data</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/examples/notebook_ensembles.ipynb.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS for nbsphinx extension */ + +/* remove conflicting styling from Sphinx themes */ +div.nbinput.container div.prompt *, +div.nboutput.container div.prompt *, +div.nbinput.container div.input_area pre, +div.nboutput.container div.output_area pre, +div.nbinput.container div.input_area .highlight, +div.nboutput.container div.output_area .highlight { + border: none; + padding: 0; + margin: 0; + box-shadow: none; +} + +div.nbinput.container > div[class*=highlight], +div.nboutput.container > div[class*=highlight] { + margin: 0; +} + +div.nbinput.container div.prompt *, +div.nboutput.container div.prompt * { + background: none; +} + +div.nboutput.container div.output_area .highlight, +div.nboutput.container div.output_area pre { + background: unset; +} + +div.nboutput.container div.output_area div.highlight { + color: unset; /* override Pygments text color */ +} + +/* avoid gaps between output lines */ +div.nboutput.container div[class*=highlight] pre { + line-height: normal; +} + +/* input/output containers */ +div.nbinput.container, +div.nboutput.container { + display: -webkit-flex; + display: flex; + align-items: flex-start; + margin: 0; + width: 100%; +} +@media (max-width: 540px) { + div.nbinput.container, + div.nboutput.container { + flex-direction: column; + } +} + +/* input container */ +div.nbinput.container { + padding-top: 5px; +} + +/* last container */ +div.nblast.container { + padding-bottom: 5px; +} + +/* input prompt */ +div.nbinput.container div.prompt pre { + color: #307FC1; +} + +/* output prompt */ +div.nboutput.container div.prompt pre { + color: #BF5B3D; +} + +/* all prompts */ +div.nbinput.container div.prompt, +div.nboutput.container div.prompt { + width: 4.5ex; + padding-top: 5px; + position: relative; + user-select: none; +} + +div.nbinput.container div.prompt > div, +div.nboutput.container div.prompt > div { + position: absolute; + right: 0; + margin-right: 0.3ex; +} + +@media (max-width: 540px) { + div.nbinput.container div.prompt, + div.nboutput.container div.prompt { + width: unset; + text-align: left; + padding: 0.4em; + } + div.nboutput.container div.prompt.empty { + padding: 0; + } + + div.nbinput.container div.prompt > div, + div.nboutput.container div.prompt > div { + position: unset; + } +} + +/* disable scrollbars on prompts */ +div.nbinput.container div.prompt pre, +div.nboutput.container div.prompt pre { + overflow: hidden; +} + +/* input/output area */ +div.nbinput.container div.input_area, +div.nboutput.container div.output_area { + -webkit-flex: 1; + flex: 1; + overflow: auto; +} +@media (max-width: 540px) { + div.nbinput.container div.input_area, + div.nboutput.container div.output_area { + width: 100%; + } +} + +/* input area */ +div.nbinput.container div.input_area { + border: 1px solid #e0e0e0; + border-radius: 2px; + /*background: #f5f5f5;*/ +} + +/* override MathJax center alignment in output cells */ +div.nboutput.container div[class*=MathJax] { + text-align: left !important; +} + +/* override sphinx.ext.imgmath center alignment in output cells */ +div.nboutput.container div.math p { + text-align: left; +} + +/* standard error */ +div.nboutput.container div.output_area.stderr { + background: #fdd; +} + +/* ANSI colors */ +.ansi-black-fg { color: #3E424D; } +.ansi-black-bg { background-color: #3E424D; } +.ansi-black-intense-fg { color: #282C36; } +.ansi-black-intense-bg { background-color: #282C36; } +.ansi-red-fg { color: #E75C58; } +.ansi-red-bg { background-color: #E75C58; } +.ansi-red-intense-fg { color: #B22B31; } +.ansi-red-intense-bg { background-color: #B22B31; } +.ansi-green-fg { color: #00A250; } +.ansi-green-bg { background-color: #00A250; } +.ansi-green-intense-fg { color: #007427; } +.ansi-green-intense-bg { background-color: #007427; } +.ansi-yellow-fg { color: #DDB62B; } +.ansi-yellow-bg { background-color: #DDB62B; } +.ansi-yellow-intense-fg { color: #B27D12; } +.ansi-yellow-intense-bg { background-color: #B27D12; } +.ansi-blue-fg { color: #208FFB; } +.ansi-blue-bg { background-color: #208FFB; } +.ansi-blue-intense-fg { color: #0065CA; } +.ansi-blue-intense-bg { background-color: #0065CA; } +.ansi-magenta-fg { color: #D160C4; } +.ansi-magenta-bg { background-color: #D160C4; } +.ansi-magenta-intense-fg { color: #A03196; } +.ansi-magenta-intense-bg { background-color: #A03196; } +.ansi-cyan-fg { color: #60C6C8; } +.ansi-cyan-bg { background-color: #60C6C8; } +.ansi-cyan-intense-fg { color: #258F8F; } +.ansi-cyan-intense-bg { background-color: #258F8F; } +.ansi-white-fg { color: #C5C1B4; } +.ansi-white-bg { background-color: #C5C1B4; } +.ansi-white-intense-fg { color: #A1A6B2; } +.ansi-white-intense-bg { background-color: #A1A6B2; } + +.ansi-default-inverse-fg { color: #FFFFFF; } +.ansi-default-inverse-bg { background-color: #000000; } + +.ansi-bold { font-weight: bold; } +.ansi-underline { text-decoration: underline; } + + +div.nbinput.container div.input_area div[class*=highlight] > pre, +div.nboutput.container div.output_area div[class*=highlight] > pre, +div.nboutput.container div.output_area div[class*=highlight].math, +div.nboutput.container div.output_area.rendered_html, +div.nboutput.container div.output_area > div.output_javascript, +div.nboutput.container div.output_area:not(.rendered_html) > img{ + padding: 5px; + margin: 0; +} + +/* fix copybtn overflow problem in chromium (needed for 'sphinx_copybutton') */ +div.nbinput.container div.input_area > div[class^='highlight'], +div.nboutput.container div.output_area > div[class^='highlight']{ + overflow-y: hidden; +} + +/* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ +.prompt .copybtn { + display: none; +} + +/* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, +div.rendered_html table { + border: none; + border-collapse: collapse; + border-spacing: 0; + color: black; + font-size: 12px; + table-layout: fixed; +} +.jp-RenderedHTMLCommon thead, +div.rendered_html thead { + border-bottom: 1px solid black; + vertical-align: bottom; +} +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, +div.rendered_html tr, +div.rendered_html th, +div.rendered_html td { + text-align: right; + vertical-align: middle; + padding: 0.5em 0.5em; + line-height: normal; + white-space: normal; + max-width: none; + border: none; +} +.jp-RenderedHTMLCommon th, +div.rendered_html th { + font-weight: bold; +} +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), +div.rendered_html tbody tr:nth-child(odd) { + background: #f5f5f5; +} +.jp-RenderedHTMLCommon tbody tr:hover, +div.rendered_html tbody tr:hover { + background: rgba(66, 165, 245, 0.2); +} + +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="Tutorial:-Generating-and-handling-ensemble-data"> +<h1>Tutorial: Generating and handling ensemble data<a class="headerlink" href="#Tutorial:-Generating-and-handling-ensemble-data" title="Permalink to this heading">ïƒ</a></h1> +<p>TODO: coming soon!</p> +<div class="nbinput nblast docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +</pre></div> +</div> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> +</pre></div> +</div> +</div> +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_api_functionality.html" class="btn btn-neutral float-left" title="Tutorial: Using the API functionality of binary_c-python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_luminosity_function_single.html" class="btn btn-neutral float-right" title="Example use case: Zero-age stellar luminosity function" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_ensembles.ipynb b/docs/build/html/examples/notebook_ensembles.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..cc9a3ad9f4cfc1efc4c1327878f01b87bad9e8e5 --- /dev/null +++ b/docs/build/html/examples/notebook_ensembles.ipynb @@ -0,0 +1,42 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d1d00572-29aa-4f27-a59c-f9f05889da7d", + "metadata": {}, + "source": [ + "# Tutorial: Generating and handling ensemble data\n", + "TODO: coming soon!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e8d9fca3-dd16-4c2c-a180-14d9a6b533ed", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docs/build/html/examples/notebook_extra_features.html b/docs/build/html/examples/notebook_extra_features.html index 2d8eea0868457fe978c2b41f760e2da182738c08..cf7b02f17136f92d261b7acdde995cf3a7936e57 100644 --- a/docs/build/html/examples/notebook_extra_features.html +++ b/docs/build/html/examples/notebook_extra_features.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Tutorial: Extra features and functionality of binary_c-python — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Tutorial: Extra features and functionality of binary_c-python — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Tutorial: Using the API functionality of binary_c-python" href="notebook_api_functionality.html" /> <link rel="prev" title="Tutorial: Running populations with binary_c-python" href="notebook_population.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -98,10 +54,10 @@ <li class="toctree-l3"><a class="reference internal" href="#Build-information-of-binary_c">Build information of binary_c</a></li> <li class="toctree-l3"><a class="reference internal" href="#Example-parse-function">Example parse function</a></li> <li class="toctree-l3"><a class="reference internal" href="#Dictionary-modification">Dictionary modification</a></li> -<li class="toctree-l3"><a class="reference internal" href="#Getting-help">Getting help</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -117,70 +73,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Tutorial: Extra features and functionality of binary_c-python</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_extra_features.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -391,11 +308,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -404,10 +322,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -419,12 +341,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -451,28 +376,27 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Tutorial:-Extra-features-and-functionality-of-binary_c-python"> -<h1>Tutorial: Extra features and functionality of binary_c-python<a class="headerlink" href="#Tutorial:-Extra-features-and-functionality-of-binary_c-python" title="Permalink to this headline">¶</a></h1> +<section id="Tutorial:-Extra-features-and-functionality-of-binary_c-python"> +<h1>Tutorial: Extra features and functionality of binary_c-python<a class="headerlink" href="#Tutorial:-Extra-features-and-functionality-of-binary_c-python" title="Permalink to this heading">ïƒ</a></h1> <p>In this notebook we’ll go over some of the extra features and functionality that was not covered in the other notebooks.</p> <p>Within the module <code class="docutils literal notranslate"><span class="pre">binarycpython.utils.functions</span></code> there are many functions that can be useful when using binarycpython. We can see which functions are in there, again by using the <code class="docutils literal notranslate"><span class="pre">help()</span></code></p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="p">(</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">Population</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="p">(</span> <span class="n">get_help</span><span class="p">,</span> <span class="n">get_help_all</span><span class="p">,</span> <span class="n">get_help_super</span><span class="p">,</span> - <span class="n">return_binary_c_version_info</span><span class="p">,</span> <span class="n">get_defaults</span> <span class="p">)</span> <span class="c1"># help(binarycpython.utils.functions)</span> </pre></div> </div> </div> -<div class="section" id="getting-extra-information-about-binary_c-parameters"> -<h2>getting extra information about binary_c parameters<a class="headerlink" href="#getting-extra-information-about-binary_c-parameters" title="Permalink to this headline">¶</a></h2> +<section id="getting-extra-information-about-binary_c-parameters"> +<h2>getting extra information about binary_c parameters<a class="headerlink" href="#getting-extra-information-about-binary_c-parameters" title="Permalink to this heading">ïƒ</a></h2> <p>There are several functions that can be used to get information about the parameters in binary_c:</p> <ul class="simple"> <li><p><code class="docutils literal notranslate"><span class="pre">get_help(parameter)</span></code>: Function to get information about the specific input parameter. Prints the output on default but returns a dictionary containing the information.</p></li> @@ -484,8 +408,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">get_help</span><span class="p">(</span><span class="s1">'M_1'</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">get_help</span><span class="p">(</span><span class="s1">'M_1'</span><span class="p">)</span> </pre></div> </div> </div> @@ -520,8 +443,7 @@ default: <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># get_help_all()</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># get_help_all()</span> </pre></div> </div> </div> @@ -529,8 +451,7 @@ default: <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># get_help_super()</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># get_help_super()</span> </pre></div> </div> </div> @@ -538,22 +459,20 @@ default: <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># get_defaults()</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># get_defaults()</span> </pre></div> </div> </div> -</div> -<div class="section" id="Build-information-of-binary_c"> -<h2>Build information of binary_c<a class="headerlink" href="#Build-information-of-binary_c" title="Permalink to this headline">¶</a></h2> -<p>Sometimes we want to know with which settings binary_c has been built. We can use the function <code class="docutils literal notranslate"><span class="pre">return_binary_c_version_info</span></code> for this. This function will parse the version info of binary_c and return a dictionary with all the settings.</p> +</section> +<section id="Build-information-of-binary_c"> +<h2>Build information of binary_c<a class="headerlink" href="#Build-information-of-binary_c" title="Permalink to this heading">ïƒ</a></h2> +<p>It can be useful to fetch the information with which the current version of binary_c has been configured with. We can do that through the Population object, by calling the instance method <code class="docutils literal notranslate"><span class="pre">return_binary_c_version_info</span></code>. This function will parse the version info of binary_c and return a dictionary with all the settings.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">version_info_dict</span> <span class="o">=</span> <span class="n">return_binary_c_version_info</span><span class="p">(</span><span class="n">parsed</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -<span class="nb">print</span><span class="p">(</span><span class="n">version_info_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">version_info</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span><span class="o">.</span><span class="n">return_binary_c_version_info</span><span class="p">(</span><span class="n">parsed</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +<span class="nb">print</span><span class="p">(</span><span class="n">version_info</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> </pre></div> </div> </div> @@ -562,99 +481,68 @@ default: </div> <div class="output_area docutils container"> <div class="highlight"><pre> -dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'nucleosynthesis_sources', 'miscellaneous']) +dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'units', 'nucleosynthesis_sources', 'miscellaneous']) </pre></div></div> </div> -</div> -<div class="section" id="Example-parse-function"> -<h2>Example parse function<a class="headerlink" href="#Example-parse-function" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Example-parse-function"> +<h2>Example parse function<a class="headerlink" href="#Example-parse-function" title="Permalink to this heading">ïƒ</a></h2> <p>TODO: In the functions module there is an example parse function that can be used in conjunction with run_system.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> </pre></div> </div> </div> -</div> -<div class="section" id="Dictionary-modification"> -<h2>Dictionary modification<a class="headerlink" href="#Dictionary-modification" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Dictionary-modification"> +<h2>Dictionary modification<a class="headerlink" href="#Dictionary-modification" title="Permalink to this heading">ïƒ</a></h2> <ul class="simple"> <li><p>merge_dicts</p></li> <li><p>update_dicts</p></li> <li><p>multiply_values_dict</p></li> </ul> <p>TODO:</p> -</div> -<div class="section" id="Getting-help"> -<h2>Getting help<a class="headerlink" href="#Getting-help" title="Permalink to this headline">¶</a></h2> -<div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: -</pre></div> -</div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> -</pre></div> -</div> -</div> -</div> -</div> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_api_functionality.html" class="btn btn-neutral float-right" title="Tutorial: Using the API functionality of binary_c-python" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_population.html" class="btn btn-neutral float-left" title="Tutorial: Running populations with binary_c-python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_population.html" class="btn btn-neutral float-left" title="Tutorial: Running populations with binary_c-python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_api_functionality.html" class="btn btn-neutral float-right" title="Tutorial: Using the API functionality of binary_c-python" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_extra_features.ipynb b/docs/build/html/examples/notebook_extra_features.ipynb index 44c19c11274fbd39732e34e03e7a14a371ff9d7c..a0f0fc0d9c66207de88d4c38672d257f9af522c2 100644 --- a/docs/build/html/examples/notebook_extra_features.ipynb +++ b/docs/build/html/examples/notebook_extra_features.ipynb @@ -18,11 +18,11 @@ "metadata": {}, "outputs": [], "source": [ + "from binarycpython import Population\n", "from binarycpython.utils.functions import (\n", " get_help,\n", " get_help_all,\n", " get_help_super,\n", - " return_binary_c_version_info,\n", " get_defaults\n", ")\n", "# help(binarycpython.utils.functions)" @@ -116,8 +116,7 @@ "metadata": {}, "source": [ "## Build information of binary_c\n", - "Sometimes we want to know with which settings binary_c has been built. We can use the function `return_binary_c_version_info` for this.\n", - "This function will parse the version info of binary_c and return a dictionary with all the settings." + "It can be useful to fetch the information with which the current version of binary_c has been configured with. We can do that through the Population object, by calling the instance method `return_binary_c_version_info`. This function will parse the version info of binary_c and return a dictionary with all the settings." ] }, { @@ -130,13 +129,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'nucleosynthesis_sources', 'miscellaneous'])\n" + "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'units', 'nucleosynthesis_sources', 'miscellaneous'])\n" ] } ], "source": [ - "version_info_dict = return_binary_c_version_info(parsed=True)\n", - "print(version_info_dict.keys())" + "version_info = Population().return_binary_c_version_info(parsed=True)\n", + "print(version_info.keys())" ] }, { @@ -168,27 +167,11 @@ "\n", "TODO:" ] - }, - { - "cell_type": "markdown", - "id": "b3c259ef-9f89-4b26-9ce3-45af625bc398", - "metadata": {}, - "source": [ - "## Getting help\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bf3c1e28-1662-47a7-abab-aa6fb0ef0882", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -202,7 +185,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/examples/notebook_individual_systems.html b/docs/build/html/examples/notebook_individual_systems.html index c1b2f4993fec694bea2c23398b86747416a7b8a7..1f9dd90714546360df02ad3f654bc338a10733e6 100644 --- a/docs/build/html/examples/notebook_individual_systems.html +++ b/docs/build/html/examples/notebook_individual_systems.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Tutorial: Running individual systems with binary_c-python — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Tutorial: Running individual systems with binary_c-python — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Tutorial: Using custom logging routines with binary_c-python" href="notebook_custom_logging.html" /> <link rel="prev" title="Example notebooks" href="../example_notebooks.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -100,6 +56,7 @@ <li class="toctree-l2"><a class="reference internal" href="notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -115,70 +72,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Tutorial: Running individual systems with binary_c-python</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_individual_systems.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -389,11 +307,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -402,10 +321,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -417,12 +340,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -449,12 +375,12 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Tutorial:-Running-individual-systems-with-binary_c-python"> -<h1>Tutorial: Running individual systems with binary_c-python<a class="headerlink" href="#Tutorial:-Running-individual-systems-with-binary_c-python" title="Permalink to this headline">¶</a></h1> +<section id="Tutorial:-Running-individual-systems-with-binary_c-python"> +<h1>Tutorial: Running individual systems with binary_c-python<a class="headerlink" href="#Tutorial:-Running-individual-systems-with-binary_c-python" title="Permalink to this heading">ïƒ</a></h1> <p>This notebook will show you how to run single systems and analyze their results.</p> <p>It can be useful to have some functions to quickly run a single system to, for example, inspect what evolutionary steps a specific system goes through, to plot the mass loss evolution of a single system, etc.</p> -<div class="section" id="Single-system-with-run_system_wrapper"> -<h2>Single system with run_system_wrapper<a class="headerlink" href="#Single-system-with-run_system_wrapper" title="Permalink to this headline">¶</a></h2> +<section id="Single-system-with-run_system_wrapper"> +<h2>Single system with run_system_wrapper<a class="headerlink" href="#Single-system-with-run_system_wrapper" title="Permalink to this heading">ïƒ</a></h2> <p>The simplest method to run a single system is to use the run_system wrapper. This function deals with setting up the argument string, makes sure all the required parameters are included and handles setting and cleaning up the custom logging functionality (see notebook_custom_logging).</p> <p>As arguments to this function we can add any of the parameters that binary_c itself actually knows, as well as:</p> <ul class="simple"> @@ -466,9 +392,8 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">os</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">temp_dir</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">temp_dir</span> <span class="n">TMP_DIR</span> <span class="o">=</span> <span class="n">temp_dir</span><span class="p">(</span><span class="s2">"notebooks"</span><span class="p">,</span> <span class="s2">"notebook_individual_systems"</span><span class="p">)</span> </pre></div> </div> @@ -477,8 +402,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.run_system_wrapper</span> <span class="k">import</span> <span class="n">run_system</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.run_system_wrapper</span> <span class="kn">import</span> <span class="n">run_system</span> <span class="c1"># help(run_system) # Uncomment to see the docstring</span> </pre></div> </div> @@ -487,8 +411,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">output</span> <span class="o">=</span> <span class="n">run_system</span><span class="p">(</span><span class="n">M_1</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">output</span> <span class="o">=</span> <span class="n">run_system</span><span class="p">(</span><span class="n">M_1</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">output</span><span class="p">)</span> </pre></div> </div> @@ -498,7 +421,7 @@ div.rendered_html tbody tr:hover { </div> <div class="output_area docutils container"> <div class="highlight"><pre> -SINGLE_STAR_LIFETIME 1 12461.2 +SINGLE_STAR_LIFETIME 1 12461.1 </pre></div></div> </div> @@ -507,8 +430,7 @@ SINGLE_STAR_LIFETIME 1 12461.2 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">log_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">TMP_DIR</span><span class="p">,</span> <span class="s1">'test_logfile.txt'</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">log_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">TMP_DIR</span><span class="p">,</span> <span class="s1">'test_logfile.txt'</span><span class="p">)</span> <span class="n">output</span> <span class="o">=</span> <span class="n">run_system</span><span class="p">(</span><span class="n">M_1</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">log_filename</span><span class="o">=</span><span class="n">log_filename</span><span class="p">,</span> <span class="n">api_log_filename_prefix</span><span class="o">=</span><span class="n">TMP_DIR</span><span class="p">)</span> <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">log_filename</span><span class="p">,</span> <span class="s1">'r'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">())</span> @@ -520,17 +442,17 @@ SINGLE_STAR_LIFETIME 1 12461.2 </div> <div class="output_area docutils container"> <div class="highlight"><pre> - TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=62172 RANDOM_COUNT=0 + TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=22065 RANDOM_COUNT=0 0.0000 1.000 0.000 1 15 -1 -1 -1.00 0.000 0.000 "INITIAL " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 "OFF_MS" 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 "TYPE_CHNGE" 11582.2424 1.000 0.000 3 15 -1 -1 -1.00 0.000 0.000 "TYPE_CHNGE" 12325.1085 0.817 0.000 4 15 -1 -1 -1.00 0.000 0.000 "TYPE_CHNGE" 12457.1301 0.783 0.000 5 15 -1 -1 -1.00 0.000 0.000 "TYPE_CHNGE" - 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 "TYPE_CHNGE" - 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 "shrinkAGB" - 12461.1627 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 "TYPE_CHNGE" - 15000.0000 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 "MAX_TIME" + 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 "TYPE_CHNGE" + 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 "shrinkAGB" + 12461.1490 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 "TYPE_CHNGE" + 15000.0000 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 "MAX_TIME" </pre></div></div> </div> @@ -539,8 +461,7 @@ SINGLE_STAR_LIFETIME 1 12461.2 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="k">import</span> <span class="n">binary_c_log_code</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="kn">import</span> <span class="n">binary_c_log_code</span> <span class="c1"># Create the print statement</span> <span class="n">custom_logging_print_statement</span> <span class="o">=</span> <span class="s2">"""</span> @@ -578,8 +499,7 @@ EXAMPLE_MASSLOSS 2.000000000000e-06 1 1 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="n">output</span><span class="p">):</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="n">output</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Example function to parse the output of binary_c</span> <span class="sd"> """</span> @@ -620,8 +540,7 @@ EXAMPLE_MASSLOSS 2.000000000000e-06 1 1 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> <span class="c1"># Load data into dataframe</span> <span class="n">example_df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">output</span><span class="p">)</span> @@ -646,25 +565,24 @@ EXAMPLE_MASSLOSS 2.000000000000e-06 1 1 1 4 0.000002 1.0 1.0 1.0 5 0.000003 1.0 1.0 1.0 ... ... ... ... ... -1345 12461.080763 0.71617 1.0 6.0 -1346 12461.162734 0.644553 1.0 11.0 -1347 13461.162734 0.644553 1.0 11.0 -1348 14461.162734 0.644553 1.0 11.0 -1349 15000.0 0.644553 1.0 11.0 +1250 12461.061259 0.718593 1.0 6.0 +1251 12461.149038 0.678026 1.0 11.0 +1252 13461.149038 0.678026 1.0 11.0 +1253 14461.149038 0.678026 1.0 11.0 +1254 15000.0 0.678026 1.0 11.0 -[1349 rows x 4 columns] +[1254 rows x 4 columns] </pre></div></div> </div> -</div> -<div class="section" id="Single-system-via-population-object"> -<h2>Single system via population object<a class="headerlink" href="#Single-system-via-population-object" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Single-system-via-population-object"> +<h2>Single system via population object<a class="headerlink" href="#Single-system-via-population-object" title="Permalink to this heading">ïƒ</a></h2> <p>When setting up your population object (see notebook_population), and configuring all the parameters, it is possible to run a single system using that same configuration. It will use the parse_function if set, and running a single system is a good method to test if everything works accordingly.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[8]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="k">import</span> <span class="n">Population</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="kn">import</span> <span class="n">Population</span> <span class="c1"># help(Population) # Uncomment to see the docstring</span> </pre></div> </div> @@ -674,8 +592,7 @@ EXAMPLE_MASSLOSS 2.000000000000e-06 1 1 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[9]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create the population object</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create the population object</span> <span class="n">example_pop</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> <span class="c1"># Set some parameters</span> @@ -698,10 +615,8 @@ EXAMPLE_MASSLOSS 2.000000000000e-06 1 1 1 </div> <div class="output_area docutils container"> <div class="highlight"><pre> -adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options -adding: M_1=10 to BSE_options Creating and loading custom logging functionality -Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems +Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems Cleaning up the custom logging stuff. type: single SINGLE_STAR_LIFETIME 10 28.4838 @@ -712,8 +627,7 @@ SINGLE_STAR_LIFETIME 10 28.4838 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[10]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">custom_logging_print_statement</span> <span class="o">=</span> <span class="s2">"""</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">custom_logging_print_statement</span> <span class="o">=</span> <span class="s2">"""</span> <span class="s2">Printf("EXAMPLE_MASSLOSS </span><span class="si">%30.12e</span><span class="s2"> </span><span class="si">%g</span><span class="s2"> </span><span class="si">%g</span><span class="s2"> </span><span class="si">%g</span><span class="s2"> </span><span class="si">%d</span><span class="se">\\</span><span class="s2">n",</span> <span class="s2"> //</span> <span class="s2"> stardata->model.time, // 1</span> @@ -750,9 +664,9 @@ Printf("EXAMPLE_MASSLOSS %30.12e %g %g %g %d\n", ); to grid_options Creating and loading custom logging functionality -Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems +Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems Cleaning up the custom logging stuff. type: single -Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_dafa15d2b1e64e19972ac0e9eb5c9a55.so +Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_34a350b8f15c4d149deab88632948c99.so EXAMPLE_MASSLOSS 0.000000000000e+00 10 0 10 1 EXAMPLE_MASSLOSS 0.000000000000e+00 10 10 10 1 EXAMPLE_MASSLOSS 1.000000000000e-06 10 10 10 1 @@ -760,13 +674,12 @@ EXAMPLE_MASSLOSS 2.000000000000e-06 10 10 10 1 </pre></div></div> </div> <p>Lastly we can add a parse_function to handle parsing the output again.</p> -<p>Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be (self, output). Returning the data is useful when running evolve_single(), but won’t be used in a population evolution.</p> +<p>Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be <code class="docutils literal notranslate"><span class="pre">(self,</span> <span class="pre">output)</span></code>. Returning the data is useful when running evolve_single(), but won’t be used in a population evolution.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[11]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">os</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span> <span class="kn">import</span> <span class="nn">json</span> <span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> @@ -815,8 +728,7 @@ EXAMPLE_MASSLOSS 2.000000000000e-06 10 10 10 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[12]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">example_pop</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">example_pop</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">parse_function</span><span class="o">=</span><span class="n">object_parse_function</span><span class="p">,</span> <span class="n">output_dir</span><span class="o">=</span><span class="n">TMP_DIR</span><span class="p">,</span> <span class="n">api_log_filename_prefix</span><span class="o">=</span><span class="n">TMP_DIR</span> @@ -837,20 +749,19 @@ EXAMPLE_MASSLOSS 2.000000000000e-06 10 10 10 1 </div> <div class="output_area docutils container"> <div class="highlight"><pre> -adding: parse_function=<function object_parse_function at 0x149c2e81ec10> to grid_options -<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to custom_options >>>> -adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options +adding: parse_function=<function object_parse_function at 0x7f35b603e9d0> to grid_options +<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-david/notebooks/notebook_individual_systems to custom_options >>>> Creating and loading custom logging functionality -Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems +Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems Cleaning up the custom logging stuff. type: single -Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_0639ee205c7d4782b4a27378f5d890bd.so +Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_446fe4cddfa94946bcafd55591ef3730.so [['time', 'mass', 'initial_mass', 'stellar_type'], [0.0, 10.0, 0.0, 10.0, 1.0], [0.0, 10.0, 10.0, 10.0, 1.0], [1e-06, 10.0, 10.0, 10.0, 1.0]] dict_keys(['time', 'mass', 'initial_mass', 'stellar_type']) </pre></div></div> </div> -</div> -<div class="section" id="Single-system-via-API-functionality"> -<h2>Single system via API functionality<a class="headerlink" href="#Single-system-via-API-functionality" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Single-system-via-API-functionality"> +<h2>Single system via API functionality<a class="headerlink" href="#Single-system-via-API-functionality" title="Permalink to this heading">ïƒ</a></h2> <p>It is possible to construct your own functionality to run a single system by directly calling the API function to run a system. Under the hood all the other functions and wrappers actually use this API.</p> <p>There are fewer failsafes for this method, so this make sure the input is correct and binary_c knows all the arguments you pass in.</p> <p>for more details on this API function see <code class="docutils literal notranslate"><span class="pre">notebook_api_functions</span></code></p> @@ -859,8 +770,7 @@ dict_keys(['time', 'mass', 'initial_mass', 'stellar_ <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[13]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># For a binary system we need to pass in these arguments</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># For a binary system we need to pass in these arguments</span> <span class="n">M_1</span> <span class="o">=</span> <span class="mf">15.0</span> <span class="c1"># Msun</span> <span class="n">M_2</span> <span class="o">=</span> <span class="mf">14.0</span> <span class="c1"># Msun</span> <span class="n">separation</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># 0 = ignored, use period</span> @@ -884,7 +794,7 @@ dict_keys(['time', 'mass', 'initial_mass', 'stellar_ <span class="n">api_log_filename_prefix</span><span class="o">=</span><span class="n">TMP_DIR</span> <span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="k">import</span> <span class="n">_binary_c_bindings</span> +<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">_binary_c_bindings</span> <span class="n">output</span> <span class="o">=</span> <span class="n">_binary_c_bindings</span><span class="o">.</span><span class="n">run_system</span><span class="p">(</span><span class="n">argstring</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">output</span><span class="p">)</span> @@ -901,62 +811,44 @@ SINGLE_STAR_LIFETIME 15 14.9927 </pre></div></div> </div> <p>As we can see above, the output is rather empty. But if SINGLE_STAR_LIFETIME is printed we know we caught the output correctly. To get actual output we should have timesteps printed in the <code class="docutils literal notranslate"><span class="pre">log_every_timestep.c</span></code> in binary_c, or add some custom_logging (see notebook_custom_logging).</p> -</div> -</div> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_custom_logging.html" class="btn btn-neutral float-right" title="Tutorial: Using custom logging routines with binary_c-python" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="../example_notebooks.html" class="btn btn-neutral float-left" title="Example notebooks" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="../example_notebooks.html" class="btn btn-neutral float-left" title="Example notebooks" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_custom_logging.html" class="btn btn-neutral float-right" title="Tutorial: Using custom logging routines with binary_c-python" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_individual_systems.ipynb b/docs/build/html/examples/notebook_individual_systems.ipynb index deb72fc55ba3785c9c829ab83ba0846cd9b86867..d752fc66ed4fdff229a1bab5d1f5e48921ea8e77 100644 --- a/docs/build/html/examples/notebook_individual_systems.ipynb +++ b/docs/build/html/examples/notebook_individual_systems.ipynb @@ -62,7 +62,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "SINGLE_STAR_LIFETIME 1 12461.2\n", + "SINGLE_STAR_LIFETIME 1 12461.1\n", "\n" ] } @@ -90,17 +90,17 @@ "name": "stdout", "output_type": "stream", "text": [ - " TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=62172 RANDOM_COUNT=0\n", + " TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=22065 RANDOM_COUNT=0\n", " 0.0000 1.000 0.000 1 15 -1 -1 -1.00 0.000 0.000 \"INITIAL \"\n", " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 \"OFF_MS\"\n", " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 11582.2424 1.000 0.000 3 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 12325.1085 0.817 0.000 4 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 12457.1301 0.783 0.000 5 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"shrinkAGB\"\n", - " 12461.1627 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 15000.0000 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", + " 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", + " 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"shrinkAGB\"\n", + " 12461.1490 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", + " 15000.0000 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", "\n" ] } @@ -236,13 +236,13 @@ "4 0.000002 1.0 1.0 1.0\n", "5 0.000003 1.0 1.0 1.0\n", "... ... ... ... ...\n", - "1345 12461.080763 0.71617 1.0 6.0\n", - "1346 12461.162734 0.644553 1.0 11.0\n", - "1347 13461.162734 0.644553 1.0 11.0\n", - "1348 14461.162734 0.644553 1.0 11.0\n", - "1349 15000.0 0.644553 1.0 11.0\n", + "1250 12461.061259 0.718593 1.0 6.0\n", + "1251 12461.149038 0.678026 1.0 11.0\n", + "1252 13461.149038 0.678026 1.0 11.0\n", + "1253 14461.149038 0.678026 1.0 11.0\n", + "1254 15000.0 0.678026 1.0 11.0\n", "\n", - "[1349 rows x 4 columns]\n" + "[1254 rows x 4 columns]\n" ] } ], @@ -299,10 +299,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options\n", - "adding: M_1=10 to BSE_options\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", "SINGLE_STAR_LIFETIME 10 28.4838\n", "\n" @@ -360,9 +358,9 @@ ");\n", " to grid_options\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", - "Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_dafa15d2b1e64e19972ac0e9eb5c9a55.so\n", + "Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_34a350b8f15c4d149deab88632948c99.so\n", "EXAMPLE_MASSLOSS 0.000000000000e+00 10 0 10 1\n", "EXAMPLE_MASSLOSS 0.000000000000e+00 10 10 10 1\n", "EXAMPLE_MASSLOSS 1.000000000000e-06 10 10 10 1\n", @@ -381,7 +379,7 @@ "\n", " stardata->star[0].stellar_type //5\n", ");\n", - "\"\"\" \n", + "\"\"\"\n", "\n", "example_pop.set(C_logging_code=custom_logging_print_statement)\n", "\n", @@ -397,7 +395,7 @@ "source": [ "Lastly we can add a parse_function to handle parsing the output again. \n", "\n", - "Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be (self, output). Returning the data is useful when running evolve_single(), but won't be used in a population evolution." + "Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be `(self, output)`. Returning the data is useful when running evolve_single(), but won't be used in a population evolution." ] }, { @@ -464,13 +462,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function object_parse_function at 0x149c2e81ec10> to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to custom_options >>>>\n", - "adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options\n", + "adding: parse_function=<function object_parse_function at 0x7f35b603e9d0> to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-david/notebooks/notebook_individual_systems to custom_options >>>>\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", - "Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_0639ee205c7d4782b4a27378f5d890bd.so\n", + "Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_446fe4cddfa94946bcafd55591ef3730.so\n", "[['time', 'mass', 'initial_mass', 'stellar_type'], [0.0, 10.0, 0.0, 10.0, 1.0], [0.0, 10.0, 10.0, 10.0, 1.0], [1e-06, 10.0, 10.0, 10.0, 1.0]]\n", "dict_keys(['time', 'mass', 'initial_mass', 'stellar_type'])\n" ] @@ -570,7 +567,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -584,7 +581,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/examples/notebook_luminosity_function_binaries.html b/docs/build/html/examples/notebook_luminosity_function_binaries.html index 2e4000a76b604d1fff5b858da49ee9fc53662f6e..b1b8629ecc314789ee66b89b09ada53db555c29d 100644 --- a/docs/build/html/examples/notebook_luminosity_function_binaries.html +++ b/docs/build/html/examples/notebook_luminosity_function_binaries.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Example use case: Zero-age stellar luminosity function in binaries — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Example use case: Zero-age stellar luminosity function in binaries — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Example use case: Hertzsprung-Russell diagrams" href="notebook_HRD.html" /> <link rel="prev" title="Example use case: Zero-age stellar luminosity function" href="notebook_luminosity_function_single.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -95,6 +51,7 @@ <li class="toctree-l2"><a class="reference internal" href="notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">Example use case: Zero-age stellar luminosity function in binaries</a><ul> <li class="toctree-l3"><a class="reference internal" href="#Setting-up-the-Population-object">Setting up the Population object</a></li> @@ -116,70 +73,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Example use case: Zero-age stellar luminosity function in binaries</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_luminosity_function_binaries.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -390,11 +308,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -403,10 +322,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -418,12 +341,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -450,8 +376,8 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Example-use-case:-Zero-age-stellar-luminosity-function-in-binaries"> -<h1>Example use case: Zero-age stellar luminosity function in binaries<a class="headerlink" href="#Example-use-case:-Zero-age-stellar-luminosity-function-in-binaries" title="Permalink to this headline">¶</a></h1> +<section id="Example-use-case:-Zero-age-stellar-luminosity-function-in-binaries"> +<h1>Example use case: Zero-age stellar luminosity function in binaries<a class="headerlink" href="#Example-use-case:-Zero-age-stellar-luminosity-function-in-binaries" title="Permalink to this heading">ïƒ</a></h1> <p>In this notebook we compute the luminosity function of the zero-age main-sequence by running a population of binary stars using binary_c.</p> <p>Before you go through this notebook, you should look at notebook_luminosity_function.ipynb which is for the - conceptually more simple - single stars.</p> <p>We start by loading in some standard Python modules and the binary_c module.</p> @@ -459,25 +385,23 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">os</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span> <span class="kn">import</span> <span class="nn">math</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="k">import</span> <span class="n">Population</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="kn">import</span> <span class="n">Population</span> <span class="c1"># help(Population) # Uncomment this line to see the public functions of this object</span> </pre></div> </div> </div> -<div class="section" id="Setting-up-the-Population-object"> -<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this headline">¶</a></h2> +<section id="Setting-up-the-Population-object"> +<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this heading">ïƒ</a></h2> <p>To set up and configure the population object we need to make a new instance of the <code class="docutils literal notranslate"><span class="pre">Population</span></code> object and configure it with the <code class="docutils literal notranslate"><span class="pre">.set()</span></code> function.</p> <p>In our case, we only need to set the maximum evolution time to something short, because we care only about zero-age main sequence stars which have, by definition, age zero.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create population object</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create population object</span> <span class="n">population</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> <span class="c1"># If you want verbosity, set this before other things</span> @@ -506,9 +430,9 @@ adding: max_evolution_time=0.1 to BSE_options verbosity is 1 </pre></div></div> </div> -</div> -<div class="section" id="Adding-grid-variables"> -<h2>Adding grid variables<a class="headerlink" href="#Adding-grid-variables" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Adding-grid-variables"> +<h2>Adding grid variables<a class="headerlink" href="#Adding-grid-variables" title="Permalink to this heading">ïƒ</a></h2> <p>The main purpose of the Population object is to handle the population synthesis side of running a set of stars. The main method to do this with binarycpython, as is the case with Perl binarygrid, is to use grid variables. These are loops over a predefined range of values, where a probability will be assigned to the systems based on the chosen probability distributions.</p> <p>Usually we use either 1 mass grid variable, or a trio of mass, mass ratio and period (other notebooks cover these examples). We can, however, also add grid sampling for e.g. eccentricity, metallicity or other parameters.</p> <p>To add a grid variable to the population object we use <code class="docutils literal notranslate"><span class="pre">population.add_grid_variable</span></code></p> @@ -516,8 +440,7 @@ verbosity is 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># help(population.add_grid_variable)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># help(population.add_grid_variable)</span> </pre></div> </div> </div> @@ -526,8 +449,7 @@ verbosity is 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">binarycpython.utils.distribution_functions</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">binarycpython.utils.distribution_functions</span> <span class="c1"># help(binarycpython.utils.distribution_functions)</span> </pre></div> </div> @@ -543,8 +465,7 @@ verbosity is 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Set resolution and mass range that we simulate</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Set resolution and mass range that we simulate</span> <span class="n">resolution</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"M_1"</span><span class="p">:</span> <span class="mi">40</span><span class="p">}</span> <span class="c1"># start with resolution = 10, and increase later if you want "more accurate" data</span> <span class="n">massrange</span> <span class="o">=</span> <span class="p">(</span><span class="mf">0.07</span><span class="p">,</span> <span class="mf">100.0</span><span class="p">)</span> <span class="c1"># we work with stars of mass 0.07 to 100 Msun</span> <span class="n">total_probability</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="c1"># theoretical integral of the mass probability density function over all masses</span> @@ -559,8 +480,7 @@ verbosity is 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Set up the binary grid in "cubic" M1 - M2=q*M1 - log10 period space</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Set up the binary grid in "cubic" M1 - M2=q*M1 - log10 period space</span> <span class="n">population</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> @@ -615,9 +535,9 @@ verbosity is 1 </pre></div> </div> </div> -</div> -<div class="section" id="Setting-logging-and-handling-the-output"> -<h2>Setting logging and handling the output<a class="headerlink" href="#Setting-logging-and-handling-the-output" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Setting-logging-and-handling-the-output"> +<h2>Setting logging and handling the output<a class="headerlink" href="#Setting-logging-and-handling-the-output" title="Permalink to this heading">ïƒ</a></h2> <p>By default, binary_c will not output anything (except for ‘SINGLE STAR LIFETIME’). It is up to us to determine what will be printed. We can either do that by hardcoding the print statements into <code class="docutils literal notranslate"><span class="pre">binary_c</span></code> (see documentation binary_c) or we can use the custom logging functionality of binarycpython (see notebook <code class="docutils literal notranslate"><span class="pre">notebook_custom_logging.ipynb</span></code>), which is faster to set up and requires no recompilation of binary_c, but is somewhat more limited in its functionality. For our current purposes, it works perfectly well.</p> <p>After configuring what will be printed, we need to make a function to parse the output. This can be done by setting the parse_function parameter in the population object (see also notebook <code class="docutils literal notranslate"><span class="pre">notebook_individual_systems.ipynb</span></code>).</p> @@ -626,8 +546,7 @@ works perfectly well.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create custom logging statement</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create custom logging statement</span> <span class="c1">#</span> <span class="c1"># we check that the model number is zero, i.e. we're on the first timestep (stars are born on the ZAMS)</span> <span class="c1"># we make sure that the stellar type is <= MAIN_SEQUENCE, i.e. the star is a main-sequence star</span> @@ -689,8 +608,7 @@ works perfectly well.</p> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">C_logging_code</span><span class="o">=</span><span class="n">custom_logging_statement</span> <span class="p">)</span> - -</pre></div> +<br/></pre></div> </div> </div> <p>The parse function must now catch lines that start with “ZERO_AGE_MAIN_SEQUENCE_STAR†and process the associated data.</p> @@ -698,10 +616,9 @@ works perfectly well.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[8]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># import the bin_data function so we can construct finite-resolution probability distributions</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># import the bin_data function so we can construct finite-resolution probability distributions</span> <span class="c1"># import the datalinedict to make a dictionary from each line of data from binary_c</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">bin_data</span><span class="p">,</span><span class="n">datalinedict</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">bin_data</span><span class="p">,</span><span class="n">datalinedict</span> <span class="kn">import</span> <span class="nn">re</span> <span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> @@ -743,9 +660,9 @@ works perfectly well.</p> </pre></div> </div> </div> -</div> -<div class="section" id="Evolving-the-grid"> -<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Evolving-the-grid"> +<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this heading">ïƒ</a></h2> <p>Now that we configured all the main parts of the population object, we can actually run the population! Doing this is straightforward: <code class="docutils literal notranslate"><span class="pre">population.evolve()</span></code></p> <p>This will start up the processing of all the systems. We can control how many cores are used by settings <code class="docutils literal notranslate"><span class="pre">num_cores</span></code>. By setting the <code class="docutils literal notranslate"><span class="pre">verbosity</span></code> of the population object to a higher value we can get a lot of verbose information about the run, but for now we will set it to 0.</p> <p>There are many grid_options that can lead to different behaviour of the evolution of the grid. Please do have a look at those: <a class="reference external" href="https://ri0005.pages.surrey.ac.uk/binary_c-python/grid_options_descriptions.html">grid options docs</a>, and try</p> @@ -753,8 +670,7 @@ works perfectly well.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[9]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># set number of threads</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># set number of threads</span> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="c1"># verbose output is not required</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> @@ -1168,8 +1084,7 @@ Done population run! <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[10]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> </pre></div> </div> </div> @@ -1185,11 +1100,10 @@ Done population run! <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[11]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># make a plot of the luminosity distribution using Seaborn and Pandas</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># make a plot of the luminosity distribution using Seaborn and Pandas</span> <span class="kn">import</span> <span class="nn">seaborn</span> <span class="k">as</span> <span class="nn">sns</span> <span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">pad_output_distribution</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">pad_output_distribution</span> <span class="c1"># set up seaborn for use in the notebook</span> <span class="n">sns</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">rc</span><span class="o">=</span><span class="p">{</span><span class="s1">'figure.figsize'</span><span class="p">:(</span><span class="mi">20</span><span class="p">,</span><span class="mi">10</span><span class="p">)})</span> @@ -1255,67 +1169,48 @@ Done population run! <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> </pre></div> </div> </div> -</div> -</div> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_HRD.html" class="btn btn-neutral float-right" title="Example use case: Hertzsprung-Russell diagrams" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_luminosity_function_single.html" class="btn btn-neutral float-left" title="Example use case: Zero-age stellar luminosity function" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_luminosity_function_single.html" class="btn btn-neutral float-left" title="Example use case: Zero-age stellar luminosity function" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_HRD.html" class="btn btn-neutral float-right" title="Example use case: Hertzsprung-Russell diagrams" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_luminosity_function_single.html b/docs/build/html/examples/notebook_luminosity_function_single.html index b09114126321a2a5cec6f20ddad94595e4ff4697..47e78f5560a211a3bcae3dd634a45c76dd689ad0 100644 --- a/docs/build/html/examples/notebook_luminosity_function_single.html +++ b/docs/build/html/examples/notebook_luminosity_function_single.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Example use case: Zero-age stellar luminosity function — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Example use case: Zero-age stellar luminosity function — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Example use case: Zero-age stellar luminosity function in binaries" href="notebook_luminosity_function_binaries.html" /> - <link rel="prev" title="Tutorial: Using the API functionality of binary_c-python" href="notebook_api_functionality.html" /> + <link rel="prev" title="Tutorial: Generating and handling ensemble data" href="notebook_ensembles.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -95,6 +51,7 @@ <li class="toctree-l2"><a class="reference internal" href="notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">Example use case: Zero-age stellar luminosity function</a><ul> <li class="toctree-l3"><a class="reference internal" href="#Setting-up-the-Population-object">Setting up the Population object</a></li> <li class="toctree-l3"><a class="reference internal" href="#Adding-grid-variables">Adding grid variables</a></li> @@ -118,70 +75,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Example use case: Zero-age stellar luminosity function</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_luminosity_function_single.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -392,11 +310,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -405,10 +324,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -420,12 +343,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -452,21 +378,20 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Example-use-case:-Zero-age-stellar-luminosity-function"> -<h1>Example use case: Zero-age stellar luminosity function<a class="headerlink" href="#Example-use-case:-Zero-age-stellar-luminosity-function" title="Permalink to this headline">¶</a></h1> +<section id="Example-use-case:-Zero-age-stellar-luminosity-function"> +<h1>Example use case: Zero-age stellar luminosity function<a class="headerlink" href="#Example-use-case:-Zero-age-stellar-luminosity-function" title="Permalink to this heading">ïƒ</a></h1> <p>In this notebook we compute the luminosity function of the zero-age main-sequence by running a population of single stars using binary_c.</p> <p>We start by loading in some standard Python modules and the binary_c module.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">os</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span> <span class="kn">import</span> <span class="nn">math</span> <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">temp_dir</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="k">import</span> <span class="n">Population</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">temp_dir</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="kn">import</span> <span class="n">Population</span> <span class="n">TMP_DIR</span> <span class="o">=</span> <span class="n">temp_dir</span><span class="p">(</span><span class="s2">"notebooks"</span><span class="p">,</span> <span class="s2">"notebook_luminosity"</span><span class="p">)</span> @@ -474,16 +399,15 @@ div.rendered_html tbody tr:hover { </pre></div> </div> </div> -<div class="section" id="Setting-up-the-Population-object"> -<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this headline">¶</a></h2> +<section id="Setting-up-the-Population-object"> +<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this heading">ïƒ</a></h2> <p>To set up and configure the population object we need to make a new instance of the <code class="docutils literal notranslate"><span class="pre">Population</span></code> object and configure it with the <code class="docutils literal notranslate"><span class="pre">.set()</span></code> function.</p> <p>In our case, we only need to set the maximum evolution time to something short, because we care only about zero-age main sequence stars which have, by definition, age zero.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create population object</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create population object</span> <span class="n">population</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> <span class="c1"># If you want verbosity, set this before other things</span> @@ -509,14 +433,13 @@ div.rendered_html tbody tr:hover { </div> <div class="output_area docutils container"> <div class="highlight"><pre> -adding: max_evolution_time=0.1 to BSE_options -adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_luminosity to grid_options +adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_luminosity to grid_options verbosity is 1 </pre></div></div> </div> -</div> -<div class="section" id="Adding-grid-variables"> -<h2>Adding grid variables<a class="headerlink" href="#Adding-grid-variables" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Adding-grid-variables"> +<h2>Adding grid variables<a class="headerlink" href="#Adding-grid-variables" title="Permalink to this heading">ïƒ</a></h2> <p>The main purpose of the Population object is to handle the population synthesis side of running a set of stars. The main method to do this with binarycpython, as is the case with Perl binarygrid, is to use grid variables. These are loops over a predefined range of values, where a probability will be assigned to the systems based on the chosen probability distributions.</p> <p>Usually we use either 1 mass grid variable, or a trio of mass, mass ratio and period (other notebooks cover these examples). We can, however, also add grid sampling for e.g. eccentricity, metallicity or other parameters.</p> <p>To add a grid variable to the population object we use <code class="docutils literal notranslate"><span class="pre">population.add_grid_variable</span></code></p> @@ -524,19 +447,7 @@ verbosity is 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># help(population.add_grid_variable)</span> -</pre></div> -</div> -</div> -<p>All the distribution functions that we can use are stored in the <code class="docutils literal notranslate"><span class="pre">binarycpython.utils.distribution_functions</span></code> or <code class="docutils literal notranslate"><span class="pre">binarycpython/utils/distribution_functions.py</span></code> on git. If you uncomment the help statement below you can see which functions are available now:</p> -<div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: -</pre></div> -</div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">binarycpython.utils.distribution_functions</span> -<span class="c1"># help(binarycpython.utils.distribution_functions)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># help(population.add_grid_variable)</span> </pre></div> </div> </div> @@ -548,11 +459,10 @@ verbosity is 1 <li><p>The binwidth sets the resolution of the final distribution. If set to 0.5, the bins in log<em>L</em> are 0.5dex wide.</p></li> </ul> <div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Set resolution and mass range that we simulate</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Set resolution and mass range that we simulate</span> <span class="n">resolution</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"M_1"</span><span class="p">:</span> <span class="mi">40</span><span class="p">}</span> <span class="c1"># start with resolution = 10, and increase later if you want "more accurate" data</span> <span class="n">massrange</span> <span class="o">=</span> <span class="p">(</span><span class="mf">0.07</span><span class="p">,</span> <span class="mf">100.0</span><span class="p">)</span> <span class="c1"># we work with stars of mass 0.07 to 100 Msun</span> <span class="n">total_probability</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="c1"># theoretical integral of the mass probability density function over all masses</span> @@ -563,12 +473,11 @@ verbosity is 1 </div> </div> <p>The next cell contains an example of adding the mass grid variable, sampling the phase space in linear mass <em>M</em>_1.</p> -<div class="nbinput docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: +<div class="nbinput nblast docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Mass</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Mass</span> <span class="n">population</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">tmp_dir</span><span class="o">=</span><span class="n">TMP_DIR</span><span class="p">,</span> @@ -577,8 +486,16 @@ verbosity is 1 <span class="n">name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> <span class="n">longname</span><span class="o">=</span><span class="s2">"Primary mass"</span><span class="p">,</span> <span class="n">valuerange</span><span class="o">=</span><span class="n">massrange</span><span class="p">,</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"const(</span><span class="si">{min}</span><span class="s2">, </span><span class="si">{max}</span><span class="s2">, </span><span class="si">{res}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">min</span> <span class="o">=</span> <span class="n">massrange</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">max</span> <span class="o">=</span> <span class="n">massrange</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resolution</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> - <span class="n">probdist</span><span class="o">=</span><span class="s2">"</span><span class="si">{probtot}</span><span class="s2">/(</span><span class="si">{max}</span><span class="s2"> - </span><span class="si">{min}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">probtot</span> <span class="o">=</span> <span class="n">total_probability</span><span class="p">,</span> <span class="nb">min</span> <span class="o">=</span> <span class="n">massrange</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">max</span> <span class="o">=</span> <span class="n">massrange</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span> <span class="c1"># dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_linear(</span><span class="si">{min}</span><span class="s2">, </span><span class="si">{max}</span><span class="s2">, </span><span class="si">{res}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="nb">min</span><span class="o">=</span><span class="n">massrange</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> + <span class="nb">max</span><span class="o">=</span><span class="n">massrange</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> + <span class="n">res</span><span class="o">=</span><span class="n">resolution</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]</span> + <span class="p">),</span> + <span class="n">probdist</span><span class="o">=</span><span class="s2">"</span><span class="si">{probtot}</span><span class="s2">/(</span><span class="si">{max}</span><span class="s2"> - </span><span class="si">{min}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="n">probtot</span><span class="o">=</span><span class="n">total_probability</span><span class="p">,</span> + <span class="nb">min</span><span class="o">=</span><span class="n">massrange</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> + <span class="nb">max</span><span class="o">=</span><span class="n">massrange</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> + <span class="p">),</span> <span class="c1"># dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)</span> <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dM_1"</span><span class="p">,</span> <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> <span class="n">condition</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="c1"># Impose a condition on this grid variable. Mostly for a check for yourself</span> @@ -586,36 +503,18 @@ verbosity is 1 </pre></div> </div> </div> -<div class="nboutput nblast docutils container"> -<div class="prompt empty docutils container"> -</div> -<div class="output_area docutils container"> -<div class="highlight"><pre> -<span class="ansi-red-fg">---------------------------------------------------------------------------</span> -<span class="ansi-red-fg">TypeError</span> Traceback (most recent call last) -<span class="ansi-green-fg">/tmp/ipykernel_519112/518757914.py</span> in <span class="ansi-cyan-fg"><module></span> -<span class="ansi-green-intense-fg ansi-bold"> 4</span> tmp_dir<span class="ansi-blue-fg">=</span>TMP_DIR<span class="ansi-blue-fg">,</span> -<span class="ansi-green-intense-fg ansi-bold"> 5</span> ) -<span class="ansi-green-fg">----> 6</span><span class="ansi-red-fg"> population.add_grid_variable( -</span><span class="ansi-green-intense-fg ansi-bold"> 7</span> name<span class="ansi-blue-fg">=</span><span class="ansi-blue-fg">"M_1"</span><span class="ansi-blue-fg">,</span> -<span class="ansi-green-intense-fg ansi-bold"> 8</span> longname<span class="ansi-blue-fg">=</span><span class="ansi-blue-fg">"Primary mass"</span><span class="ansi-blue-fg">,</span> - -<span class="ansi-red-fg">TypeError</span>: add_grid_variable() got an unexpected keyword argument 'resolution' -</pre></div></div> -</div> -</div> -<div class="section" id="Setting-logging-and-handling-the-output"> -<h2>Setting logging and handling the output<a class="headerlink" href="#Setting-logging-and-handling-the-output" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Setting-logging-and-handling-the-output"> +<h2>Setting logging and handling the output<a class="headerlink" href="#Setting-logging-and-handling-the-output" title="Permalink to this heading">ïƒ</a></h2> <p>By default, binary_c will not output anything (except for ‘SINGLE STAR LIFETIME’). It is up to us to determine what will be printed. We can either do that by hardcoding the print statements into <code class="docutils literal notranslate"><span class="pre">binary_c</span></code> (see documentation binary_c) or we can use the custom logging functionality of binarycpython (see notebook <code class="docutils literal notranslate"><span class="pre">notebook_custom_logging.ipynb</span></code>), which is faster to set up and requires no recompilation of binary_c, but is somewhat more limited in its functionality. For our current purposes, it works perfectly well.</p> <p>After configuring what will be printed, we need to make a function to parse the output. This can be done by setting the parse_function parameter in the population object (see also notebook <code class="docutils literal notranslate"><span class="pre">notebook_individual_systems.ipynb</span></code>).</p> <p>In the code below we will set up both the custom logging and a parse function to handle that output.</p> <div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create custom logging statement</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create custom logging statement</span> <span class="c1">#</span> <span class="c1"># we check that the model number is zero, i.e. we're on the first timestep (stars are born on the ZAMS)</span> <span class="c1"># we make sure that the stellar type is <= MAIN_SEQUENCE, i.e. the star is a main-sequence star</span> @@ -642,19 +541,17 @@ works perfectly well.</p> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">C_logging_code</span><span class="o">=</span><span class="n">custom_logging_statement</span> <span class="p">)</span> - -</pre></div> +<br/></pre></div> </div> </div> <p>The parse function must now catch lines that start with “ZERO_AGE_MAIN_SEQUENCE_STAR†and process the associated data.</p> -<div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +<div class="nbinput docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[15]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># import the bin_data function so we can construct finite-resolution probability distributions</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># import the bin_data function so we can construct finite-resolution probability distributions</span> <span class="c1"># import the datalinedict to make a dictionary from each line of data from binary_c</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">bin_data</span><span class="p">,</span><span class="n">datalinedict</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">bin_data</span><span class="p">,</span><span class="n">datalinedict</span> <span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> <span class="sd">"""</span> @@ -675,12 +572,9 @@ works perfectly well.</p> <span class="c1"># bin the log10(luminosity) to the nearest 0.1dex</span> <span class="n">binned_log_luminosity</span> <span class="o">=</span> <span class="n">bin_data</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">linedata</span><span class="p">[</span><span class="s1">'luminosity'</span><span class="p">]),</span> <span class="n">binwidth</span><span class="p">[</span><span class="s1">'luminosity'</span><span class="p">])</span> - <span class="c1"># append the data to the results_dictionary</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'luminosity distribution'</span><span class="p">][</span><span class="n">binned_log_luminosity</span><span class="p">]</span> <span class="o">+=</span> <span class="n">linedata</span><span class="p">[</span><span class="s1">'probability'</span><span class="p">]</span> - <span class="c1">#print (self.grid_results)</span> - <span class="c1"># verbose reporting</span> <span class="c1">#print("parse out results_dictionary=",self.grid_results)</span> @@ -691,24 +585,31 @@ works perfectly well.</p> </pre></div> </div> </div> +<div class="nboutput nblast docutils container"> +<div class="prompt empty docutils container"> </div> -<div class="section" id="Evolving-the-grid"> -<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this headline">¶</a></h2> +<div class="output_area docutils container"> +<div class="highlight"><pre> +adding: parse_function=<function parse_function at 0x7f6920fd2430> to grid_options +</pre></div></div> +</div> +</section> +<section id="Evolving-the-grid"> +<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this heading">ïƒ</a></h2> <p>Now that we configured all the main parts of the population object, we can actually run the population! Doing this is straightforward: <code class="docutils literal notranslate"><span class="pre">population.evolve()</span></code></p> <p>This will start up the processing of all the systems. We can control how many cores are used by settings <code class="docutils literal notranslate"><span class="pre">num_cores</span></code>. By setting the <code class="docutils literal notranslate"><span class="pre">verbosity</span></code> of the population object to a higher value we can get a lot of verbose information about the run, but for now we will set it to 0.</p> <p>There are many grid_options that can lead to different behaviour of the evolution of the grid. Please do have a look at those: <a class="reference external" href="https://ri0005.pages.surrey.ac.uk/binary_c-python/grid_options_descriptions.html">grid options docs</a>, and try</p> -<div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +<div class="nbinput docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[16]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># set number of threads</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># set number of threads</span> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="c1"># verbose output is not required</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="c1"># set number of threads (i.e. number of CPU cores we use)</span> <span class="n">num_cores</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> - <span class="p">)</span> +<span class="p">)</span> <span class="c1"># Evolve the population - this is the slow, number-crunching step</span> <span class="n">analytics</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">evolve</span><span class="p">()</span> @@ -718,25 +619,61 @@ works perfectly well.</p> </pre></div> </div> </div> +<div class="nboutput nblast docutils container"> +<div class="prompt empty docutils container"> +</div> +<div class="output_area docutils container"> +<div class="highlight"><pre> +adding: verbosity=0 to grid_options +Do dry run? True +Doing dry run to calculate total starcount and probability +Grid has handled 39 stars with a total probability of 1 +************************** +* Dry run * +* Total starcount is 39 * +* Total probability is 1 * +************************** + +Do join of subprocesses ... +Joined subprocesses. +********************************************************** +* Population-f9b28e4ed6ec4a67b17cd86c5a43c41c finished! * +* The total probability is 1. * +* It took a total of 3.99s to run 39 systems on 2 cores * +* = 7.98s of CPU time. * +* Maximum memory use 343.570 MB * +********************************************************** + +No failed systems were found in this run. +Do analytics +Added analytics to metadata +</pre></div></div> +</div> <p>After the run is complete, some technical report on the run is returned. I stored that in <code class="docutils literal notranslate"><span class="pre">analytics</span></code>. As we can see below, this dictionary is like a status report of the evolution. Useful for e.g. debugging.</p> -<div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +<div class="nbinput docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[19]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> </pre></div> </div> </div> -<div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +<div class="nboutput nblast docutils container"> +<div class="prompt empty docutils container"> +</div> +<div class="output_area docutils container"> +<div class="highlight"><pre> +{'population_id': 'f9b28e4ed6ec4a67b17cd86c5a43c41c', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.9999999999999999, 'total_count': 39, 'start_timestamp': 1655508316.7679594, 'end_timestamp': 1655508320.7581806, 'time_elapsed': 3.9902212619781494, 'total_mass_run': 1951.365, 'total_probability_weighted_mass_run': 50.035, 'zero_prob_stars_skipped': 0} +</pre></div></div> +</div> +<div class="nbinput docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[18]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># make a plot of the luminosity distribution using Seaborn and Pandas</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># make a plot of the luminosity distribution using Seaborn and Pandas</span> <span class="kn">import</span> <span class="nn">seaborn</span> <span class="k">as</span> <span class="nn">sns</span> <span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">pad_output_distribution</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">pad_output_distribution</span> <span class="c1"># set up seaborn for use in the notebook</span> <span class="n">sns</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">rc</span><span class="o">=</span><span class="p">{</span><span class="s1">'figure.figsize'</span><span class="p">:(</span><span class="mi">20</span><span class="p">,</span><span class="mi">10</span><span class="p">)})</span> @@ -763,30 +700,44 @@ works perfectly well.</p> </pre></div> </div> </div> -<p>Does this look like a reasonable stellar luminosity function to you? The implication is that the most likely stellar luminosity is 105.8 L☉! Clearly, this is not very realistic… let’s see what went wrong.</p> +<div class="nboutput docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[18]: +</pre></div> +</div> +<div class="output_area docutils container"> +<div class="highlight"><pre> +[None] +</pre></div></div> +</div> +<div class="nboutput nblast docutils container"> +<div class="prompt empty docutils container"> </div> -<div class="section" id="ZAMS-Luminosity-distribution-with-the-initial-mass-function"> -<h2>ZAMS Luminosity distribution with the initial mass function<a class="headerlink" href="#ZAMS-Luminosity-distribution-with-the-initial-mass-function" title="Permalink to this headline">¶</a></h2> +<div class="output_area docutils container"> +<img alt="../_images/examples_notebook_luminosity_function_single_18_1.png" src="../_images/examples_notebook_luminosity_function_single_18_1.png" /> +</div> +</div> +<p>Does this look like a reasonable stellar luminosity function to you? The implication is that the most likely stellar luminosity is 105.8 L☉! Clearly, this is not very realistic… let’s see what went wrong.</p> +</section> +<section id="ZAMS-Luminosity-distribution-with-the-initial-mass-function"> +<h2>ZAMS Luminosity distribution with the initial mass function<a class="headerlink" href="#ZAMS-Luminosity-distribution-with-the-initial-mass-function" title="Permalink to this heading">ïƒ</a></h2> <p>In the previous example, all the stars in our grid had an equal weighting. This is very unlikely to be true in reality: indeed, we know that low mass stars are far more likely than high mass stars. So we now include an initial mass function as a three-part power law based on Kroupa (2001). Kroupa’s distribution is a three-part power law: we have a function that does this for us (it’s very common to use power laws in astrophysics).</p> <div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[22]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Update the probability distribution to use the three-part power law IMF</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Update the probability distribution to use the three-part power law IMF</span> <span class="n">population</span><span class="o">.</span><span class="n">update_grid_variable</span><span class="p">(</span> <span class="n">name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="s2">"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="s2">"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)"</span><span class="p">,</span> <span class="p">)</span> </pre></div> </div> </div> -<div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +<div class="nbinput docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[23]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Clean and re-evolve the population</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Clean and re-evolve the population</span> <span class="n">population</span><span class="o">.</span><span class="n">clean</span><span class="p">()</span> <span class="n">analytics</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">evolve</span><span class="p">()</span> @@ -795,12 +746,40 @@ works perfectly well.</p> </pre></div> </div> </div> -<div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +<div class="nboutput nblast docutils container"> +<div class="prompt empty docutils container"> +</div> +<div class="output_area docutils container"> +<div class="highlight"><pre> +Do dry run? True +Doing dry run to calculate total starcount and probability +Grid has handled 39 stars with a total probability of 0.211729 +********************************** +* Dry run * +* Total starcount is 39 * +* Total probability is 0.211729 * +********************************** + +Do join of subprocesses ... +Joined subprocesses. +********************************************************** +* Population-1d1d556abeae4549aa28f9740807dc84 finished! * +* The total probability is 0.211729. * +* It took a total of 3.90s to run 39 systems on 2 cores * +* = 7.80s of CPU time. * +* Maximum memory use 519.211 MB * +********************************************************** + +No failed systems were found in this run. +Do analytics +Added analytics to metadata +</pre></div></div> +</div> +<div class="nbinput docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[24]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># plot luminosity distribution</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># plot luminosity distribution</span> <span class="n">ldist</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'luminosity distribution'</span><span class="p">]</span> <span class="c1"># pad the distribution with zeros where data is missing</span> @@ -818,37 +797,70 @@ works perfectly well.</p> </pre></div> </div> </div> +<div class="nboutput docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[24]: +</pre></div> +</div> +<div class="output_area docutils container"> +<div class="highlight"><pre> +[None] +</pre></div></div> +</div> +<div class="nboutput nblast docutils container"> +<div class="prompt empty docutils container"> +</div> +<div class="output_area docutils container"> +<img alt="../_images/examples_notebook_luminosity_function_single_23_1.png" src="../_images/examples_notebook_luminosity_function_single_23_1.png" /> +</div> +</div> <p>This distribution is peaked at low luminosity, as one expects from observations, but the resolution is clearly not great because it’s not smooth - it’s spiky!</p> <p>If you noticed above, the total probability of the grid was about 0.2. Given that the total probability of a probability distribution function should be 1.0, this shows that our sampling is (very) poor.</p> <p>We could simply increase the resolution to compensate, but this is very CPU intensive and a complete waste of time and resources. Instead, let’s try sampling the masses of the stars in a smarter way.</p> -</div> -<div class="section" id="A-better-sampled-grid"> -<h2>A better-sampled grid<a class="headerlink" href="#A-better-sampled-grid" title="Permalink to this headline">¶</a></h2> +</section> +<section id="A-better-sampled-grid"> +<h2>A better-sampled grid<a class="headerlink" href="#A-better-sampled-grid" title="Permalink to this heading">ïƒ</a></h2> <p>The IMF has many more low-mass stars than high-mass stars. So, instead of sampling M1 linearly, we can sample it in log space.</p> <p>To do this we first rename the mass grid variable so that it is clear we are working in (natural) logarithmic phase space.</p> -<div class="nbinput nblast docutils container"> -<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: +<div class="nbinput docutils container"> +<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[27]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Rename the old variable (M_1) because we want it to be called lnM_1 now</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Rename the old variable (M_1) because we want it to be called lnM_1 now</span> <span class="n">population</span><span class="o">.</span><span class="n">rename_grid_variable</span><span class="p">(</span><span class="s2">"M_1"</span><span class="p">,</span><span class="s2">"lnM_1"</span><span class="p">)</span> </pre></div> </div> </div> +<div class="nboutput nblast docutils container"> +<div class="prompt empty docutils container"> +</div> +<div class="output_area docutils container"> +<div class="highlight"><pre> +<span class="ansi-red-fg">---------------------------------------------------------------------------</span> +<span class="ansi-red-fg">ValueError</span> Traceback (most recent call last) +Input <span class="ansi-green-fg">In [27]</span>, in <span class="ansi-cyan-fg"><cell line: 2></span><span class="ansi-blue-fg">()</span> +<span class="ansi-green-intense-fg ansi-bold"> 1</span> <span style="color: rgb(95,135,135)"># Rename the old variable (M_1) because we want it to be called lnM_1 now</span> +<span class="ansi-green-fg">----> 2</span> <span class="ansi-yellow-bg">population</span><span class="ansi-yellow-bg" style="color: rgb(98,98,98)">.</span><span class="ansi-yellow-bg">rename_grid_variable</span><span class="ansi-yellow-bg">(</span><span class="ansi-yellow-bg" style="color: rgb(175,0,0)">"</span><span class="ansi-yellow-bg" style="color: rgb(175,0,0)">M_1</span><span class="ansi-yellow-bg" style="color: rgb(175,0,0)">"</span><span class="ansi-yellow-bg">,</span><span class="ansi-yellow-bg" style="color: rgb(175,0,0)">"</span><span class="ansi-yellow-bg" style="color: rgb(175,0,0)">lnM_1</span><span class="ansi-yellow-bg" style="color: rgb(175,0,0)">"</span><span class="ansi-yellow-bg">)</span> + +File <span class="ansi-green-fg">~/.pyenv/versions/3.9.9/envs/dev_binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/utils/population_extensions/gridcode.py:965</span>, in <span class="ansi-cyan-fg">gridcode.rename_grid_variable</span><span class="ansi-blue-fg">(self, oldname, newname)</span> +<span class="ansi-green-intense-fg ansi-bold"> 963</span> <span class="ansi-bold" style="color: rgb(0,135,0)">else</span>: +<span class="ansi-green-intense-fg ansi-bold"> 964</span> msg <span style="color: rgb(98,98,98)">=</span> <span style="color: rgb(175,0,0)">"</span><span style="color: rgb(175,0,0)">Failed to rename grid variable </span><span class="ansi-bold" style="color: rgb(175,95,135)">{}</span><span style="color: rgb(175,0,0)"> to </span><span class="ansi-bold" style="color: rgb(175,95,135)">{}</span><span style="color: rgb(175,0,0)">.</span><span style="color: rgb(175,0,0)">"</span><span style="color: rgb(98,98,98)">.</span>format(oldname, newname) +<span class="ansi-green-fg">--> 965</span> <span class="ansi-bold" style="color: rgb(0,135,0)">raise</span> <span class="ansi-bold" style="color: rgb(215,95,95)">ValueError</span>(msg) + +<span class="ansi-red-fg">ValueError</span>: Failed to rename grid variable M_1 to lnM_1. +</pre></div></div> +</div> <p>Next, we change the spacing function so that it works in the log space. We also adapt the probability calculation so that it calculates dprob/dlnM = M * dprob/dM. Finally, we set the precode to compute M_1 because binary_c requires the actual mass, not the logarithm of the mass.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># update the sampling, note that the IMF is dprob/dM1, and the phase</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># update the sampling, note that the IMF is dprob/dM1, and the phase</span> <span class="c1"># space is now sampled in lnM1, so we multiply by M_1 to</span> <span class="c1"># because M * dprob/dM = dprob/dlnM</span> <span class="n">population</span><span class="o">.</span><span class="n">update_grid_variable</span><span class="p">(</span> <span class="n">name</span><span class="o">=</span><span class="s2">"lnM_1"</span><span class="p">,</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"const(math.log(</span><span class="si">{min}</span><span class="s2">), math.log(</span><span class="si">{max}</span><span class="s2">), </span><span class="si">{res}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">min</span> <span class="o">=</span> <span class="n">massrange</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">max</span> <span class="o">=</span> <span class="n">massrange</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resolution</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> - <span class="n">probdist</span><span class="o">=</span><span class="s2">"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1"</span><span class="p">,</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_linear(math.log(</span><span class="si">{min}</span><span class="s2">), math.log(</span><span class="si">{max}</span><span class="s2">), </span><span class="si">{res}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">min</span> <span class="o">=</span> <span class="n">massrange</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">max</span> <span class="o">=</span> <span class="n">massrange</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resolution</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> + <span class="n">probdist</span><span class="o">=</span><span class="s2">"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1"</span><span class="p">,</span> <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dlnM_1"</span><span class="p">,</span> <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> <span class="n">precode</span><span class="o">=</span><span class="s2">"M_1=math.exp(lnM_1)"</span><span class="p">,</span> @@ -861,8 +873,7 @@ works perfectly well.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Clean and re-evolve the population</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Clean and re-evolve the population</span> <span class="n">population</span><span class="o">.</span><span class="n">clean</span><span class="p">()</span> <span class="n">analytics</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">evolve</span><span class="p">()</span> @@ -876,8 +887,7 @@ works perfectly well.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># plot luminosity distribution</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># plot luminosity distribution</span> <span class="n">ldist</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'luminosity distribution'</span><span class="p">]</span> <span class="c1"># pad the distribution with zeros where data is missing</span> @@ -912,67 +922,48 @@ works perfectly well.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> </pre></div> </div> </div> -</div> -</div> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_luminosity_function_binaries.html" class="btn btn-neutral float-right" title="Example use case: Zero-age stellar luminosity function in binaries" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_api_functionality.html" class="btn btn-neutral float-left" title="Tutorial: Using the API functionality of binary_c-python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_ensembles.html" class="btn btn-neutral float-left" title="Tutorial: Generating and handling ensemble data" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_luminosity_function_binaries.html" class="btn btn-neutral float-right" title="Example use case: Zero-age stellar luminosity function in binaries" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_luminosity_function_single.ipynb b/docs/build/html/examples/notebook_luminosity_function_single.ipynb index 93e041531422571b1a499b0089f9e4e465d4a0f3..0a19202d3d6b54cc27b089c742e1a194a226587a 100644 --- a/docs/build/html/examples/notebook_luminosity_function_single.ipynb +++ b/docs/build/html/examples/notebook_luminosity_function_single.ipynb @@ -54,8 +54,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: max_evolution_time=0.1 to BSE_options\n", - "adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_luminosity to grid_options\n", + "adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_luminosity to grid_options\n", "verbosity is 1\n" ] } @@ -104,28 +103,6 @@ "# help(population.add_grid_variable)" ] }, - { - "cell_type": "markdown", - "id": "bd75cebe-2152-4025-b680-dc020b80889b", - "metadata": {}, - "source": [ - "All the distribution functions that we can use are stored in the `binarycpython.utils.distribution_functions` or `binarycpython/utils/distribution_functions.py` on git. If you uncomment the help statement below you can see which functions are available now:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "048db541-3e92-4c5d-a25c-9c5a34b9c857", - "metadata": { - "scrolled": true, - "tags": [] - }, - "outputs": [], - "source": [ - "import binarycpython.utils.distribution_functions\n", - "# help(binarycpython.utils.distribution_functions)" - ] - }, { "cell_type": "markdown", "id": "2a9104fc-4136-4e53-8604-f24ad52fbe56", @@ -141,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "id": "aba3fe4e-18f2-4bb9-8e5c-4c6007ab038b", "metadata": {}, "outputs": [], @@ -165,22 +142,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "id": "47979841-2c26-4b26-8945-603d013dc93a", "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "add_grid_variable() got an unexpected keyword argument 'resolution'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/tmp/ipykernel_519112/518757914.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mtmp_dir\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mTMP_DIR\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m )\n\u001b[0;32m----> 6\u001b[0;31m population.add_grid_variable(\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"M_1\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mlongname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"Primary mass\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mTypeError\u001b[0m: add_grid_variable() got an unexpected keyword argument 'resolution'" - ] - } - ], + "outputs": [], "source": [ "# Mass\n", "population = Population()\n", @@ -191,8 +156,16 @@ " name=\"M_1\",\n", " longname=\"Primary mass\",\n", " valuerange=massrange,\n", - " samplerfunc=\"const({min}, {max}, {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", - " probdist=\"{probtot}/({max} - {min})\".format(probtot = total_probability, min = massrange[0], max = massrange[1]), # dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)\n", + " samplerfunc=\"self.const_linear({min}, {max}, {res})\".format(\n", + " min=massrange[0],\n", + " max=massrange[1],\n", + " res=resolution[\"M_1\"]\n", + " ),\n", + " probdist=\"{probtot}/({max} - {min})\".format(\n", + " probtot=total_probability,\n", + " min=massrange[0],\n", + " max=massrange[1]\n", + " ), # dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)\n", " dphasevol=\"dM_1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -214,7 +187,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "0c986215-93b1-4e30-ad79-f7c397e9ff7d", "metadata": {}, "outputs": [], @@ -258,10 +231,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "fd197154-a8ce-4865-8929-008d3483101a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "adding: parse_function=<function parse_function at 0x7f6920fd2430> to grid_options\n" + ] + } + ], "source": [ "# import the bin_data function so we can construct finite-resolution probability distributions\n", "# import the datalinedict to make a dictionary from each line of data from binary_c\n", @@ -279,18 +260,15 @@ " for line in output.splitlines():\n", " # obtain the line of data in dictionary form \n", " linedata = datalinedict(line,parameters)\n", - " \n", + "\n", " # Check the header and act accordingly\n", " if linedata['header'] == \"ZERO_AGE_MAIN_SEQUENCE_STAR\":\n", - " \n", + "\n", " # bin the log10(luminosity) to the nearest 0.1dex\n", " binned_log_luminosity = bin_data(math.log10(linedata['luminosity']),\n", " binwidth['luminosity'])\n", - " \n", " # append the data to the results_dictionary \n", " self.grid_results['luminosity distribution'][binned_log_luminosity] += linedata['probability'] \n", - " \n", - " #print (self.grid_results)\n", " \n", " # verbose reporting\n", " #print(\"parse out results_dictionary=\",self.grid_results)\n", @@ -316,12 +294,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "8ea376c1-1e92-45af-8cab-9d7fdca564eb", "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "adding: verbosity=0 to grid_options\n", + "Do dry run? True\n", + "Doing dry run to calculate total starcount and probability\n", + "Grid has handled 39 stars with a total probability of 1\n", + "**************************\n", + "* Dry run *\n", + "* Total starcount is 39 *\n", + "* Total probability is 1 *\n", + "**************************\n", + "\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", + "**********************************************************\n", + "* Population-f9b28e4ed6ec4a67b17cd86c5a43c41c finished! *\n", + "* The total probability is 1. *\n", + "* It took a total of 3.99s to run 39 systems on 2 cores *\n", + "* = 7.98s of CPU time. *\n", + "* Maximum memory use 343.570 MB *\n", + "**********************************************************\n", + "\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" + ] + } + ], "source": [ "# set number of threads\n", "population.set(\n", @@ -329,7 +337,7 @@ " verbosity=0,\n", " # set number of threads (i.e. number of CPU cores we use)\n", " num_cores=2,\n", - " )\n", + ")\n", "\n", "# Evolve the population - this is the slow, number-crunching step\n", "analytics = population.evolve() \n", @@ -348,20 +356,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "e1f0464b-0424-4022-b34b-5b744bc2c59d", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'population_id': 'f9b28e4ed6ec4a67b17cd86c5a43c41c', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.9999999999999999, 'total_count': 39, 'start_timestamp': 1655508316.7679594, 'end_timestamp': 1655508320.7581806, 'time_elapsed': 3.9902212619781494, 'total_mass_run': 1951.365, 'total_probability_weighted_mass_run': 50.035, 'zero_prob_stars_skipped': 0}\n" + ] + } + ], "source": [ "print(analytics)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "05c6d132-abee-423e-b1a8-2039c8996fbc", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[None]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaMAAAEdCAYAAAChVQjxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAA9vklEQVR4nO3dd3hUVfrA8e/MpJNAQu81cOhNihB6ExUVVMTeXcva19V1ddfuqj93bWtvgLoqKLZdBAKCoqEjHY4K0gMpJEAgdWZ+f9xJmCSTZCbM5M5M3s/z5Enm3jt33twk8+ace857LE6nEyGEEMJMVrMDEEIIISQZCSGEMJ0kIyGEEKaTZCSEEMJ0koyEEEKYLsLsAEJUNDAYSAfsJscihBChwga0AtYAhe47JBnVzmBgudlBCCFEiBoJ/Oi+QZJR7aQD5OScwOEI7DytJk3iyc7OC+hr1FdybQNHrm3ghPK1tVotJCU1ANd7qDtJRrVjB3A4nAFPRqWvIwJDrm3gyLUNnDC4tpVub8gABiGEEKaTZCSEEMJ0koyEEEKYTpKREEII00kyEkIIYToZTReC8vNPkJeXi91eYnYoIS0jw4rD4TA7jLAk19Z7hcUOrBaIjPCubRCM19ZmiyA+PpHY2Aa1PockoxCTn3+C48dzSExsRmRkFBaLxeyQQlZEhJWSkuD6ow4Xcm29c6KgmIKcfOwWC62aNSDCVnNCCrZr63Q6KS4uIjc3E6DWCUm66UJMXl4uiYnNiIqKlkQkRIg7frLY+MLpJL8wNHs6LBYLUVHRJCY2Iy8vt9bnkWQUYuz2EiIjo8wOQwhxmkrsDgrcElB+UWiXuYyMjDqtWweSjEKQtIiECH0n8ovLPS4oLMHpDN3KCqf7viTJSAgh6pjT6SSvQjJyOJwUB9G9oLomyUgIIepYUYmjLPE0iI0s2x7qXXWnQ5KREAFw8cXn8dRTj5ry2rff/gduv/0Pprx2qYMHDzJixCDmz//GlNdPT6/8+k899SgXX3yeaa89efKYssfuraKk+GhsrlF0BX4YxODp9UOBDO0WpkpPP8j06efXeNxf//oI55xT/o0kOzuLCy88F4fDwdy539CyZctKz7v99j+wYcN6OnXqzAcfzKm0/7vvFvP3v/8FgJdffoOBAweV7du4cQOzZ7/Hzp2/cuzYURITk0hO7saECWcxadJkX7/Vem/lyjS2bt3MDTfcbHYoXtuyZTOrVqVxySWXk5CQ4JdzOp3OsvtFMVERRERYiYmycSLfQUGRHafT6dX9l1C8ntWRZCRMlZiYxN/+9rjHfQ6Hg1deeYH8/JN07aoq7V+yZBExMTHYbBEsXryAK6+81uN5oqKi+P33Xfz2268kJ3ctty81dQFRUdEUFZVbdJLvvlvMI488SNeu3Zg+/VISEhqSnn6QDRvW8803XwR1MnrhhVfNDoFWrVqxZMlPRESceotZtWoFc+d+bNqb5wMPPOzzZNFt2zbz/vtvc84553mdjFq2rPy9u8svLClbAiI+1jgmNtrGifxinE4nhcV2YqJqfmuu6nrW9PrBKrSiFWEnNjaWs846x+O+d999k2PHjnL77XfTtWu3SvtTUxcwYsRooqKiSE1dWGUyat++IydPnmDx4oXlklFe3nFWrUpj2LAUvv9+abnnvPfeW3Tu3IU335xJZGRkuX05OUd8/C7rVsV4zWCxWIiOjjY7jHIC/eZst9ux2+1ERUVV+73n5RtdcRaLhbgY42flnnwKirxLRlUJxmvvDblnJILShg3rmT37PYYNS2HGjCsq7d+3by/bt29j/PhJjB8/iZ07f2XXrp1Vnm/8+EksWbKo3NDZpUuXYLFYGDlyTKXjDx7cT8+evT2+sSclNfb5+3n33TcZMWJQpe3z53/DiBGDSE8/WLbt4ovP48EH/8SaNSu5/vorGDcuheuvv4Jt27YA8O23/+XSSy9k3Ljh3H77Hzh48EC5c1a8Z7R+/VpGjBjE999/x8yZ7zB16tmMGzecu+66lf3791WKacmSRVx33eWMGzecKVMm8o9/PE5ubm65Y/bt28tDD/2Z888/i3HjhjNt2jk88siD5OUZK5BWvGf01FOPMnfuxwCMGDGo7OPkyZNMmDCCF198vlIc+/btZcSIQcybN7faa3v8+HGeeupRzjprNJMnj+HJJx8hL+94peM83TNavHgh119/JRMnjmLSpNFcffUM5swx4nz33Td5+eV/ATB9+vllMZf+rEaMGMRLL/2Tb7/9L5dffhHjxg1ny5ZN1d6z2bN3D39/6G5uuPIc7rxlBh9/PBuACJuVyAgr27ZuYMrkFNavX1vueRXPWdX19HRsqbVrV3PrrdczfnwKkyeP5eGHH6j0u1N6b+vw4UM88MA9TJw4kilTJvDvf7+I3R7YwRXSMhJB59ixozz++N9ISmrMQw895rH/PDV1AQkJDRky5EwsFguNGzchNXUBN9/8R4/nnDhxMh988D5btmyiT59+ACxatJDhw0cSF1e5fEmLFi1Zu3Y1mZkZNGvW3L/foBf27NnNk08+wtSpFzNpUiwffjiL+++/h1tu+SMffTSbCy64kJMnT/DRR7N49tkneeml12s856xZ72K12rj88qs5fvwYH3/8AY899jBvvz2r7Jj587/h6acfo1evPtx6651kZBzm888/Zfv2rbz99myio6MpLi7m3nvvwGazMmPG5TRq1IjDhw+TlvYjeXnHiY+Pr/TaF1xwIdnZ2axevaJct2xcXByjRo1l6dJU7rjjHmw2W9m+RYu+JSIigvHjJ1b5PTmdTh588E9s2rSBqVMvokOHjvzwwzKefPLRGq/HmjUrefTRhxg9eiznnz8Nu93O7t2/s3nzRi655DJGjx7HwYP7WbjwW+68814aNUoEjK5l93N8990ipk2bTkJCAk2bNq3y9UpKSrjvvjtJ7tabS6/8A9s2reb1118B4IorrinXGqppulFV17Pq73UV9913J+3adeDGG2/l5MkTzJ37MbfeegMzZ35MUtKp76mkpIR7772dPn368cc/3sWaNav45JMPadOmLdOmXVzja9WWJCMRdP7xjyfIysrkxRdfIzEx0eMxqakLGDVqTFnXy5gx41i8eCF/+MNtHpNX585d6NIlmdTUBfTp04/s7CzWr1/L448/4/H8V1xxDc888wQzZkylT59+9O3bn8GDh9K7d1+s1sB3KOzdu4e33ppJz569AWjWrAWPPPIgr776Mp98Mq/sjbGkpIQPPnifw4cP0aJF5QEc7kpKSnjvvVll16xhw0a89NLz7Nr1G507J1NSUsLrr79CcnI3XnnlTaKijEofSnXn0Ucf4ptvvuDiiy9l9+5dpKcf4O23Z9GjR6+y81d3L6h377506NCR1atXVOqWPeusc1i06FvWr1/D4MFnlm1PTV3A0KHDyr5XT3788Xs2bFjPHXfcU9aCnjr1Yu6885ZqrwVAWtpPdOrUmaee+j+P+5OTu6JUDxYu/JaRI8fQqlXrSsfs27eXDz6YQ/v2Hcq2ubdy3RUUFHDG4BQuvfIWbDYr1199BffeewczZ77LtGnTiYk+1QovLqm+FVLd9fTktddeIjExkddff7fs3tfQocO55Zbr+PDDmdxxxz3l4pw8+Vyuuuo6wLie119/Bf/971eSjET1dh08xjc//U6ByXMUYqJsnJfSic6tG9b6HJ9/Pofly5dx7bU3lhvZ5m7Hjm3s27eXe+65v2zb+PFnMW/eXDZv3kjfvv09Pm/ChLOYM+dj7rrrPr77bjGxsbEMG5bCypVplY6dMuUCmjVrzqeffsT69WtZt24N77//Nm3atOVvf3uC3r371Pp79EaXLl3LEhFAr17G1yNGjCr35tyzp5EM0tMP1piMzj33/HL3Tfr16w/AwYMH6Nw5mR07tpGTc4Sbbrq1LBEBjBs3kVdffYm0tJ+4+OJLadDAaPn89NNykpO7nfY9qkGDhtCkSVMWLVpQloy2bdvC/v37uOmm26p97ooVPxEZGckFF1xUts1ms3HRRTPYuPHnap8bHx9PRsZhtm7dUnZ9fTVw4KByiagm4yYaI0cbxEZgs9mYNu0i1q1bzaZNGxg85FQiLiz2399yVlYWv/76C1dddV25QRi9e/ehV68+rFjxY7lkBEbLy13fvgNYuHC+32LyRJJRGEhdu4+NO7PNDgOA2OgI/nB+r5oP9GDnzt949dWX6NdvANddd1OVxy1a9C1xcQ1o2bJl2T2Pxo0bk5iYyKJFC6pMRuPHT+LNN19l7drVpKYuYPToseXedCsaOnQYQ4cOo6CgAK23s2TJIr76ah733383H330WbmuDX+rmFhKE0Dz5i08bj9+/JjP50xIaOh6rnF/5dChdIBKb65Wq5W2bdtx+LCxv3XrNsyYcQUzZ77Dp5/+hwEDBjJ8+EgmTZrsscuzJjabjYkTJ/PNN19w330PEh0dzaJFC2jQoAEjRoys9rmHDh2iadPmxMTElNvuTYK48MLpLF26mJtvvpZWrdowePAQxo6dwODBQ72O3VNrqSo2m42mzYyfQbxr4ELbtu0BOHToIDarlUjXfKOiYv9VYqjq5wrQoUNHFi9eVG5bbGwcDRs2KrctISHBq9+x0yHJKAxMHNSOgsKSoGgZTRzcrlbPLSws4JFH/kpMTAyPPPJkuXsH7hwOB0uWpHLy5Akuv7xyl8GyZYu5++77PI6cat26Db169eGDD95n27Yt3HzzrV7FFhMTQ79+A+jXbwCNGiXy/vtvs3LlT5x99hSvv7+q5o04HJ5/ZrYqlhKoqovQm5JmVqvna1qbemh33HEP5557HsuXf8/q1Sv517+eZfbs93jzzfdrdY9t8uRz+eSTD0lLW86oUWP57rtURo8eR3R0TM1PrqWkpMa8//5/WL16JStXprFyZRpff/0F5557Pg8++HevzuFtfO7XOCrSRlSk559FdJSxvdjuwO5wYHP9vOty/aKqfvcCTZJRGOjcuiF3Te9ndhin5cUX/8nu3bt45pl/Vvrv3926dWvIzs7i5ptvp23btuX2ZWZm8PLL/2L16pUMHz7C4/MnTjyLF198nqSkxgwaNMSrN3F33bv3BIyuD1+4t0Lcu0oOHTrkWwAB1LJlK8C4X9W//8Cy7U6nk/3799GpU5dyx3funEznzslcc80NbN26hZtvvpYvv/ycm27ynOSrm8eZnNyVLl26smjRAuLiGnDkSDaTJp3tRcwt+fnntRQUFJRrHe3du6fG54IxDD4lZSQpKSNxOp288MJzzJs3l6uvvp42bdoC/ilK7HA4sdvtZGUeonvXzmXb9+/fC0CLFsa1b5KUCMDJE3kUFNppEGskhtLWjTtv65K6/1wr2rt3j8fJ4maQod3CdEuXLnbdHJ/BiBGjqz02NXUB8fHxXHbZlYwdO6Hcx/Tpl5GU1JjU1AVVPn/8+LO47rqbuOee+6tsfYExDNaTFSt+ArzrBnJnvLHBxo3ry7bl5+fz7bf/9ek8gdS9e0+Skhrz5ZefUVx8qlzN0qVLyMzMYPjwFABOnMijpKR82ZrOnbtgs9koKiqq8vwxMbHAqW7BiiZPPpdVq9L44ou5NG3arMp7hu6GDUuhuLiYr776vGyb3W7n888/rfG5R4/mlntssVjo0sWYh1ZYaEyCjo01YvY0VNwXxXajZZO68CsaxBhtAIfDwRdffE5sbCz9+g0AoF3btlitVnZs21Sup+OLLyoPb6/pepZq2rQpXbt2Y/78b8qG3oNxX27Llk0MG+b5H7e6Ji0jYaqsrEyeffYpYmPjSE7uWuVN0jZt2tK1q+KHH5YyePCZHrvhLBYLw4alsHTpYvLz88veSNwlJSV5VQHgwQf/RKtWrUlJGUWbNm3Izy9g7dpV/PTTcnr06ElKSvX3MioaMuRMWrRoyTPPPMFll+3GarXxv/99TWJiEocPB0frKCIigltvvYOnn36MO+64mQkTJpGRcZjPPvuUzp27cN550wBYt24tL7zwHGPGjKd9+w44HHYWLvwWi8XC6NHjqjy/Uj0AePHF/2Po0GFYrVYmTDirbP/EiZN5441X+PHHH7j00iu9GrWYkjKKPn368eqrL3HgwH46dOjEDz8sLfemW5VnnnmS48ePMXDgIJo3b87hw8b32rVrNzp27OSKuTsAb731GuPHTyIiIoKUlFEef7eq4nA4KbE7iY6O4ee1aTz77BMo1YO0tB9Zt241N998O3FxcQA0bJjAsJSxpC74ApvNikruRFracnJyciqdt6br6e622+7ivvvu5NZbr+fcc8/nxIkTzJ37CU2aNK1ysnhdk2QkTLV3756y/zqfeebJKo87++wppKSMJC8vr8ouOICUlJHMn/8Ny5d/f1olex544GGWL/+e775LJSsrE6fTuOd09dXXc+WV1/g8mz8iIoKnn36ef/7zGd555w0aN27CJZdcRkJCQ55++rFax+lv55xzHlFRUXz00SxeffUlGjRowMSJk7nlljvKZvUnJ3dlyJAzSUtbzldfzSMmJobk5K48//zL1Y4yHDlyNNOnX0Zq6gIWLfoWp9NZ7s2zadOmnHHGENdw5Zq76MC4h/bss//ipZf+ycKF87FYLKSkjOL22+/muusqT5Z2d9ZZZ/P111/wxRefkZd3nMaNmzBu3ASuv/4PZYmwW7fu3HzzH5k3by6rVq1w1UH82qdkdLKwBJzGAIann3mB1155niVLFpGQ0JCbb76dq666ttzxt91+L0VFxSxe+DU/LI1i3LgJ3HbbXVx99Yxyx9V0Pd0NHjyU559/mXfffZO33nqdqKhIBg0awm233RXQgTi+sITyYk4m6gj8np2dV1ZjKlCaNUsgM/NUM/zQoT20bOlbF5HwLCLCSkk9Xj8mkGp7be+//x7S0w94LGobqg4dOUlBYQlWq4V2zeNrLIJaUFTCoeyTADRtFEN8XPkRn8H8e1vT+5PVaqFJk3iATsDucvsCGpkQQngpI+Mwq1aleTWJM1S4Ly3eICbSq2rc0ZE2LFbjuPq0vpF00wkhTHXw4AE2b97IV1/NIyoqmilTppodkt+4Ly0eH+vd5GCLxUJMpI38whIKikq8XlIi1EnLSAhhqg0b1vPEE38nI+MwDz/8WJUloEKN+9LikRFWoiK9f7uNjTbaCXa7s2wkXriTlpEQwlTnnHNepYUTw0HFpcV9ad3ERJ2adlBQaCcqouppCOFCWkZCCBEAebXooisVGWHFVnbf6PSXIg8FkoyEEMLPyi0tHh1BhI8ldiwWCzGurrpC11Lk4U6SUQiqD7+YQoQyT0uL+6q0q87hcPq1cGqgnO77kiSjEGOzRVBcXHXJFSGE+Uq76CwWC3HRtVtiI9Ztsb1Q6KorLi7CZqv9MASvn6mUagI011pvd9vWCbgXaAzM1lovrHUkwivx8Ynk5maSmNiMyMioejHkU4hQYnc4jKoLQFxMBFZr7f5GIyKsZRNcza7IXx2n00lxcRG5uZkkJNS+moMvaewloBswBEApFQ8sB0oX9JihlBqntf6h1tGIGsXGGuvFHD2ahd0e/P8tBTOr1Vqnpfnrk/p8bfML7ZwoMFpGNnsUhwpq3wFVkF9MQZGdE4CzMAaLJTivrc0WQUJCUtn7U234koyGAR+4PZ6BkYjOATYAqcD9gCSjAIuNbXBaP3RhqFhqSfhPfb62T85ey66Dx2jSMJpnbx2O9TR6L9bsyOD1L7cA8OfLBtCjQ1LYXltfUnYLYJ/b47OBtVrrBVrrQ8BMYIAfYxNCiJCSnn2CXQeNFVGH9W55WokIoHv7xLKvt+85clrnCna+JKNiwL1U7Wjge7fHuUATP8QkhBAhacXWU8uBDOt1+ovWJcRF0b65sbT89t2Vl5EIJ74ko1+Ai5RSFqXU+RiDFpa47W8HhHfqFkKIKjicTlZsMZJR59YNadXEP13pPToagwJ+Tz/OyYLwvU/sSzJ6FaM1lAN8BuyifDIaCWz2X2hCCBE69N5cso8ZK8Sm9PbfUt49OjQGjGSn94Vv68jrZKS1ng1cg5GAPgTO1loXQ9mw70QgfBYhEUIIH6RtTgcgwmZhcI8Wfjtvt3aNykoDhXNXnVej6ZRSNqAN8D+t9QcV92uts4Ez/BybEEKEhMIiO2t1JgD9kpv6XIuuOjFREXRp3ZBf9h9l+57wTUbetowiMbrlbghgLEIIEZLW/ZJBYbExMXW4H7voSvXoaHTVHcg6Qc6xAr+fPxh4lYy01gVAFnAisOEIIUToSXMNXIiPjaRPZ/8PKu7R4VRlg42/Zfn9/MHAlwEM84EpgQpECCFC0ZFjBWX3cs7s2cLnCt3e6Ny6IdGRRuHUTb9m+v38wcCXq3Y/0EopNUsp1UcpFROooIQQIlSs2HqI0nrVw/v4v4sOIMJmpVu7RAA2/poZlpX7fSkHlAE4gX7AlQBKqYrHOLXWsnqsEKJecDqdZV10bZo2oEOLhIC9Vo8OSWzelU1GTj6Zufk0T4oL2GuZwZfEMRsIv3QshBC1tPvQcdKzTwLGwIVAVtHv2fHUfaNte3LqbzLSWl8bwDiEECLkpG02WkUWC5zph/I/1WnbPJ742Ejy8ovZtjuHMf3bBPT16posrieEELVQYnewavthAHp2bExSQnRAX89qsZSNqtuxJwdHmN03qtX9HddaRol4SGZa672nGZMQQgS9TTuzy1Z09Wf5n+r06JjEmh0Z5OUXsz8jj/YBvEdV13xKRkqpS4GHgR7VHGY7rYiEECIElA5ciImyMaBbszp5zZ5u84227c4Jq2TkdTedUmoq8B+MBPYmYAE+BuZiLC+xDnjc/yEKIURwycsvLpt8Oqh787I5QIHWLDGW5knGSj7hVhrIl3tG9wHbgf7A313b3tNaXwoMAhTGiq9CCBHWVm07jN1h3LOpqy46AIvFQr+uRivsl325lNiDa/nx0+FLMuoLzHKVBiq9AjYArfUW4C3gQf+GJ4QQwSdti1Ghu0nDGLq6JqPWlb6uZFRYbC9bVTYc+JKMbEC26+t81+dGbvs10NsfQQkhRLA6mHWC39OPA8bcotNdWtxX/ZKbln0dTl11viSj/UAHAK11PkZFBvdlIxRSSFUIEebclxYPRIXumiQ1jKFNU2MV2e27w2dxbV9G06UBEzh1v+hr4G6lVD5GUvsj8I1/wxNCiODhcJwq/5PcphEtGptTBaFHhyQOZJ1g58FjFBSVEBMV+lXYfGkZvQYsU0rFuh4/hNE19yhGgtqJMchBCCHC0o69OeQcN5YWN6NVVKqna30ju8PJL/uOmhaHP/lSDmgNsMbtcSbQXynVF7AD27XW4TO0QwghKvjJVf4nwmZlcI/mpsWh2iditVhwOJ1s33OEvl38v4ZSXfNlntEopVSlmV1a601a661AY6XUKL9GJ4QQQaKgqIR1v2QA0L9rUxrE+G9pcV/FRkfQqZUx4bV0LaVQ50s33VJgYjX7x7uOEUKIsLNOZ1JUbHT+mNlFV6qHq4r33ow8jp8sMjma0+dLMqpp/KKNU/OPhBAirJQOXGgYF0nvTo1NjgZ6dDgVw469ueYF4ie+Vu2urkzscCA8F2cXQtRr+zPy2OGa0zO0Z8uALC3uq+Q2DYmMMOIIhyHe1Q5gUErdBdzltulFpdRTHg5NAhoC7/kxNiGECApzl+3EibGMw5gBrc0OB4DICBtd2zZi2+4ctoXB5NeaRtPlAntcX3fEqMBwuMIxTmALsBJ4wY+xCSGE6bbvPsLmXUbxmVH9WtGqSQOTIzqlR4cktu3OISMnn+yjBTRpFGN2SLVWbTLSWs8CZgEopX4H/qK1/rouAhNCCLM5nE7mLNsJQHSkjQtGdDI5ovJ6dmzM59/vAmDbniOM7Bscrbba8GWeUXD9FIQQIsBWbz/MnkNGHbqzhrSjUXxgV3P1VYcWCcRFR3CysITtu3PqRzJSSjUBmmutt7tt6wTcCzQGZmutF/o/RCGEqHvFJQ7muVodDeMiOWtIe5MjqsxqtdC9QxLrf8lk+54cnE4nljou3OovvgwJeQlXlx2ULT2+HKMm3WXA/2TSqxAiXCz9+QBZRwsAOH9EJ2Kjg7P+Ww/X6q9HTxRxMCt0a1X7koyGAfPdHs8AWgPnuD5vB+73X2hCCGGOkwXF/DdtNwAtkmIZ1S94u796dnRbijyER9X5koxaAPvcHp8NrNVaL9BaHwJmAgP8GJsQQphi/sq95OUXA3DR6C5BMa+oKi0bx5EYHwWEdmkgX65wMRDr9ng08L3b41wg9Kv1CSHqtSPHCkhda/zf3aV1Q86oXJIzqFgslrJqDHpfDnZHaBbC8SUZ/QJcpJSyKKXOxxi0sMRtfzsg9KcBCyHqtS+X/05xifGGPn1sckgMCCjtqssvtLPbNfov1PiSjF7FaA3lAJ8BuyifjEYCm/0XmhBC1K39GXn8tCUdgAFdm9KtXaK5AXmpdBADhG5XndfJSGs9G7gGIwF9CJyttS6GsmHficCcAMQohBB14rPvd+J0gsVi3CsKFY0bxpStOrs9RAcx+DRWUWv9AfCBh+3ZwBn+CkoIIera9j05bNpZWvanNa2bBk/ZH2/07JjE4SMn+XX/UYqK7URF2swOySfBO0RECCHqiMPpZO7S3wCIirQGXdkfb/R0ddWV2B38eiD0liKXZCSEqPfW7sgou/F/1uD2JAZZ2R9vqPZJZYvOheJ9I0lGQoh6rcTu4PPvjWKoCXGRTB4afGV/vBEfG0n7lq6lyPeE3sBmSUZCiHpt6c8HyMx1lf1JCd6yP94o7arbfeg4JwuKTY7GN5KMhBD11smCEr75aTcAzZNiGd0/eMv+eKOHa76R0xl6S5FXmYyUUrtck1tLH/9dKdW7bsISQojA+3bVnrKyPxcHedkfb3Rtm0iEzbhzFGr3jaq78u2BBLfHjwJ9AxqNEELUkZzjhaSuMcr+dA6Bsj/eiI600aV1I8BYbC+UVJeMDgB9KmxzBjAWIYSoM18u30VRadmfMV1CouyPN0q76tKzT5JzvNDkaLxX3Z26r4D7lVKTOVVz7mGl1E3VPMeptR7vt+iEECIADmTm8eNmo+xP/+SmqPZJNTwjdPTs2Jgvl/8OwI49OQzr3dLkiLxTXTJ6AKMO3QSgA0arqBkQVwdxCSFEwHy2zK3sz5jQKfvjjU6tEoiJslFQZGfb7iOhn4y01vnAI64PlFIO4G6t9X/qKDYhhPA7vTeHja6yPyP7tqJNiJX9qYnNaqVbu0Q27cwOqUoMvgwduQ5IC1QgQggRaE6nkzmlZX8irFwworPJEQVGowbGYnulS2GEAq9nd2mtZ5V+7arSXVq86XdXoVQhhAhqa3Zk8Hu6UfZn0pB2JCWEXtmfcOXTVGOlVD/gZWBEhe3LgTu11pv8GJsQQvhNid3BvO93AUbpnLOHdjA5IuHO62TkmvD6IxCDMdJuq2tXL+A8YLlSarjWemsVpxBCCNMs+/kAGbn5AJyf0jGky/6EI19+Go8DxUBKxRaQK1H94DrmIv+FJ4QQpy+/sISvS8v+JMYyZkAbcwMSlfgygGEU8Kqnrjit9RbgNYxlyYUQIqi4l/25cHTnkC/7E458+Yk0AA5Vsz/ddYwQQgSNnOOFLFptlP3p1CqBwd2bmxyR8MSXZLQLmFLN/imuY4QQImh89eOpsj+XjE0Om7I/4caXe0azgX8opf4DPAXscG3vATwITAL+4t/whBCi9g5knWD5JqPsT78uTcKq7E+48SUZPQ8MBC4FZgCls6msgAWYA/zTr9EFiFLqMWA60B24XGv9ickhCSEC4HO3sj8Xh1nZn3Djy6RXOzBDKfUOMJVTk153AV9qrRf7P7yA+RW4C3jC7ECEEIGh9+aw4bcsAEb0aUWbZvEmRySq4/NAe611KpAagFjqjNb6QwCl1ENmxyKE8D+n08ncZTsBo+zP1JHhWfYnnJg660sp1QqjhTIUGATEA2O11ss8HBuNMY/pKiAJ2Ag8pLVeUmcBCyFCwjqdya6DxwCYOFjK/oQCswfbK4ylKtoCNZUSmgncA3yIkcAcwLdKqWGBDFAIEVpK7A4++95oFUnZn9Bhdj2MdUBTrXW2Umoq8IWng5RSQzAGTtyjtX7RtW02sAV4FmNCbumxy6h68u2ftdbP+yt4IUTw+X7DQTJyjLI/5w3vSFyM2W9zwhum/pS01se9PPRijFJE77g9t0Ap9S7wlFKqldY63bV9jN8DFUKEhBK7g/+t2A1As8QYxg6Usj+hIlT+ZRgA7NBa51XYvhpjWHl/jAoQXlFKRQI2jG7KSKVUDFCktQ6dxT+EEJWs2ZFBbl4RAFOGdZSyPyHEq2SklIrFmJejtdarAhuSR62AAx62lyag1j6e723gGtfXIzEm9I4FlvlykiZN6maoaLNmCXXyOvWRXNvAqetr63Q6WbrhIACJ8dFMGZ1MVKStTmOoKzVd25iYSACsVkvI/I572zIqxHgDvwswIxnFumKoqMBtv9e01tcC155eSJCdnYfD4Tzd01SrWbMEMjO97c0UvpBrGzhmXNtf9uXy275cAEb1a8XR3JN1+vp1xZtrW1BgFIV1OJxB9TtutVqq/Cfeqzasq/tqH9DQj3H5Ih/wNDYzxm2/EKIeS11jFEONsFkYO7CtydEIX/nSoToLuMo136eupWN01VVUuu1gHcYihAgymbn5rP81E4ChPVvQqEGUyREJX/kygCENuBDYoJR6DaOkTqV2sNb6Bz/F5m4DcJdSKr7CIIahrs8bA/CaQogQsWTdfpyuHvOJg9qZG4yoFV+SkXsJoJeAijdLLK5tgbhj+BlwH3Aj8CKUVWS4DvhJay0tIyHqqfzCEn7YaLwFdG+fSPsWoXHDXpTnSzK6LhABKKUedn3Zw/X5KqXUCCBXa/1vAK31KqXUXOA5VwmhnRij4Trgh4EIQojQ9eOmdAqK7ABMGtze5GhEbflStXtWgGKoWDn7etfnPcC/3bZf7Tr2aozadJuAc7TWPwUoLiFEkHM4nKSuNQYuNE+KpW9yE5MjErVl+qRXrbVXyy5qrQuAP7s+hBCCDb9lkXXUmOExcVA7rLKKa8jyKRkppdoBj2Gs6tocmKy1/k4p1QyjRtzrWus1/g9TCCEqW+Qazh0bHUFKn5YmRyNOh9dDu5VSnYC1wEXAVtwGKmitMzGWgLjR3wEKIYQnew4d5xfXJNfR/VoTE2V6R484Db789J7CWLahN8Yk04wK++cD5/kpLiGEqFZpq8hqsTD+DJnkGup8mfQ6AXhNa72PysO6wRhwIL8RQoiAy80rZPX2wwCcoZrRpFFMDc8Qwc6XZNSQ6itjRxEEAyKEEOHvu/UHsLvqQk4cLJNcq+J0BrZ2pj/5koz2Ab2q2X8m8NvphSOEENUrKraz7GejiH/n1g1JbtPI5IiCTygOKvQlGc0DrldK9Xbb5gRQSl2EscTEHD/GJoQQlazYeoi8fKMq9SRpFYUNX5LRU8B+jCUkPsRIRH9RSq3ASEIbgX/6PUIhhHBxOp2krt0PQFJCNAO7NTM5IuEvXicjrfUxYBjG0t+DMGrRTQQU8Bow1jUxVQghAmLr7iMczDoBwIQz2spKrmHEpwEHroR0F0YF7WYYCSlTax06d8mEECErdY3RKoqKtDKqv68LPItgVuvRb66JrkIIUScOZp1g865sAFL6tKKBa2ltER58TkZKqUuAaUBn16ZdwBdaaxm8IIQImMWugqggaxaFI6+TkVKqAfAlMA6jey7XtWswcIlS6mbgfK31CT/HKISo5/Lyi0nbcgiAvl2a0LJxnMkRCX/zdTTdeOAVoLXWurHWujHQ2rVtrOsYIYTwq+83HKCoxAHIcO5w5Us33Qxgrtb6bveNWutDwN1KqTauY+6u/FQhhKidEruDJeuMgQttmzWgR4ckkyMSgeBrOaCl1ez/znWMEEL4zdodGeTmFQHGvSJLKJYXEDXyJRltArpWs78rsPn0whFCiFOcTmdZde6EuEjO7NXC5IhEoPiSjB4GblJKVVomQil1AcZaRn/1V2BCCPHbgaPsPnQcgLED2hAZYavhGSJUVXnPSCn1nofNvwNfKqU0sN21rQdGFYbNwBUY3XVCCHHaSltFETYLYwfKCjXhrLoBDNdWs6+768NdX6APcMNpxiSEEGTm5rP+F2Nu/dCeLWjUIMrkiEQgVZmMtNZS9EkIYZol6/ZTuhyPTHINf5JwhBBBJ7+whOWbDgLQvX0i7VskmByRCDRJRkKIoPPj5nTyC+0ATBrc3uRoRF3wqTadUmo48EeMYdxNMMoCuXNqrbv4KTYhRD3kcDjL6tA1T4qlb3ITkyMSdcGX2nQ3AW8ARYAG9gYqKCFE/bXhtywyc42l0SYOaodVJrnWC760jP4KbADO0lpnBSYcIUR9l+oazh0bHUFKn5YmRyPqii/3jFoA70oiEkIEyp5Dx9H7cgEY3a81MVG1XnJNhBhfktF2QCoUCiECJtV1r8hqsTD+DJnkWp/4uoTEbUopWetXCOF3uXmFrNp2GICBqhlNGsWYHJGoS163gbXW85RSccA2pdRXwG7AXuEwp9b6CT/GJ4SoJ75bfwC7w5jlKmsW1T++jKbrBjyOsUzEVVUc5gQkGQkhfFJUbGfZzwcA6Ny6IcltGpkckahrvtwdfA1oDtwFLAdyAhKREKLeWbntMHn5xYCU/qmvfElGw4D/01q/EqhghBD1j9PpLBvOnZQQzRmqmckRCTP4MoDhKJAZqECEEPXTtt05HMg6AcD4M9oSYZMqZfWRLz/1OcCFgQpECFE/la5ZFBVpZXR/GaxbX/nSTfcmMEsp9SXwMsZCexVH06G1ljJBQgivpGefYPOubABS+rSiQUykyRGFF6fZAfjAl2S0FeN7GwRUWnrcjawLLITwSura/WVfT5BJrn4UevX8fElGjxNaiVYI4SdZR/PJchUv9caho4Xk5p6s9pgSh4O0zekA9O3ShFZNGpxWjCK0+TLp9dEAxiGECFJ7Dx/niVlryyakBoJMchUybEUIUa35K/cENBF1adOQHh2k7GV950sFhlHeHKe1/qH24QghgsmRYwWs3WHM6Oif3NTrFkxiYlyN3XQAVquFDi0TsMiaRfWeL/eMluHdPSMZwCBEmFiyfj8Op/Fnf15KRzq1aujV85o1SyAz83ggQxNhxpdkdF0Vz+8CXItROPXN0w9JCBEMCovs/LDhIABd2zbyOhEJURu+DGCYVdU+pdT/Aev9EpEQIiikbUnnREEJIPXiROD5ZQCD1joHeAe43x/nE0KYy+F0ssg1B6hpoxgGdpN6cSKw/DmaLgfo7MfzCSFMsnlnNoePGAMQxp/RFqtVBhiIwPJLMlJKxWCscXTIH+cTQpirdPnv6CgbI/tKvTgReL4M7X6vil2NMZaXaAb82R9BCSHMsz8jj227jeXKRvZtRVyML+OchKgdX37Lrq1i+xHgF+AerfV/TjsiIYSpSltFFqRenKg7voymk2oNQoS5YyeKWLH1MAD9uzaleVKcyRGJ+kISjBCizLKfD1BidwBSL07ULUlGQggAikscfPfzAQDat4inW7tEcwMS9Uq13XRKqa99PJ9Ta33BacQjhDDJ6u2HOXaiCDBaRVIvTtSlmu4ZTfHxfLLekRAhyOl0kupa/rtRgyiG9GhhckSivqk2GXkzaEEpNRp4DhgMpPspLiFEHdJ7c9mbkQfAuIFtiLBJD76oW7WeQKCU6g08C0wGjgN/A/7lp7iEEHVokatVFBlhZfSANiZHI+ojn5ORUqod8ARwBWAHXgae1Fpn+zk2IUQdOJxzko2/ZQEwrFcLGsZFmRyRqI98qcCQBDwE3AZEAx8DD2utdwcmNCFEXVi8dn/ZzV6pzi3MUmMyUkpFA3cDDwCJQCrwgNZ6QyADE0IE3smCYn7cZNzq7dUxiTbN4k2OSNRXNQ3tvgF4FGiNsV7RX7TWS+ogLiFEHfhhYzqFxXYAJg5ub3I0oj6rqWX0NsZw7bXAHKCfUqpfNcc7tdYv+Cs4IUTg2B0OlqwzBi60ahJH786NTY5I1Gfe3DOyYAzbHuzFsU5AkpEQIeDnX7LIPlYIwIRB7bDKJFdhopqS0dg6iUIIUedKh3M3iIlgeO+WJkcj6ruaJr1+X1eBCCHqzq6Dx/jtwFEAxgxoQ3SkzeSIRH0n06yFqIdK1yyyWS2MGyhrFgnzSTISop45cqyAtTsyABjcvTlJCdEmRySEJCMh6p3v1h/A7jCmuU6UNYvCWwiVrpZkJEQ9Ulhk5/sNxppFyW0b0alVQ5MjEoEQigMjJRkJUY+kbUnnREEJAJOk9I8IIpKMhKgnHE4nqWv3A9CkYQwDujU1OSIhTpFkJEQ9sWVXNoeOnARgwqC22Kzy5y+Ch/w2ClFPlK7kGh1lY2Tf1iZHI0R5koyEqAf2Z+axdXcOACP7tCIuptbragoREJKMhKgHSltFFowuOiGCjSQjIcLcsZNFrNh6GID+XZvSPCnO5IiEqEySkRBhbtnPByixOwCYJJNcRZCSZCREGCsucbB0vTHJtX2LeLq1SzQ3ICGqIMlIiDC2evthjp4oAmDioHZYQnFqvqgXJBkJEaacTmfZwIVGDaIY0qOFyREJUTVJRkKEqV/25bI3Iw+AsQPbEBkhf+4ieMlvpxBhqnQl1wiblTED2pgcjRDVk2QkRBg6nHOSDb9mATC8dwsaxkWZHJEQ1ZNkJEQYWrJ2f9lSNhOkOrcIAZKMhAgzJwtKWL45HYBeHZNo2yze5IiEqJkkIyHCzPJNBykssgOykqsIHZKMhAgjdoeDxa41i1o2jqN35yYmRySEdyQZCRFGfv4li+xjBYDRKrLKJFcRIiQZhYEjxwp4ce7GsgmOwn8ycvN5Yc5Glv18wOxQvLJorfE70CAmguG9WpocjRDek2QUBt757zY27czm4yW/4nA4a36C8Npr8zazeVc2sxdqs0OpUWGxnd/2HwUgpU8roqNsJkckhPckGYUBvS/X7BDCVmkFg1Dg/o9IUkK0iZEI4TtJRkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTRZgdQIiyAVitdVNqpabXaZ4Ui9N56ti6iisceHNtvT3WbDabtSzeBrGRpsdr9uuHs5qubcMGUTRPiiU+Liqofg5usVSakW1xOmXGfi2MAJabHYQQQoSokcCP7hskGdVONDAYSAfsJscihBChwga0AtYAhe47JBkJIYQwnQxgEEIIYTpJRkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSW26IKSUigYeB64CkoCNwENa6yWmBhbilFKDgWuBsUAHIBtIAx7WWv9mYmhhRyl1P/AssFFr3d/kcMKC6/f3UWA4EAnsBF7QWs80MSy/kZZRcJoJ3AN8CNwFOIBvlVLDzAwqDDwAXAgsxriubwFjgJ+VUj1MjCusKKVaAg8DJ8yOJVwopc4GfsJIQn8D/oTxe9zOzLj8SVpGQUYpNQS4FLhHa/2ia9tsYAvGf5qjzIsu5P0LuFxrXVS6QSn1KbAZI1Fda1Jc4eYZYC3GP7uJ5oYS+pRSjTD+QX1da32XyeEEjLSMgs/FQDHwTukGrXUB8C4wQinVyqzAQp3WOs09Ebm2/QpsBaRl5Aeuf6auBO41O5YwcjlGUv87gFIqQSkVPOtC+Ikko+AzANihtc6rsH01YAH613lEYcz1R90CyDI7llDnupavALO01htMDiecTAB2AOcopfYBx4AjSqlnlFKV1gUKVdJNF3xaAQc8bE93fW5dh7HUB1cAbYCHzA4kDFwN9ASmmhxHuEnGuDc0E3gO+BmYgtG1HAPcbVZg/iTJKPjEUmGdD5cCt/3CD5RS3YFXMRb5+sDkcEKaUioB417RM1rr9JqOFz6JxxhV+xet9bOubfOUUvHAbUqpJ7XWId+yl2664JOPsXhfRTFu+8Vpco34+h+QA0zXWjtMDinUPQwUYQwSEf5V+jf/cYXtH2GMrhtSt+EEhrSMgk86RlddRaXbDtZhLGHJNTrpW6ARkKK1PmRySCHNNajmbowhxy2UUqW7YoAopVRH4KjWOseUAENfOtALOFxhe+njpLoNJzCkZRR8NgDdXU1wd0NdnzfWbTjhRSkVA3wDdAOmaK21ySGFgxZAFMbUg9/dPoZijFL8HeP+hqidda7PbSpsb+v6nFmHsQSMJKPg8xlG0/vG0g2uigzXAT9praVlVEuukUefAsMwuuZWmhxSuPgdmObhYyuw2/X1bLOCCwNzXZ9vKN3gGrl4I8bE4rD4PbY4nU6zYxAVKKXmYIxIegGj5Mc1wGBgrNb6JxNDC2lKqRcxKi98A8ypsDtPa/1lXccUzpRSy4BEKQd0+pRSszDKg70LrAfOdX3cr7X+PzNj8xe5ZxScrgaecH1OAjYB50giOm39XZ/Pc3242wN8WZfBCOGDm4C9GP+YXgPsAm7RWr9palR+JC0jIYQQppN7RkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSTISQghhOklGQgghTCfJSIQUpdQYpZRTKXWt2bGcLqVUb6VUiVJqotmx1AdKqQuUUkVKqa5mxyIqk2QkhHn+hVGJPdV9o1KqsSvhfmtSXAGjlPq3UuqAq+p0VceU/sNxnz9fW2v9FbAZY6kLEWQkGQlhAqXUMGAinldGHej6vL7uIgo8VwKaCnyltTarKOZLwDSlVC+TXl9UQZKREOa4DcgC5nvYF5bJCGMZlDaYWx19HnASuMXEGIQHsoSECAtKqabAY8D5GCuPHga+Bv6utc6ucGxH4J8YLROApRjLZi8FdmutxwQ41giMFsJ/tdbFHg4J12Q0DcjFuM6m0FrnKaWWAxcDd5gVh6hMWkYi5CmlGgFpwK3AQozEssD1+EelVILbsU2A5RjrGc3EWA77BMYbZIM6CvkMIB5YXcX+gUCO1vr3OoqnrkwD5leRgOvSCqClUqq7yXEIN9IyEuHgfqAr8Eet9WulG5VSG4B/u/b/zbX5AaAtcKXW+iPXtteVUs8Bf66jeHu6Pu+suMOVOJMxsfUQCEqpHoACHjY7Fk5d917ADjMDEadIMhLhYBqQCbxVYfubwCOu/aXJ6DwgHfi4wrHPU3fJqJnr8xEP+wYAFsKvi24qUIDRYvUrpVRLjFWRuwMZwFyt9bpqnlLabdvc37GI2pNkJMJBJ2Ct1rrEfaPWukQp9Qun7sGUHrtaa+2ocGyGUirXfZtS6hLgTozlyrO01h0r7I/AuPd0FUaX9+cYrbOCGuItHUnmaXjzGa7PVSYjpdRIwNOw7yjAprW2VTj+NYwuy+Fa6xUV9i0DRmMsa/+t2/ZLgE+B/2mtp7i2dQOeA1KAGFz35bTW91YVq5tpwGKtdZ4Xx3pNKXURMA54F3gFI8FcrpS6GPhrFaP2Sq+7LHMdRCQZCVG1HIxuvhbAPR72/xUYC/QBijAGTDyHkcCqk+n63NjDvhoHL2itl2PccyqjlGoNrHXF6749FrgcoxV2I8b9kop2ADdQPsHdSOUurP9hjEa7EmNEWheMxFQtpVRbYBBwU03H+kIp1RvoqLX+o9vmPcA/lFJnYoyYe93DU0uve6aHfcIkMoBBhINdgHK1VMq4Hndz7S+1G0hWSlkrHNscSHTfprVO1Vp/gvEG58mNwNNa6wNa60zgUeBapZStiuNLbXF99lQJYCCQB/xSwznKKKWiMZLEj1rrpyvsng44MAZ1XKKUiqeyOcA4pVQz1/k6YLQGv3R7jaYY97Le0Frnaa0dWutftdYzvQhxKkYr5GtvvycvXYjneVporVcCTSv+Trgkuz5v8bBPmESSkQgHX2Lch7mxwvabXNu/cNv2DdAKuKzCsT7N9ldKJQLtgA1um9cDCUDHGp7+M3AMOLPCOeMwbvJv8HFS6BsY3WbXeth3I/AJRsIpBi71cMxxjGt0tevxDcB/gMLSA7TWWcB24D2l1KVKqS4+xDcNI1H6uyVysvQ6KaWGKaWylFLuAyTWYfwzUtGZwGGttfZzPOI0SDedCAfPYbQAXlVKDcR4sx+A8aaqXftLPYvRbfW+UmoIRlfUSGA4xiRUb5NA6XDxXLdtuRX2eaS1tiul5gFTlVLRWuvSN/1+gA2IUUr9xcNT87TWFbvh7gSmAIO11icr7OuG8b39WWtdqJT6BOOavOPh3O8C7yilXsRIaucCF1U4ZgxG0v4r0FMptRf4i9Z6TlXfq1KqMTAKY0Sjr8YrpWI8bM/SWr9RYVs/oAnluw2PUeFn4WoZjgTeq0U8IoCkZSRCntb6KMab0JvAOcDLrs9vACO01sfdjs0CRgD/Ba7HSE4NMO79WIB8L1+29JyN3LYlVthXndddx09x21Z6v2gQ8A8PH9PdT6CUGuuKf7rWereH17gR2KG1XuV6PBM401MpHK11Gsb3/yhwSGu92cMxGVrr+7XWfTHuu7wG/KeG+TpTMP7p/aKaY6oyGXjCw8fdrv2xbse+g9ECu8ZtWz/g1wrnvAiIw/hdEUFEWkYipGitl+FhFJqrC+g210dN5/gd435DGddk2CbAXi/jyFVK7cO4t1La3TMAIxHt9uL5q5VSpRN0P3dtexV41ZvXd1WRmIPR6lnmYX8kRrdbI6XUoQq7bwA8jYB7F6MVeasX8R8DnldKPUj183WmARurSJZVnXsZnkcaVrRbKTVca53mGkn5ZekO10TojlrrisPn7wK+0FrL/aIgI8lI1DtKqVitdcUWUGm3WKrbcTYg0vVhcXUZOd261d4BHnSVlynGaFXM1FrbvQzlT8BGpdQkrfUiH+KPw3jj/bpit52b84AkjATp/oZ8JfCAUuovWuuiCs95C+MeWJqH10zCmIf1EcbgCitGd14cxr2ZqqwA3q72G6q9D4GXlFIN3CufK6U6YbSgyiVcpdRUoDcwI0DxiNMgyUjUR/OVUnswBhxYgfEY3UlplC/ieRXwvtvjfIyRdR1dj58GmgJbXef5DKPCg1e01lup3d/gRRhdUN2UUp7eWHtidNF9rLXe5r5DKfUG8BDGCLdy93pcrZ3FVbxmEdASY0RcC4zBDVuB86tr9Witn6tq3+nSWjuVUncDtyulbsQYNWjFmNR8V8WahFrrLzHmYokgZHE6Zd6XqF+UUn/C6MLqiHHfYT/G0OjH3O8vCSHqjiQjIYQQppPRdEIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSTISQghhuv8HejwwbWv8RfwAAAAASUVORK5CYII=\n", + "text/plain": [ + "<Figure size 432x288 with 1 Axes>" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "# make a plot of the luminosity distribution using Seaborn and Pandas\n", "import seaborn as sns\n", @@ -412,7 +451,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "1f37d2c0-1108-4ab9-a309-20b1e6b6e3fd", "metadata": {}, "outputs": [], @@ -420,16 +459,45 @@ "# Update the probability distribution to use the three-part power law IMF \n", "population.update_grid_variable(\n", " name=\"M_1\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)\",\n", ")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "6f4463e8-1935-45f2-8c5f-e7b215f8dc47", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Do dry run? True\n", + "Doing dry run to calculate total starcount and probability\n", + "Grid has handled 39 stars with a total probability of 0.211729\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 39 *\n", + "* Total probability is 0.211729 *\n", + "**********************************\n", + "\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", + "**********************************************************\n", + "* Population-1d1d556abeae4549aa28f9740807dc84 finished! *\n", + "* The total probability is 0.211729. *\n", + "* It took a total of 3.90s to run 39 systems on 2 cores *\n", + "* = 7.80s of CPU time. *\n", + "* Maximum memory use 519.211 MB *\n", + "**********************************************************\n", + "\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" + ] + } + ], "source": [ "# Clean and re-evolve the population \n", "population.clean()\n", @@ -441,10 +509,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "id": "cfe45a9e-1121-43b6-b6b6-4de6f8946a18", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[None]" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEdCAYAAABDiROIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAABEJElEQVR4nO3dd3hUVfrA8e+kBxJIgAAhIC3wgoCA0nsVxQYKYl97Wxu7lnV1f3ZXXfvaK7ZVwYoFpYnSq3Q80msCAUIJJJAyvz/uJEySSTITZnJnkvfzPDyTnHvmzjuXyX3nnHvuOQ6n04lSSilltzC7A1BKKaVAE5JSSqkgoQlJKaVUUNCEpJRSKihoQlJKKRUUIuwOIERFA92BNCDf5liUUipUhAPJwGLgWMmNmpAqpzsw2+4glFIqRPUH5pQs1IRUOWkAmZlHKCgI7H1c9evHsW9fVkBfo6bSYxs4emwDJ5SPbViYg8TE2uA6h5akCaly8gEKCpwBT0iFr6MCQ49t4OixDZxqcGw9XurQQQ1KKaWCgiYkpZRSQUETklJKqaCgCUkppVRQ0ISklFIqKOgouxCUnX2ErKwD5OfnFZXl5hWQX+AkOjIch8PG4ELInj1hFBQU2B1GtaTHNnCC8diGhYUTERFFfHwCkZFRld6PJqQQk519hMOHM0lISCIyMgqHw0FBgZNtuw9DONSuG0OdWpX/QNQkERFh5OUF1x92daHHNnCC7dg6nU4KCvI5diybzMw9xMcnEhtbu1L70i67EJOVdYCEhCSioqJxuJpCefknPpyHjxy3KzSlVA3kcDgID4+gVq14EhIacOTIwUrvSxNSiMnPzzupJrFSSgVKZGQ0eXm5lX6+JqQQ5NCLREqpIHSy5yZNSEoppYKCJiSllFJBQROSUgEyZsx5PPHEw7a89m233chtt91oy2sXSkvbRb9+3fjxx++C5vWfeOJhxow5z7bXPuusQQF/7bJePxTU2GHfIvIIMBZoB1xmjPnM5pBqrLS0XYwde36F9f75z4cYObL4yWTfvr1ceOE5FBQUMGnSdzRu3LjU82677UaWL19Gy5at+OijiaW2z5w5nf/7v38A8PLLb3D66d2Ktq1YsZwPP3yPjRvXc+jQQRISEklNbcuwYSM488yzfH2rNd6CBfNYs2YV1113k92heG316lUsXDiPiy++jPj4eLvDKSYUj2d5amxCAtYDdwKP2R1ITZeQkMi//vWox20FBQX8978vkJ19lDZtpNT2GTOmEhMTQ3h4BNOn/8QVV1ztcT9RUVFs3ryJDRvWk5rapti2adN+IioqmuPHiy9gOXPmdB566H7atGnL2LGXEB9fh7S0XSxfvozvvvs6qBPSCy+8ancING6czIwZc4mIOHGaWbhwPpMmfWrbCfS++x70+abStWtX8f77bzNy5HleJyRP7z0QyjqeVfX6/hZa0fqRMeZjABF5wO5YarrY2FhGjBjpcdu7777JoUMHue22u2jTpm2p7dOm/US/fgOJiopi2rSfy0xIp5zSgqNHjzB9+s/FElJWVhYLF86jd+++/PrrL8We8957b9GqVWvefHMCkZGRxbZlZu738V1WrZLx2sHhcBAdHW13GMUE+gSdn59Pfn4+UVFRtr73YDz23rD9GpKIJIvIUyLyi4gcFhGniAwqo260iDwtIrtEJFtEFojI0CoOWVWR5cuX8eGH79G7d1/Gjbu81Pbt27exbt1ahg49k6FDz2TjxvVs2rSxzP0NHXomM2ZMxek8sbjZrFkzcDgc9O8/qFT9Xbt2cOqpHT2e3BMT6/n8ft5990369etWqvzHH7+jX79upKXtKiobM+Y87r//7yxevIBrr72cIUP6cu21l7N27WoApkz5nksuuZAhQ/pw2203smvXzmL7LHkNadmyJfTr141ff53JhAnvMGrU2QwZ0oc777yFHTu2l4ppxoypXHPNZQwZ0odzzx3Ov//9KAcOHChWZ/v2bTzwwD2cf/4Ihgzpw+jRI3noofvJyrJWMy15HeOJJx5m0qRPAejXr1vRv6NHjzJsWD9efPHZUnFs376Nfv268dVXk8o9tocPH+aJJx5mxIiBnHXWIB5//CGysg6XqufpGtL06T9z7bVXMHz4AM48cyBXXTWOiROtON99901efvl5AMaOPb8o5sL/q379uvHSS88xZcr3XHbZRQwZ0ofVq1eWew1nx47t3HXXrQwb1o8LLzyHTz75oNj2wv+rZcuWFCsv3Of3308u93i61y35+kuWLOKWW65l6NC+nHXWYB588L5Sn53Ca127d6dz333jGT68P+eeO4xXXnmR/HyP6+r5TTC0kAS4D9gArAT6lFN3AnAR8KKr/tXAFBEZaIyZH9AoVZU6dOggjz76LxIT6/HAA494vL9h2rSfiI+vQ48evXA4HNSrV59p037ippv+6nGfw4efxUcfvc/q1Svp1KkzYJ2M+vTpT61apac6adSoMUuWLCIjYw9JSQ39+wa9sHXrFh5//CFGjRrDmWfG8vHHH3DvveO5+ea/8sknH3LBBRdy9OgRPvnkA55++nFeeun1Cvf5wQfvEhYWzmWXXcXhw4f49NOPeOSRB3n77RMnxR9//I4nn3yEDh06ccstd7Bnz26+/PJz1q1bw9tvf0h0dDS5ubn87W+3Ex4exrhxl1G3bl12797NvHlzyMo6TEJCnVKvfcEFF7Jv3z4WLZpfrIu2Vq1aDBgwmF9+mcbtt48nPDy8aNvUqVOIiIhg6NDhZb4np9PJ/ff/nZUrlzNq1EU0b96C336bxeOPP1zh8Vi8eAEPP/wAAwcO5vzzR5Ofn8+WLZtZtWoFF198KQMHDmHXrh38/PMU7rjjb9StmwBY3czu+5g5cyqjR48lPj6eBg0alPl6eXl5/P3vt9O5c1duueUO5s2bw+uv/xeAyy//S4XxuivreJb9Xhdy99130KxZc66//haOHj3CpEmfcsst1zFhwqckJp54T3l5efztb7fRqVNn/vrXO1m8eCGfffYxKSlNGT16jE9x+iIYEtJSoIExZp+IjAK+9lRJRHoAlwDjjTEvuso+BFYDTwMD3OrOAgaW8Xr3GGNKfxVTQeXf/36MvXszePHF10hISPBYZ9q0nxgwYFBRN8ygQUOYPv1nbrzxVo8JrFWr1rRuncq0aT/RqVNn9u3by++/L+XRR5/yuP/LL/8LTz31GOPGjaJTp86cdloXunfvSceOpxEWFvjOhW3btvLWWxM49dSOACQlNeKhh+7n1Vdf5rPPvio6Oebl5fHRR++ze3c6jRqVHtThLi8vj/fe+6DomNWpU5eXXnqWTZs20KpVKnl5ebz++n9JTW3Lf//7JlFR1qwgIu14+OEH+O67rxkz5hK2bNlEWtpO3n77A9q371C0//KuDXXseBrNm7dg0aL5pbpoR4wYydSpU1i2bDHdu/cqKp827Sd69uxd9F49mTPnV5YvX8btt48vakmPGjWGO+64udxjATBv3lxatmzFE0/8x+P21NQ2iLTn55+n0L//IJKTm5Sqs337Nj76aCKnnNK8qMy9tesuJyeHfv0Gcvvt4wEYPXoM48ffxoQJ7zJ69Fhq1apVYcyFyjuenrz22kskJCTw+uvvFl0L69mzDzfffA0ffzyhKKbCOM866xyuvPIawDqe1157Od9//231TkjGmNLtas/GALnAO27PzRGRd4EnRCTZGJPmKh/k90CD3M6MLH5bmUZuXgHRkeEVPyFAYqLCOa9vS1o1Kf0N2VtffjmR2bNncfXV1xcb8ebujz/Wsn37NsaPv7eobOjQEXz11SRWrVrBaad18fi8YcNGMHHip9x5591Mnz6N2NhYevfuy4IF80rVPffcC0hKasjnn3/CsmVLWLp0Me+//zYpKU35178eo2PHTpV+j95o3bpNUTIC6NDB+rlfvwHFTtCnnmolhLS0XRUmpHPOOb/YdZTOnbsAsGvXTlq1SuWPP9aSmbmfG264pSgZAQwZMpxXX32JefPmMmbMJdSuHQfA3LmzSU1te9LXrLp160H9+g2YOvWnooS0du1qduzYzg033Fruc+fPn0tkZCQXXHBRUVl4eDgXXTSOFSt+L/e5cXFx7NmzmzVrVhcdX1+dfnq3YsmoIhdeOLbo57CwMEaPvoilSxexcuVyevUqr4Oo8vbu3cv69X9y5ZXXFBuY0bFjJzp06MT8+XOKJSSwWmDuTjutKz///GNA4itke0LyQVfgD2NMVonyRYAD6AKkebszEYkEwrGuo0WKSAxw3BgTPNPo+mDhuj2s31H5SQ39KTY6ghvP71BxRQ82btzAq6++ROfOXbnmmhvKrDd16hRq1apN48aNi66B1KtXj4SEBKZO/anMhDR06Jm8+earLFmyiKlTpzBgwOBiJ96SevbsTc+evcnJycGYdcyYMZVvv/2Ke++9i08++aJYN4e/lUwuhUmgYcNGHssPHz7k8z7j4+u4nmt9L0xPt/6ESp5gw8LCaNq0Gbt3W9ubNElh3LjLmTDhHT7//H907Xo6ffr058wzz/LY/VmR8PBwhg8/i++++5q7776f6Ohopk79idq1a9OvX/9yn5uenk6DBg2JiYkpVu5NkrjwwrH88st0brrpapKTU+jevQeDBw+je/eeXsfuqdVUlvDw8FL1mzY9BYD0dM+tKn8o6/8VoHnzFkyfPrVYWWxsLerUqVusLD4+3qvP2MkIpYSUDOz0UF6YhLz/VFjeBgo7bfsDHwKDgVmVCc5uPds35FhuflC0kIZ3b1ap5x47lsNDD/2TmJgYHnro8WLXEtwVFBQwY8Y0jh49wmWXle4+mDVrOnfddbfHEVVNmqTQoUMnPvrofdasWc1111XcrQMQExND585d6dy5K3XrJvD++2+zYMFczj77XK/fX1nzfBUUeL5QHB7uuVuwrO5Ct7EaZQoL83xMnd48uYTbbx/POeecx+zZv7Jo0QKef/5pPvzwPd58832Sk8tvqXly1lnn8NlnHzNv3mwGDBjMzJnTGDhwCNHRMRU/uZISE+vx/vv/Y9GiBSxYMI8FC+YxefLXnHPO+dx///95tQ9/x1f256TqviuX9dkLtFBKSLHAMQ/lOW7bvWaMuRprUESl1a8fdzJP91pS0okm9p49YUREFP+w5DudpCTFcenQNkRFhnNK4+C6ec9b//nPc2zZsolnnnmBJk2Sy6y3aNFi9u3by6233k7TpsWT3549u3nxxedYunQhffta36wdDgcOB0XHbcSIs3n++WdITKxHz549CQ8PIzzcOgmEh5c+viV16GC1/jIz91VY1+FwFNWpW9f6xpmdfaRYt8mePbs9vrb7c+FE/GFhxcsLTx7h4SfKC09qhb97quNeXrjPlBTre92OHdvo1u1Ed6nT6WTHju20bt262PPbtm1L27Ztue66G1i9ehXXX/8XJk/+iptuurXUvgtf3z0ud+3aCampbZg+/Wfi4+PYv38fZ589ssJj3KRJMr//voS8vGPExJw4Dezcua3U65c8LtbP0QwcOJCBAwfidDp57rmn+eKLiVxzzXU0bdrM7dh5/myEhZV+P57eu8PhID8/n4yMdFJSmhbV3bVrh+t9pBAREUZCwonPift+MzLS3WIu/3iWfP2mTU/8v5asu337VpKTk8s9RoX78lRe+niEFTtn+SKUElI24GlgfYzb9iq1b18WBQW+f7P0RVJSPBkZJy6zFRQUlFqcK9/td6fTGVSLd3nrl1+m8+23XzNmzDj69Olf7nv46acfiYuL4+KLLy/VCnI6nXzwwfv89NMUevbsW1TmdFK0z8GDh5OZmUlqaipOp4O8vALy863/x/z8E8d3yZJFdOvWo9Trz5kzB4CUlFMqPNbu/x/JySkALF26hH79rDE32dnZ/PDDd6Veu+Rz4UT8BQXFy/Nd62Hl558oL2zxFP7uqY57eeE+27RpT2JiPb76ahIjRpxTdG1o5szpZGTs4fLLryIvr4AjR7KIjo4pdvybN29FeHg4OTnHPO4bICrK+nPNzDzo8SbTESPO4e23XyM/P58GDZLo3PmMCo9xz559+Oabr/jyyy+KBjXk5+czceJnpV6/5HE5ePBAqQETLVumAnD0aA55eQVFMR88eJCGDUu3/AoKKP036eG9F772xImfF12vKSgo4MsvJxEbG0vHjp3JyysgKakx4eHhLFu2lL59T4zN+uKLE7OMVHQ8S75+QkJ92rRpy/ffT+bSS68iLs76Mr127WpWrVrJuHGXl3mMTrxPz+Wlj0dBsXOWu7AwR7lf5EMpIaVhdduVVFgWuA5YFVB792bw9NNPEBtbi9TUNmVeOE1JaUqbNsJvv/1C9+69PHbJORwOevfuyy+/TCc7O5vY2NIN58TERK677qYKV968//6/k5zchL59B5CSkkJ2dg5Llixk7tzZtG9/alELzFs9evSiUaPGPPXUY1x66RbCwsL54YfJJCQksnt3esU7qAIRERHccsvtPPnkI9x++00MG3Yme/bs5osvPqdVq9acd95owEqqL7zwDIMGDeWUU5pTUJDPzz9PweFwMHDgkDL3L9IegBdf/A89e/YmLCyMYcNGFG0fPvws3njjv8yZ8xuXXHKFV6MZ+/YdQKdOnXn11ZfYuXMHzZu35Lfffim6H6o8Tz31OIcPH+L007vRsGFDdu+23mubNm1p0aKlK+Z2ALz11msMHXomERER9O07wONnqyIxMTHMmfMrhw8fQqQ98+bNYenSRdx0021FI+zi4uIYNGgoX3zxOeAgJaUp8+bNJjMzs9T+Kjqe7m699U7uvvsObrnlWs4553yOHDnCpEmfUb9+gzJvKK9qoZSQlgN3ikhciYENhVcfV1R9SMoftm3bWnQT41NPPV5mvbPPPpe+ffuTlZVFnz79yqzXt29/fvzxO2bP/vWkpve5774HmT37V2bOnMbevRk4nVa3ylVXXcsVV/zF57v+IyIiePLJZ3nuuad45503qFevPhdffCnx8XV48slHKh2nv40ceR5RUVF88skHvPrqS9SuXZvhw8/i5ptvL7r7PzW1DT169GLevNl8++1XxMTEkJrahmeffbnc0Yf9+w9k7NhLmTbtJ6ZOnYLT6Sx2Am3QoAFnnNHDNZT5bK/iDQsL4+mnn+ell57j559/xOFw0LfvAG677S6uuab0DdXuRow4m8mTv+brr78gK+sw9erVZ8iQYVx77Y1FybBt23bcdNNf+eqrSSxcON81b+LkSiWkiIgInnvuvzz77L+ZMWMq8fF1uOmm27jyyquL1Rs//l7y8/P49tsviYyMYsiQYdx6651cddW4YvUqOp7uunfvybPPvsy7777JW2+9TlRUJN269eDWW+8M6OAcXzgqczEzUNzuQxpsjJlVYltPYAHF70OKxroPabcxpuwzlP+1ADbb0WWXnr6Vxo2Lj5Q5npvPrr1HAIiMCCMlqWqubYW6ilpIqvJO5tjee+940tJ2epwIVwX/59bTOaqQW5ddS2BLye1B0UISkQddP7Z3PV4pIv2AA8aYVwCMMQtFZBLwjIgkAxuxRsk15yQHJyilgsOePbtZuHAeN9xwi92hKBsERUKi9Izb17oetwKvuJVf5ap7FZCINdXQSGPM3IBHqJQKmF27drJq1Qq+/fYroqKiOffcUXaHpGwQFAnJGOPVQuzGmBzgHtc/pVQ1sXz5Mp588hEaN07mwQcfKXO6KFW9BUVCUkrVbCNHnldq8UVV89i+/IRSSikFmpCUUkoFCU1IISiYhuorpVShkz03aUIKMeHhEeTmHrc7DKWUKiU39xgREZVfisTrQQ0iUh9oaIxZ51bWEvgbUA/40Bjzc6UjUV6Ji0vgwIEMEhKSiIyMKnNmYKWUqgpOp5OCgnxycrI5cuQg8fGVn/XBl1F2LwFtgR4AIhIHzObEsg/jRGSIMea3SkejKhQba601c/DgXvLz8wDIy3eSlWVNaBkR5iA939MctKqksLCwKp3SvybRYxs4wXhsw8LCiYyMIjGxIZGRZa8vVhFfElJv4CO338dhJaORWPPMTQPuBTQhBVhsbO2ixASwfU8Wz3+9CICUpNo8dp33i4vVZCWnZVL+o8c2cKrzsfXlGlIjYLvb72cDS4wxPxlj0oEJWKu6qiqmnXZKqerAl4SUS/FF8AYCv7r9fgCo74eYlFJK1UC+dNn9CVwkIq8C52ENZJjhtr0ZsN+PsSmllKpBfElIr2J1y2UCtYBNFE9I/YFVfotMKaVUjeJ1l50x5kOs5R5mAB8DZxtjcqFoSHgCoAuYKKWUqhSvWkgiEg6kAD8YYz4qud0Ysw84w8+xKaWUqkG8bSFFYnXRXRfAWJRSStVgXiUk1zpEe4EjgQ1HKaVUTeXLsO8fgXMDFYiqPJ1qVSlVHfiSkO4FkkXkAxHpJCIxgQpKVZ7eJKuUClW+DPveg/VlvDNwBYCIlKzjNMboKrQ20taSUipU+ZI8PkTPd0FJW0VKqerA64RkjLk6gHEopZSq4XSBPqWUUkGhUtd7XGshJeAhoRljtp1kTEoppWognxKSiFwCPAi0L6da+ElFpJRSqkbyustOREYB/8NKYm9iXUv/FJiEtTTFUuBR/4eolFKqJvDlGtLdwDqgC/B/rrL3jDGXAN0AwVo5VimllPKZLwnpNOAD1zRChQu6hwMYY1YDbwH3+zc85Q0di6+Uqg58SUjhwD7Xz9mux7pu2w3Q0R9BqcrTe5KUUqHKl4S0A2gOYIzJxpq5wX3JCUEnX7WdtpaUUqHKl1F284BhnLh+NBm4S0SysRLbX4Hv/Bue8oa2ipRS1YEvLaTXgFkiEuv6/QGsbrqHsZLURqyBD0oppZTPfJk6aDGw2O33DKCLiJwG5APrjDEFZT1fKaWUKo8v9yENEJGkkuXGmJXGmDVAPREZ4NfolFJK1Ri+dNn9AgwvZ/tQVx2llFLKZ74kpIqunYdz4v4kpaqVAqeOX1Qq0Hyd7bu8v8o+wN6TiEVVkp4qA8fpdPKfT3/nntfmkXn4mN3hKFWtlTuoQUTuBO50K3pRRJ7wUDURqAO858fYVCXoEHD/2rTrEOu2ZgLw6fQ/uXV0J5sjUqr6qmiU3QFgq+vnFlgzNewuUccJrAYWAC/4MTalbHc870QvdFZ2ro2RKFX9lZuQjDEfAB8AiMhm4B/GmMlVEZiqHO2+U0qFKl/uQ2oZyECqkohEA29gjRqMB5YBt7mGr4cc7aZTSlUHXickEakPNDTGrHMrawn8DagHfGiM+dn/IQZEBLAJ6AWkYV0n+wZoY2NMSilVo/kyl91LQFugBxQtYz4baOLaPk5EhhhjfvNviP5njDkCPFb4u4i8AjwrIvWNMfvKfqZSSqlA8SUh9QY+cvt9HFYyGom1MN804F7Ap4QkIslYLZSeWAv9xQGDjTGzPNSNxlqV9kqskX0rgAeMMTN8eU0PegN7NBkppZR9fLkPqRGw3e33s4ElxpifjDHpwASgayViEOA+oCmwsoK6E4DxwMdYSawAmCIivSvxutaLiyRgLS74z8ruQyml1MnzpYWUC8S6/T4QK0EUOgDUr0QMS4EGxph9IjIK+NpTJRHpAVwCjDfGvOgq+xBryPnTwAC3urNc8XlyjzHmWVe9GOBb4HtjjN5DpZRSNvIlIf0JXCQirwLnYQ1kcO8qawbs9zUAY8xhL6uOwUqK77g9N0dE3gWeEJFkY0yaq3xQRTsTkXDgM6xWX0gvm6FDvZVS1YEvCelVrBZRJlALa5Sae0LqD6zyW2SldQX+MMZklShfhDXyuQvWiDlvvQ3EAGONMdXmnK5DwJVSocqX+5A+FBEnMAo4CDxpjMmFoiHhCViL+AVKMrDTQ3lhEmriYZtHItIcuAbIATJFpHDT2caY2d7up379OG+rnpSkpPhyt2flnphNICIivML66oSKjlXawZyinyMjI/TY+kCPVeBU12PrSwsJY8xHFB9pV1i+DzjDX0GVIRbwNLtljtt2rxhjtuKHxsS+fVkUFAS2cZWUFE9GRvm9mpmZR4t+zsvLr7C+snhzbA8cyC76OTc3T4+tl7w5tqpyQvnYhoU5yv0i7+ts33bKBqI9lMe4ba/xqk3fo1KqxgmlhJSG1W1XUmHZriqMJajodSOlVHUQSglpOdDONUOEu56uxxVVG45SSil/CqWE9AUQCVxfWOCaueEaYK4xpsa2kJRSqjrwaVBDoIjIg64f27serxSRfsABY8wrAMaYhSIyCXjGNd3QRuAvQHPg6ioOWSmllJ+VmZBEZBNwV+H6RyLyf8BXxpjVAYjjsRK/X+t63Aq84lZ+lavuVVhz2a0ERhpj5gYgJqWUUlWovBbSKVhrBRV6GNiANVWPXxljvLoub4zJAe5x/VMuOrIugJx6dJWqKuVdQ9oJdCpRpn+dQU5H3CmlQlV5LaRvgXtF5CxOzFH3oIjcUM5znMaYoX6LTimlVI1RXkK6D2veumFYAwecQBLWPHZK1QwObXMqVVXKTEjGmGzgIdc/RKQAa5DD/6ooNlUJ2qeqlApVvtyHdA0wL1CBqMrT7/BKqerAl9m+Pyj82TW7d0vXr5t16W+llFIny6cbY0WkM/Ay0K9E+WzgDmNMRUuQK6WUUh55nZBEpCMwB2t27W+BNa5NHbBWkJ0tIn2MMWvK2IVSKsD+3H6Aj6f+SZMGtejVoTEdW9YjIjyUZghTNZkvLaRHsZYQ71uyJeRKVr+56lzkv/CUUr6YvWIXOzKy2JGRxaJ1e4iLjaRH+4b06tCY1k3q4NBRgyqI+ZKQBgCveuqWM8asFpHXgJv9Fpnymo6sC6AQm6khr8SCkVnZucxctpOZy3aSlBBDr1Mb06tDI5Lr17YpQqXK5ktCqg2kl7M9zVVH2Ui//yqA+nWiuXBAa+avTWfN5v04nZBxIIfv5m3hu3lbaNE4nt4dGtPj1EbUrR1ld7hKAb4lpE3AucCrZWw/11VHKWWziPAwendsTO+OjTmYdYxF6/awYG06m9Ospa+3pB9mS/phPp+5gVNbJNK7Q2O6tm1ATFRQLACgaihfPn0fAv8Wkf8BTwB/uMrbA/cDZwL/8G94StmsGlxzqRsXzfDuzRjevRlp+46wYM1uFqxNJ+NADgVOJ6s372f15v1ERYZxepskenVoTIeWiYSH6WAIVbV8SUjPAqcDlwDjgAJXeRhWT9FE4Dm/RqeU8qvk+rUZPaAVo/q3ZOOuQyxYk86idXvIys7leG4BC9buZsHa3cTXiqRH+0b06tCIVsk6GEJVDV9ujM0HxonIO8AoTtwYuwn4xhgz3f/hKV+F1iV4ZReHw0FqSl1SU+pyydA2rN68nwVr0vl9/V5y8wo4fDSXGUt3MGPpDhomxtLr1Eb07tiYRok6laUKHJ87jI0x04BpAYhFVZJ+d1UnIyI8jC6pDeiS2oDsY3ks+zODBWvSWbs1E6cT9mRmM3nuFr6bu4Wxg1M5q+cpdoesqim9gqmUKhIbHUHfTsn07ZTMgaxjLFq7m/lrdrN192GcwMRfNhATHc6gLil2h6qqIU1ISimPEuKiObPHKZzZ4xQ2px3i+c+XcyQnj49+MtSKjqBH+0Z2h6iqGR1Go1Q14gzQjbwtk+sw/uIuREeG4wTe/m4tqzbpnMrKvzQhVQM6kCGAQmymhkBq1aQOt1/UiYhwB/kFTl79ahXrdxywOyxVjWhCqmZ0gIMCAnb/1Kkt6nHzBR1xOOB4XgEvTlrJtt2HA/JaqubxKiGJSKyIXCUiPQMdkFIquJ3eNolrR7YHIPtYHs9/vpz0/UdtjkpVB962kI4BbwNdAxiLUipE9O2UzKVD2wBw6Gguz332O/sP5dgclQp1XiUkY0wBsB2oE9hwlAoyOkNBmYZ3b8b5fVsAsO/QMZ77fDmHjh63NygV0ny5hvQBcKWIRAcqGHXy9BK8qkoX9GvJ0DOaApC27ygvTFxB9rE8m6NSocqX+5DmARcCy11rH60HSnUcG2N+81Nsykv6HV7ZxeFwcOmwNhzNyWP+mnS2ph/m5S9W8sRf+9kdmgpBviQk9+mCXqL0l3GHqyz8ZINSSoWOMIeDa0a2I/tYHss37MVsP8DTHy7mhnPa6/Lpyie+JKRrAhaFUiqkRYSHccuoDrwwcQV/bDvA4rW7CXfA9eeeSpheh1Ne8mW27w8CGYhSKrRFRoRz+0Wn8Z9Pf2dL+mEWrNlNregILh/eVpevUF7R9nQ1oAMZAkhnavBJbHQE4y/uTLNGcQDMXLaTb2ZvtjkqFSp8Skgi0kxE3hORHSJyXESGuMqTXOXdAxOm8pZ+D1Vg7+cgvlYUj97Yh/p1YgD4bt4Wpi7aZmNEKlR4nZBEpCWwBLgIWIPb4AVjTAbQDbje3wEqpUJPg4RY7r60C3VqRwHw2cwNzF6xy+aoVLDzpYX0BNay5R2Byyn9JexHQMd6KqUAaJRYi7+P60KtaOtS9YSf/mCp2WNzVCqY+ZKQhgGvGWO24/myxVagqV+iUipY6MX4k9KsYRx3je1MVGQYTie8OXkNa7bstzssFaR8SUh1gLRytkehC/7ZTi/Bq2CT2rQut43uRHiYg7x8J698uYqNOw/aHZYKQr4kpO1Ah3K29wI2nFw4qjL0O7wKdh1b1efG8zvgcMCx3HxenLSCHXuy7A5LBRlfEtJXwLUi0tGtzAkgIhcBY4GJfoxNKVWNdG/XkL+c1Q6AIzl5PPf5cvZk6rIV6gRfBzXsABYCH2Mlo3+IyHysRLQCeM7vESqlqo0BnZswdnBrAA4eOc6zny0n8/Axm6NSwcLrhGSMOQT0Bt7BGuLtAIYDArwGDDbG6IIoStkoFO7jPbtnc87p3RyAvQdzePqTZXwzexOrN+/jaI7OFF6T+TQIwZWU7gTuFJEkrKSUYYwJgT+DE0TkdWAUUBtrdOD9xpjvbQ3qJITUwQ81oXCGD0EXDmjFkZw8Zv2+kz0Hspk8dwtgnVBSkmqTmlKX1il1SW1al4YJsTr1UA1R6VFxrpthQ9VLwHhjTI6IdAOmi0hLY0ym3YGdLP2zVRD8o9UdDgdXDG9LQu0oFq7bTdo+61qSE9iRcYQdGUeYtdy6kTa+ViSpKXWLklSLxvFEReqiAtWRzwlJRC4GRgOtXEWbgK+NMSEzoMEY80eJomggGQj5hKRUqAgLc3B+v5ac368lWdm5bNx5kA07D7Jx50E2pR3ieG4BAIeP5vL7+r38vn4vAOFhDpo3ji+WpBLjdd3Q6sDrhCQitYFvgCFYX8QPuDZ1By4WkZuA840xR3zYZzJWF2BPrOtScVjXomZ5qBsNPApcCSRiDaJ4wBgzw9vXK7G/17CW1IgBvgfWVWY/SqmTFxcbSefUBnRObQBAXn4BOzKy2LDjRJLad8ga/JBf4GTTrkNs2nWIqYu3A9CgbsyJbr6UujRtWJvwMJ07OtT40kJ6AhgKvAw8ZYxJBxCRxsA/gDtcde7yYZ8C3Id1/9JKoE85dSdgzaP3oqv+1cAUERlojJnvw2sCYIy5VURuBwYDHULtOphS1VlEeBgtGtehReM6DOvWDID9h3LYuOtQUZLatvsw+QXWn+3egznsPZjDgrW7AYiODKdrmwZcOLAVDerG2vY+lG98SUjjgEnGmLvcC12J6S4RSXHVuav0U8u0FGhgjNknIqOArz1VEpEewCVY131edJV9CKwGngYGuNWdBQws4/XuMcY86xZ7Ptb1oztF5A9jzM8+xK5qgmC/GFOD1KsTQ706MXRv1xCA47n5bEk/zIadB4uSVFZ2LmDdfLtg7W6W/pnB2T1P4exezYnW605Bz5eEVAf4pZztM4GRvry4Meawl1XHALlYQ84Ln5sjIu8CT4hIsjEmzVU+yJcYXCKA1pV4XtDRZp6qKaIiw2nbLIG2zRIAcDqd7MnMZsPOgyzfsJelJoPcvAImz93CnFVpXDw4le7tGuqIvSDmS0JaCbQpZ3sbYNXJhVOmrsAfxpiSc40swrqe1YXy59krIiJxWEO+vwFygAuwuu3u9U+oVU//vJSyRu41qleLRvVq0bdTMn9uP8Cn09ezdfdh9h86xhvfrmHmsp1cNqwNpzSKtztc5YEvCelB4GsRmWWM+c59g4hcgLUW0ig/xuYuGdjpobwwCTXxYV9O4FrgFaxz+QbgUmOMz8m0fv04X59SKUlJ5f/xHMk70S6KCA+rsL46oaJjlXbwxL3ekZERQX9so11LPYQHwecgGF6/V5emTF+0jY+mrOVg1nH+3H6ARycs5sxeLbjirHbUjQvN0Xl2H9tAKTMhich7Hoo3A9+IiOHEqLT2WIMTVmGtkzTT30ECsYCn+UVy3LZ7xTUKcIg/gtq3L4uCgsB2kiUlxZORUX7PZub+EwMb8/ILKqyvLN4c2wMHsot+zs3NC/pjm3PMmukg3+bPgTfHtqqc3roe7a7vyeS5W5ixdAf5BU5+mr+F35bt4IJ+LRl8egoR4aEzIi+Yjq2vwsIc5X6RL6+FdHU529q5/rk7DegEXOdtcD7IxrpXqKQYt+01ll43CiCdqaFaqBUTySVD2zCgcxM+m7Ge1Zv3c/RYHp/OWM+vK3Zx6dA2dGhZz+4wa7wyE5IxJpi+MqRhdduVVFimayO76PUkpcrWpEFtxl/cmRUb9vHZjPXsOZDNrr1HeO7z5XRt04BxQ1JpmFjL7jBrrGBKOuVZDrRzDUhw19P1uKJqw1FKhSqHw0GXNg147PqejB3Umugoazj47+v38uA7C/ny143kHNdJXu0QKgnpCyASa+AEUDRzwzXAXGOMtpCUUj6JjAjj7F7N+feNvejbsTEAeflOfpi/lX++tYD5q9NxapdtlfJpLjsR6QP8FWuId31K9xA5jTE+3c8jIg+6fmzverxSRPoBB4wxrwAYYxaKyCTgGdd0QxuBvwDNKf9al1JKlSshLprrzj2VQaen8L9p69mcdogDWcd5+/u1zPx9B5cNa0vL5Dp2h1kj+DKX3Q3AG8BxwADb/BTDYyV+v9b1uBVraHahq1x1r8Kay24lMNIYM9dPcSilarDWTerywFVnMH91Ol/M2sjBI8fZuPMQj32whH6dkrloYKuQHSYeKnxpIf0T61rOCGPMXn8FYIzx6jq8a/G/e1z/VBm0g8HP9K7+GiXM4aBvp2ROb5vE9/O2MHXxdvILnMxZlcYSs4fz+7ZkWLemITVMPJT4clQbAe/6Mxkp/9BTplL+FRsdwdjBqTx+fU+6uGYgzzmez8RfNvDPtxYwZ2Ua+QUFNkdZ/fiSkNZhdZUppVSN0KheLe4Ycxp/u7gzyfWt4eB7D+bw3o/r+Nc7i1i0bjcFOvDBb3xJSE8At4qIL9P0qCqgfw6qiJ4cA6Jjq/o8cm0PrhwhJMRFAZC+/yhvfLuGR95fzPL1e3VEnh94fQ3JGPOViNQC1orIt8AWIL9ENacxpuQgBVWFtPvOz/Qko1wiwsMY3DWFvh0bM+v3nfywYCuHj+ayfU8WL3+5klZN6jB6QCtObZ6oM4pXki+j7NpirdhaB2vVVk+clB41p5SqYnpCDJyoyHDO7HEKA7o0YdqSHfy0cBvZx/LYtOsQz322HGmWwIUDW9GmaYLdoYYcX0bZvQY0xFpyfDaQGZCIlFIqBMRERXBenxYMOT2FnxdtY9riHRzLzcdsP8C/P15Gp1b1GT2gJS0a6z1M3vIlIfUG/mOM+W+gglFKqVBTOyaSCwe0Zli3Zvw4fyszl+0kL7+AVZv2sWrTPs5om8So/i1JSaqa5WpCmS8J6SCQEahAlFIqlNWpFcUlQ9swoscpfD9vC7+t2EV+gZOlf2aw7M8MenZoxAX9WtJIJ28tky+j7CYCFwYqEKWUqg4S46O5coTw5I296NupMQ6HdXF9wZrdPPDWQiZM+YP9h3Iq3E9N5EsL6U3gAxH5BngZa7G+kqPsMMb4a0ohVQk6JszPdHCAqqSkhFiuO+dURvZqzjezN7P4jz0UOJ38tmIX81anMahLCuf0aUHd2lF2hxo0fElIa7DOd92A88qpF35SESmf6SlTqeCVXL82t4zqyDm7D/PN7M0s37CXvHwn05fu4LeVuxh6RlPO7tmcuNhIu0O1nS8J6VH0C7hSSlXKKY3iuWPMaWzcdZCvf9vE2i2ZHM8tYMqCbcz6fRd/H9eFVk1q9og8X26MfTiAcaiToN8SAijEbowNrWhrptZN6nL3JV35Y2smX/22iQ07D5J9LI+JM9fzjyvOsDs8W+mUtdWMdt8pFRraNU/k/itOZ9gZTQH4c8dBtqYftjkqe/kyU8MAb+oZY36rfDhKKX/QLyahweFwcGaPZsxYtgOnE6Yv2c51555qd1i28eUa0iy86xHQQQ1KKeWlBnVjOaNtEktMBgvX7WbM4NQaO/LOl4R0TRnPb421jPgWrKHhSimlfDCsWzOWmAzy8p38+vtOzu/X0u6QbOHLoIYPytomIv8BlvklIqWUqmHaNK1L80bxbN19mF9+38nI3s1r5Kq0fnnHxphM4B3gXn/sTymlahKHw8GwbtbghoNHjrN43R6bI7KHP1NwJtDKj/tTSqkao0f7RtRxXTuatmR7jVzwzy8JSURisNZISvfH/lTl1byPcIDp1EGqikRGhDGoi7Ug95b0w2zcecjmiKqeL8O+3ytjUz2spSmSgHv8EZTyjZ4ylaoeBndN4Yf5W8kvcDJtyXZSm9a1O6Qq5csou6vLKN8P/AmMN8b876QjUj7TVlEAhVq3SYiFq4qrGxdNj/aNmL8mnaUmg/2HcqhXJ8busKqML6Psat6QjxCkrSUF6AchhA3v3pT5a9IpcDqZuWwnYwa1tjukKqNJRimlgkiLxnWKuup+Xb6TY7mlVvmptjQhKaVUkBnerRkAR3LyWLCm5owVK7fLTkQm+7g/pzHmgpOIRymlarzT2zagXp1o9h86xvQlOxjQuQmOGjDis6JrSOf6uD+9pKqUUicpPCyMIac35YtZG9m59whrt2bSoUU9u8MKuHITkjcDGURkIPAM0B1I81NcSilVow3o3ITJczZzPK+A6Yu314iEVOlrSCLSUUR+AGYCAvwLaOOvwJRSqiaLi42kd8fGAKzcuI/dmUdtjijwfE5IItJMRCYAvwNDgZeB1saYJ4wx2X6OT/lI+0z9rAb026vgVbh4nxOYsWSHvcFUAV9makgEHgBuBaKBT4EHjTFbAhOa8paeMpWqnlKS4ji1RSJrt2QyZ1UaowdU7+lCK0xIIhIN3AXcByQA04D7jDHLAxmY8p62igIoxGZqCK1olTeGdWvG2i2Z5BzPZ87KNC5rmmh3SAFTbpediFwHbACeBDYCw40xIzQZBS9tLSnQz0F1clrr+jRMjAVgxtId5BdU368dFbWQ3sb60rUEmAh0FpHO5dR3GmNe8FdwSilV04U5HAw9oymfTl/PngPZLF23m5YNa9sdVkB4cw3JgTWku7sXdZ2AJiSllPKjfp2S+fq3TeQcz2fy7I3cedFpdocUEBUlpMFVEoVSSqkyxUZH0O+0ZKYv2cGK9XvZkZFF06Q4u8Pyu4pujP21qgJRSilVtmFnNGXGkh04gelLdnD12e3sDsnvdHJVpZQKAQ0Ta9E5tQEA89ekk5Wda3NE/lejE5KI9BaRAhH5h92xKKVURYZ3s26Uzc0r4NflO22Oxv9qbEISkTCsARiL7Y7Fn6rvgFClVLvmiTRvHA/AzGU7ycsvsDki/6qxCQm4EVgIrLM7kJOl95wEkE4dpIKIw+HgvP7WCrKZh4+x7M8MmyPyL6+nDgoEEUkG7gR6At2AOGCwMWaWh7rRwKPAlUAisAJ4wBgzoxKvWx9r9olewIuViz54aKsogEJtpoYQi1f5btAZTZnw/RqysnOZvmQHPdo3sjskv7G7hSRYUxI1BVZWUHcCMB74GCuJFQBTRKR3JV73CeBFY8yBSjw3qOn3eWXRT0J1FR0ZzsAuTQDYsPMgm9MO2RyR/9jaQgKWAg2MMftEZBTwtadKItIDuAQYb4x50VX2IbAaeBoY4FZ3FjCwjNe7B5iBdZPvX/3yDpRSqooN7prClAXbKHA6mb5kOzec18HukPzC1oRkjDnsZdUxQC7wjttzc0TkXeAJEUk2xqS5ygeVtyMRuQurZbZTRADqAnki0sIYc7PPb0IppapYvToxdGuXxKJ1e1i0bg9jB6eSEBdtd1gnze4uO291Bf4wxmSVKF+E1TfRxYd9vQWkup7TBZgMvITVdaiUUiFhWLdmAOQXOJn1e/UYAm53l523kgFPR7xwyfQm3u7IGHMUKFp6UUSygSxjzEFfg6pfv2qm7khKii93e1buiaGfERHhFdZXJ1R0rHYdyCn6OSoqIuiPbXS09ScdERFme6x2v351lpQUT4MGcbSZtZH12w/w24o0rj6/I5ER4XaHdlJCJSHFAsc8lOe4ba8UY8zVlX3uvn1ZFAR4KvikpHgyMsrv2cx0W9o4Ly+/wvrK4s2xPXjgxLE9fjwv6I/tsWN5AOTlFdgaqzfHVlWO+7Ed1KUJ67cf4EDWMX74bSN9OyXbHF35wsIc5X6RD5Uuu2ysVWpLinHbrpRSNUr3dg2pGxcFwLQl20N+2H+oJKQ0rG67kgrLdlVhLEopFRQiwsMY3DUFgG27s1i/w+crD0ElVBLScqCdiJRs6/V0Pa6o2nCCV2h/PwpCOlODCnKDuqQQEW59Tqct2W5zNCcnVBLSF0AkcH1hgWvmhmuAucYYbSGpwAjxLhBV/dWpHUXPU63ZGpb9mcHeg6F7BcP2QQ0i8qDrx/auxytFpB9wwBjzCoAxZqGITAKecU03tBH4C9AcuLqKQw5q+n1egTbsaprh3Zoxd1U6Tqc16erFg1PtDqlSbE9IwGMlfr/W9bgVeMWt/CpX3auw5rJbCYw0xswNeIRKKRXETmkUT9tmCfy5/QC/Ld/FBX1bEh0VekPAbU9IxhivvssZY3Kwpv65J7ARKaVU6BnerSl/bj/A0WN5zFuTXjTYIZSEyjUkpZRS5ejaJon6daw7YaaH6BBwTUhKKVUNhIU5GHqGtaJs2r6jrNmy3+aIfKcJSSmlqon+nZOJirRO69OX7LA5Gt9pQlJKqWqidkwkfTta8wWs3LiPtH1HbI7IN5qQlFKqGhnWrWnRzzOWhlYrSRNSNRN6lzGVUv6UXL82HVvWA2DuqnSO5uTZHJH3NCEpVY2E4MAqFQCDT7eGfB/LzWfjrtCZ304TUjWjN+gr0M9BTee+emx+gJfI8SdNSEoppYKCJiSllFJBQROSUkqpoKAJSSmlVFDQhKSUUiooaEJSSikVFDQhKaWUCgq2r4cUosLBml23KlT0OlGR4TRMjAWgXt2YKourOqjoWEVHnTi2ifHRQX9sE+KjaZgYS7069n8O7H796syXc0JMVETQ/F+4xeFx9UBHKK6ZEQT6AbPtDkIppUJUf2BOyUJNSJUTDXQH0oB8m2NRSqlQEQ4kA4uBYyU3akJSSikVFHRQg1JKqaCgCUkppVRQ0ISklFIqKGhCUkopFRQ0ISmllAoKmpCUUkoFBU1ISimlgoImJKWUUkFB57ILQiISDTwKXAkkAiuAB4wxM2wNLMSJSHfgamAw0BzYB8wDHjTGbLAxtGpJRO4FngZWGGO62BxOyHN9fh8G+gCRwEbgBWPMBBvD8ittIQWnCcB44GPgTqAAmCIive0Mqhq4D7gQmI51XN8CBgG/i0h7G+OqdkSkMfAgcMTuWKoDETkbmIuViP4F/B3rc9zMzrj8TVtIQUZEegCXAOONMS+6yj4EVmN92xxgX3Qh73ngMmPM8cICEfkcWIWVrK62Ka7q6ClgCdaX3gR7QwltIlIX60vq68aYO20OJ6C0hRR8xgC5wDuFBcaYHOBdoJ+IJNsVWKgzxsxzT0ausvXAGkBbSH7i+lJ1BfA3u2OpJi7DSur/ByAi8SISHOtJ+JkmpODTFfjDGJNVonwR4AC6VHlE1ZjrD7sRsNfuWKoD1/H8L/CBMWa5zeFUF8OAP4CRIrIdOATsF5GnRMTjukKhSrvsgk8ysNNDeZrrsUkVxlITXA6kAA/YHUg1cRVwKjDK5jiqk1Ssa0UTgGeA34FzsbqZY4C77ArM3zQhBZ9YPKwTAuS4bVd+ICLtgFexFgr7yOZwQp6IxGNdO3rKGJNWUX3ltTis0bb/MMY87Sr7SkTigFtF5HFjTLVo4WuXXfDJxloAsKQYt+3qJLlGgf0AZAJjjTEFNodUHTwIHMcaPKL8p/Bv/tMS5Z9gjbrrUbXhBI62kIJPGla3XUmFZbuqMJZqyTVqaQpQF+hrjEm3OaSQ5xpscxfWkORGIlK4KQaIEpEWwEFjTKYtAYa2NKADsLtEeeHviVUbTuBoCyn4LAfauZrj7nq6HldUbTjVi4jEAN8BbYFzjTHG5pCqi0ZAFNatCZvd/vXEGsG4Geuah/LdUtdjSonypq7HjCqMJaA0IQWfL7Ca4dcXFrhmbrgGmGuM0RZSJblGJH0O9Mbqpltgc0jVyWZgtId/a4Atrp8/tCu4EDfJ9XhdYYFrNOP1WDceV5vPscPpdNodgypBRCZijVJ6AWt6kL8A3YHBxpi5NoYW0kTkRawZGr4DJpbYnGWM+aaqY6ruRGQWkKBTB50cEfkAayqxd4FlwDmuf/caY/5jZ2z+pNeQgtNVwGOux0RgJTBSk9FJ6+J6PM/1z91W4JuqDEYpH9wAbMP6cvoXYBNwszHmTVuj8jNtISmllAoKeg1JKaVUUNCEpJRSKihoQlJKKRUUNCEppZQKCpqQlFJKBQVNSEoppYKCJiSllFJBQROSUkqpoKAJSSmlVFDQhKRCiogMEhGniFxtdywnS0Q6ikieiAy3O5aaQEQuEJHjItLG7liUZ5qQlLLP81gzuE9zLxSReq6kO8WmuAJGRF4RkZ2u2arLqlP4peNuf762MeZbYBXWEhkqCGlCUsoGItIbGI7n1VVPdz0uq7qIAs+VhEYB3xpj7JpE8yVgtIh0sOn1VTk0ISllj1uBvcCPHrZVy4SEtYRKCvbOqv4VcBS42cYYVBl0+QlVLYhIA+AR4Hys1Ut3A5OB/zPG7CtRtwXwHFYLBeAXrOW3fwG2GGMGBTjWCKyWwvfGmFwPVaprQhoNHMA6zrYwxmSJyGxgDHC7XXEoz7SFpEKeiNQF5gG3AD9jJZefXL/PEZF4t7r1gdlY6yFNwFpW+wjWSbJ2FYV8BhAHLCpj++lApjFmcxXFU1VGAz+WkYSr0nygsYi0szkOVYK2kFR1cC/QBvirMea1wkIRWQ684tr+L1fxfUBT4ApjzCeustdF5BngniqK91TX48aSG1zJMxUbWxGBICLtAQEetDsWThz3DsAfdgaiitOEpKqD0UAG8FaJ8jeBh1zbCxPSeUAa8GmJus9SdQkpyfW438O2roCD6tddNwrIwWq5+pWINMZaXbkdsAeYZIxZWs5TCrtwG/o7FnVyNCGp6qAlsMQYk+deaIzJE5E/OXFNprDuImNMQYm6e0TkgHuZiFwM3IG19PleY0yLEtsjsK5FXYnV/f0lVistp4J4C0eYeRr6fIbrscyEJCL9AU9DwqOAcGNMeIn6r2F1X/YxxswvsW0WMBAYaYyZ4lZ+MfA58IMx5lxXWVvgGaAvEIPrOp0x5m9lxepmNDDdGJPlRV2vichFwBDgXeC/WEnmMhEZA/yzjNF8hcddl8sOMpqQlCpbJlaXXyNgvIft/wQGA52A41iDKJ7BSmLlyXA91vOwrcIBDcaY2VjXoIqISBNgiSte9/JY4DKs1tj1WNdPSvoDuI7iSe56Sndn/YA1Su0KrJFqrbGSU7lEpCnQDbihorq+EJGOQAtjzF/dircC/xaRXlgj6V738NTC457hYZuykQ5qUNXBJkBcLZYirt/burYX2gKkikhYiboNgQT3MmPMNGPMZ1gnOU+uB540xuw0xmQADwNXi0h4GfULrXY9epox4HQgC/izgn0UEZForEQxxxjzZInNY4ECrIEeF4tIHKVNBIaISJJrf82xWoXfuL1GA6xrW28YY7KMMQXGmPXGmAlehDgKqzUy2dv35KUL8XwfF8aYBUCDkp8Jl1TX42oP25SNNCGp6uAbrOsy15cov8FV/rVb2XdAMnBpibo+zQogIglAM2C5W/EyIB5oUcHTfwcOAb1K7LMW1oX/5T7eOPoGVhfa1R62XQ98hpV0coFLPNQ5jHWMrnL9fh3wP+BYYQVjzF5gHfCeiFwiIq19iG80VrL0d4vkaOFxEpHeIrJXRNwHTSzF+kJSUi9gtzHG+DkedZK0y05VB89gtQReFZHTsU74XbFOrMa1vdDTWF1Y74tID6xuqf5AH6wbVb1NBIVDyQ+4lR0osc0jY0y+iHwFjBKRaGNM4Ym/MxAOxIjIPzw8NcsYU7JL7g7gXKC7MeZoiW1tsd7bPcaYYyLyGdYxecfDvt8F3hGRF7ES2znARSXqDMJK3P8EThWRbcA/jDETy3qvIlIPGIA10tFXQ0UkxkP5XmPMGyXKOgP1Kd6FeIgS/xeuFmJ/4L1KxKMCTFtIKuQZYw5inYjeBEYCL7se3wD6GWMOu9XdC/QDvgeuxUpQtbGuBTmAbC9ftnCfdd3KEkpsK8/rrvrnupUVXj/qBvzbw7+x7jsQkcGu+McaY7Z4eI3rgT+MMQtdv08AenmaNscYMw/r/T8MpBtjVnmos8cYc68x5jSs6zCvAf+r4H6ec7G++H5dTp2ynAU85uHfXa7tsW5138Fqif3FrawzsL7EPi8CamF9VlSQ0RaSCinGmFl4GJ3m6g661fWvon1sxrr+UMR1w2x9YJuXcRwQke1Y11oKu366YiWjLV48f5GIFN7E+6Wr7FXgVW9e3zXbxESs1s8sD9sjsbrg6opIeonN1wGeRsa9i9WavMWL+A8Bz4rI/ZR/P89oYEUZCbOsfc/C8wjEkraISB9jzDzXCMtvCje4bpZuYYwpObT+TuBrY4xePwpCmpBUjSMiscaYki2hwi6yaW71woFI1z+Hq/vI6dbF9g5wv2sqmlys1sUEY0y+l6H8HVghImcaY6b6EH8trJPv5JJdeG7OAxKxkqT7SfkK4D4R+Ycx5niJ57yFdU1snofXTMS6T+sTrAEXYVhde7WwrtWUZT7wdrlvqPI+Bl4SkdruM6aLSEusllSxpCsio4COwLgAxaNOkiYkVRP9KCJbsQYhhAFDsbqW5lF84s8rgffdfs/GGnHXwvX7k0ADYI1rP19gzQThFWPMGir3N3gRVndUWxHxdHI9Fau77lNjzFr3DSLyBvAA1si3Ytd+XK2e6WW85nGgMdZIuUZYAx7WAOeX1/oxxjxT1raTZYxxishdwG0icj3WaMIwrBuf7yw5h6Ex5huse7VUkHI4nXpvmKpZROTvWN1ZLbCuQ+zAGjb9iPv1JqVU1dKEpJRSKijoKDullFJBQROSUkqpoKAJSSmlVFDQhKSUUiooaEJSSikVFDQhKaWUCgqakJRSSgUFTUhKKaWCwv8DfwO2Q+o/xrYAAAAASUVORK5CYII=\n", + "text/plain": [ + "<Figure size 432x288 with 1 Axes>" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "# plot luminosity distribution\n", "ldist = population.grid_results['luminosity distribution']\n", @@ -491,10 +582,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "id": "5956f746-e3b9-4912-b75f-8eb0af66d3f6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ValueError", + "evalue": "Failed to rename grid variable M_1 to lnM_1.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Input \u001b[0;32mIn [27]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Rename the old variable (M_1) because we want it to be called lnM_1 now\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mpopulation\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrename_grid_variable\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mM_1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mlnM_1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/.pyenv/versions/3.9.9/envs/dev_binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/utils/population_extensions/gridcode.py:965\u001b[0m, in \u001b[0;36mgridcode.rename_grid_variable\u001b[0;34m(self, oldname, newname)\u001b[0m\n\u001b[1;32m 963\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 964\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFailed to rename grid variable \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m to \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(oldname, newname)\n\u001b[0;32m--> 965\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(msg)\n", + "\u001b[0;31mValueError\u001b[0m: Failed to rename grid variable M_1 to lnM_1." + ] + } + ], "source": [ "# Rename the old variable (M_1) because we want it to be called lnM_1 now\n", "population.rename_grid_variable(\"M_1\",\"lnM_1\")" @@ -520,8 +624,8 @@ "# because M * dprob/dM = dprob/dlnM\n", "population.update_grid_variable(\n", " name=\"lnM_1\",\n", - " samplerfunc=\"const(math.log({min}), math.log({max}), {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " samplerfunc=\"self.const_linear(math.log({min}), math.log({max}), {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnM_1\",\n", " parameter_name=\"M_1\",\n", " precode=\"M_1=math.exp(lnM_1)\",\n", @@ -615,7 +719,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -629,7 +733,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/examples/notebook_massive_remnants.html b/docs/build/html/examples/notebook_massive_remnants.html index 95cf0f6abb8fa9c0b214ad7137a74615493a62d2..c7ba875fff5c1484674ddc57193065cd9d6e2660 100644 --- a/docs/build/html/examples/notebook_massive_remnants.html +++ b/docs/build/html/examples/notebook_massive_remnants.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Example use case: Massive star luminosity — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Example use case: Massive star luminosity — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Example use case: Solar system using the API functionality" href="notebook_solar_system.html" /> <link rel="prev" title="Example use case: Binary black hole systems" href="notebook_BHBH.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -95,6 +51,7 @@ <li class="toctree-l2"><a class="reference internal" href="notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -118,70 +75,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Example use case: Massive star luminosity</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_massive_remnants.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -392,11 +310,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -405,10 +324,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -420,12 +343,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -452,21 +378,20 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Example-use-case:-Massive-star-luminosity"> -<h1>Example use case: Massive star luminosity<a class="headerlink" href="#Example-use-case:-Massive-star-luminosity" title="Permalink to this headline">¶</a></h1> +<section id="Example-use-case:-Massive-star-luminosity"> +<h1>Example use case: Massive star luminosity<a class="headerlink" href="#Example-use-case:-Massive-star-luminosity" title="Permalink to this heading">ïƒ</a></h1> <p>In this notebook we compute the luminosity function of the zero-age main-sequence by running a population of single stars using binary_c.</p> <p>We start by loading in some standard Python modules and the binary_c module.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">os</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span> <span class="kn">import</span> <span class="nn">math</span> <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">temp_dir</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="k">import</span> <span class="n">Population</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">temp_dir</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="kn">import</span> <span class="n">Population</span> <span class="n">TMP_DIR</span> <span class="o">=</span> <span class="n">temp_dir</span><span class="p">(</span><span class="s2">"notebooks"</span><span class="p">,</span> <span class="s2">"notebook_luminosity"</span><span class="p">)</span> @@ -474,16 +399,15 @@ div.rendered_html tbody tr:hover { </pre></div> </div> </div> -<div class="section" id="Setting-up-the-Population-object"> -<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this headline">¶</a></h2> +<section id="Setting-up-the-Population-object"> +<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this heading">ïƒ</a></h2> <p>To set up and configure the population object we need to make a new instance of the <code class="docutils literal notranslate"><span class="pre">Population</span></code> object and configure it with the <code class="docutils literal notranslate"><span class="pre">.set()</span></code> function.</p> <p>In our case, we only need to set the maximum evolution time to something short, because we care only about zero-age main sequence stars which have, by definition, age zero.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create population object</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create population object</span> <span class="n">population</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> <span class="c1"># If you want verbosity, set this before other things</span> @@ -514,9 +438,9 @@ adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_luminosity to gri verbosity is 1 </pre></div></div> </div> -</div> -<div class="section" id="Adding-grid-variables"> -<h2>Adding grid variables<a class="headerlink" href="#Adding-grid-variables" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Adding-grid-variables"> +<h2>Adding grid variables<a class="headerlink" href="#Adding-grid-variables" title="Permalink to this heading">ïƒ</a></h2> <p>The main purpose of the Population object is to handle the population synthesis side of running a set of stars. The main method to do this with binarycpython, as is the case with Perl binarygrid, is to use grid variables. These are loops over a predefined range of values, where a probability will be assigned to the systems based on the chosen probability distributions.</p> <p>Usually we use either 1 mass grid variable, or a trio of mass, mass ratio and period (other notebooks cover these examples). We can, however, also add grid sampling for e.g. eccentricity, metallicity or other parameters.</p> <p>To add a grid variable to the population object we use <code class="docutils literal notranslate"><span class="pre">population.add_grid_variable</span></code></p> @@ -524,8 +448,7 @@ verbosity is 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># help(population.add_grid_variable)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># help(population.add_grid_variable)</span> </pre></div> </div> </div> @@ -534,8 +457,7 @@ verbosity is 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">binarycpython.utils.distribution_functions</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">binarycpython.utils.distribution_functions</span> <span class="c1"># help(binarycpython.utils.distribution_functions)</span> </pre></div> </div> @@ -551,8 +473,7 @@ verbosity is 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Set resolution and mass range that we simulate</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Set resolution and mass range that we simulate</span> <span class="n">resolution</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"M_1"</span><span class="p">:</span> <span class="mi">40</span><span class="p">}</span> <span class="c1"># start with resolution = 10, and increase later if you want "more accurate" data</span> <span class="n">massrange</span> <span class="o">=</span> <span class="p">(</span><span class="mf">0.07</span><span class="p">,</span> <span class="mf">100.0</span><span class="p">)</span> <span class="c1"># we work with stars of mass 0.07 to 100 Msun</span> <span class="n">total_probability</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="c1"># theoretical integral of the mass probability density function over all masses</span> @@ -567,8 +488,7 @@ verbosity is 1 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Mass</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Mass</span> <span class="n">population</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">tmp_dir</span><span class="o">=</span><span class="n">TMP_DIR</span><span class="p">,</span> @@ -586,9 +506,9 @@ verbosity is 1 </pre></div> </div> </div> -</div> -<div class="section" id="Setting-logging-and-handling-the-output"> -<h2>Setting logging and handling the output<a class="headerlink" href="#Setting-logging-and-handling-the-output" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Setting-logging-and-handling-the-output"> +<h2>Setting logging and handling the output<a class="headerlink" href="#Setting-logging-and-handling-the-output" title="Permalink to this heading">ïƒ</a></h2> <p>By default, binary_c will not output anything (except for ‘SINGLE STAR LIFETIME’). It is up to us to determine what will be printed. We can either do that by hardcoding the print statements into <code class="docutils literal notranslate"><span class="pre">binary_c</span></code> (see documentation binary_c) or we can use the custom logging functionality of binarycpython (see notebook <code class="docutils literal notranslate"><span class="pre">notebook_custom_logging.ipynb</span></code>), which is faster to set up and requires no recompilation of binary_c, but is somewhat more limited in its functionality. For our current purposes, it works perfectly well.</p> <p>After configuring what will be printed, we need to make a function to parse the output. This can be done by setting the parse_function parameter in the population object (see also notebook <code class="docutils literal notranslate"><span class="pre">notebook_individual_systems.ipynb</span></code>).</p> @@ -597,8 +517,7 @@ works perfectly well.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create custom logging statement</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create custom logging statement</span> <span class="c1">#</span> <span class="c1"># we check that the model number is zero, i.e. we're on the first timestep (stars are born on the ZAMS)</span> <span class="c1"># we make sure that the stellar type is <= MAIN_SEQUENCE, i.e. the star is a main-sequence star</span> @@ -625,8 +544,7 @@ works perfectly well.</p> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">C_logging_code</span><span class="o">=</span><span class="n">custom_logging_statement</span> <span class="p">)</span> - -</pre></div> +<br/></pre></div> </div> </div> <p>The parse function must now catch lines that start with “ZERO_AGE_MAIN_SEQUENCE_STAR†and process the associated data.</p> @@ -634,10 +552,9 @@ works perfectly well.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[8]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># import the bin_data function so we can construct finite-resolution probability distributions</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># import the bin_data function so we can construct finite-resolution probability distributions</span> <span class="c1"># import the datalinedict to make a dictionary from each line of data from binary_c</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">bin_data</span><span class="p">,</span><span class="n">datalinedict</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">bin_data</span><span class="p">,</span><span class="n">datalinedict</span> <span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> <span class="sd">"""</span> @@ -674,9 +591,9 @@ works perfectly well.</p> </pre></div> </div> </div> -</div> -<div class="section" id="Evolving-the-grid"> -<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Evolving-the-grid"> +<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this heading">ïƒ</a></h2> <p>Now that we configured all the main parts of the population object, we can actually run the population! Doing this is straightforward: <code class="docutils literal notranslate"><span class="pre">population.evolve()</span></code></p> <p>This will start up the processing of all the systems. We can control how many cores are used by settings <code class="docutils literal notranslate"><span class="pre">num_cores</span></code>. By setting the <code class="docutils literal notranslate"><span class="pre">verbosity</span></code> of the population object to a higher value we can get a lot of verbose information about the run, but for now we will set it to 0.</p> <p>There are many grid_options that can lead to different behaviour of the evolution of the grid. Please do have a look at those: <a class="reference external" href="https://ri0005.pages.surrey.ac.uk/binary_c-python/grid_options_descriptions.html">grid options docs</a>, and try</p> @@ -684,8 +601,7 @@ works perfectly well.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[9]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># set number of threads</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># set number of threads</span> <span class="n">population</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="c1"># verbose output is not required</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> @@ -731,8 +647,7 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[10]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> </pre></div> </div> </div> @@ -748,11 +663,10 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[11]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># make a plot of the luminosity distribution using Seaborn and Pandas</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># make a plot of the luminosity distribution using Seaborn and Pandas</span> <span class="kn">import</span> <span class="nn">seaborn</span> <span class="k">as</span> <span class="nn">sns</span> <span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">pad_output_distribution</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">pad_output_distribution</span> <span class="c1"># set up seaborn for use in the notebook</span> <span class="n">sns</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">rc</span><span class="o">=</span><span class="p">{</span><span class="s1">'figure.figsize'</span><span class="p">:(</span><span class="mi">20</span><span class="p">,</span><span class="mi">10</span><span class="p">)})</span> @@ -796,16 +710,15 @@ There were no errors found in this run. </div> </div> <p>Does this look like a reasonable stellar luminosity function to you? The implication is that the most likely stellar luminosity is 105.8 L☉! Clearly, this is not very realistic… let’s see what went wrong.</p> -</div> -<div class="section" id="ZAMS-Luminosity-distribution-with-the-initial-mass-function"> -<h2>ZAMS Luminosity distribution with the initial mass function<a class="headerlink" href="#ZAMS-Luminosity-distribution-with-the-initial-mass-function" title="Permalink to this headline">¶</a></h2> +</section> +<section id="ZAMS-Luminosity-distribution-with-the-initial-mass-function"> +<h2>ZAMS Luminosity distribution with the initial mass function<a class="headerlink" href="#ZAMS-Luminosity-distribution-with-the-initial-mass-function" title="Permalink to this heading">ïƒ</a></h2> <p>In the previous example, all the stars in our grid had an equal weighting. This is very unlikely to be true in reality: indeed, we know that low mass stars are far more likely than high mass stars. So we now include an initial mass function as a three-part power law based on Kroupa (2001). Kroupa’s distribution is a three-part power law: we have a function that does this for us (it’s very common to use power laws in astrophysics).</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[12]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Update the probability distribution to use the three-part power law IMF</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Update the probability distribution to use the three-part power law IMF</span> <span class="n">population</span><span class="o">.</span><span class="n">update_grid_variable</span><span class="p">(</span> <span class="n">name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> <span class="n">probdist</span><span class="o">=</span><span class="s2">"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)"</span><span class="p">,</span> @@ -817,8 +730,7 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[13]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Clean and re-evolve the population</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Clean and re-evolve the population</span> <span class="n">population</span><span class="o">.</span><span class="n">clean</span><span class="p">()</span> <span class="n">analytics</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">evolve</span><span class="p">()</span> @@ -856,8 +768,7 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[14]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># plot luminosity distribution</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># plot luminosity distribution</span> <span class="n">ldist</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'luminosity distribution'</span><span class="p">]</span> <span class="c1"># pad the distribution with zeros where data is missing</span> @@ -894,17 +805,16 @@ There were no errors found in this run. <p>This distribution is peaked at low luminosity, as one expects from observations, but the resolution is clearly not great because it’s not smooth - it’s spiky!</p> <p>If you noticed above, the total probability of the grid was about 0.2. Given that the total probability of a probability distribution function should be 1.0, this shows that our sampling is (very) poor.</p> <p>We could simply increase the resolution to compensate, but this is very CPU intensive and a complete waste of time and resources. Instead, let’s try sampling the masses of the stars in a smarter way.</p> -</div> -<div class="section" id="A-better-sampled-grid"> -<h2>A better-sampled grid<a class="headerlink" href="#A-better-sampled-grid" title="Permalink to this headline">¶</a></h2> +</section> +<section id="A-better-sampled-grid"> +<h2>A better-sampled grid<a class="headerlink" href="#A-better-sampled-grid" title="Permalink to this heading">ïƒ</a></h2> <p>The IMF has many more low-mass stars than high-mass stars. So, instead of sampling M1 linearly, we can sample it in log space.</p> <p>To do this we first rename the mass grid variable so that it is clear we are working in (natural) logarithmic phase space.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[15]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Rename the old variable (M_1) because we want it to be called lnM_1 now</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Rename the old variable (M_1) because we want it to be called lnM_1 now</span> <span class="n">population</span><span class="o">.</span><span class="n">rename_grid_variable</span><span class="p">(</span><span class="s2">"M_1"</span><span class="p">,</span><span class="s2">"lnM_1"</span><span class="p">)</span> </pre></div> </div> @@ -914,8 +824,7 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[16]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># update the sampling, note that the IMF is dprob/dM1, and the phase</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># update the sampling, note that the IMF is dprob/dM1, and the phase</span> <span class="c1"># space is now sampled in lnM1, so we multiply by M_1 to</span> <span class="c1"># because M * dprob/dM = dprob/dlnM</span> <span class="n">population</span><span class="o">.</span><span class="n">update_grid_variable</span><span class="p">(</span> @@ -934,8 +843,7 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[17]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Clean and re-evolve the population</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Clean and re-evolve the population</span> <span class="n">population</span><span class="o">.</span><span class="n">clean</span><span class="p">()</span> <span class="n">analytics</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">evolve</span><span class="p">()</span> @@ -974,8 +882,7 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[18]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># plot luminosity distribution</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># plot luminosity distribution</span> <span class="n">ldist</span> <span class="o">=</span> <span class="n">population</span><span class="o">.</span><span class="n">grid_results</span><span class="p">[</span><span class="s1">'luminosity distribution'</span><span class="p">]</span> <span class="c1"># pad the distribution with zeros where data is missing</span> @@ -1017,67 +924,48 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> </pre></div> </div> </div> -</div> -</div> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_solar_system.html" class="btn btn-neutral float-right" title="Example use case: Solar system using the API functionality" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_BHBH.html" class="btn btn-neutral float-left" title="Example use case: Binary black hole systems" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_BHBH.html" class="btn btn-neutral float-left" title="Example use case: Binary black hole systems" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_solar_system.html" class="btn btn-neutral float-right" title="Example use case: Solar system using the API functionality" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_population.html b/docs/build/html/examples/notebook_population.html index 32d45c58300f393e2dd734db288f2016cc9d7f04..6df2341d54976ee3ff7965ec5c0b72ba0fa834f0 100644 --- a/docs/build/html/examples/notebook_population.html +++ b/docs/build/html/examples/notebook_population.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Tutorial: Running populations with binary_c-python — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Tutorial: Running populations with binary_c-python — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Tutorial: Extra features and functionality of binary_c-python" href="notebook_extra_features.html" /> <link rel="prev" title="Tutorial: Using custom logging routines with binary_c-python" href="notebook_custom_logging.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -98,11 +54,16 @@ <li class="toctree-l3"><a class="reference internal" href="#Setting-logging-and-handling-the-output">Setting logging and handling the output</a></li> <li class="toctree-l3"><a class="reference internal" href="#Evolving-the-grid">Evolving the grid</a></li> <li class="toctree-l3"><a class="reference internal" href="#Noteworthy-functionality">Noteworthy functionality</a></li> -<li class="toctree-l3"><a class="reference internal" href="#Full-examples-of-population-scripts">Full examples of population scripts</a></li> +<li class="toctree-l3"><a class="reference internal" href="#Full-examples-of-population-scripts">Full examples of population scripts</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#Single-star-population">Single star population</a></li> +<li class="toctree-l4"><a class="reference internal" href="#Binary-star-population">Binary star population</a></li> +</ul> +</li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -118,70 +79,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Tutorial: Running populations with binary_c-python</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_population.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -392,11 +314,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -405,10 +328,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -420,12 +347,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -452,8 +382,8 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Tutorial:-Running-populations-with-binary_c-python"> -<h1>Tutorial: Running populations with binary_c-python<a class="headerlink" href="#Tutorial:-Running-populations-with-binary_c-python" title="Permalink to this headline">¶</a></h1> +<section id="Tutorial:-Running-populations-with-binary_c-python"> +<h1>Tutorial: Running populations with binary_c-python<a class="headerlink" href="#Tutorial:-Running-populations-with-binary_c-python" title="Permalink to this heading">ïƒ</a></h1> <p>This notebook will show you how to evolve a population of stars</p> <p>Much of the code in the binarycpython package is written to evolve a population of stars through the Population object, rather than running a single system. Let’s go through the functionality of this object step by step and set up some example populations.</p> <p>At the bottom of this notebook there are some complete example scripts</p> @@ -461,11 +391,10 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">os</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="k">import</span> <span class="n">temp_dir</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.grid</span> <span class="k">import</span> <span class="n">Population</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="kn">import</span> <span class="n">temp_dir</span> +<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">Population</span> <span class="n">TMP_DIR</span> <span class="o">=</span> <span class="n">temp_dir</span><span class="p">(</span><span class="s2">"notebooks"</span><span class="p">,</span> <span class="s2">"notebook_population"</span><span class="p">)</span> @@ -473,8 +402,8 @@ div.rendered_html tbody tr:hover { </pre></div> </div> </div> -<div class="section" id="Setting-up-the-Population-object"> -<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this headline">¶</a></h2> +<section id="Setting-up-the-Population-object"> +<h2>Setting up the Population object<a class="headerlink" href="#Setting-up-the-Population-object" title="Permalink to this heading">ïƒ</a></h2> <p>To set up and configure the population object we need to make an object instance of the <code class="docutils literal notranslate"><span class="pre">Population</span></code> object, and add configuration via the <code class="docutils literal notranslate"><span class="pre">.set()</span></code> function.</p> <p>There are three categories of options that the Population object can set: - BSE options: these options will be used for the binary_c calls, and are recognized by comparing the arguments to a known list of available arguments of binary_c. To see which options are available, see section <code class="docutils literal notranslate"><span class="pre">`binary_c</span> <span class="pre">parameters</span></code> in the documentation <<a class="reference external" href="https://ri0005.pages.surrey.ac.uk/binary_c-python/binary_c_parameters.html">https://ri0005.pages.surrey.ac.uk/binary_c-python/binary_c_parameters.html</a>>`__. You can access these through <code class="docutils literal notranslate"><span class="pre">population.bse_options['<bse</span> <span class="pre">option</span> <span class="pre">name>']</span></code> after you have set them.</p> @@ -486,8 +415,7 @@ have set them.</p> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create population object</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create population object</span> <span class="n">example_pop</span> <span class="o">=</span> <span class="n">Population</span><span class="p">()</span> <span class="c1"># If you want verbosity, set this before other things</span> @@ -528,13 +456,9 @@ have set them.</p> </div> <div class="output_area docutils container"> <div class="highlight"><pre> -adding: M_1=10 to BSE_options -adding: orbital_period=45000000080 to BSE_options -adding: max_evolution_time=15000 to BSE_options -adding: eccentricity=0.02 to BSE_options adding: num_cores=2 to grid_options -adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population to grid_options -<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>> +adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_population to grid_options +<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result to custom_options >>>> <<<< Warning: Key does not match previously known parameter: adding: base_filename=example_pop.dat to custom_options >>>> 1 example_pop.dat @@ -554,8 +478,7 @@ example_pop.dat <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">example_pop</span><span class="o">.</span><span class="n">export_all_info</span><span class="p">()</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">example_pop</span><span class="o">.</span><span class="n">export_all_info</span><span class="p">()</span> </pre></div> </div> </div> @@ -564,7 +487,11 @@ example_pop.dat </div> <div class="output_area docutils container"> <div class="highlight"><pre> -Writing settings to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json +ok +File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it +ok +ok pre +ok ret </pre></div></div> </div> <div class="nboutput nblast docutils container"> @@ -573,12 +500,12 @@ Writing settings to /tmp/binary_c_python-izzard/notebooks/notebook_population/ex </div> <div class="output_area docutils container"> <div class="highlight"><pre> -'/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json' +'/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz' </pre></div></div> </div> -</div> -<div class="section" id="Adding-grid-variables"> -<h2>Adding grid variables<a class="headerlink" href="#Adding-grid-variables" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Adding-grid-variables"> +<h2>Adding grid variables<a class="headerlink" href="#Adding-grid-variables" title="Permalink to this heading">ïƒ</a></h2> <p>The main purpose of the Population object is to handle the population synthesis side of running a set of stars. The main method to do this with binarycpython, as is the case with Perl binarygrid, is to use grid variables. These are loops over a predefined range of values, where a probability will be assigned to the systems based on the chosen probability distributions.</p> <p>Usually we use either 1 mass grid variable, or a trio of mass, mass ratio and period (See below for full examples of all of these). We can, however, also add grid sampling for e.g. eccentricity, metallicity or other parameters.</p> <p>In some cases it could be easier to set up a for loop that sets that parameter and calls the evolve function several times, e.g. when you want to vary a prescription (usually a discrete, unweighted parameter)</p> @@ -588,8 +515,7 @@ Writing settings to /tmp/binary_c_python-izzard/notebooks/notebook_population/ex <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">help</span><span class="p">(</span><span class="n">example_pop</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">help</span><span class="p">(</span><span class="n">example_pop</span><span class="o">.</span><span class="n">add_grid_variable</span><span class="p">)</span> </pre></div> </div> </div> @@ -598,9 +524,9 @@ Writing settings to /tmp/binary_c_python-izzard/notebooks/notebook_population/ex </div> <div class="output_area docutils container"> <div class="highlight"><pre> -Help on method add_grid_variable in module binarycpython.utils.grid: +Help on method add_grid_variable in module binarycpython.utils.population_extensions.gridcode: -add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int], gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None) -> None method of binarycpython.utils.grid.Population instance +add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int] = -1, gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None, index: Optional[int] = None, dry_parallel: Optional[bool] = False) -> None method of binarycpython.utils.grid.Population instance Function to add grid variables to the grid_options. The execution of the grid generation will be through a nested for loop. @@ -611,17 +537,15 @@ add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Uni beware that if you insert some destructive piece of code, it will be executed anyway. Use at own risk. - Tasks: - - TODO: Fix this complex function. - Args: name: name of parameter used in the grid Python code. This is evaluated as a parameter and you can use it throughout the rest of the function - Examples: - name = 'lnm1' + Examples:: + + name = 'lnM_1' parameter_name: name of the parameter in binary_c @@ -636,47 +560,66 @@ add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Uni longname: Long name of parameter - Examples: + Examples:: + longname = 'Primary mass' + range: Range of values to take. Does not get used really, the samplerfunc is used to get the values from - Examples: + Examples:: + range = [math.log(m_min), math.log(m_max)] + samplerfunc: Function returning a list or numpy array of samples spaced appropriately. You can either use a real function, or a string representation of a function call. - Examples: - samplerfunc = "const(math.log(m_min), math.log(m_max), {})".format(resolution['M_1']) + Examples:: + + samplerfunc = "self.const_linear(math.log(m_min), math.log(m_max), {})".format(resolution['M_1']) precode: Extra room for some code. This code will be evaluated within the loop of the - sampling function (i.e. a value for lnm1 is chosen already) + sampling function (i.e. a value for lnM_1 is chosen already) + + Examples:: + + precode = 'M_1=math.exp(lnM_1);' - Examples: - precode = 'M_1=math.exp(lnm1);' postcode: Code executed after the probability is calculated. + probdist: Function determining the probability that gets assigned to the sampled parameter - Examples: - probdist = 'Kroupa2001(M_1)*M_1' + Examples:: + + probdist = 'self.Kroupa2001(M_1)*M_1' + dphasevol: part of the parameter space that the total probability is calculated with. Put to -1 if you want to ignore any dphasevol calculations and set the value to 1 - Examples: - dphasevol = 'dlnm1' + + Examples:: + + dphasevol = 'dlnM_1' + condition: condition that has to be met in order for the grid generation to continue - Examples: - condition = 'self.grid_options['binary']==1' + + Examples:: + + condition = "self.grid_options['binary']==1" + gridtype: Method on how the value range is sampled. Can be either 'edge' (steps starting at the lower edge of the value range) or 'centred' - (steps starting at lower edge + 0.5 * stepsize). + (steps starting at ``lower edge + 0.5 * stepsize``). + + dry_parallel: + If True, try to parallelize this variable in dry runs. topcode: Code added at the very top of the block. @@ -691,19 +634,17 @@ add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Uni <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># import binarycpython.utils.distribution_functions</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># import binarycpython.utils.distribution_functions</span> <span class="c1"># help(binarycpython.utils.distribution_functions)</span> </pre></div> </div> </div> <p>The next cell contains an example of adding the mass grid variable, but sampling in log mass. The commented grid variables are examples of the mass ratio sampling and the period sampling.</p> -<div class="nbinput docutils container"> +<div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Add grid variables</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Add grid variables</span> <span class="n">resolution</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"M_1"</span><span class="p">:</span> <span class="mi">20</span><span class="p">}</span> <span class="c1"># Mass</span> @@ -711,9 +652,9 @@ add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Uni <span class="n">name</span><span class="o">=</span><span class="s2">"lnm1"</span><span class="p">,</span> <span class="n">longname</span><span class="o">=</span><span class="s2">"Primary mass"</span><span class="p">,</span> <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">150</span><span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"const(math.log(2), math.log(150), </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_linear(math.log(2), math.log(150), </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> <span class="n">precode</span><span class="o">=</span><span class="s2">"M_1=math.exp(lnm1)"</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="s2">"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="s2">"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1"</span><span class="p">,</span> <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dlnm1"</span><span class="p">,</span> <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> <span class="n">condition</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="c1"># Impose a condition on this grid variable. Mostly for a check for yourself</span> @@ -724,8 +665,8 @@ add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Uni <span class="c1"># name="q",</span> <span class="c1"># longname="Mass ratio",</span> <span class="c1"># valuerange=["0.1/M_1", 1],</span> -<span class="c1"># samplerfunc="const(0.1/M_1, 1, {})".format(resolution['q']),</span> -<span class="c1"># probdist="flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])",</span> +<span class="c1"># samplerfunc="self.const_linear(0.1/M_1, 1, {})".format(resolution['q']),</span> +<span class="c1"># probdist="self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])",</span> <span class="c1"># dphasevol="dq",</span> <span class="c1"># precode="M_2 = q * M_1",</span> <span class="c1"># parameter_name="M_2",</span> @@ -737,50 +678,21 @@ add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Uni <span class="c1"># name="log10per", # in days</span> <span class="c1"># longname="log10(Orbital_Period)",</span> <span class="c1"># valuerange=[0.15, 5.5],</span> -<span class="c1"># samplerfunc="const(0.15, 5.5, {})".format(resolution["per"]),</span> +<span class="c1"># samplerfunc="self.const_linear(0.15, 5.5, {})".format(resolution["per"]),</span> <span class="c1"># precode="""orbital_period = 10** log10per</span> <span class="c1"># sep = calc_sep_from_period(M_1, M_2, orbital_period)</span> <span class="c1"># sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)</span> <span class="c1"># sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)""",</span> -<span class="c1"># probdist="sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)",</span> +<span class="c1"># probdist="self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)",</span> <span class="c1"># parameter_name="orbital_period",</span> <span class="c1"># dphasevol="dlog10per",</span> <span class="c1"># )</span> - -</pre></div> -</div> +<br/></pre></div> </div> -<div class="nboutput nblast docutils container"> -<div class="prompt empty docutils container"> </div> -<div class="output_area docutils container"> -<div class="highlight"><pre> -Added grid variable: { - "name": "lnm1", - "parameter_name": "M_1", - "longname": "Primary mass", - "valuerange": [ - 2, - 150 - ], - "samplerfunc": "const(math.log(2), math.log(150), 20)", - "precode": "M_1=math.exp(lnm1)", - "postcode": null, - "probdist": "three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1", - "dphasevol": "dlnm1", - "condition": "", - "gridtype": "centred", - "branchpoint": 0, - "branchcode": null, - "topcode": null, - "bottomcode": null, - "grid_variable_number": 0 -} -</pre></div></div> -</div> -</div> -<div class="section" id="Setting-logging-and-handling-the-output"> -<h2>Setting logging and handling the output<a class="headerlink" href="#Setting-logging-and-handling-the-output" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Setting-logging-and-handling-the-output"> +<h2>Setting logging and handling the output<a class="headerlink" href="#Setting-logging-and-handling-the-output" title="Permalink to this heading">ïƒ</a></h2> <p>On default, binary_c will not output anything (except for ‘SINGLE STAR LIFETIME’). It is up to us to determine what will be printed. We can either do that by hardcoding the print statements into <code class="docutils literal notranslate"><span class="pre">binary_c</span></code> (see documentation binary_c). Or, we can use the custom logging functionality of binarycpython (see notebook <code class="docutils literal notranslate"><span class="pre">notebook_custom_logging.ipynb</span></code>), which is faster to set up and requires no recompilation of binary_c, but is somewhat more limited in its functionality.</p> <p>After configuring what will be printed, we need to make a function to parse the output. This can be done by setting the parse_function parameter in the population object (see also notebook <code class="docutils literal notranslate"><span class="pre">notebook_individual_systems.ipynb</span></code>).</p> <p>In the code below we will set up both the custom logging, and a parse function to handle that output</p> @@ -788,9 +700,8 @@ Added grid variable: { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># Create custom logging statement: in this case we will log when the star turns into a compact object, and then terminate the evolution.</span> -<span class="n">custom_logging_statement</span> <span class="o">=</span> <span class="s2">"""</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create custom logging statement: in this case we will log when the star turns into a compact object, and then terminate the evolution.</span> +<span class="n">custom_logging_code</span> <span class="o">=</span> <span class="s2">"""</span> <span class="s2">if(stardata->star[0].stellar_type >= 13)</span> <span class="s2">{</span> <span class="s2"> if (stardata->model.time < stardata->model.max_evolution_time)</span> @@ -810,7 +721,7 @@ Added grid variable: { <span class="s2">"""</span> <span class="n">example_pop</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> - <span class="n">C_logging_code</span><span class="o">=</span><span class="n">custom_logging_statement</span> + <span class="n">C_logging_code</span><span class="o">=</span><span class="n">custom_logging_code</span> <span class="p">)</span> </pre></div> </div> @@ -845,8 +756,7 @@ if(stardata->star[0].stellar_type >= 13) <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[8]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Example parse function</span> <span class="sd"> """</span> @@ -897,12 +807,12 @@ if(stardata->star[0].stellar_type >= 13) </div> <div class="output_area docutils container"> <div class="highlight"><pre> -adding: parse_function=<function parse_function at 0x1528ac7290d0> to grid_options +adding: parse_function=<function parse_function at 0x7f2b6ca163a0> to grid_options </pre></div></div> </div> -</div> -<div class="section" id="Evolving-the-grid"> -<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Evolving-the-grid"> +<h2>Evolving the grid<a class="headerlink" href="#Evolving-the-grid" title="Permalink to this heading">ïƒ</a></h2> <p>Now that we configured all the main parts of the population object, we can actually run the population! Doing this is straightforward: <code class="docutils literal notranslate"><span class="pre">example_pop.evolve()</span></code></p> <p>This will start up the processing of all the systems. We can control how many cores are used by settings <code class="docutils literal notranslate"><span class="pre">num_cores</span></code>. By setting the <code class="docutils literal notranslate"><span class="pre">verbosity</span></code> of the population object to a higher value we can get a lot of verbose information about the run, but for now we will set it to 0.</p> <p>There are many grid_options that can lead to different behaviour of the evolution of the grid. Please do have a look at those: <a class="reference external" href="https://ri0005.pages.surrey.ac.uk/binary_c-python/grid_options_descriptions.html">grid options docs</a>, and try</p> @@ -910,8 +820,7 @@ adding: parse_function=<function parse_function at 0x1528ac7290d0> to grid <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[9]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># change verbosity</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># change verbosity</span> <span class="n">example_pop</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> <span class="c1">## Executing a population</span> @@ -926,38 +835,41 @@ adding: parse_function=<function parse_function at 0x1528ac7290d0> to grid <div class="output_area docutils container"> <div class="highlight"><pre> adding: verbosity=0 to grid_options +Do dry run? True Doing dry run to calculate total starcount and probability -Generating grid code -Grid has handled 20 stars with a total probability of 0.0444029 -************************************** -* Total starcount for this run is 20 * -* Total probability is 0.0444029 * -************************************** - -Generating grid code -EXAMPLE_COMPACT_OBJECT 4.139293101586e+01 1.29427 8.13626 0.00202467 13 -EXAMPLE_COMPACT_OBJECT 2.802986496151e+01 1.33699 10.0967 0.00152924 13 -EXAMPLE_COMPACT_OBJECT 1.963621764679e+01 1.39754 12.5294 0.00115504 13 -EXAMPLE_COMPACT_OBJECT 1.427601421985e+01 1.47745 15.5483 0.000872405 13 -EXAMPLE_COMPACT_OBJECT 1.094409257247e+01 1.57571 19.2947 0.00065893 13 -EXAMPLE_COMPACT_OBJECT 9.181971798545e+00 1.68748 23.9436 0.000497691 13 -EXAMPLE_COMPACT_OBJECT 7.905335716621e+00 1.77287 29.7128 0.000375908 13 -EXAMPLE_COMPACT_OBJECT 7.451192744924e+00 1.81495 36.872 0.000283924 13 -EXAMPLE_COMPACT_OBJECT 7.396133472739e+00 1.82088 45.7561 0.000214449 13 -EXAMPLE_COMPACT_OBJECT 7.396675941641e+00 1.82123 56.7809 0.000161974 13 -EXAMPLE_COMPACT_OBJECT 7.404641347602e+00 1.82074 70.4621 0.000122339 13 -EXAMPLE_COMPACT_OBJECT 7.444217227690e+00 1.81636 87.4397 9.2403e-05 13 -EXAMPLE_COMPACT_OBJECT 7.453317880232e+00 1.81536 108.508 6.97923e-05 13 -EXAMPLE_COMPACT_OBJECT 7.450828476487e+00 1.81563 134.653 5.27143e-05 13 +Grid has handled 19 stars with a total probability of 0.0443872 +********************************** +* Dry run * +* Total starcount is 19 * +* Total probability is 0.0443872 * +********************************** + +EXAMPLE_COMPACT_OBJECT 3.598268106227e+01 1.30592 8.75988 0.00193614 13 +EXAMPLE_COMPACT_OBJECT 2.436983545111e+01 1.35842 10.9948 0.00144093 13 +EXAMPLE_COMPACT_OBJECT 1.690157944401e+01 1.43124 13.7998 0.00107238 13 +EXAMPLE_COMPACT_OBJECT 1.242397939068e+01 1.52416 17.3205 0.000798096 13 +EXAMPLE_COMPACT_OBJECT 9.756794139032e+00 1.66914 21.7394 0.000593966 13 +EXAMPLE_COMPACT_OBJECT 8.401414766976e+00 1.73729 27.2857 0.000442046 13 +EXAMPLE_COMPACT_OBJECT 7.536373523810e+00 1.80677 34.247 0.000328983 13 +EXAMPLE_COMPACT_OBJECT 7.393982410080e+00 1.82164 42.9844 0.000244839 13 +EXAMPLE_COMPACT_OBJECT 7.396470605248e+00 1.82129 53.9508 0.000182216 13 +Do join of subprocesses ... +EXAMPLE_COMPACT_OBJECT 7.399005684057e+00 1.82041 67.7151 0.00013561 13 +EXAMPLE_COMPACT_OBJECT 7.443375325717e+00 1.81645 84.9909 0.000100925 13 +EXAMPLE_COMPACT_OBJECT 7.451195752942e+00 1.81559 106.674 7.51114e-05 13 +EXAMPLE_COMPACT_OBJECT 7.452661646076e+00 1.81543 133.89 5.59e-05 13 +Joined subprocesses. ********************************************************** -* Population-50fb66cc659c46c8bbc29fe0c8651c2f finished! * -* The total probability is 0.0444029. * -* It took a total of 3.30s to run 20 systems on 2 cores * -* = 6.60s of CPU time. * -* Maximum memory use 433.070 MB * +* Population-ce756bb317f64099a459bf8b55a746ac finished! * +* The total probability is 0.0443872. * +* It took a total of 0.73s to run 19 systems on 2 cores * +* = 1.46s of CPU time. * +* Maximum memory use 293.406 MB * ********************************************************** -There were no errors found in this run. +No failed systems were found in this run. +Do analytics +Added analytics to metadata </pre></div></div> </div> <p>After the run is complete, some technical report on the run is returned. I stored that in <code class="docutils literal notranslate"><span class="pre">analytics</span></code>. As we can see below, this dictionary is like a status report of the evolution. Useful for e.g. debugging.</p> @@ -965,8 +877,7 @@ There were no errors found in this run. <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[10]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">analytics</span><span class="p">)</span> </pre></div> </div> </div> @@ -975,19 +886,18 @@ There were no errors found in this run. </div> <div class="output_area docutils container"> <div class="highlight"><pre> -{'population_name': '50fb66cc659c46c8bbc29fe0c8651c2f', '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': 1635760967.3245144, 'end_timestamp': 1635760970.6249793, 'total_mass_run': 684.2544031669784, 'total_probability_weighted_mass_run': 0.28134439269236855, 'zero_prob_stars_skipped': 0} +{'population_id': 'ce756bb317f64099a459bf8b55a746ac', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.044387171445641534, 'total_count': 19, 'start_timestamp': 1646563001.7193637, 'end_timestamp': 1646563002.4480088, 'time_elapsed': 0.7286450862884521, 'total_mass_run': 649.905447944397, 'total_probability_weighted_mass_run': 0.28133908148630704, 'zero_prob_stars_skipped': 0} </pre></div></div> </div> -</div> -<div class="section" id="Noteworthy-functionality"> -<h2>Noteworthy functionality<a class="headerlink" href="#Noteworthy-functionality" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Noteworthy-functionality"> +<h2>Noteworthy functionality<a class="headerlink" href="#Noteworthy-functionality" title="Permalink to this heading">ïƒ</a></h2> <p>Some extra features that are available from via the population object are: - write_binary_c_calls_to_file: Function to write the calls that would be passed to binary_c to a file</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[11]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">help</span><span class="p">(</span><span class="n">example_pop</span><span class="o">.</span><span class="n">write_binary_c_calls_to_file</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">help</span><span class="p">(</span><span class="n">example_pop</span><span class="o">.</span><span class="n">write_binary_c_calls_to_file</span><span class="p">)</span> </pre></div> </div> </div> @@ -996,9 +906,9 @@ There were no errors found in this run. </div> <div class="output_area docutils container"> <div class="highlight"><pre> -Help on method write_binary_c_calls_to_file in module binarycpython.utils.grid: +Help on method write_binary_c_calls_to_file in module binarycpython.utils.population_extensions.dataIO: -write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False) -> None method of binarycpython.utils.grid.Population instance +write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False, encoding='utf-8') -> None method of binarycpython.utils.grid.Population instance Function that loops over the grid code and writes the generated parameters to a file. In the form of a command line call @@ -1009,10 +919,6 @@ write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: On default this will write to the datadir, if it exists - Tasks: - - TODO: test this function - - TODO: make sure the binary_c_python .. output file has a unique name - Args: output_dir: (optional, default = None) directory where to write the file to. If custom_options['data_dir'] is present, then that one will be used first, and then the output_dir output_filename: (optional, default = None) filename of the output. If not set it will be called "binary_c_calls.txt" @@ -1027,13 +933,13 @@ write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[12]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">example_pop</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">verbosity</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">example_pop</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">verbosity</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> <span class="n">calls_filename</span> <span class="o">=</span> <span class="n">example_pop</span><span class="o">.</span><span class="n">write_binary_c_calls_to_file</span><span class="p">()</span> <span class="nb">print</span><span class="p">(</span><span class="n">calls_filename</span><span class="p">)</span> <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">calls_filename</span><span class="p">,</span> <span class="s1">'r'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[:</span><span class="mi">4</span><span class="p">]))</span> +<span class="nb">print</span><span class="p">(</span><span class="s2">"(abridged)"</span><span class="p">)</span> </pre></div> </div> </div> @@ -1043,31 +949,32 @@ write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: <div class="output_area docutils container"> <div class="highlight"><pre> Generating grid code -Generating grid code -Saving grid code to grid_options -Writing grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py [dry_run = False] -Symlinked grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid-latest2 -Loading grid code function from /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py +Save grid code to grid_options +Write grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py [dry_run = False] +Symlinked grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid-latest2 +Load grid code function from /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py Grid code loaded -Writing binary_c calls to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt -Grid has handled 20 stars with a total probability of 0.0444029 -/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt -binary_c M_1 2.227955577093495 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681548 probability 0.010905083645619543 -binary_c M_1 2.7647737053496777 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.2158744056768156 probability 0.00823663875514986 -binary_c M_1 3.430936289925951 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681537 probability 0.0062211552141636295 -binary_c M_1 4.2576084265970895 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.2158744056768156 probability 0.004698855121516281 +Writing binary_c calls to /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt +Grid has handled 19 stars with a total probability of 0.0443872 +/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt +binary_c M_1 2.2406484012210224 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.011394572976608001 +binary_c M_1 2.812296769855663 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191117 probability 0.008480166685456411 +binary_c M_1 3.5297876799548944 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.006311182276049824 +binary_c M_1 4.430329401616038 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.004696962123378559 +(abridged) </pre></div></div> </div> -</div> -<div class="section" id="Full-examples-of-population-scripts"> -<h2>Full examples of population scripts<a class="headerlink" href="#Full-examples-of-population-scripts" title="Permalink to this headline">¶</a></h2> +</section> +<section id="Full-examples-of-population-scripts"> +<h2>Full examples of population scripts<a class="headerlink" href="#Full-examples-of-population-scripts" title="Permalink to this heading">ïƒ</a></h2> +<section id="Single-star-population"> +<h3>Single star population<a class="headerlink" href="#Single-star-population" title="Permalink to this heading">ïƒ</a></h3> <p>Below is a full setup for a population of single stars</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[13]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Example parsing function</span> <span class="sd"> """</span> @@ -1173,9 +1080,9 @@ binary_c M_1 4.2576084265970895 eccentricity 0.02 max_evolution_time 15000 orbit <span class="n">name</span><span class="o">=</span><span class="s2">"lnm1"</span><span class="p">,</span> <span class="n">longname</span><span class="o">=</span><span class="s2">"Primary mass"</span><span class="p">,</span> <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">150</span><span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"const(math.log(2), math.log(150), </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_linear(math.log(2), math.log(150), </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> <span class="n">precode</span><span class="o">=</span><span class="s2">"M_1=math.exp(lnm1)"</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="s2">"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="s2">"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1"</span><span class="p">,</span> <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dlnm1"</span><span class="p">,</span> <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> <span class="n">condition</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> @@ -1205,53 +1112,63 @@ binary_c M_1 4.2576084265970895 eccentricity 0.02 max_evolution_time 15000 orbit </div> <div class="output_area docutils container"> <div class="highlight"><pre> -<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>> +<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result to custom_options >>>> <<<< Warning: Key does not match previously known parameter: adding: base_filename=example_pop.dat to custom_options >>>> +ok +File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it +ok +ok pre +ok ret +Do dry run? True Doing dry run to calculate total starcount and probability -Generating grid code -Grid has handled 20 stars with a total probability of 0.0444029 -************************************** -* Total starcount for this run is 20 * -* Total probability is 0.0444029 * -************************************** - -Generating grid code +Grid has handled 19 stars with a total probability of 0.0443872 +********************************** +* Dry run * +* Total starcount is 19 * +* Total probability is 0.0443872 * +********************************** + +Do join of subprocesses ... +Joined subprocesses. ********************************************************** -* Population-05e51ba114934b37bab48f1db40b7333 finished! * -* The total probability is 0.0444029. * -* It took a total of 3.46s to run 20 systems on 2 cores * -* = 6.93s of CPU time. * -* Maximum memory use 437.047 MB * +* Population-0fa4c2b8707741a5ab41d209ef95a3a4 finished! * +* The total probability is 0.0443872. * +* It took a total of 0.61s to run 19 systems on 2 cores * +* = 1.23s of CPU time. * +* Maximum memory use 299.531 MB * ********************************************************** -There were no errors found in this run. +No failed systems were found in this run. +Do analytics +Added analytics to metadata time mass zams_mass probability radius stellar_type -4.139293101586e+01 1.29427 8.13626 0.00202467 1.72498e-05 13 -2.802986496151e+01 1.33699 10.0967 0.00152924 1.72498e-05 13 -1.963621764679e+01 1.39754 12.5294 0.00115504 1.72498e-05 13 -1.427601421985e+01 1.47745 15.5483 0.000872405 1.72498e-05 13 -1.094409257247e+01 1.57571 19.2947 0.00065893 1.72498e-05 13 -9.181971798545e+00 1.68748 23.9436 0.000497691 1.72498e-05 13 -7.905335716621e+00 1.77287 29.7128 0.000375908 1.72498e-05 13 -7.451192744924e+00 1.81495 36.872 0.000283924 1.72498e-05 13 -7.396133472739e+00 1.82088 45.7561 0.000214449 1.72498e-05 13 -7.396675941641e+00 1.82123 56.7809 0.000161974 1.72498e-05 13 -7.404641347602e+00 1.82074 70.4621 0.000122339 1.72498e-05 13 -7.444217227690e+00 1.81636 87.4397 9.2403e-05 1.72498e-05 13 -7.453317880232e+00 1.81536 108.508 6.97923e-05 1.72498e-05 13 -7.450828476487e+00 1.81563 134.653 5.27143e-05 1.72498e-05 13 +3.598268106227e+01 1.30592 8.75988 0.00193614 1.72498e-05 13 +2.436983545111e+01 1.35842 10.9948 0.00144093 1.72498e-05 13 +1.690157944401e+01 1.43124 13.7998 0.00107238 1.72498e-05 13 +1.242397939068e+01 1.52416 17.3205 0.000798096 1.72498e-05 13 +9.756794139032e+00 1.66914 21.7394 0.000593966 1.72498e-05 13 +8.401414766976e+00 1.73729 27.2857 0.000442046 1.72498e-05 13 +7.536373523810e+00 1.80677 34.247 0.000328983 1.72498e-05 13 +7.393982410080e+00 1.82164 42.9844 0.000244839 1.72498e-05 13 +7.396470605248e+00 1.82129 53.9508 0.000182216 1.72498e-05 13 +7.399005684057e+00 1.82041 67.7151 0.00013561 1.72498e-05 13 +7.451195752942e+00 1.81559 106.674 7.51114e-05 1.72498e-05 13 +7.443375325717e+00 1.81645 84.9909 0.000100925 1.72498e-05 13 +7.452661646076e+00 1.81543 133.89 5.59e-05 1.72498e-05 13 </pre></div></div> </div> -<p>We can also set up a population that samples biinary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded top be more useful</p> +</section> +<section id="Binary-star-population"> +<h3>Binary star population<a class="headerlink" href="#Binary-star-population" title="Permalink to this heading">ïƒ</a></h3> +<p>We can also set up a population that samples binary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded to be more useful. Also note that we run very little systems in the following example, as its just intended to show how the code works.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[14]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">parse_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Example parsing function</span> <span class="sd"> """</span> @@ -1375,9 +1292,9 @@ time mass zams_mass probability radius stellar_type <span class="n">name</span><span class="o">=</span><span class="s2">"lnm1"</span><span class="p">,</span> <span class="n">longname</span><span class="o">=</span><span class="s2">"Primary mass"</span><span class="p">,</span> <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">150</span><span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"const(math.log(2), math.log(150), </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_linear(math.log(2), math.log(150), </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s2">"M_1"</span><span class="p">]),</span> <span class="n">precode</span><span class="o">=</span><span class="s2">"M_1=math.exp(lnm1)"</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="s2">"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="s2">"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1"</span><span class="p">,</span> <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dlnm1"</span><span class="p">,</span> <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_1"</span><span class="p">,</span> <span class="n">condition</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="c1"># Impose a condition on this grid variable. Mostly for a check for yourself</span> @@ -1388,8 +1305,8 @@ time mass zams_mass probability radius stellar_type <span class="n">name</span><span class="o">=</span><span class="s2">"q"</span><span class="p">,</span> <span class="n">longname</span><span class="o">=</span><span class="s2">"Mass ratio"</span><span class="p">,</span> <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span><span class="s2">"0.1/M_1"</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"const(0.1/M_1, 1, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s1">'q'</span><span class="p">]),</span> - <span class="n">probdist</span><span class="o">=</span><span class="s2">"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])"</span><span class="p">,</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_linear(0.1/M_1, 1, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s1">'q'</span><span class="p">]),</span> + <span class="n">probdist</span><span class="o">=</span><span class="s2">"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])"</span><span class="p">,</span> <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dq"</span><span class="p">,</span> <span class="n">precode</span><span class="o">=</span><span class="s2">"M_2 = q * M_1"</span><span class="p">,</span> <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"M_2"</span><span class="p">,</span> @@ -1401,12 +1318,12 @@ time mass zams_mass probability radius stellar_type <span class="n">name</span><span class="o">=</span><span class="s2">"log10per"</span><span class="p">,</span> <span class="c1"># in days</span> <span class="n">longname</span><span class="o">=</span><span class="s2">"log10(Orbital_Period)"</span><span class="p">,</span> <span class="n">valuerange</span><span class="o">=</span><span class="p">[</span><span class="mf">0.15</span><span class="p">,</span> <span class="mf">5.5</span><span class="p">],</span> - <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"const(0.15, 5.5, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s2">"per"</span><span class="p">]),</span> + <span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_linear(0.15, 5.5, </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s2">"per"</span><span class="p">]),</span> <span class="n">precode</span><span class="o">=</span><span class="s2">"""orbital_period = 10** log10per</span> <span class="s2">sep = calc_sep_from_period(M_1, M_2, orbital_period)</span> <span class="s2">sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)</span> <span class="s2">sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)"""</span><span class="p">,</span> - <span class="n">probdist</span><span class="o">=</span><span class="s2">"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)"</span><span class="p">,</span> + <span class="n">probdist</span><span class="o">=</span><span class="s2">"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)"</span><span class="p">,</span> <span class="n">parameter_name</span><span class="o">=</span><span class="s2">"orbital_period"</span><span class="p">,</span> <span class="n">dphasevol</span><span class="o">=</span><span class="s2">"dlog10per"</span><span class="p">,</span> <span class="p">)</span> @@ -1434,104 +1351,84 @@ time mass zams_mass probability radius stellar_type </div> <div class="output_area docutils container"> <div class="highlight"><pre> -<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>> +<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result to custom_options >>>> <<<< Warning: Key does not match previously known parameter: adding: base_filename=example_pop.dat to custom_options >>>> +ok +File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it +ok +ok pre +ok ret +Do dry run? True Doing dry run to calculate total starcount and probability -Generating grid code -Grid has handled 27 stars with a total probability of 0.0248684 -************************************** -* Total starcount for this run is 27 * -* Total probability is 0.0248684 * -************************************** - -Generating grid code +Grid has handled 8 stars with a total probability of 0.0211592 +********************************** +* Dry run * +* Total starcount is 8 * +* Total probability is 0.0211592 * +********************************** + +Do join of subprocesses ... +Joined subprocesses. ********************************************************** -* Population-8bc1eafea1c34b05894c1618639d8c37 finished! * -* The total probability is 0.0248684. * -* It took a total of 16.10s to run 27 systems on 2 cores * -* = 32.20s of CPU time. * -* Maximum memory use 437.695 MB * +* Population-0eb5c0c9abd34607a6ee060b26a7e32f finished! * +* The total probability is 0.0211592. * +* It took a total of 0.84s to run 8 systems on 2 cores * +* = 1.68s of CPU time. * +* Maximum memory use 300.125 MB * ********************************************************** -There were no errors found in this run. +No failed systems were found in this run. +Do analytics +Added analytics to metadata 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 -1.219029061236e+01 1.60007 17.3205 0 2.97008 13 5 15 15 0.02 0.000498487 -1.935920339886e+01 1.29448 17.3205 0 8.71025 13 13 15 2 0.02 0.000498487 -2.123794969278e+01 1.30902 17.3205 1.58518 8.71025 13 13 13 5 0.02 0.000287968 -3.579099761269e+01 1.52414 17.3205 1.30642 8.71025 13 13 13 5 0.02 0.000220016 -1.674063083432e+01 1.29457 17.3205 0 14.4504 13 13 15 2 0.02 0.000498487 -1.548740826516e+01 1.52415 17.3205 1.45407 14.4504 13 13 13 5 0.02 0.000220016 -1.779197348711e+01 1.3228 17.3205 1.71196 14.4504 13 13 13 8 0.02 0.000287968 -1.367065497322e+01 1.66003 73.0434 1.79487 12.2572 13 13 13 8 0.02 7.67586e-05 -1.772169325355e+01 1.81957 73.0434 1.46573 12.2572 13 13 13 5 0.02 4.43422e-05 -2.021960493499e+01 1.82061 73.0434 1.39205 12.2572 13 13 13 5 0.02 3.38788e-05 -9.012246630357e+00 1.81529 73.0434 0 36.5717 13 8 15 15 0.02 7.67586e-05 -7.462779538274e+00 1.82255 73.0434 1.81499 36.5717 13 13 13 8 0.02 3.38788e-05 -1.030499912298e+01 1.80592 73.0434 1.81066 36.5717 13 13 13 8 0.02 4.43422e-05 -9.823059079115e+00 2.43711 73.0434 1.81689 60.8862 14 14 13 8 0.02 7.67586e-05 -7.394722435913e+00 1.79092 73.0434 1.79092 60.8862 13 8 13 8 0.02 4.43422e-05 -7.396288708628e+00 1.8216 73.0434 1.8216 60.8862 13 8 13 8 0.02 3.38788e-05 +1.378266748188e+01 1.66293 50.9713 1.78767 12.8178 13 13 13 8 0.02 0.000339963 +1.817608462595e+01 1.82104 50.9713 1.41436 12.8178 13 13 13 5 0.02 0.000193036 +7.422997711686e+00 1.82479 50.9713 1.82171 38.2535 13 13 13 8 0.02 0.000193036 +1.205711924468e+01 1.73765 50.9713 0 38.2535 13 13 15 8 0.02 0.000339963 </pre></div></div> </div> -</div> -</div> +</section> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="notebook_extra_features.html" class="btn btn-neutral float-right" title="Tutorial: Extra features and functionality of binary_c-python" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_custom_logging.html" class="btn btn-neutral float-left" title="Tutorial: Using custom logging routines with binary_c-python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_custom_logging.html" class="btn btn-neutral float-left" title="Tutorial: Using custom logging routines with binary_c-python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="notebook_extra_features.html" class="btn btn-neutral float-right" title="Tutorial: Extra features and functionality of binary_c-python" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/notebook_population.ipynb b/docs/build/html/examples/notebook_population.ipynb index 760b1480e9f9bdcc508ced177f8f0d806cfb53eb..ebc19cff04f8dd9e8e2fe6694fa9b0346425afe9 100644 --- a/docs/build/html/examples/notebook_population.ipynb +++ b/docs/build/html/examples/notebook_population.ipynb @@ -25,7 +25,7 @@ "import os\n", "\n", "from binarycpython.utils.custom_logging_functions import temp_dir\n", - "from binarycpython.utils.grid import Population\n", + "from binarycpython import Population\n", "\n", "TMP_DIR = temp_dir(\"notebooks\", \"notebook_population\")\n", "\n", @@ -58,13 +58,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: M_1=10 to BSE_options\n", - "adding: orbital_period=45000000080 to BSE_options\n", - "adding: max_evolution_time=15000 to BSE_options\n", - "adding: eccentricity=0.02 to BSE_options\n", "adding: num_cores=2 to grid_options\n", - "adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_population to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", @@ -139,13 +135,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "Writing settings to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json\n" + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n" ] }, { "data": { "text/plain": [ - "'/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json'" + "'/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz'" ] }, "execution_count": 3, @@ -185,9 +185,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on method add_grid_variable in module binarycpython.utils.grid:\n", + "Help on method add_grid_variable in module binarycpython.utils.population_extensions.gridcode:\n", "\n", - "add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int], gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None) -> None method of binarycpython.utils.grid.Population instance\n", + "add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int] = -1, gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None, index: Optional[int] = None, dry_parallel: Optional[bool] = False) -> 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", @@ -198,17 +198,15 @@ " beware that if you insert some destructive piece of code, it will be executed anyway.\n", " Use at own risk.\n", " \n", - " Tasks:\n", - " - TODO: Fix this complex function.\n", - " \n", " Args:\n", " name:\n", " name of parameter used in the grid Python code.\n", " This is evaluated as a parameter and you can use it throughout\n", " the rest of the function\n", " \n", - " Examples:\n", - " name = 'lnm1'\n", + " Examples::\n", + " \n", + " name = 'lnM_1'\n", " \n", " parameter_name:\n", " name of the parameter in binary_c\n", @@ -223,47 +221,66 @@ " longname:\n", " Long name of parameter\n", " \n", - " Examples:\n", + " Examples::\n", + " \n", " longname = 'Primary mass'\n", + " \n", " range:\n", " Range of values to take. Does not get used really, the samplerfunc is used to\n", " get the values from\n", " \n", - " Examples:\n", + " Examples::\n", + " \n", " range = [math.log(m_min), math.log(m_max)]\n", + " \n", " samplerfunc:\n", " Function returning a list or numpy array of samples spaced appropriately.\n", " You can either use a real function, or a string representation of a function call.\n", " \n", - " Examples:\n", - " samplerfunc = \"const(math.log(m_min), math.log(m_max), {})\".format(resolution['M_1'])\n", + " Examples::\n", + " \n", + " samplerfunc = \"self.const_linear(math.log(m_min), math.log(m_max), {})\".format(resolution['M_1'])\n", " \n", " 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", + " sampling function (i.e. a value for lnM_1 is chosen already)\n", + " \n", + " Examples::\n", + " \n", + " precode = 'M_1=math.exp(lnM_1);'\n", " \n", - " Examples:\n", - " precode = 'M_1=math.exp(lnm1);'\n", " postcode:\n", " Code executed after the probability is calculated.\n", + " \n", " probdist:\n", " Function determining the probability that gets assigned to the sampled parameter\n", " \n", - " Examples:\n", - " probdist = 'Kroupa2001(M_1)*M_1'\n", + " Examples::\n", + " \n", + " probdist = 'self.Kroupa2001(M_1)*M_1'\n", + " \n", " dphasevol:\n", " part of the parameter space that the total probability is calculated with. Put to -1\n", " if you want to ignore any dphasevol calculations and set the value to 1\n", - " Examples:\n", - " dphasevol = 'dlnm1'\n", + " \n", + " Examples::\n", + " \n", + " dphasevol = 'dlnM_1'\n", + " \n", " condition:\n", " condition that has to be met in order for the grid generation to continue\n", - " Examples:\n", - " condition = 'self.grid_options['binary']==1'\n", + " \n", + " Examples::\n", + " \n", + " condition = \"self.grid_options['binary']==1\"\n", + " \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 'centred'\n", - " (steps starting at lower edge + 0.5 * stepsize).\n", + " (steps starting at ``lower edge + 0.5 * stepsize``).\n", + " \n", + " dry_parallel:\n", + " If True, try to parallelize this variable in dry runs.\n", " \n", " topcode:\n", " Code added at the very top of the block.\n", @@ -313,35 +330,7 @@ "execution_count": 6, "id": "47979841-2c26-4b26-8945-603d013dc93a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Added grid variable: {\n", - " \"name\": \"lnm1\",\n", - " \"parameter_name\": \"M_1\",\n", - " \"longname\": \"Primary mass\",\n", - " \"valuerange\": [\n", - " 2,\n", - " 150\n", - " ],\n", - " \"samplerfunc\": \"const(math.log(2), math.log(150), 20)\",\n", - " \"precode\": \"M_1=math.exp(lnm1)\",\n", - " \"postcode\": null,\n", - " \"probdist\": \"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", - " \"dphasevol\": \"dlnm1\",\n", - " \"condition\": \"\",\n", - " \"gridtype\": \"centred\",\n", - " \"branchpoint\": 0,\n", - " \"branchcode\": null,\n", - " \"topcode\": null,\n", - " \"bottomcode\": null,\n", - " \"grid_variable_number\": 0\n", - "}\n" - ] - } - ], + "outputs": [], "source": [ "# Add grid variables\n", "resolution = {\"M_1\": 20}\n", @@ -351,9 +340,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -364,8 +353,8 @@ "# name=\"q\",\n", "# longname=\"Mass ratio\",\n", "# valuerange=[\"0.1/M_1\", 1],\n", - "# samplerfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n", - "# probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", + "# samplerfunc=\"self.const_linear(0.1/M_1, 1, {})\".format(resolution['q']),\n", + "# probdist=\"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", "# dphasevol=\"dq\",\n", "# precode=\"M_2 = q * M_1\",\n", "# parameter_name=\"M_2\",\n", @@ -377,12 +366,12 @@ "# name=\"log10per\", # in days\n", "# longname=\"log10(Orbital_Period)\",\n", "# valuerange=[0.15, 5.5],\n", - "# samplerfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", + "# samplerfunc=\"self.const_linear(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", "# precode=\"\"\"orbital_period = 10** log10per\n", "# sep = calc_sep_from_period(M_1, M_2, orbital_period)\n", "# sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n", "# sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n", - "# probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", + "# probdist=\"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", "# parameter_name=\"orbital_period\",\n", "# dphasevol=\"dlog10per\",\n", "# )\n" @@ -434,7 +423,7 @@ ], "source": [ "# Create custom logging statement: in this case we will log when the star turns into a compact object, and then terminate the evolution.\n", - "custom_logging_statement = \"\"\"\n", + "custom_logging_code = \"\"\"\n", "if(stardata->star[0].stellar_type >= 13) \n", "{\n", " if (stardata->model.time < stardata->model.max_evolution_time)\n", @@ -454,7 +443,7 @@ "\"\"\"\n", "\n", "example_pop.set(\n", - " C_logging_code=custom_logging_statement\n", + " C_logging_code=custom_logging_code\n", ")" ] }, @@ -476,7 +465,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function parse_function at 0x1528ac7290d0> to grid_options\n" + "adding: parse_function=<function parse_function at 0x7f2b6ca163a0> to grid_options\n" ] } ], @@ -552,38 +541,41 @@ "output_type": "stream", "text": [ "adding: verbosity=0 to grid_options\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "**************************************\n", - "* Total starcount for this run is 20 *\n", - "* Total probability is 0.0444029 *\n", - "**************************************\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 19 *\n", + "* Total probability is 0.0443872 *\n", + "**********************************\n", "\n", - "Generating grid code\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.450828476487e+00 1.81563 134.653 5.27143e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 3.598268106227e+01 1.30592 8.75988 0.00193614 13\n", + "EXAMPLE_COMPACT_OBJECT 2.436983545111e+01 1.35842 10.9948 0.00144093 13\n", + "EXAMPLE_COMPACT_OBJECT 1.690157944401e+01 1.43124 13.7998 0.00107238 13\n", + "EXAMPLE_COMPACT_OBJECT 1.242397939068e+01 1.52416 17.3205 0.000798096 13\n", + "EXAMPLE_COMPACT_OBJECT 9.756794139032e+00 1.66914 21.7394 0.000593966 13\n", + "EXAMPLE_COMPACT_OBJECT 8.401414766976e+00 1.73729 27.2857 0.000442046 13\n", + "EXAMPLE_COMPACT_OBJECT 7.536373523810e+00 1.80677 34.247 0.000328983 13\n", + "EXAMPLE_COMPACT_OBJECT 7.393982410080e+00 1.82164 42.9844 0.000244839 13\n", + "EXAMPLE_COMPACT_OBJECT 7.396470605248e+00 1.82129 53.9508 0.000182216 13\n", + "Do join of subprocesses ...\n", + "EXAMPLE_COMPACT_OBJECT 7.399005684057e+00 1.82041 67.7151 0.00013561 13\n", + "EXAMPLE_COMPACT_OBJECT 7.443375325717e+00 1.81645 84.9909 0.000100925 13\n", + "EXAMPLE_COMPACT_OBJECT 7.451195752942e+00 1.81559 106.674 7.51114e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 7.452661646076e+00 1.81543 133.89 5.59e-05 13\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-50fb66cc659c46c8bbc29fe0c8651c2f finished! *\n", - "* The total probability is 0.0444029. *\n", - "* It took a total of 3.30s to run 20 systems on 2 cores *\n", - "* = 6.60s of CPU time. *\n", - "* Maximum memory use 433.070 MB *\n", + "* Population-ce756bb317f64099a459bf8b55a746ac finished! *\n", + "* The total probability is 0.0443872. *\n", + "* It took a total of 0.73s to run 19 systems on 2 cores *\n", + "* = 1.46s of CPU time. *\n", + "* Maximum memory use 293.406 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n" + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" ] } ], @@ -614,7 +606,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'population_name': '50fb66cc659c46c8bbc29fe0c8651c2f', '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': 1635760967.3245144, 'end_timestamp': 1635760970.6249793, 'total_mass_run': 684.2544031669784, 'total_probability_weighted_mass_run': 0.28134439269236855, 'zero_prob_stars_skipped': 0}\n" + "{'population_id': 'ce756bb317f64099a459bf8b55a746ac', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.044387171445641534, 'total_count': 19, 'start_timestamp': 1646563001.7193637, 'end_timestamp': 1646563002.4480088, 'time_elapsed': 0.7286450862884521, 'total_mass_run': 649.905447944397, 'total_probability_weighted_mass_run': 0.28133908148630704, 'zero_prob_stars_skipped': 0}\n" ] } ], @@ -642,9 +634,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on method write_binary_c_calls_to_file in module binarycpython.utils.grid:\n", + "Help on method write_binary_c_calls_to_file in module binarycpython.utils.population_extensions.dataIO:\n", "\n", - "write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False) -> None method of binarycpython.utils.grid.Population instance\n", + "write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False, encoding='utf-8') -> None method of binarycpython.utils.grid.Population instance\n", " Function that loops over the grid code and writes the generated parameters to a file.\n", " In the form of a command line call\n", " \n", @@ -655,10 +647,6 @@ " \n", " On default this will write to the datadir, if it exists\n", " \n", - " Tasks:\n", - " - TODO: test this function\n", - " - TODO: make sure the binary_c_python .. output file has a unique name\n", - " \n", " Args:\n", " output_dir: (optional, default = None) directory where to write the file to. If custom_options['data_dir'] is present, then that one will be used first, and then the output_dir\n", " output_filename: (optional, default = None) filename of the output. If not set it will be called \"binary_c_calls.txt\"\n", @@ -685,19 +673,19 @@ "output_type": "stream", "text": [ "Generating grid code\n", - "Generating grid code\n", - "Saving grid code to grid_options\n", - "Writing grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py [dry_run = False]\n", - "Symlinked grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid-latest2 \n", - "Loading grid code function from /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py\n", + "Save grid code to grid_options\n", + "Write grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py [dry_run = False]\n", + "Symlinked grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid-latest2 \n", + "Load grid code function from /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py\n", "Grid code loaded\n", - "Writing binary_c calls to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "/tmp/binary_c_python-izzard/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.2158744056768156 probability 0.00823663875514986\n", - "binary_c M_1 3.430936289925951 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681537 probability 0.0062211552141636295\n", - "binary_c M_1 4.2576084265970895 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.2158744056768156 probability 0.004698855121516281\n" + "Writing binary_c calls to /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "binary_c M_1 2.2406484012210224 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.011394572976608001\n", + "binary_c M_1 2.812296769855663 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191117 probability 0.008480166685456411\n", + "binary_c M_1 3.5297876799548944 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.006311182276049824\n", + "binary_c M_1 4.430329401616038 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.004696962123378559\n", + "(abridged)\n" ] } ], @@ -707,7 +695,8 @@ "print(calls_filename)\n", "\n", "with open(calls_filename, 'r') as f:\n", - " print('\\n'.join(f.read().splitlines()[:4]))" + " print('\\n'.join(f.read().splitlines()[:4]))\n", + "print(\"(abridged)\")" ] }, { @@ -715,7 +704,15 @@ "id": "60359eb1-4d0c-4d2d-8265-ec5171b944a2", "metadata": {}, "source": [ - "## Full examples of population scripts\n", + "## Full examples of population scripts" + ] + }, + { + "cell_type": "markdown", + "id": "1ee279d6-e120-4aef-9e57-845e534f5c6a", + "metadata": {}, + "source": [ + "### Single star population\n", "Below is a full setup for a population of single stars" ] }, @@ -729,43 +726,51 @@ "name": "stdout", "output_type": "stream", "text": [ - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "**************************************\n", - "* Total starcount for this run is 20 *\n", - "* Total probability is 0.0444029 *\n", - "**************************************\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 19 *\n", + "* Total probability is 0.0443872 *\n", + "**********************************\n", "\n", - "Generating grid code\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-05e51ba114934b37bab48f1db40b7333 finished! *\n", - "* The total probability is 0.0444029. *\n", - "* It took a total of 3.46s to run 20 systems on 2 cores *\n", - "* = 6.93s of CPU time. *\n", - "* Maximum memory use 437.047 MB *\n", + "* Population-0fa4c2b8707741a5ab41d209ef95a3a4 finished! *\n", + "* The total probability is 0.0443872. *\n", + "* It took a total of 0.61s to run 19 systems on 2 cores *\n", + "* = 1.23s of CPU time. *\n", + "* Maximum memory use 299.531 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n", "\n", "\n", "time mass zams_mass probability radius stellar_type\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.450828476487e+00 1.81563 134.653 5.27143e-05 1.72498e-05 13\n", + "3.598268106227e+01 1.30592 8.75988 0.00193614 1.72498e-05 13\n", + "2.436983545111e+01 1.35842 10.9948 0.00144093 1.72498e-05 13\n", + "1.690157944401e+01 1.43124 13.7998 0.00107238 1.72498e-05 13\n", + "1.242397939068e+01 1.52416 17.3205 0.000798096 1.72498e-05 13\n", + "9.756794139032e+00 1.66914 21.7394 0.000593966 1.72498e-05 13\n", + "8.401414766976e+00 1.73729 27.2857 0.000442046 1.72498e-05 13\n", + "7.536373523810e+00 1.80677 34.247 0.000328983 1.72498e-05 13\n", + "7.393982410080e+00 1.82164 42.9844 0.000244839 1.72498e-05 13\n", + "7.396470605248e+00 1.82129 53.9508 0.000182216 1.72498e-05 13\n", + "7.399005684057e+00 1.82041 67.7151 0.00013561 1.72498e-05 13\n", + "7.451195752942e+00 1.81559 106.674 7.51114e-05 1.72498e-05 13\n", + "7.443375325717e+00 1.81645 84.9909 0.000100925 1.72498e-05 13\n", + "7.452661646076e+00 1.81543 133.89 5.59e-05 1.72498e-05 13\n", "\n" ] } @@ -877,9 +882,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\",\n", @@ -908,7 +913,8 @@ "id": "c2ab0979-6575-481d-9c1c-ca98517b2437", "metadata": {}, "source": [ - "We can also set up a population that samples biinary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded top be more useful" + "### Binary star population\n", + "We can also set up a population that samples binary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded to be more useful. Also note that we run very little systems in the following example, as its just intended to show how the code works." ] }, { @@ -921,45 +927,42 @@ "name": "stdout", "output_type": "stream", "text": [ - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 27 stars with a total probability of 0.0248684\n", - "**************************************\n", - "* Total starcount for this run is 27 *\n", - "* Total probability is 0.0248684 *\n", - "**************************************\n", + "Grid has handled 8 stars with a total probability of 0.0211592\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 8 *\n", + "* Total probability is 0.0211592 *\n", + "**********************************\n", "\n", - "Generating grid code\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-8bc1eafea1c34b05894c1618639d8c37 finished! *\n", - "* The total probability is 0.0248684. *\n", - "* It took a total of 16.10s to run 27 systems on 2 cores *\n", - "* = 32.20s of CPU time. *\n", - "* Maximum memory use 437.695 MB *\n", + "* Population-0eb5c0c9abd34607a6ee060b26a7e32f finished! *\n", + "* The total probability is 0.0211592. *\n", + "* It took a total of 0.84s to run 8 systems on 2 cores *\n", + "* = 1.68s of CPU time. *\n", + "* Maximum memory use 300.125 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\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", - "1.219029061236e+01 1.60007 17.3205 0 2.97008 13 5 15 15 0.02 0.000498487\n", - "1.935920339886e+01 1.29448 17.3205 0 8.71025 13 13 15 2 0.02 0.000498487\n", - "2.123794969278e+01 1.30902 17.3205 1.58518 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.548740826516e+01 1.52415 17.3205 1.45407 14.4504 13 13 13 5 0.02 0.000220016\n", - "1.779197348711e+01 1.3228 17.3205 1.71196 14.4504 13 13 13 8 0.02 0.000287968\n", - "1.367065497322e+01 1.66003 73.0434 1.79487 12.2572 13 13 13 8 0.02 7.67586e-05\n", - "1.772169325355e+01 1.81957 73.0434 1.46573 12.2572 13 13 13 5 0.02 4.43422e-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", - "9.823059079115e+00 2.43711 73.0434 1.81689 60.8862 14 14 13 8 0.02 7.67586e-05\n", - "7.394722435913e+00 1.79092 73.0434 1.79092 60.8862 13 8 13 8 0.02 4.43422e-05\n", - "7.396288708628e+00 1.8216 73.0434 1.8216 60.8862 13 8 13 8 0.02 3.38788e-05\n", + "1.378266748188e+01 1.66293 50.9713 1.78767 12.8178 13 13 13 8 0.02 0.000339963\n", + "1.817608462595e+01 1.82104 50.9713 1.41436 12.8178 13 13 13 5 0.02 0.000193036\n", + "7.422997711686e+00 1.82479 50.9713 1.82171 38.2535 13 13 13 8 0.02 0.000193036\n", + "1.205711924468e+01 1.73765 50.9713 0 38.2535 13 13 15 8 0.02 0.000339963\n", "\n" ] } @@ -1089,9 +1092,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -1102,8 +1105,8 @@ " name=\"q\",\n", " longname=\"Mass ratio\",\n", " valuerange=[\"0.1/M_1\", 1],\n", - " samplerfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n", - " probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", + " samplerfunc=\"self.const_linear(0.1/M_1, 1, {})\".format(resolution['q']),\n", + " probdist=\"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", " dphasevol=\"dq\",\n", " precode=\"M_2 = q * M_1\",\n", " parameter_name=\"M_2\",\n", @@ -1115,12 +1118,12 @@ " name=\"log10per\", # in days\n", " longname=\"log10(Orbital_Period)\",\n", " valuerange=[0.15, 5.5],\n", - " samplerfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", + " samplerfunc=\"self.const_linear(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", " precode=\"\"\"orbital_period = 10** log10per\n", "sep = calc_sep_from_period(M_1, M_2, orbital_period)\n", "sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n", "sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n", - " probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", + " probdist=\"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", " parameter_name=\"orbital_period\",\n", " dphasevol=\"dlog10per\",\n", ")\n", @@ -1145,7 +1148,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1159,7 +1162,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/examples/notebook_solar_system.html b/docs/build/html/examples/notebook_solar_system.html index 630c4b35aae9794c57a9b45bbcd30bd3201bfa46..36ea37b5f8063d1d45656742b71d6cc9f163306d 100644 --- a/docs/build/html/examples/notebook_solar_system.html +++ b/docs/build/html/examples/notebook_solar_system.html @@ -1,72 +1,38 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Example use case: Solar system using the API functionality — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Example use case: Solar system using the API functionality — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Binary_c parameters" href="../binary_c_parameters.html" /> <link rel="prev" title="Example use case: Massive star luminosity" href="notebook_massive_remnants.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -74,17 +40,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> @@ -95,6 +51,7 @@ <li class="toctree-l2"><a class="reference internal" href="notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -110,70 +67,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../index.html">Docs</a> »</li> - + <li><a href="../index.html" class="icon icon-home"></a> »</li> <li><a href="../example_notebooks.html">Example notebooks</a> »</li> - <li>Example use case: Solar system using the API functionality</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../_sources/examples/notebook_solar_system.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -384,11 +302,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -397,10 +316,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -412,12 +335,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -444,18 +370,17 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Example-use-case:-Solar-system-using-the-API-functionality"> -<h1>Example use case: Solar system using the API functionality<a class="headerlink" href="#Example-use-case:-Solar-system-using-the-API-functionality" title="Permalink to this headline">¶</a></h1> +<section id="Example-use-case:-Solar-system-using-the-API-functionality"> +<h1>Example use case: Solar system using the API functionality<a class="headerlink" href="#Example-use-case:-Solar-system-using-the-API-functionality" title="Permalink to this heading">ïƒ</a></h1> <p>We use the API interface to construct a model of the Solar system.</p> <p>First we must construct the argument string that we pass to binary_c</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">os</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">temp_dir</span> -<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="k">import</span> <span class="n">_binary_c_bindings</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">temp_dir</span> +<span class="kn">from</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="n">_binary_c_bindings</span> <span class="n">TMP_DIR</span> <span class="o">=</span> <span class="n">temp_dir</span><span class="p">(</span><span class="s2">"notebooks"</span><span class="p">,</span> <span class="s2">"notebook_solar_system"</span><span class="p">)</span> <span class="n">M_1</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="c1"># Msun</span> @@ -498,8 +423,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[13]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">re</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">re</span> <span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> <span class="kn">import</span> <span class="nn">math</span> <span class="c1">#pd.set_option("display.max_rows", None, "display.max_columns", None)</span> @@ -544,8 +468,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[11]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">dataframes</span> <span class="o">=</span> <span class="p">{}</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">dataframes</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">for</span> <span class="n">planet</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span> <span class="n">dataframes</span><span class="p">[</span><span class="n">planet</span><span class="p">]</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">planet</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">float</span><span class="p">,</span> <span class="c1"># required! argh!</span> @@ -569,9 +492,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[12]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> - -<span></span><span class="kn">import</span> <span class="nn">seaborn</span> <span class="k">as</span> <span class="nn">sns</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><br/><span></span><span class="kn">import</span> <span class="nn">seaborn</span> <span class="k">as</span> <span class="nn">sns</span> <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> <span class="c1"># set up seaborn for use in the notebook</span> @@ -626,9 +547,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> - -<span></span><span class="kn">import</span> <span class="nn">seaborn</span> <span class="k">as</span> <span class="nn">sns</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><br/><span></span><span class="kn">import</span> <span class="nn">seaborn</span> <span class="k">as</span> <span class="nn">sns</span> <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> <span class="c1"># set up seaborn for use in the notebook</span> @@ -677,61 +596,43 @@ div.rendered_html tbody tr:hover { </div> </div> <p>It gets a little toasty on Earth in the not too distant future!</p> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="../binary_c_parameters.html" class="btn btn-neutral float-right" title="Binary_c parameters" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="notebook_massive_remnants.html" class="btn btn-neutral float-left" title="Example use case: Massive star luminosity" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="notebook_massive_remnants.html" class="btn btn-neutral float-left" title="Example use case: Massive star luminosity" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="../binary_c_parameters.html" class="btn btn-neutral float-right" title="Binary_c parameters" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/old/basic_example.html b/docs/build/html/examples/old/basic_example.html index 0f6c96d692e6e1ef34c8625f4a4016499a86b152..4c264a96504223eeb224e30177e494c2cd65ad2d 100644 --- a/docs/build/html/examples/old/basic_example.html +++ b/docs/build/html/examples/old/basic_example.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title><no title> — binary_c-python documentation</title> - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Basic example — binary_c-python documentation</title> + <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - <script type="text/javascript" src="../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script> <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script> <script src="../../_static/jquery.js"></script> <script src="../../_static/underscore.js"></script> + <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../../_static/js/theme.js"></script> <link rel="index" title="Index" href="../../genindex.html" /> <link rel="search" title="Search" href="../../search.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,17 +38,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="../../readme_link.html">Python module for binary_c</a></li> @@ -94,68 +50,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../../index.html">Docs</a> »</li> - - <li><no title></li> - - + <li><a href="../../index.html" class="icon icon-home"></a> »</li> + <li>Basic example</li> <li class="wy-breadcrumbs-aside"> - - <a href="../../_sources/examples/old/basic_example.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -366,11 +284,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -379,10 +298,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -394,12 +317,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -426,18 +352,20 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> +<section id="Basic-example"> +<h1>Basic example<a class="headerlink" href="#Basic-example" title="Permalink to this heading">ïƒ</a></h1> +<p>Running a single system</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> <span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> <span class="kn">import</span> <span class="nn">binarycpython</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="k">import</span> <span class="n">binary_c_log_code</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.run_system_wrapper</span> <span class="k">import</span> <span class="n">run_system</span> -<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">example_parse_output</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="kn">import</span> <span class="n">binary_c_log_code</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.run_system_wrapper</span> <span class="kn">import</span> <span class="n">run_system</span> +<span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">example_parse_output</span> </pre></div> </div> </div> @@ -445,8 +373,7 @@ div.rendered_html tbody tr:hover { <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[10]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="c1"># You can decide to `write` your own logging_line, which allows you to write a more complex logging statement with conditionals.</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># You can decide to `write` your own logging_line, which allows you to write a more complex logging statement with conditionals.</span> <span class="n">logging_line</span> <span class="o">=</span> <span class="s1">'Printf("MY_STELLAR_DATA time=</span><span class="si">%g</span><span class="s1"> radius=</span><span class="si">%g</span><span class="se">\\</span><span class="s1">n",stardata->model.time,stardata->star[0].radius)'</span> <span class="c1"># Generate entire shared lib code around logging lines</span> @@ -478,15 +405,14 @@ div.rendered_html tbody tr:hover { <div class="prompt empty docutils container"> </div> <div class="output_area docutils container"> -<img alt="../../_images/examples_old_basic_example_1_1.png" src="../../_images/examples_old_basic_example_1_1.png" /> +<img alt="../../_images/examples_old_basic_example_2_1.png" src="../../_images/examples_old_basic_example_2_1.png" /> </div> </div> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> </pre></div> </div> </div> @@ -503,63 +429,51 @@ div.rendered_html tbody tr:hover { <div class="prompt empty docutils container"> </div> <div class="output_area docutils container"> -<img alt="../../_images/examples_old_basic_example_2_1.png" src="../../_images/examples_old_basic_example_2_1.png" /> +<img alt="../../_images/examples_old_basic_example_3_1.png" src="../../_images/examples_old_basic_example_3_1.png" /> </div> </div> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> </pre></div> </div> </div> +</section> </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/old/basic_example.ipynb b/docs/build/html/examples/old/basic_example.ipynb index 9078cfcb5fdcd35336ee3675accb3f810c21e5fe..7146b97671caad9e82ce7454511dcad2aa416a78 100644 --- a/docs/build/html/examples/old/basic_example.ipynb +++ b/docs/build/html/examples/old/basic_example.ipynb @@ -1,5 +1,14 @@ { "cells": [ + { + "cell_type": "markdown", + "id": "c09b9f85-5250-4fd2-8142-bb8097d138b5", + "metadata": {}, + "source": [ + "# Basic example\n", + "Running a single system" + ] + }, { "cell_type": "code", "execution_count": 1, @@ -106,7 +115,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -120,7 +129,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/examples/old/workshop_example_notebook.html b/docs/build/html/examples/old/workshop_example_notebook.html index f0612dad41d9082fa003d82842476012617a42eb..4722e7dc6aad83d22d32e10e39f75389f0a5faec 100644 --- a/docs/build/html/examples/old/workshop_example_notebook.html +++ b/docs/build/html/examples/old/workshop_example_notebook.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Binary_c and python example notebook — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Binary_c and python example notebook — binary_c-python documentation</title> + <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../../_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="../../_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script> <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script> <script src="../../_static/jquery.js"></script> <script src="../../_static/underscore.js"></script> + <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script> - - <script type="text/javascript" src="../../_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> + <script src="../../_static/js/theme.js"></script> <link rel="index" title="Index" href="../../genindex.html" /> <link rel="search" title="Search" href="../../search.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="../../index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,17 +38,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="../../readme_link.html">Python module for binary_c</a></li> @@ -94,68 +50,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../../index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="../../index.html">Docs</a> »</li> - + <li><a href="../../index.html" class="icon icon-home"></a> »</li> <li>Binary_c and python example notebook</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="../../_sources/examples/old/workshop_example_notebook.ipynb.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS for nbsphinx extension */ @@ -366,11 +284,12 @@ div.nboutput.container div.output_area > div[class^='highlight']{ } /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */ -.prompt a.copybtn { +.prompt .copybtn { display: none; } /* Some additional styling taken form the Jupyter notebook CSS */ +.jp-RenderedHTMLCommon table, div.rendered_html table { border: none; border-collapse: collapse; @@ -379,10 +298,14 @@ div.rendered_html table { font-size: 12px; table-layout: fixed; } +.jp-RenderedHTMLCommon thead, div.rendered_html thead { border-bottom: 1px solid black; vertical-align: bottom; } +.jp-RenderedHTMLCommon tr, +.jp-RenderedHTMLCommon th, +.jp-RenderedHTMLCommon td, div.rendered_html tr, div.rendered_html th, div.rendered_html td { @@ -394,12 +317,15 @@ div.rendered_html td { max-width: none; border: none; } +.jp-RenderedHTMLCommon th, div.rendered_html th { font-weight: bold; } +.jp-RenderedHTMLCommon tbody tr:nth-child(odd), div.rendered_html tbody tr:nth-child(odd) { background: #f5f5f5; } +.jp-RenderedHTMLCommon tbody tr:hover, div.rendered_html tbody tr:hover { background: rgba(66, 165, 245, 0.2); } @@ -426,30 +352,28 @@ div.rendered_html tbody tr:hover { text-align: unset; } </style> -<div class="section" id="Binary_c-and-python-example-notebook"> -<h1>Binary_c and python example notebook<a class="headerlink" href="#Binary_c-and-python-example-notebook" title="Permalink to this headline">¶</a></h1> +<section id="Binary_c-and-python-example-notebook"> +<h1>Binary_c and python example notebook<a class="headerlink" href="#Binary_c-and-python-example-notebook" title="Permalink to this heading">ïƒ</a></h1> <p>The following notebook servers as an example of how the binary_c python wrapper works and how it could be used.</p> <p>By: David Hendriks 30 nov 2019</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[16]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">binarycpython</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">binarycpython</span> <span class="kn">import</span> <span class="nn">binary_c_python_api</span> </pre></div> </div> </div> -<div class="section" id="Core-api-wrapper-functions:"> -<h2>Core api wrapper functions:<a class="headerlink" href="#Core-api-wrapper-functions:" title="Permalink to this headline">¶</a></h2> -<div class="section" id="run_binary()"> -<h3>run_binary()<a class="headerlink" href="#run_binary()" title="Permalink to this headline">¶</a></h3> +<section id="Core-api-wrapper-functions:"> +<h2>Core api wrapper functions:<a class="headerlink" href="#Core-api-wrapper-functions:" title="Permalink to this heading">ïƒ</a></h2> +<section id="run_binary()"> +<h3>run_binary()<a class="headerlink" href="#run_binary()" title="Permalink to this heading">ïƒ</a></h3> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[17]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="n">m1</span> <span class="o">=</span> <span class="mf">15.0</span> <span class="c1"># Msun</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">m1</span> <span class="o">=</span> <span class="mf">15.0</span> <span class="c1"># Msun</span> <span class="n">m2</span> <span class="o">=</span> <span class="mf">14.0</span> <span class="c1"># Msun</span> <span class="n">separation</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># 0 = ignored, use period</span> <span class="n">orbital_period</span> <span class="o">=</span> <span class="mf">4530.0</span> <span class="c1"># days</span> @@ -496,15 +420,14 @@ example_header_1 time=2e-07 mass_1=15 mass_2=14 st1=1 st2=1 sep=3540.3 ecc=0 example_header_2 2e-07 15 14 1 1 3540.3 0 </pre></div></div> </div> -</div> -<div class="section" id="run_binary_with_log"> -<h3>run_binary_with_log<a class="headerlink" href="#run_binary_with_log" title="Permalink to this headline">¶</a></h3> +</section> +<section id="run_binary_with_log"> +<h3>run_binary_with_log<a class="headerlink" href="#run_binary_with_log" title="Permalink to this heading">ïƒ</a></h3> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[18]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">tempfile</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">tempfile</span> <span class="kn">import</span> <span class="nn">os</span> <span class="n">m1</span> <span class="o">=</span> <span class="mf">15.0</span> <span class="c1"># Msun</span> @@ -571,15 +494,14 @@ Probability : 1 </pre></div></div> </div> -</div> -<div class="section" id="run-binary-with-custom-logging-line"> -<h3>run binary with custom logging line<a class="headerlink" href="#run-binary-with-custom-logging-line" title="Permalink to this headline">¶</a></h3> +</section> +<section id="run-binary-with-custom-logging-line"> +<h3>run binary with custom logging line<a class="headerlink" href="#run-binary-with-custom-logging-line" title="Permalink to this heading">ïƒ</a></h3> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[19]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython.utils</span> <span class="k">import</span> <span class="n">custom_logging_functions</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython.utils</span> <span class="kn">import</span> <span class="n">custom_logging_functions</span> <span class="c1"># generate logging lines. Here you can choose whatever you want to have logged, and with what header</span> <span class="c1"># this generates working print statements</span> <span class="n">logging_line</span> <span class="o">=</span> <span class="n">custom_logging_functions</span><span class="o">.</span><span class="n">autogen_C_logging_code</span><span class="p">(</span> @@ -647,13 +569,13 @@ example_header_2 4e-07 15 14 1 1 3540.3 0 MY_STELLAR_DATA time=4e-07 mass=15 </pre></div></div> </div> -</div> -</div> -<div class="section" id="Using-utils-functions"> -<h2>Using utils functions<a class="headerlink" href="#Using-utils-functions" title="Permalink to this headline">¶</a></h2> +</section> +</section> +<section id="Using-utils-functions"> +<h2>Using utils functions<a class="headerlink" href="#Using-utils-functions" title="Permalink to this heading">ïƒ</a></h2> <p>In the utils.functions there are some functions that make it easier to interact with the core api functions.</p> -<div class="section" id="run_system()"> -<h3>run_system()<a class="headerlink" href="#run_system()" title="Permalink to this headline">¶</a></h3> +<section id="run_system()"> +<h3>run_system()<a class="headerlink" href="#run_system()" title="Permalink to this heading">ïƒ</a></h3> <p>This function serves as an example on the function run_system and parse_output. There is more functionality with this method and several tasks are done behind the scene.</p> <p>Requires pandas, numpy to run.</p> <p>run_system: mostly just makes passing arguments to the function easier. It also loads all the necessary defaults in the background parse_output: Takes the raw output of binary_c and selects those lines that start with the given header. Note, if you dont use the custom_logging functionality binary_c should be configured to have output that starts with that given header</p> @@ -662,8 +584,7 @@ MY_STELLAR_DATA time=4e-07 mass=15 <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[20]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="k">import</span> <span class="n">run_system</span><span class="p">,</span> <span class="n">parse_output</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.functions</span> <span class="kn">import</span> <span class="n">run_system</span><span class="p">,</span> <span class="n">parse_output</span> <span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> <span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> @@ -692,8 +613,7 @@ MY_STELLAR_DATA time=4e-07 mass=15 <span class="n">df2</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">result_example_header_2</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">)</span> <span class="n">df2</span><span class="o">.</span><span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="s1">'time'</span><span class="p">,</span> <span class="s1">'mass_1'</span><span class="p">,</span> <span class="s1">'mass_2'</span><span class="p">,</span> <span class="s1">'st1'</span><span class="p">,</span> <span class="s1">'st2'</span><span class="p">,</span> <span class="s1">'sep'</span><span class="p">,</span> <span class="s1">'ecc'</span><span class="p">]</span> <span class="nb">print</span><span class="p">(</span><span class="n">df2</span><span class="p">)</span> - -</pre></div> +<br/></pre></div> </div> </div> <div class="nboutput nblast docutils container"> @@ -744,16 +664,15 @@ example_header_2 2e-07 10 20 1 1 2.81762e+08 0 [3932 rows x 7 columns] </pre></div></div> </div> -</div> -<div class="section" id="run_system()-and-custom-logging"> -<h3>run_system() and custom logging<a class="headerlink" href="#run_system()-and-custom-logging" title="Permalink to this headline">¶</a></h3> +</section> +<section id="run_system()-and-custom-logging"> +<h3>run_system() and custom logging<a class="headerlink" href="#run_system()-and-custom-logging" title="Permalink to this heading">ïƒ</a></h3> <p>Function that will use a automatically generated piece of logging code. Compile it, load it into memory and run a binary system. See run_system on how several things are done in the background here.</p> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[21]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="k">import</span> <span class="p">(</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">binarycpython.utils.custom_logging_functions</span> <span class="kn">import</span> <span class="p">(</span> <span class="n">autogen_C_logging_code</span><span class="p">,</span> <span class="n">binary_c_log_code</span><span class="p">,</span> <span class="p">)</span> @@ -816,17 +735,16 @@ example_header_2 2e-07 10 20 1 1 2.81762e+08 0 [3635 rows x 2 columns] </pre></div></div> </div> -</div> -</div> -<div class="section" id="Other-example"> -<h2>Other example<a class="headerlink" href="#Other-example" title="Permalink to this headline">¶</a></h2> +</section> +</section> +<section id="Other-example"> +<h2>Other example<a class="headerlink" href="#Other-example" title="Permalink to this heading">ïƒ</a></h2> <p>Checking how much mass stars lose on the main sequence.</p> <div class="nbinput nblast docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[12]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="k">def</span> <span class="nf">run_and_calc_mass</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">run_and_calc_mass</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Function to run a given system and look at the mass lost in the main sequence of the star</span> <span class="sd"> """</span> @@ -863,22 +781,20 @@ example_header_2 2e-07 10 20 1 1 2.81762e+08 0 <span class="c1"># Return the mass fraction (wrt initial mass)</span> <span class="k">return</span> <span class="n">fraction</span> - -</pre></div> +<br/></pre></div> </div> </div> <div class="nbinput docutils container"> <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[13]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">time</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">time</span> <span class="n">metallicity_002</span> <span class="o">=</span> <span class="mf">0.02</span> <span class="n">metallicity_001</span> <span class="o">=</span> <span class="mf">0.01</span> <span class="n">metallicity_0002</span> <span class="o">=</span> <span class="mf">0.002</span> -<span class="n">mass_range</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">25</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">)</span> +<span class="n">mass_range</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">25</span><span class="p">,</span> <span class="mf">.5</span><span class="p">)</span> <span class="n">start</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="n">fractions_z002</span> <span class="o">=</span> <span class="p">[</span><span class="n">run_and_calc_mass</span><span class="p">(</span><span class="n">M_1</span><span class="o">=</span><span class="n">mass</span><span class="p">,</span> @@ -921,8 +837,7 @@ Took 14.214274644851685s <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[22]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">nrows</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span><span class="mi">8</span><span class="p">))</span> @@ -951,58 +866,45 @@ Took 14.214274644851685s <div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]: </pre></div> </div> -<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre> -<span></span> +<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span> </pre></div> </div> </div> -</div> -</div> +</section> +</section> </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/examples/old/workshop_example_notebook.ipynb b/docs/build/html/examples/old/workshop_example_notebook.ipynb index 4eca5879779a9fec40521c733bda59768c8c4140..78d0860ad1dfc12104b4bb639055957d527c01e7 100644 --- a/docs/build/html/examples/old/workshop_example_notebook.ipynb +++ b/docs/build/html/examples/old/workshop_example_notebook.ipynb @@ -619,7 +619,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -633,7 +633,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/build/html/functions.html b/docs/build/html/functions.html index fdeaafa2fd1960b54eab220065211015ace60012..5b5a9e33237c241fbaef3a4667d7d141d368bc9e 100644 --- a/docs/build/html/functions.html +++ b/docs/build/html/functions.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>functions module — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>functions module — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> - <link rel="next" title="grid_class module" href="grid.html" /> - <link rel="prev" title="distribution_functions module" href="distribution_functions.html" /> + <link rel="next" title="Population class module" href="grid.html" /> + <link rel="prev" title="ensemble module" href="ensemble.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,30 +38,32 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> <li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="ensemble.html">ensemble module</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid.html">Population class module</a></li> <li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> <li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> <li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> <li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> </ul> @@ -107,70 +75,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li><a href="modules.html">Binarycpython code</a> »</li> - <li>functions module</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/functions.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -195,8 +124,8 @@ text-align: unset; } </style> -<div class="section" id="module-binarycpython.utils.functions"> -<span id="functions-module"></span><h1>functions module<a class="headerlink" href="#module-binarycpython.utils.functions" title="Permalink to this headline">¶</a></h1> +<section id="module-binarycpython.utils.functions"> +<span id="functions-module"></span><h1>functions module<a class="headerlink" href="#module-binarycpython.utils.functions" title="Permalink to this heading">ïƒ</a></h1> <p>Module containing most of the utility functions for the binarycpython package</p> <p>Functions here are mostly functions used in other classes/functions, or useful functions for the user</p> @@ -208,18 +137,18 @@ useful functions for the user</p> </dl> <dl class="py class"> <dt class="sig sig-object py" id="binarycpython.utils.functions.Capturing"> -<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">Capturing</span></span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#Capturing"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.Capturing" title="Permalink to this definition">¶</a></dt> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">Capturing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">iterable</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">/</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#Capturing"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.Capturing" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p> <p>Context manager to capture output and store it</p> <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.functions.Capturing.__enter__"> -<span class="sig-name descname"><span class="pre">__enter__</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#Capturing.__enter__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.Capturing.__enter__" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">__enter__</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#Capturing.__enter__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.Capturing.__enter__" title="Permalink to this definition">ïƒ</a></dt> <dd><p>On entry we capture the stdout output</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.functions.Capturing.__exit__"> -<span class="sig-name descname"><span class="pre">__exit__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#Capturing.__exit__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.Capturing.__exit__" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">__exit__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#Capturing.__exit__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.Capturing.__exit__" title="Permalink to this definition">ïƒ</a></dt> <dd><p>On exit we release the capture again</p> </dd></dl> @@ -227,45 +156,52 @@ useful functions for the user</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.bin_data"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">bin_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">binwidth</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#bin_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.bin_data" title="Permalink to this definition">¶</a></dt> -<dd><p>Function that bins the data</p> -<p>Uses the absolute value of binwidth</p> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">bin_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">binwidth</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#bin_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.bin_data" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that bins the data using the absolute value of binwidth using the following formula:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">((</span><span class="mf">0.5</span> <span class="k">if</span> <span class="n">value</span> <span class="o">></span> <span class="mf">0.0</span> <span class="k">else</span> <span class="o">-</span><span class="mf">0.5</span><span class="p">)</span> <span class="o">+</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span> <span class="o">/</span> <span class="nb">abs</span><span class="p">(</span><span class="n">binwidth</span><span class="p">)))</span> <span class="o">*</span> <span class="nb">abs</span><span class="p">(</span><span class="n">binwidth</span><span class="p">)</span> +</pre></div> +</div> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>value</strong> – value that we want to bin</p></li> +<li><p><strong>binwidth</strong> – width of the binning</p></li> +</ul> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>binned value</p> +</dd> +</dl> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.call_binary_c_config"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">call_binary_c_config</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">argument</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#call_binary_c_config"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.call_binary_c_config" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">call_binary_c_config</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">argument</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#call_binary_c_config"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.call_binary_c_config" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to interface with the binary_c config file</p> -<dl class="simple"> -<dt>input:</dt><dd><ul class="simple"> -<li><p>argument: argument for the binary_c config</p></li> -</ul> -</dd> -</dl> <dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p><ul class="simple"> -<li><p>raw output of binary_c-config</p></li> -</ul> -</p> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>argument</strong> – argument for the binary_c config</p> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>raw output of binary_c-config</p> </dd> </dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="binarycpython.utils.functions.catchtime"> -<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">catchtime</span></span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#catchtime"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.catchtime" title="Permalink to this definition">¶</a></dt> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">catchtime</span></span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#catchtime"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.catchtime" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> <p>Context manager to calculate time spent</p> <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.functions.catchtime.__enter__"> -<span class="sig-name descname"><span class="pre">__enter__</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#catchtime.__enter__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.catchtime.__enter__" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">__enter__</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#catchtime.__enter__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.catchtime.__enter__" title="Permalink to this definition">ïƒ</a></dt> <dd><p>On entry we start the clock</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.functions.catchtime.__exit__"> -<span class="sig-name descname"><span class="pre">__exit__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">traceback</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#catchtime.__exit__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.catchtime.__exit__" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">__exit__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">exc_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exc_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exc_tb</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#catchtime.__exit__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.catchtime.__exit__" title="Permalink to this definition">ïƒ</a></dt> <dd><p>On exit we stop the clock and measure the time spent</p> </dd></dl> @@ -273,31 +209,37 @@ useful functions for the user</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.check_if_in_shell"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">check_if_in_shell</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#check_if_in_shell"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.check_if_in_shell" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">check_if_in_shell</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#check_if_in_shell"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.check_if_in_shell" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to check whether the script is running from a shell</p> </dd></dl> +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.functions.command_string_from_list"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">command_string_from_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">list</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#command_string_from_list"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.command_string_from_list" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Given a list, turn it into a quoted command string</p> +</dd></dl> + <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.conv_time_units"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">conv_time_units</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">t</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#conv_time_units"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.conv_time_units" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">conv_time_units</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">t</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#conv_time_units"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.conv_time_units" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Converts time (t, in seconds, passing in as the only argument) to seconds, minutes or hours depending on its magnitude. Returns a tuple (t,units).</p> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.convert_bytes"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">convert_bytes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#convert_bytes"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.convert_bytes" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">convert_bytes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#convert_bytes"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.convert_bytes" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to return the size + a magnitude string</p> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.convfloat"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">convfloat</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#convfloat"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.convfloat" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">convfloat</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#convfloat"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.convfloat" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Convert scalar x to a float if we can, in which case return the float, otherwise just return x without changing it. Usually, x is a string, but could be anything that float() can handle without failure.</p> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.create_arg_string"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">create_arg_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">arg_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sort</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filter_values</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#create_arg_string"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.create_arg_string" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">create_arg_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">arg_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sort</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filter_values</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#create_arg_string"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.create_arg_string" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that creates the arg string for binary_c. Takes a dictionary containing the arguments and writes them to a string This string is missing the ‘binary_c ‘ at the start.</p> @@ -320,7 +262,7 @@ This string is missing the ‘binary_c ‘ at the start.</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.create_hdf5"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">create_hdf5</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data_dir</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#create_hdf5"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.create_hdf5" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">create_hdf5</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data_dir</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#create_hdf5"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.create_hdf5" title="Permalink to this definition">ïƒ</a></dt> <dd><dl class="simple"> <dt>Function to create an hdf5 file from the contents of a directory:</dt><dd><ul class="simple"> <li><p>settings file is selected by checking on files ending on settings</p></li> @@ -344,16 +286,25 @@ This string is missing the ‘binary_c ‘ at the start.</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.datalinedict"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">datalinedict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">line</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parameters</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#datalinedict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.datalinedict" title="Permalink to this definition">¶</a></dt> -<dd><p>Convert a line of data to a more convenient dictionary. -:param line = a line of data as a string: -:param parameters = a list of the parameter names:</p> -<p>Note: if the parameter is a floating point number, it will be converted to Python’s float type.</p> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">datalinedict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">line</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parameters</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#datalinedict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.datalinedict" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Convert a line of data to a more convenient dictionary.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>string</strong> (<em>line = a line of data as a</em>) – </p></li> +<li><p><strong>names</strong> (<em>parameters = a list of the parameter</em>) – </p></li> +</ul> +</dd> +</dl> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>If the parameter is a floating point number, it will be converted to Python’s float type.</p> +</div> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.example_parse_output"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">example_parse_output</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_header</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#example_parse_output"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.example_parse_output" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">example_parse_output</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_header</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#example_parse_output"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.example_parse_output" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that parses output of binary_c. This version serves as an example and is quite detailed. Custom functions can be easier:</p> <p>This function works in two cases: @@ -389,7 +340,7 @@ process)</p></li> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.filter_arg_dict"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">filter_arg_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">arg_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#filter_arg_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.filter_arg_dict" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">filter_arg_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">arg_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#filter_arg_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.filter_arg_dict" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to filter out keys that contain values included in [‘NULL’, ‘Function’, ‘’]</p> <p>This function is called by get_defaults()</p> <dl class="field-list simple"> @@ -407,17 +358,19 @@ process)</p></li> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.format_number"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">format_number</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">number</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#format_number"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.format_number" title="Permalink to this definition">¶</a></dt> -<dd></dd></dl> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">format_number</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">number</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#format_number"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.format_number" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to take a number, express format it in scientific notation, and remove the trailing 0 if the exponent is 0</p> +</dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.get_ANSI_colours"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_ANSI_colours</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_ANSI_colours"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_ANSI_colours" title="Permalink to this definition">¶</a></dt> -<dd></dd></dl> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_ANSI_colours</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_ANSI_colours"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_ANSI_colours" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that returns a dictionary with text-colors in ANSI formatting</p> +</dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.get_arg_keys"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_arg_keys</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_arg_keys"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_arg_keys" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_arg_keys</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_arg_keys"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_arg_keys" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that return the list of possible keys to give in the arg string. This function calls get_defaults()</p> <dl class="field-list simple"> @@ -433,7 +386,7 @@ we call get_defaults())</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.get_defaults"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_defaults</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filter_values</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_defaults"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_defaults" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_defaults</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filter_values</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_defaults"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_defaults" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that calls the binaryc get args function and cast it into a dictionary.</p> <p>All the values are strings</p> <dl class="field-list simple"> @@ -451,21 +404,15 @@ we call get_defaults())</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.get_help"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_help</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">param_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">print_help</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fail_silently</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_help"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_help" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_help</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">param_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">print_help</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fail_silently</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_help"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_help" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that returns the help info for a given parameter, by interfacing with binary_c</p> <p>Will check whether it is a valid parameter.</p> -<p>Binary_c will output things in the following order; +<p>Binary_c will output things in the following order: - Did you mean? - binary_c help for variable - default - available macros</p> <p>This function reads out that structure and catches the different components of this output</p> -<dl class="simple"> -<dt>Tasks:</dt><dd><ul class="simple"> -<li><p>TODO: consider not returning None, but return empty dict</p></li> -</ul> -</dd> -</dl> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> @@ -480,15 +427,15 @@ valid parameter name</p></li> <dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>]</p> </dd> <dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>Dictionary containing the help info. This dictionary contains ‘parameter_name’, -‘parameter_value_input_type’, ‘description’, optionally ‘macros’</p> +<dd class="field-odd"><p>Dictionary containing the help info. This dictionary contains <cite>parameter_name</cite>, +<cite>parameter_value_input_type</cite>, <cite>description</cite>, optionally <cite>macros</cite></p> </dd> </dl> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.get_help_all"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_help_all</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">print_help</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_help_all"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_help_all" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_help_all</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">print_help</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_help_all"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_help_all" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that reads out the output of the return_help_all API call to binary_c. This return_help_all binary_c returns all the information for the parameters, their descriptions and other properties. The output is categorised in sections.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -505,7 +452,7 @@ valid parameter name</p></li> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.get_help_super"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_help_super</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">print_help</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fail_silently</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_help_super"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_help_super" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_help_super</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">print_help</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fail_silently</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_help_super"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_help_super" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that first runs get_help_all, and then per argument also run the help function to get as much information as possible.</p> <dl class="field-list simple"> @@ -524,44 +471,61 @@ the help function to get as much information as possible.</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.functions.get_moe_di_stefano_dataset"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_moe_di_stefano_dataset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_moe_di_stefano_dataset"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_moe_di_stefano_dataset" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to get the default Moe and di Stefano dataset or accept a user input.</p> -<p>Returns a dict containing the (JSON) data.</p> -</dd></dl> - <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.get_size"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_size</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">obj</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seen</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_size"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_size" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_size</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">obj</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seen</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_size"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_size" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Recursively finds size of objects</p> <p>From <a class="reference external" href="https://github.com/bosswissam/pysize">https://github.com/bosswissam/pysize</a></p> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.get_username"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_username</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_username"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_username" title="Permalink to this definition">¶</a></dt> -<dd></dd></dl> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">get_username</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_username"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.get_username" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to get the username of the user that spawned the current process</p> +</dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.imports"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">imports</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#imports"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.imports" title="Permalink to this definition">¶</a></dt> -<dd></dd></dl> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">imports</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#imports"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.imports" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Generator that generates the names of all the modules that are loaded in the globals</p> +</dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.is_capsule"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">is_capsule</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">o</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#is_capsule"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.is_capsule" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">is_capsule</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">o</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#is_capsule"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.is_capsule" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to tell whether object is a capsule</p> </dd></dl> +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.functions.isfloat"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">isfloat</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#isfloat"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.isfloat" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return <cite>True</cite> if the “number†x, which could be a string, is an float, otherwise return <cite>False</cite>.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>x</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – string float or int that we will attempt to convert to an <cite>float</cite> value.</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.functions.isint"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">isint</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#isint"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.isint" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return <cite>True</cite> if the “number†x, which could be a string, is an int, otherwise return <cite>False</cite>.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>x</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – string float or int that we will attempt to convert to an <cite>int</cite> value.</p> +</dd> +</dl> +</dd></dl> + <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.load_logfile"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">load_logfile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">logfile</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#load_logfile"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.load_logfile" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">load_logfile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">logfile</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#load_logfile"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.load_logfile" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Experimental function that parses the generated log file of binary_c.</p> <p>This function is not finished and shouldn’t be used yet.</p> <dl class="simple"> <dt>Tasks:</dt><dd><ul class="simple"> -<li><p>TODO:</p></li> +<li><p>TODO: fix this function</p></li> </ul> </dd> </dl> @@ -580,7 +544,7 @@ the help function to get as much information as possible.</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.make_build_text"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">make_build_text</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#make_build_text"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.make_build_text" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">make_build_text</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#make_build_text"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.make_build_text" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to make build text</p> <dl class="field-list simple"> <dt class="field-odd">Return type</dt> @@ -594,13 +558,28 @@ the help function to get as much information as possible.</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.mem_use"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">mem_use</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#mem_use"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.mem_use" title="Permalink to this definition">¶</a></dt> -<dd><p>Return current process memory use in MB. (Takes no arguments) Note: this is per-thread only.</p> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">mem_use</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#mem_use"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.mem_use" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return current process memory use in MB. (Takes no arguments)</p> +<p>Note: this is per-thread only.</p> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.functions.now"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">now</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">now_object</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">style</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">custom_format</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#now"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.now" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>convenience function to return a string of the current time, using the format <code class="docutils literal notranslate"><span class="pre">%m/%d/%Y</span> <span class="pre">%H:%M:%S</span></code></p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>style</strong> – if “nospace†then return the date/time with the format <code class="docutils literal notranslate"><span class="pre">%Y%m%d_%H%M%S</span></code>, else use format <code class="docutils literal notranslate"><span class="pre">%m/%d/%Y</span> <span class="pre">%H:%M:%S</span></code></p></li> +<li><p><strong>custom_format</strong> – if set, uses this as a format rather than whatever is set by default or in the style variable</p></li> +</ul> +</dd> +</dl> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.output_lines"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">output_lines</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#output_lines"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.output_lines" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">output_lines</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#output_lines"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.output_lines" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that outputs the lines that were received from the binary_c run, but now as an iterator.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -617,31 +596,27 @@ the help function to get as much information as possible.</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.pad_output_distribution"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">pad_output_distribution</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">binwidth</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#pad_output_distribution"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.pad_output_distribution" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">pad_output_distribution</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">binwidth</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#pad_output_distribution"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.pad_output_distribution" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Given a distribution, dist (a dictionary), which should be binned every binwidth (float), fill the distribution with zeros when there is no data. Note: this changes the data in place.</p> -</dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.functions.parse_binary_c_version_info"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">parse_binary_c_version_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">version_info_string</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#parse_binary_c_version_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.parse_binary_c_version_info" title="Permalink to this definition">¶</a></dt> -<dd><p>Function that parses the binary_c version info. Long function with a lot of branches</p> -<p>TODO: fix this function. stuff is missing: isotopes, macros, nucleosynthesis_sources</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>version_info_string</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – raw output of version_info call to binary_c</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>‘isotopes’ for isotope info, ‘argpairs’ for argument pair info (TODO: explain), ‘ensembles’ for ensemble settings/info, ‘macros’ for macros, ‘elements’ for atomic element info, ‘DTlimit’ for (TODO: explain), ‘nucleosynthesis_sources’ for nucleosynthesis sources, and ‘miscellaneous’ for all those that were not caught by the previous groups. ‘git_branch’, ‘git_build’, ‘revision’ and ‘email’ are also keys, but its clear what those contain.</p> -</dd> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>Parsed version of the version info, which is a dictionary containing the keys</p> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>dist</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary containing the distribution data.</p></li> +<li><p><strong>binwidth</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>) – binwidth that is used to fill the distribution with 0 in places where there is no value/key.</p></li> +</ul> </dd> </dl> </dd></dl> +<dl class="py function"> +<dt class="sig sig-object py" id="binarycpython.utils.functions.quotewrap"> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">quotewrap</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">list</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#quotewrap"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.quotewrap" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Given a list, wrap each item in double quotes and return the new list</p> +</dd></dl> + <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.remove_file"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">remove_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#remove_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.remove_file" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">remove_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#remove_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.remove_file" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to remove files but with verbosity</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -659,33 +634,14 @@ the help function to get as much information as possible.</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.functions.return_binary_c_version_info"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">return_binary_c_version_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parsed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#return_binary_c_version_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.return_binary_c_version_info" title="Permalink to this definition">¶</a></dt> -<dd><p>Function that returns the version information of binary_c. This function calls the function -_binary_c_bindings.return_version_info()</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>parsed</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – Boolean flag whether to parse the version_info output of binary_c. default = False</p> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>]</p> -</dd> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>Either the raw string of binary_c or a parsed version of this in the form of a nested -dictionary</p> -</dd> -</dl> -</dd></dl> - <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.temp_dir"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">temp_dir</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#temp_dir"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.temp_dir" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to create directory within the TMP directory of the file system</p> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">temp_dir</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">child_dirs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#temp_dir"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.temp_dir" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to create directory within the TMP directory of the file system, starting with <cite>/<TMP>/binary_c_python-<username></cite></p> <p>Makes use of os.makedirs exist_ok which requires python 3.2+</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>arguments</strong> (<em>function</em>) – str input where each next input will be a child of the previous full_path. e.g. temp_dir(‘tests’, ‘grid’) will become ‘/tmp/binary_c_python/tests/grid’</p> +<dd class="field-odd"><p><strong>*child_dirs</strong> – str input where each next input will be a child of the previous full_path. e.g. <code class="docutils literal notranslate"><span class="pre">temp_dir('tests',</span> <span class="pre">'grid')</span></code> will become <code class="docutils literal notranslate"><span class="pre">'/tmp/binary_c_python-<username>/tests/grid'</span></code></p> </dd> <dt class="field-even">Return type</dt> <dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></p> @@ -698,29 +654,39 @@ dictionary</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.timedelta"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">timedelta</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">delta</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#timedelta"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.timedelta" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">timedelta</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">delta</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#timedelta"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.timedelta" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to convert a length of time (float, seconds) to a string for human-readable output.</p> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.trem"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">trem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dt</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">count</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dn</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#trem"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.trem" title="Permalink to this definition">¶</a></dt> -<dd><p>Estimate time remaining (seconds) given a differential time and count (i.e. progress = $count/$n). $dt is the time since the last call, $count is the current progress count, $dn is the number run since the last call, and $n is the total number required.</p> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">trem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dt</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">count</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dn</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#trem"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.trem" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Estimate time remaining (seconds) given a differential time and count (i.e. <code class="docutils literal notranslate"><span class="pre">progress</span> <span class="pre">=</span> <span class="pre">count/n</span></code>).</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>dt</strong> – is the time since the last call.</p></li> +<li><p><strong>count</strong> – is the current progress count.</p></li> +<li><p><strong>dn</strong> – is the number run since the last call.</p></li> +<li><p><strong>n</strong> – is the total number required.</p></li> +</ul> +</dd> +</dl> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.verbose_print"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">verbose_print</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">message</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">minimal_verbosity</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#verbose_print"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.verbose_print" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">verbose_print</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">message</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">minimal_verbosity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newline</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'\\n'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#verbose_print"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.verbose_print" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that decides whether to print a message based on the current verbosity -and its minimum verbosity</p> -<p>if verbosity is equal or higher than the minimum, then we print</p> +and its minimum verbosity. If verbosity is equal or higher than the minimum, then we print.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> -<li><p><strong>message</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – message to print</p></li> -<li><p><strong>verbosity</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – current verbosity level</p></li> -<li><p><strong>minimal_verbosity</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – threshold verbosity above which to print</p></li> +<li><p><strong>message</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – message to print.</p></li> +<li><p><strong>verbosity</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – current verbosity level.</p></li> +<li><p><strong>minimal_verbosity</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – threshold verbosity above which to print.</p></li> +<li><p><strong>newline</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – newline character (or set of characters), defaults to <code class="docutils literal notranslate"><span class="pre">\n</span></code> but <code class="docutils literal notranslate"><span class="pre">\x0d</span></code> (carriage return) might be useful.</p></li> </ul> </dd> <dt class="field-even">Return type</dt> @@ -731,20 +697,10 @@ and its minimum verbosity</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.functions.write_binary_c_parameter_descriptions_to_rst_file"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">write_binary_c_parameter_descriptions_to_rst_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output_file</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#write_binary_c_parameter_descriptions_to_rst_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.write_binary_c_parameter_descriptions_to_rst_file" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.functions.</span></span><span class="sig-name descname"><span class="pre">write_binary_c_parameter_descriptions_to_rst_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output_file</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#write_binary_c_parameter_descriptions_to_rst_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.functions.write_binary_c_parameter_descriptions_to_rst_file" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that calls the get_help_super() to get the help text/descriptions for all the -parameters available in that build. -Writes the results to a .rst file that can be included in the docs.</p> -<dl class="simple"> -<dt>Tasks:</dt><dd><ul class="simple"> -<li><dl class="simple"> -<dt>TODO: add the specific version git branch, git build, git commit, and binary_c version to</dt><dd><p>this document</p> -</dd> -</dl> -</li> -</ul> -</dd> -</dl> +parameters available in that build.</p> +<p>Writes the results to a .rst file that can be included in the docs.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>output_file</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – name of the output .rst file containing the ReStructuredText formatted output @@ -756,61 +712,43 @@ of all the binary_c parameters.</p> </dl> </dd></dl> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="grid.html" class="btn btn-neutral float-right" title="grid_class module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="distribution_functions.html" class="btn btn-neutral float-left" title="distribution_functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="ensemble.html" class="btn btn-neutral float-left" title="ensemble module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="grid.html" class="btn btn-neutral float-right" title="Population class module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/genindex.html b/docs/build/html/genindex.html index 02711cae23ed012fb9952f9629d93e23bd122405..a0455283886374076dd3c8c6287450fd02d8de98 100644 --- a/docs/build/html/genindex.html +++ b/docs/build/html/genindex.html @@ -1,68 +1,33 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Index — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="#" /> <link rel="search" title="Search" href="search.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -70,17 +35,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> @@ -92,66 +47,29 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li>Index</li> - - <li class="wy-breadcrumbs-aside"> - - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <h1 id="index">Index</h1> @@ -164,13 +82,16 @@ | <a href="#E"><strong>E</strong></a> | <a href="#F"><strong>F</strong></a> | <a href="#G"><strong>G</strong></a> + | <a href="#H"><strong>H</strong></a> | <a href="#I"><strong>I</strong></a> + | <a href="#J"><strong>J</strong></a> | <a href="#K"><strong>K</strong></a> | <a href="#L"><strong>L</strong></a> | <a href="#M"><strong>M</strong></a> | <a href="#N"><strong>N</strong></a> | <a href="#O"><strong>O</strong></a> | <a href="#P"><strong>P</strong></a> + | <a href="#Q"><strong>Q</strong></a> | <a href="#R"><strong>R</strong></a> | <a href="#S"><strong>S</strong></a> | <a href="#T"><strong>T</strong></a> @@ -183,14 +104,14 @@ <h2 id="_">_</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.NullCache.__delitem__">__delitem__() (binarycpython.utils.population_extensions.cache.cache.NullCache method)</a> +</li> <li><a href="functions.html#binarycpython.utils.functions.Capturing.__enter__">__enter__() (binarycpython.utils.functions.Capturing method)</a> <ul> <li><a href="functions.html#binarycpython.utils.functions.catchtime.__enter__">(binarycpython.utils.functions.catchtime method)</a> </li> </ul></li> - </ul></td> - <td style="width: 33%; vertical-align: top;"><ul> <li><a href="functions.html#binarycpython.utils.functions.Capturing.__exit__">__exit__() (binarycpython.utils.functions.Capturing method)</a> <ul> @@ -198,18 +119,38 @@ </li> </ul></li> </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="dicts.html#binarycpython.utils.dicts.AutoVivificationDict.__getitem__">__getitem__() (binarycpython.utils.dicts.AutoVivificationDict method)</a> + + <ul> + <li><a href="population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.NullCache.__getitem__">(binarycpython.utils.population_extensions.cache.cache.NullCache method)</a> +</li> + </ul></li> + <li><a href="dicts.html#binarycpython.utils.dicts.AutoVivificationDict.__iadd__">__iadd__() (binarycpython.utils.dicts.AutoVivificationDict method)</a> +</li> + <li><a href="population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.NullCache.__setitem__">__setitem__() (binarycpython.utils.population_extensions.cache.cache.NullCache method)</a> +</li> + </ul></td> </tr></table> <h2 id="A">A</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="grid.html#binarycpython.utils.grid.Population.add_grid_variable">add_grid_variable() (binarycpython.utils.grid.Population method)</a> + <li><a href="population_extensions/metadata.html#binarycpython.utils.population_extensions.metadata.metadata.add_ensemble_metadata">add_ensemble_metadata() (binarycpython.utils.population_extensions.metadata.metadata method)</a> +</li> + <li><a href="population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode.add_grid_variable">add_grid_variable() (binarycpython.utils.population_extensions.gridcode.gridcode method)</a> +</li> + <li><a href="population_extensions/metadata.html#binarycpython.utils.population_extensions.metadata.metadata.add_system_metadata">add_system_metadata() (binarycpython.utils.population_extensions.metadata.metadata method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.Arenou2010_binary_fraction">Arenou2010_binary_fraction() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics">analytics (class in binarycpython.utils.population_extensions.analytics)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Arenou2010_binary_fraction">Arenou2010_binary_fraction() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> <li><a href="custom_logging_functions.html#binarycpython.utils.custom_logging_functions.autogen_C_logging_code">autogen_C_logging_code() (in module binarycpython.utils.custom_logging_functions)</a> +</li> + <li><a href="dicts.html#binarycpython.utils.dicts.AutoVivificationDict">AutoVivificationDict (class in binarycpython.utils.dicts)</a> </li> </ul></td> </tr></table> @@ -222,6 +163,12 @@ <li><a href="custom_logging_functions.html#binarycpython.utils.custom_logging_functions.binary_c_log_code">binary_c_log_code() (in module binarycpython.utils.custom_logging_functions)</a> </li> <li><a href="custom_logging_functions.html#binarycpython.utils.custom_logging_functions.binary_c_write_log_code">binary_c_write_log_code() (in module binarycpython.utils.custom_logging_functions)</a> +</li> + <li><a href="ensemble.html#binarycpython.utils.ensemble.binaryc_json_serializer">binaryc_json_serializer() (in module binarycpython.utils.ensemble)</a> +</li> + <li><a href="ensemble.html#binarycpython.utils.ensemble.BinarycDecoder">BinarycDecoder (class in binarycpython.utils.ensemble)</a> +</li> + <li><a href="ensemble.html#binarycpython.utils.ensemble.BinarycEncoder">BinarycEncoder (class in binarycpython.utils.ensemble)</a> </li> <li> binarycpython.utils.custom_logging_functions @@ -231,10 +178,17 @@ </li> </ul></li> <li> - binarycpython.utils.distribution_functions + binarycpython.utils.dicts <ul> - <li><a href="distribution_functions.html#module-binarycpython.utils.distribution_functions">module</a> + <li><a href="dicts.html#module-binarycpython.utils.dicts">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.ensemble + + <ul> + <li><a href="ensemble.html#module-binarycpython.utils.ensemble">module</a> </li> </ul></li> <li> @@ -252,40 +206,117 @@ </li> </ul></li> <li> - binarycpython.utils.grid_options_defaults + binarycpython.utils.plot_functions <ul> - <li><a href="grid_options_defaults.html#module-binarycpython.utils.grid_options_defaults">module</a> + <li><a href="plot_functions.html#module-binarycpython.utils.plot_functions">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.population_extensions.analytics + + <ul> + <li><a href="population_extensions/analytics.html#module-binarycpython.utils.population_extensions.analytics">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.population_extensions.cache + + <ul> + <li><a href="population_extensions/cache.html#module-binarycpython.utils.population_extensions.cache">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.population_extensions.condor + + <ul> + <li><a href="population_extensions/condor.html#module-binarycpython.utils.population_extensions.condor">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.population_extensions.dataIO + + <ul> + <li><a href="population_extensions/dataIO.html#module-binarycpython.utils.population_extensions.dataIO">module</a> </li> </ul></li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li> - binarycpython.utils.hpc_functions + binarycpython.utils.population_extensions.distribution_functions <ul> - <li><a href="hpc_functions.html#module-binarycpython.utils.hpc_functions">module</a> + <li><a href="population_extensions/distribution_functions.html#module-binarycpython.utils.population_extensions.distribution_functions">module</a> </li> </ul></li> <li> - binarycpython.utils.plot_functions + binarycpython.utils.population_extensions.grid_logging <ul> - <li><a href="plot_functions.html#module-binarycpython.utils.plot_functions">module</a> + <li><a href="population_extensions/grid_logging.html#module-binarycpython.utils.population_extensions.grid_logging">module</a> </li> </ul></li> <li> - binarycpython.utils.run_system_wrapper + binarycpython.utils.population_extensions.grid_options_defaults <ul> - <li><a href="run_system_wrapper.html#module-binarycpython.utils.run_system_wrapper">module</a> + <li><a href="population_extensions/grid_options_defaults.html#module-binarycpython.utils.population_extensions.grid_options_defaults">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.population_extensions.gridcode + + <ul> + <li><a href="population_extensions/gridcode.html#module-binarycpython.utils.population_extensions.gridcode">module</a> </li> </ul></li> <li> - binarycpython.utils.spacing_functions + binarycpython.utils.population_extensions.HPC <ul> - <li><a href="spacing_functions.html#module-binarycpython.utils.spacing_functions">module</a> + <li><a href="population_extensions/HPC.html#module-binarycpython.utils.population_extensions.HPC">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.population_extensions.metadata + + <ul> + <li><a href="population_extensions/metadata.html#module-binarycpython.utils.population_extensions.metadata">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.population_extensions.Moe_di_Stefano_2017 + + <ul> + <li><a href="population_extensions/Moe_di_Stefano_2017.html#module-binarycpython.utils.population_extensions.Moe_di_Stefano_2017">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.population_extensions.slurm + + <ul> + <li><a href="population_extensions/slurm.html#module-binarycpython.utils.population_extensions.slurm">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.population_extensions.spacing_functions + + <ul> + <li><a href="population_extensions/spacing_functions.html#module-binarycpython.utils.population_extensions.spacing_functions">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.population_extensions.version_info + + <ul> + <li><a href="population_extensions/version_info.html#module-binarycpython.utils.population_extensions.version_info">module</a> +</li> + </ul></li> + <li> + binarycpython.utils.run_system_wrapper + + <ul> + <li><a href="run_system_wrapper.html#module-binarycpython.utils.run_system_wrapper">module</a> </li> </ul></li> <li> @@ -302,7 +333,7 @@ <li><a href="useful_funcs.html#module-binarycpython.utils.useful_funcs">module</a> </li> </ul></li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.build_q_table">build_q_table() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.build_q_table">build_q_table() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> </ul></td> </tr></table> @@ -310,17 +341,21 @@ <h2 id="C">C</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.calc_e_integral">calc_e_integral() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache">cache (class in binarycpython.utils.population_extensions.cache)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.calc_P_integral">calc_P_integral() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.NullCache">cache.NullCache (class in binarycpython.utils.population_extensions.cache)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_e_integral">calc_e_integral() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_P_integral">calc_P_integral() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> <li><a href="useful_funcs.html#binarycpython.utils.useful_funcs.calc_period_from_sep">calc_period_from_sep() (in module binarycpython.utils.useful_funcs)</a> </li> <li><a href="useful_funcs.html#binarycpython.utils.useful_funcs.calc_sep_from_period">calc_sep_from_period() (in module binarycpython.utils.useful_funcs)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.calc_total_probdens">calc_total_probdens() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_total_probdens">calc_total_probdens() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.calculate_constants_three_part_powerlaw">calculate_constants_three_part_powerlaw() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calculate_constants_three_part_powerlaw">calculate_constants_three_part_powerlaw() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.call_binary_c_config">call_binary_c_config() (in module binarycpython.utils.functions)</a> </li> @@ -333,20 +368,42 @@ <li><a href="grid.html#binarycpython.utils.grid.Population.clean">clean() (binarycpython.utils.grid.Population method)</a> </li> <li><a href="plot_functions.html#binarycpython.utils.plot_functions.color_by_index">color_by_index() (in module binarycpython.utils.plot_functions)</a> +</li> + <li><a href="functions.html#binarycpython.utils.functions.command_string_from_list">command_string_from_list() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="custom_logging_functions.html#binarycpython.utils.custom_logging_functions.compile_shared_lib">compile_shared_lib() (in module binarycpython.utils.custom_logging_functions)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.compression_type">compression_type() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor">condor (class in binarycpython.utils.population_extensions.condor)</a> +</li> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_check_requirements">condor_check_requirements() (binarycpython.utils.population_extensions.condor.condor method)</a> +</li> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_dirs">condor_dirs() (binarycpython.utils.population_extensions.condor.condor method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="custom_logging_functions.html#binarycpython.utils.custom_logging_functions.compile_shared_lib">compile_shared_lib() (in module binarycpython.utils.custom_logging_functions)</a> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_grid">condor_grid() (binarycpython.utils.population_extensions.condor.condor method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.const">const() (in module binarycpython.utils.distribution_functions)</a> - - <ul> - <li><a href="spacing_functions.html#binarycpython.utils.spacing_functions.const">(in module binarycpython.utils.spacing_functions)</a> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_outfile">condor_outfile() (binarycpython.utils.population_extensions.condor.condor method)</a> </li> - </ul></li> - <li><a href="spacing_functions.html#binarycpython.utils.spacing_functions.const_dt">const_dt() (in module binarycpython.utils.spacing_functions)</a> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_queue_stats">condor_queue_stats() (binarycpython.utils.population_extensions.condor.condor method)</a> +</li> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condor_status_file">condor_status_file() (binarycpython.utils.population_extensions.condor.condor method)</a> +</li> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condorID">condorID() (binarycpython.utils.population_extensions.condor.condor method)</a> +</li> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.condorpath">condorpath() (binarycpython.utils.population_extensions.condor.condor method)</a> </li> - <li><a href="spacing_functions.html#binarycpython.utils.spacing_functions.const_ranges">const_ranges() (in module binarycpython.utils.spacing_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.const_distribution">const_distribution() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_dt">const_dt() (binarycpython.utils.population_extensions.spacing_functions.spacing_functions method)</a> +</li> + <li><a href="population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_int">const_int() (binarycpython.utils.population_extensions.spacing_functions.spacing_functions method)</a> +</li> + <li><a href="population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_linear">const_linear() (binarycpython.utils.population_extensions.spacing_functions.spacing_functions method)</a> +</li> + <li><a href="population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_ranges">const_ranges() (binarycpython.utils.population_extensions.spacing_functions.spacing_functions method)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.conv_time_units">conv_time_units() (in module binarycpython.utils.functions)</a> </li> @@ -354,13 +411,19 @@ </li> <li><a href="functions.html#binarycpython.utils.functions.convfloat">convfloat() (in module binarycpython.utils.functions)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.cosmic_SFH_madau_dickinson2014">cosmic_SFH_madau_dickinson2014() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.cosmic_SFH_madau_dickinson2014">cosmic_SFH_madau_dickinson2014() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="dicts.html#binarycpython.utils.dicts.count_keys_recursive">count_keys_recursive() (in module binarycpython.utils.dicts)</a> +</li> + <li><a href="population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics.CPU_time">CPU_time() (binarycpython.utils.population_extensions.analytics.analytics method)</a> </li> <li><a href="custom_logging_functions.html#binarycpython.utils.custom_logging_functions.create_and_load_logging_function">create_and_load_logging_function() (in module binarycpython.utils.custom_logging_functions)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.create_arg_string">create_arg_string() (in module binarycpython.utils.functions)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.create_hdf5">create_hdf5() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="dicts.html#binarycpython.utils.dicts.custom_sort_dict">custom_sort_dict() (in module binarycpython.utils.dicts)</a> </li> </ul></td> </tr></table> @@ -368,15 +431,31 @@ <h2 id="D">D</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO">dataIO (class in binarycpython.utils.population_extensions.dataIO)</a> +</li> <li><a href="functions.html#binarycpython.utils.functions.datalinedict">datalinedict() (in module binarycpython.utils.functions)</a> </li> - <li><a href="grid.html#binarycpython.utils.grid.Population.delete_grid_variable">delete_grid_variable() (binarycpython.utils.grid.Population method)</a> + <li><a href="ensemble.html#binarycpython.utils.ensemble.BinarycDecoder.decode">decode() (binarycpython.utils.ensemble.BinarycDecoder method)</a> </li> + <li><a href="ensemble.html#binarycpython.utils.ensemble.BinarycEncoder.default">default() (binarycpython.utils.ensemble.BinarycEncoder method)</a> +</li> + <li><a href="population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.default_cache_dir">default_cache_dir() (binarycpython.utils.population_extensions.cache.cache method)</a> + + <ul> + <li><a href="population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.default_cache_dir">(binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults method)</a> +</li> + </ul></li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode.delete_grid_variable">delete_grid_variable() (binarycpython.utils.population_extensions.gridcode.gridcode method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.dir_ok">dir_ok() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions">distribution_functions (class in binarycpython.utils.population_extensions.distribution_functions)</a> +</li> <li><a href="plot_functions.html#binarycpython.utils.plot_functions.dummy">dummy() (in module binarycpython.utils.plot_functions)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.duquennoy1991">duquennoy1991() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.duquennoy1991">duquennoy1991() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> </ul></td> </tr></table> @@ -384,15 +463,25 @@ <h2 id="E">E</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="grid.html#binarycpython.utils.grid.Population.evolve">evolve() (binarycpython.utils.grid.Population method)</a> + <li><a href="ensemble.html#binarycpython.utils.ensemble.ensemble_compression">ensemble_compression() (in module binarycpython.utils.ensemble)</a> </li> - <li><a href="grid.html#binarycpython.utils.grid.Population.evolve_single">evolve_single() (binarycpython.utils.grid.Population method)</a> + <li><a href="ensemble.html#binarycpython.utils.ensemble.ensemble_file_type">ensemble_file_type() (in module binarycpython.utils.ensemble)</a> +</li> + <li><a href="ensemble.html#binarycpython.utils.ensemble.ensemble_setting">ensemble_setting() (in module binarycpython.utils.ensemble)</a> +</li> + <li><a href="grid.html#binarycpython.utils.grid.Population.evolve">evolve() (binarycpython.utils.grid.Population method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="grid.html#binarycpython.utils.grid.Population.evolve_single">evolve_single() (binarycpython.utils.grid.Population method)</a> +</li> <li><a href="functions.html#binarycpython.utils.functions.example_parse_output">example_parse_output() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="grid.html#binarycpython.utils.grid.Population.exit">exit() (binarycpython.utils.grid.Population method)</a> </li> <li><a href="grid.html#binarycpython.utils.grid.Population.export_all_info">export_all_info() (binarycpython.utils.grid.Population method)</a> +</li> + <li><a href="ensemble.html#binarycpython.utils.ensemble.extract_ensemble_json_from_string">extract_ensemble_json_from_string() (in module binarycpython.utils.ensemble)</a> </li> </ul></td> </tr></table> @@ -400,15 +489,21 @@ <h2 id="F">F</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.fill_data">fill_data() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.fill_data">fill_data() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.filter_arg_dict">filter_arg_dict() (in module binarycpython.utils.functions)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.flat">flat() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="dicts.html#binarycpython.utils.dicts.filter_dict">filter_dict() (in module binarycpython.utils.dicts)</a> +</li> + <li><a href="dicts.html#binarycpython.utils.dicts.filter_dict_through_values">filter_dict_through_values() (in module binarycpython.utils.dicts)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.flatsections">flatsections() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.flat">flat() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.flatsections">flatsections() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="ensemble.html#binarycpython.utils.ensemble.format_ensemble_results">format_ensemble_results() (in module binarycpython.utils.ensemble)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.format_number">format_number() (in module binarycpython.utils.functions)</a> </li> @@ -420,65 +515,165 @@ <h2 id="G">G</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.gaussian">gaussian() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian">gaussian() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.gaussian_func">gaussian_func() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian_func">gaussian_func() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.gaussian_normalizing_const">gaussian_normalizing_const() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian_normalizing_const">gaussian_normalizing_const() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> - <li><a href="spacing_functions.html#binarycpython.utils.spacing_functions.gaussian_zoom">gaussian_zoom() (in module binarycpython.utils.spacing_functions)</a> + <li><a href="population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.gaussian_zoom">gaussian_zoom() (binarycpython.utils.population_extensions.spacing_functions.spacing_functions method)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.get_ANSI_colours">get_ANSI_colours() (in module binarycpython.utils.functions)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.get_arg_keys">get_arg_keys() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.get_condor_status">get_condor_status() (binarycpython.utils.population_extensions.condor.condor method)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.get_defaults">get_defaults() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.get_grid_options_defaults_dict">get_grid_options_defaults_dict() (binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults method)</a> +</li> + <li><a href="population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.get_grid_options_descriptions">get_grid_options_descriptions() (binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults method)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.get_help">get_help() (in module binarycpython.utils.functions)</a> </li> - </ul></td> - <td style="width: 33%; vertical-align: top;"><ul> <li><a href="functions.html#binarycpython.utils.functions.get_help_all">get_help_all() (in module binarycpython.utils.functions)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.get_help_super">get_help_super() (in module binarycpython.utils.functions)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.get_integration_constant_q">get_integration_constant_q() (in module binarycpython.utils.distribution_functions)</a> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.get_integration_constant_q">get_integration_constant_q() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.get_max_multiplicity">get_max_multiplicity() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options">get_Moe_di_Stefano_2017_default_options() (binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017 method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.get_max_multiplicity">get_max_multiplicity() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options_description">get_Moe_di_Stefano_2017_default_options_description() (binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017 method)</a> </li> - <li><a href="functions.html#binarycpython.utils.functions.get_moe_di_stefano_dataset">get_moe_di_stefano_dataset() (in module binarycpython.utils.functions)</a> + <li><a href="population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_moe_di_stefano_dataset">get_moe_di_stefano_dataset() (binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017 method)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.get_size">get_size() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.get_slurm_status">get_slurm_status() (binarycpython.utils.population_extensions.slurm.slurm method)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.get_username">get_username() (in module binarycpython.utils.functions)</a> </li> - <li><a href="grid_options_defaults.html#binarycpython.utils.grid_options_defaults.grid_options_description_checker">grid_options_description_checker() (in module binarycpython.utils.grid_options_defaults)</a> + <li><a href="population_extensions/grid_logging.html#binarycpython.utils.population_extensions.grid_logging.grid_logging">grid_logging (class in binarycpython.utils.population_extensions.grid_logging)</a> +</li> + <li><a href="population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults">grid_options_defaults (class in binarycpython.utils.population_extensions.grid_options_defaults)</a> +</li> + <li><a href="population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.grid_options_description_checker">grid_options_description_checker() (binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults method)</a> </li> - <li><a href="grid_options_defaults.html#binarycpython.utils.grid_options_defaults.grid_options_help">grid_options_help() (in module binarycpython.utils.grid_options_defaults)</a> + <li><a href="population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.grid_options_help">grid_options_help() (binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults method)</a> +</li> + <li><a href="population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode">gridcode (class in binarycpython.utils.population_extensions.gridcode)</a> </li> </ul></td> </tr></table> -<h2 id="I">I</h2> +<h2 id="H">H</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.imf_chabrier2003">imf_chabrier2003() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="ensemble.html#binarycpython.utils.ensemble.handle_ensemble_string_to_json">handle_ensemble_string_to_json() (in module binarycpython.utils.ensemble)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC">HPC (class in binarycpython.utils.population_extensions.HPC)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_can_join">HPC_can_join() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_check_requirements">HPC_check_requirements() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_dir">HPC_dir() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_dirs">HPC_dirs() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_dump_status">HPC_dump_status() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_get_status">HPC_get_status() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_grid">HPC_grid() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_id_filename">HPC_id_filename() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_id_from_dir">HPC_id_from_dir() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_job">HPC_job() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_job_id_range">HPC_job_id_range() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_job_task">HPC_job_task() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_job_type">HPC_job_type() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_jobID">HPC_jobID() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_jobID_tuple">HPC_jobID_tuple() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_join_from_files">HPC_join_from_files() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_join_previous">HPC_join_previous() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_joinlist">HPC_joinlist() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_load_joinfiles_list">HPC_load_joinfiles_list() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_make_joiningfile">HPC_make_joiningfile() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_njobs">HPC_njobs() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_path">HPC_path() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_queue_stats">HPC_queue_stats() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_restore">HPC_restore() (binarycpython.utils.population_extensions.HPC.HPC method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.imf_scalo1986">imf_scalo1986() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_set_status">HPC_set_status() (binarycpython.utils.population_extensions.HPC.HPC method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.imf_scalo1998">imf_scalo1998() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_snapshot_filename">HPC_snapshot_filename() (binarycpython.utils.population_extensions.HPC.HPC method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.imf_tinsley1980">imf_tinsley1980() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_status">HPC_status() (binarycpython.utils.population_extensions.HPC.HPC method)</a> +</li> + <li><a href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC.HPC_touch">HPC_touch() (binarycpython.utils.population_extensions.HPC.HPC method)</a> </li> </ul></td> +</tr></table> + +<h2 id="I">I</h2> +<table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_chabrier2003">imf_chabrier2003() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_scalo1986">imf_scalo1986() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_scalo1998">imf_scalo1998() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_tinsley1980">imf_tinsley1980() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> <li><a href="functions.html#binarycpython.utils.functions.imports">imports() (in module binarycpython.utils.functions)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.interpolate_in_mass_izzard2012">interpolate_in_mass_izzard2012() (in module binarycpython.utils.distribution_functions)</a> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="dicts.html#binarycpython.utils.dicts.inspect_dict">inspect_dict() (in module binarycpython.utils.dicts)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.interpolate_in_mass_izzard2012">interpolate_in_mass_izzard2012() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.is_capsule">is_capsule() (in module binarycpython.utils.functions)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.Izzard2012_period_distribution">Izzard2012_period_distribution() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="functions.html#binarycpython.utils.functions.isfloat">isfloat() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="functions.html#binarycpython.utils.functions.isint">isint() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Izzard2012_period_distribution">Izzard2012_period_distribution() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + </ul></td> +</tr></table> + +<h2 id="J">J</h2> +<table style="width: 100%" class="indextable genindextable"><tr> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="grid.html#binarycpython.utils.grid.Population.jobID">jobID() (binarycpython.utils.grid.Population method)</a> </li> </ul></td> </tr></table> @@ -486,11 +681,13 @@ <h2 id="K">K</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.Kroupa2001">Kroupa2001() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="dicts.html#binarycpython.utils.dicts.keys_to_floats">keys_to_floats() (in module binarycpython.utils.dicts)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.ktg93">ktg93() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Kroupa2001">Kroupa2001() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.ktg93">ktg93() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> </ul></td> </tr></table> @@ -498,11 +695,21 @@ <h2 id="L">L</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.linear_extrapolation_q">linear_extrapolation_q() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.linear_extrapolation_q">linear_extrapolation_q() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="ensemble.html#binarycpython.utils.ensemble.load_ensemble">load_ensemble() (in module binarycpython.utils.ensemble)</a> +</li> + <li><a href="functions.html#binarycpython.utils.functions.load_logfile">load_logfile() (in module binarycpython.utils.functions)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="functions.html#binarycpython.utils.functions.load_logfile">load_logfile() (in module binarycpython.utils.functions)</a> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.load_population_object">load_population_object() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.load_snapshot">load_snapshot() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.locked_close">locked_close() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.locked_open_for_write">locked_open_for_write() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> </li> </ul></td> </tr></table> @@ -510,17 +717,33 @@ <h2 id="M">M</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics.make_analytics_dict">make_analytics_dict() (binarycpython.utils.population_extensions.analytics.analytics method)</a> +</li> <li><a href="functions.html#binarycpython.utils.functions.make_build_text">make_build_text() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.make_condor_dirs">make_condor_dirs() (binarycpython.utils.population_extensions.condor.condor method)</a> +</li> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.make_slurm_dirs">make_slurm_dirs() (binarycpython.utils.population_extensions.slurm.slurm method)</a> </li> <li><a href="useful_funcs.html#binarycpython.utils.useful_funcs.maximum_mass_ratio_for_RLOF">maximum_mass_ratio_for_RLOF() (in module binarycpython.utils.useful_funcs)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.mem_use">mem_use() (in module binarycpython.utils.functions)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.merge_multiplicities">merge_multiplicities() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="dicts.html#binarycpython.utils.dicts.merge_dicts">merge_dicts() (in module binarycpython.utils.dicts)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.merge_multiplicities">merge_multiplicities() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.merge_populations">merge_populations() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.merge_populations_from_file">merge_populations_from_file() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/metadata.html#binarycpython.utils.population_extensions.metadata.metadata">metadata (class in binarycpython.utils.population_extensions.metadata)</a> </li> <li><a href="useful_funcs.html#binarycpython.utils.useful_funcs.minimum_period_for_RLOF">minimum_period_for_RLOF() (in module binarycpython.utils.useful_funcs)</a> </li> <li><a href="useful_funcs.html#binarycpython.utils.useful_funcs.minimum_separation_for_RLOF">minimum_separation_for_RLOF() (in module binarycpython.utils.useful_funcs)</a> +</li> + <li><a href="population_extensions/version_info.html#binarycpython.utils.population_extensions.version_info.version_info.minimum_stellar_mass">minimum_stellar_mass() (binarycpython.utils.population_extensions.version_info.version_info method)</a> </li> <li> module @@ -528,21 +751,45 @@ <ul> <li><a href="custom_logging_functions.html#module-binarycpython.utils.custom_logging_functions">binarycpython.utils.custom_logging_functions</a> </li> - <li><a href="distribution_functions.html#module-binarycpython.utils.distribution_functions">binarycpython.utils.distribution_functions</a> + <li><a href="dicts.html#module-binarycpython.utils.dicts">binarycpython.utils.dicts</a> +</li> + <li><a href="ensemble.html#module-binarycpython.utils.ensemble">binarycpython.utils.ensemble</a> </li> <li><a href="functions.html#module-binarycpython.utils.functions">binarycpython.utils.functions</a> </li> <li><a href="grid.html#module-binarycpython.utils.grid">binarycpython.utils.grid</a> </li> - <li><a href="grid_options_defaults.html#module-binarycpython.utils.grid_options_defaults">binarycpython.utils.grid_options_defaults</a> + <li><a href="plot_functions.html#module-binarycpython.utils.plot_functions">binarycpython.utils.plot_functions</a> +</li> + <li><a href="population_extensions/analytics.html#module-binarycpython.utils.population_extensions.analytics">binarycpython.utils.population_extensions.analytics</a> </li> - <li><a href="hpc_functions.html#module-binarycpython.utils.hpc_functions">binarycpython.utils.hpc_functions</a> + <li><a href="population_extensions/cache.html#module-binarycpython.utils.population_extensions.cache">binarycpython.utils.population_extensions.cache</a> </li> - <li><a href="plot_functions.html#module-binarycpython.utils.plot_functions">binarycpython.utils.plot_functions</a> + <li><a href="population_extensions/condor.html#module-binarycpython.utils.population_extensions.condor">binarycpython.utils.population_extensions.condor</a> </li> - <li><a href="run_system_wrapper.html#module-binarycpython.utils.run_system_wrapper">binarycpython.utils.run_system_wrapper</a> + <li><a href="population_extensions/dataIO.html#module-binarycpython.utils.population_extensions.dataIO">binarycpython.utils.population_extensions.dataIO</a> +</li> + <li><a href="population_extensions/distribution_functions.html#module-binarycpython.utils.population_extensions.distribution_functions">binarycpython.utils.population_extensions.distribution_functions</a> +</li> + <li><a href="population_extensions/grid_logging.html#module-binarycpython.utils.population_extensions.grid_logging">binarycpython.utils.population_extensions.grid_logging</a> </li> - <li><a href="spacing_functions.html#module-binarycpython.utils.spacing_functions">binarycpython.utils.spacing_functions</a> + <li><a href="population_extensions/grid_options_defaults.html#module-binarycpython.utils.population_extensions.grid_options_defaults">binarycpython.utils.population_extensions.grid_options_defaults</a> +</li> + <li><a href="population_extensions/gridcode.html#module-binarycpython.utils.population_extensions.gridcode">binarycpython.utils.population_extensions.gridcode</a> +</li> + <li><a href="population_extensions/HPC.html#module-binarycpython.utils.population_extensions.HPC">binarycpython.utils.population_extensions.HPC</a> +</li> + <li><a href="population_extensions/metadata.html#module-binarycpython.utils.population_extensions.metadata">binarycpython.utils.population_extensions.metadata</a> +</li> + <li><a href="population_extensions/Moe_di_Stefano_2017.html#module-binarycpython.utils.population_extensions.Moe_di_Stefano_2017">binarycpython.utils.population_extensions.Moe_di_Stefano_2017</a> +</li> + <li><a href="population_extensions/slurm.html#module-binarycpython.utils.population_extensions.slurm">binarycpython.utils.population_extensions.slurm</a> +</li> + <li><a href="population_extensions/spacing_functions.html#module-binarycpython.utils.population_extensions.spacing_functions">binarycpython.utils.population_extensions.spacing_functions</a> +</li> + <li><a href="population_extensions/version_info.html#module-binarycpython.utils.population_extensions.version_info">binarycpython.utils.population_extensions.version_info</a> +</li> + <li><a href="run_system_wrapper.html#module-binarycpython.utils.run_system_wrapper">binarycpython.utils.run_system_wrapper</a> </li> <li><a href="stellar_types.html#module-binarycpython.utils.stellar_types">binarycpython.utils.stellar_types</a> </li> @@ -551,11 +798,17 @@ </ul></li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="grid.html#binarycpython.utils.grid.Population.Moe_di_Stefano_2017">Moe_di_Stefano_2017() (binarycpython.utils.grid.Population method)</a> + <li><a href="population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017">Moe_di_Stefano_2017 (class in binarycpython.utils.population_extensions.Moe_di_Stefano_2017)</a> +</li> + <li><a href="population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.Moe_di_Stefano_2017">Moe_di_Stefano_2017() (binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017 method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Moe_di_Stefano_2017_multiplicity_fractions">Moe_di_Stefano_2017_multiplicity_fractions() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.Moe_di_Stefano_2017_multiplicity_fractions">Moe_di_Stefano_2017_multiplicity_fractions() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Moe_di_Stefano_2017_pdf">Moe_di_Stefano_2017_pdf() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.Moe_di_Stefano_2017_pdf">Moe_di_Stefano_2017_pdf() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="dicts.html#binarycpython.utils.dicts.multiply_float_values">multiply_float_values() (in module binarycpython.utils.dicts)</a> +</li> + <li><a href="dicts.html#binarycpython.utils.dicts.multiply_values_dict">multiply_values_dict() (in module binarycpython.utils.dicts)</a> </li> </ul></td> </tr></table> @@ -563,11 +816,17 @@ <h2 id="N">N</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.normalize_dict">normalize_dict() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.NFS_flush_hack">NFS_flush_hack() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.NFSpath">NFSpath() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.number">number() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="dicts.html#binarycpython.utils.dicts.normalize_dict">normalize_dict() (in module binarycpython.utils.dicts)</a> +</li> + <li><a href="functions.html#binarycpython.utils.functions.now">now() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.number">number() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> </ul></td> </tr></table> @@ -575,6 +834,12 @@ <h2 id="O">O</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.open">open() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="ensemble.html#binarycpython.utils.ensemble.open_ensemble">open_ensemble() (in module binarycpython.utils.ensemble)</a> +</li> <li><a href="functions.html#binarycpython.utils.functions.output_lines">output_lines() (in module binarycpython.utils.functions)</a> </li> </ul></td> @@ -585,7 +850,7 @@ <td style="width: 33%; vertical-align: top;"><ul> <li><a href="functions.html#binarycpython.utils.functions.pad_output_distribution">pad_output_distribution() (in module binarycpython.utils.functions)</a> </li> - <li><a href="functions.html#binarycpython.utils.functions.parse_binary_c_version_info">parse_binary_c_version_info() (in module binarycpython.utils.functions)</a> + <li><a href="population_extensions/version_info.html#binarycpython.utils.population_extensions.version_info.version_info.parse_binary_c_version_info">parse_binary_c_version_info() (binarycpython.utils.population_extensions.version_info.version_info method)</a> </li> <li><a href="grid.html#binarycpython.utils.grid.Population.parse_cmdline">parse_cmdline() (binarycpython.utils.grid.Population method)</a> </li> @@ -595,31 +860,43 @@ </li> <li><a href="plot_functions.html#binarycpython.utils.plot_functions.parse_function_orbit">parse_function_orbit() (in module binarycpython.utils.plot_functions)</a> </li> - <li><a href="spacing_functions.html#binarycpython.utils.spacing_functions.peak_normalized_gaussian_func">peak_normalized_gaussian_func() (in module binarycpython.utils.spacing_functions)</a> + <li><a href="population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.peak_normalized_gaussian_func">peak_normalized_gaussian_func() (binarycpython.utils.population_extensions.spacing_functions.spacing_functions method)</a> </li> <li><a href="plot_functions.html#binarycpython.utils.plot_functions.plot_HR_diagram">plot_HR_diagram() (in module binarycpython.utils.plot_functions)</a> </li> <li><a href="plot_functions.html#binarycpython.utils.plot_functions.plot_masses">plot_masses() (in module binarycpython.utils.plot_functions)</a> </li> - </ul></td> - <td style="width: 33%; vertical-align: top;"><ul> <li><a href="plot_functions.html#binarycpython.utils.plot_functions.plot_orbit">plot_orbit() (in module binarycpython.utils.plot_functions)</a> </li> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> <li><a href="plot_functions.html#binarycpython.utils.plot_functions.plot_system">plot_system() (in module binarycpython.utils.plot_functions)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.poisson">poisson() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.poisson">poisson() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.NullCache.popitem">popitem() (binarycpython.utils.population_extensions.cache.cache.NullCache method)</a> </li> <li><a href="grid.html#binarycpython.utils.grid.Population">Population (class in binarycpython.utils.grid)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.powerlaw">powerlaw() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw">powerlaw() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_constant">powerlaw_constant() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.powerlaw_constant">powerlaw_constant() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_constant_nocache">powerlaw_constant_nocache() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.powerlaw_extrapolation_q">powerlaw_extrapolation_q() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_extrapolation_q">powerlaw_extrapolation_q() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.prepare_dict">prepare_dict() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="dicts.html#binarycpython.utils.dicts.prepare_dict">prepare_dict() (in module binarycpython.utils.dicts)</a> </li> - <li><a href="grid_options_defaults.html#binarycpython.utils.grid_options_defaults.print_option_descriptions">print_option_descriptions() (in module binarycpython.utils.grid_options_defaults)</a> + <li><a href="population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.print_option_descriptions">print_option_descriptions() (binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults method)</a> +</li> + </ul></td> +</tr></table> + +<h2 id="Q">Q</h2> +<table style="width: 100%" class="indextable genindextable"><tr> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="functions.html#binarycpython.utils.functions.quotewrap">quotewrap() (in module binarycpython.utils.functions)</a> </li> </ul></td> </tr></table> @@ -629,24 +906,24 @@ <td style="width: 33%; vertical-align: top;"><ul> <li><a href="useful_funcs.html#binarycpython.utils.useful_funcs.ragb">ragb() (in module binarycpython.utils.useful_funcs)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.raghavan2010_binary_fraction">raghavan2010_binary_fraction() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.raghavan2010_binary_fraction">raghavan2010_binary_fraction() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="dicts.html#binarycpython.utils.dicts.recursive_change_key_to_float">recursive_change_key_to_float() (in module binarycpython.utils.dicts)</a> +</li> + <li><a href="dicts.html#binarycpython.utils.dicts.recursive_change_key_to_string">recursive_change_key_to_string() (in module binarycpython.utils.dicts)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.remove_file">remove_file() (in module binarycpython.utils.functions)</a> </li> - <li><a href="grid.html#binarycpython.utils.grid.Population.rename_grid_variable">rename_grid_variable() (binarycpython.utils.grid.Population method)</a> + <li><a href="population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode.rename_grid_variable">rename_grid_variable() (binarycpython.utils.population_extensions.gridcode.gridcode method)</a> </li> <li><a href="grid.html#binarycpython.utils.grid.Population.return_all_info">return_all_info() (binarycpython.utils.grid.Population method)</a> -</li> - <li><a href="grid.html#binarycpython.utils.grid.Population.return_binary_c_defaults">return_binary_c_defaults() (binarycpython.utils.grid.Population method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="grid.html#binarycpython.utils.grid.Population.return_binary_c_version_info">return_binary_c_version_info() (binarycpython.utils.grid.Population method)</a> - - <ul> - <li><a href="functions.html#binarycpython.utils.functions.return_binary_c_version_info">(in module binarycpython.utils.functions)</a> + <li><a href="grid.html#binarycpython.utils.grid.Population.return_binary_c_defaults">return_binary_c_defaults() (binarycpython.utils.grid.Population method)</a> +</li> + <li><a href="population_extensions/version_info.html#binarycpython.utils.population_extensions.version_info.version_info.return_binary_c_version_info">return_binary_c_version_info() (binarycpython.utils.population_extensions.version_info.version_info method)</a> </li> - </ul></li> <li><a href="custom_logging_functions.html#binarycpython.utils.custom_logging_functions.return_compilation_dict">return_compilation_dict() (in module binarycpython.utils.custom_logging_functions)</a> </li> <li><a href="grid.html#binarycpython.utils.grid.Population.return_population_settings">return_population_settings() (binarycpython.utils.grid.Population method)</a> @@ -663,15 +940,53 @@ <h2 id="S">S</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.sana12">sana12() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.sana12">sana12() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.save_population_object">save_population_object() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.save_snapshot">save_snapshot() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> </li> <li><a href="grid.html#binarycpython.utils.grid.Population.set">set() (binarycpython.utils.grid.Population method)</a> +</li> + <li><a href="population_extensions/condor.html#binarycpython.utils.population_extensions.condor.condor.set_condor_status">set_condor_status() (binarycpython.utils.population_extensions.condor.condor method)</a> +</li> + <li><a href="population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.set_moe_di_stefano_settings">set_moe_di_stefano_settings() (binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017 method)</a> +</li> + <li><a href="dicts.html#binarycpython.utils.dicts.set_opts">set_opts() (in module binarycpython.utils.dicts)</a> +</li> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.set_slurm_status">set_slurm_status() (binarycpython.utils.population_extensions.slurm.slurm method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.set_status">set_status() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics.set_time">set_time() (binarycpython.utils.population_extensions.analytics.analytics method)</a> +</li> + <li><a href="population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.setup_function_cache">setup_function_cache() (binarycpython.utils.population_extensions.cache.cache method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="grid.html#binarycpython.utils.grid.Population.set_moe_di_stefano_settings">set_moe_di_stefano_settings() (binarycpython.utils.grid.Population method)</a> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm">slurm (class in binarycpython.utils.population_extensions.slurm)</a> +</li> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_check_requirements">slurm_check_requirements() (binarycpython.utils.population_extensions.slurm.slurm method)</a> +</li> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_dirs">slurm_dirs() (binarycpython.utils.population_extensions.slurm.slurm method)</a> +</li> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_grid">slurm_grid() (binarycpython.utils.population_extensions.slurm.slurm method)</a> +</li> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_outfile">slurm_outfile() (binarycpython.utils.population_extensions.slurm.slurm method)</a> +</li> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_queue_stats">slurm_queue_stats() (binarycpython.utils.population_extensions.slurm.slurm method)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.set_opts">set_opts() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurm_status_file">slurm_status_file() (binarycpython.utils.population_extensions.slurm.slurm method)</a> +</li> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurmID">slurmID() (binarycpython.utils.population_extensions.slurm.slurm method)</a> +</li> + <li><a href="population_extensions/slurm.html#binarycpython.utils.population_extensions.slurm.slurm.slurmpath">slurmpath() (binarycpython.utils.population_extensions.slurm.slurm method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.snapshot_filename">snapshot_filename() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> +</li> + <li><a href="population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions">spacing_functions (class in binarycpython.utils.population_extensions.spacing_functions)</a> +</li> + <li><a href="dicts.html#binarycpython.utils.dicts.subtract_dicts">subtract_dicts() (in module binarycpython.utils.dicts)</a> </li> </ul></td> </tr></table> @@ -681,10 +996,14 @@ <td style="width: 33%; vertical-align: top;"><ul> <li><a href="functions.html#binarycpython.utils.functions.temp_dir">temp_dir() (in module binarycpython.utils.functions)</a> </li> - <li><a href="distribution_functions.html#binarycpython.utils.distribution_functions.three_part_powerlaw">three_part_powerlaw() (in module binarycpython.utils.distribution_functions)</a> + <li><a href="population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache.test_caches">test_caches() (binarycpython.utils.population_extensions.cache.cache method)</a> +</li> + <li><a href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.three_part_powerlaw">three_part_powerlaw() (binarycpython.utils.population_extensions.distribution_functions.distribution_functions method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics.time_elapsed">time_elapsed() (binarycpython.utils.population_extensions.analytics.analytics method)</a> +</li> <li><a href="functions.html#binarycpython.utils.functions.timedelta">timedelta() (in module binarycpython.utils.functions)</a> </li> <li><a href="functions.html#binarycpython.utils.functions.trem">trem() (in module binarycpython.utils.functions)</a> @@ -695,7 +1014,11 @@ <h2 id="U">U</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="grid.html#binarycpython.utils.grid.Population.update_grid_variable">update_grid_variable() (binarycpython.utils.grid.Population method)</a> + <li><a href="dicts.html#binarycpython.utils.dicts.update_dicts">update_dicts() (in module binarycpython.utils.dicts)</a> +</li> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode.update_grid_variable">update_grid_variable() (binarycpython.utils.population_extensions.gridcode.gridcode method)</a> </li> </ul></td> </tr></table> @@ -703,13 +1026,19 @@ <h2 id="V">V</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="grid.html#binarycpython.utils.grid.Population.vb1print">vb1print() (binarycpython.utils.grid.Population method)</a> + <li><a href="population_extensions/grid_logging.html#binarycpython.utils.population_extensions.grid_logging.grid_logging.vb1print">vb1print() (binarycpython.utils.population_extensions.grid_logging.grid_logging method)</a> +</li> + <li><a href="population_extensions/grid_logging.html#binarycpython.utils.population_extensions.grid_logging.grid_logging.vb2print">vb2print() (binarycpython.utils.population_extensions.grid_logging.grid_logging method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="grid.html#binarycpython.utils.grid.Population.vb2print">vb2print() (binarycpython.utils.grid.Population method)</a> + <li><a href="population_extensions/grid_logging.html#binarycpython.utils.population_extensions.grid_logging.grid_logging.verbose_print">verbose_print() (binarycpython.utils.population_extensions.grid_logging.grid_logging method)</a> + + <ul> + <li><a href="functions.html#binarycpython.utils.functions.verbose_print">(in module binarycpython.utils.functions)</a> </li> - <li><a href="functions.html#binarycpython.utils.functions.verbose_print">verbose_print() (in module binarycpython.utils.functions)</a> + </ul></li> + <li><a href="population_extensions/version_info.html#binarycpython.utils.population_extensions.version_info.version_info">version_info (class in binarycpython.utils.population_extensions.version_info)</a> </li> </ul></td> </tr></table> @@ -717,15 +1046,19 @@ <h2 id="W">W</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="grid.html#binarycpython.utils.grid.Population.write_binary_c_calls_to_file">write_binary_c_calls_to_file() (binarycpython.utils.grid.Population method)</a> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.wait_for_unlock">wait_for_unlock() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> </li> - <li><a href="functions.html#binarycpython.utils.functions.write_binary_c_parameter_descriptions_to_rst_file">write_binary_c_parameter_descriptions_to_rst_file() (in module binarycpython.utils.functions)</a> + <li><a href="grid.html#binarycpython.utils.grid.Population.was_killed">was_killed() (binarycpython.utils.grid.Population method)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.write_binary_c_calls_to_file">write_binary_c_calls_to_file() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="grid.html#binarycpython.utils.grid.Population.write_ensemble">write_ensemble() (binarycpython.utils.grid.Population method)</a> + <li><a href="functions.html#binarycpython.utils.functions.write_binary_c_parameter_descriptions_to_rst_file">write_binary_c_parameter_descriptions_to_rst_file() (in module binarycpython.utils.functions)</a> +</li> + <li><a href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO.write_ensemble">write_ensemble() (binarycpython.utils.population_extensions.dataIO.dataIO method)</a> </li> - <li><a href="grid_options_defaults.html#binarycpython.utils.grid_options_defaults.write_grid_options_to_rst_file">write_grid_options_to_rst_file() (in module binarycpython.utils.grid_options_defaults)</a> + <li><a href="population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.write_grid_options_to_rst_file">write_grid_options_to_rst_file() (binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults method)</a> </li> </ul></td> </tr></table> @@ -741,48 +1074,36 @@ </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/grid.html b/docs/build/html/grid.html index ca3371454980df4c5ee241d5574d6fad88eab4eb..2e1649edaa45e732b43ba2644dd426ce57e8c6d4 100644 --- a/docs/build/html/grid.html +++ b/docs/build/html/grid.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>grid_class module — binary_c-python documentation</title> - - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class module — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> - <link rel="next" title="Grid options and descriptions" href="grid_options_defaults.html" /> + <link rel="next" title="plot_functions module" href="plot_functions.html" /> <link rel="prev" title="functions module" href="functions.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,30 +38,32 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> <li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="ensemble.html">ensemble module</a></li> <li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2 current"><a class="current reference internal" href="#">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class module</a></li> <li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> <li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> <li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> <li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> </ul> @@ -107,70 +75,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li><a href="modules.html">Binarycpython code</a> »</li> - - <li>grid_class module</li> - - + <li>Population class module</li> <li class="wy-breadcrumbs-aside"> - - <a href="_sources/grid.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -195,10 +124,11 @@ text-align: unset; } </style> -<div class="section" id="module-binarycpython.utils.grid"> -<span id="grid-class-module"></span><h1>grid_class module<a class="headerlink" href="#module-binarycpython.utils.grid" title="Permalink to this headline">¶</a></h1> +<section id="module-binarycpython.utils.grid"> +<span id="population-class-module"></span><h1>Population class module<a class="headerlink" href="#module-binarycpython.utils.grid" title="Permalink to this heading">ïƒ</a></h1> <p>Module containing the Population grid class object.</p> <p>Here all the functionality of a Population object is defined.</p> +<p>TODO: the save_snapshots and save_snapshot, are they actually distinct?</p> <dl class="simple"> <dt>Tasks:</dt><dd><ul class="simple"> <li><p>TODO: add functionality to ‘on-init’ set arguments</p></li> @@ -212,112 +142,23 @@ <li><p>TODO: consider spreading the functions over more files.</p></li> <li><p>TODO: type the private functions</p></li> <li><p>TODO: fix the correct object types for the default values of the bse_options</p></li> -<li><p>TODO: uncomment and implement the HPC functionality</p></li> <li><p>TODO: think of a clean and nice way to unload and remove the custom_logging_info library from memory (and from disk)</p></li> <li><p>TODO: think of a nice way to remove the loaded grid_code/ generator from memory.</p></li> </ul> </dd> </dl> +<p>TODO: Some of the methods that we have defined in the (mixin) class are designed to be used as a portal to information (return_binary_c_version_info for example.) THe current design is that they are all instance methods, but that is not always necessary. We can decorate them with @staticmethod, or @classmethod to make it easier to use them (<a class="reference external" href="https://realpython.com/instance-class-and-static-methods-demystified/">https://realpython.com/instance-class-and-static-methods-demystified/</a>)</p> <dl class="py class"> <dt class="sig sig-object py" id="binarycpython.utils.grid.Population"> -<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.grid.</span></span><span class="sig-name descname"><span class="pre">Population</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population" title="Permalink to this definition">¶</a></dt> -<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.grid.</span></span><span class="sig-name descname"><span class="pre">Population</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <a class="reference internal" href="population_extensions/analytics.html#binarycpython.utils.population_extensions.analytics.analytics" title="binarycpython.utils.population_extensions.analytics.analytics"><code class="xref py py-class docutils literal notranslate"><span class="pre">analytics</span></code></a>, <a class="reference internal" href="population_extensions/cache.html#binarycpython.utils.population_extensions.cache.cache" title="binarycpython.utils.population_extensions.cache.cache"><code class="xref py py-class docutils literal notranslate"><span class="pre">cache</span></code></a>, <a class="reference internal" href="population_extensions/dataIO.html#binarycpython.utils.population_extensions.dataIO.dataIO" title="binarycpython.utils.population_extensions.dataIO.dataIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">dataIO</span></code></a>, <a class="reference internal" href="population_extensions/distribution_functions.html#binarycpython.utils.population_extensions.distribution_functions.distribution_functions" title="binarycpython.utils.population_extensions.distribution_functions.distribution_functions"><code class="xref py py-class docutils literal notranslate"><span class="pre">distribution_functions</span></code></a>, <a class="reference internal" href="population_extensions/grid_logging.html#binarycpython.utils.population_extensions.grid_logging.grid_logging" title="binarycpython.utils.population_extensions.grid_logging.grid_logging"><code class="xref py py-class docutils literal notranslate"><span class="pre">grid_logging</span></code></a>, <a class="reference internal" href="population_extensions/grid_options_defaults.html#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults" title="binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults"><code class="xref py py-class docutils literal notranslate"><span class="pre">grid_options_defaults</span></code></a>, <a class="reference internal" href="population_extensions/gridcode.html#binarycpython.utils.population_extensions.gridcode.gridcode" title="binarycpython.utils.population_extensions.gridcode.gridcode"><code class="xref py py-class docutils literal notranslate"><span class="pre">gridcode</span></code></a>, <a class="reference internal" href="population_extensions/HPC.html#binarycpython.utils.population_extensions.HPC.HPC" title="binarycpython.utils.population_extensions.HPC.HPC"><code class="xref py py-class docutils literal notranslate"><span class="pre">HPC</span></code></a>, <a class="reference internal" href="population_extensions/metadata.html#binarycpython.utils.population_extensions.metadata.metadata" title="binarycpython.utils.population_extensions.metadata.metadata"><code class="xref py py-class docutils literal notranslate"><span class="pre">metadata</span></code></a>, <a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017" title="binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017"><code class="xref py py-class docutils literal notranslate"><span class="pre">Moe_di_Stefano_2017</span></code></a>, <a class="reference internal" href="population_extensions/spacing_functions.html#binarycpython.utils.population_extensions.spacing_functions.spacing_functions" title="binarycpython.utils.population_extensions.spacing_functions.spacing_functions"><code class="xref py py-class docutils literal notranslate"><span class="pre">spacing_functions</span></code></a>, <a class="reference internal" href="population_extensions/version_info.html#binarycpython.utils.population_extensions.version_info.version_info" title="binarycpython.utils.population_extensions.version_info.version_info"><code class="xref py py-class docutils literal notranslate"><span class="pre">version_info</span></code></a></p> <p>Population Object. Contains all the necessary functions to set up, run and process a population of systems</p> -<dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.Moe_di_Stefano_2017"> -<span class="sig-name descname"><span class="pre">Moe_di_Stefano_2017</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.Moe_di_Stefano_2017"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.Moe_di_Stefano_2017" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to handle setting the user input settings, -set up the data and load that into interpolators and -then set the distribution functions</p> -<p>Takes a dictionary as its only argument</p> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.add_grid_variable"> -<span class="sig-name descname"><span class="pre">add_grid_variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parameter_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">longname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">valuerange</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">samplerfunc</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">probdist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dphasevol</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gridtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'centred'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">branchpoint</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">branchcode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">precode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">postcode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">topcode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bottomcode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condition</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.add_grid_variable"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.add_grid_variable" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to add grid variables to the grid_options.</p> -<p>The execution of the grid generation will be through a nested for loop. -Each of the grid variables will get create a deeper for loop.</p> -<p>The real function that generates the numbers will get written to a new file in the TMP_DIR, -and then loaded imported and evaluated. -beware that if you insert some destructive piece of code, it will be executed anyway. -Use at own risk.</p> -<dl class="simple"> -<dt>Tasks:</dt><dd><ul class="simple"> -<li><p>TODO: Fix this complex function.</p></li> -</ul> -</dd> -</dl> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>name</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <p>name of parameter used in the grid Python code. -This is evaluated as a parameter and you can use it throughout -the rest of the function</p> -<p class="rubric">Examples</p> -<p>name = ‘lnm1’</p> -</p></li> -<li><p><strong>parameter_name</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <p>name of the parameter in binary_c</p> -<p>This name must correspond to a Python variable of the same name, -which is automatic if parameter_name == name.</p> -<dl class="simple"> -<dt>Note: if parameter_name != name, you must set a</dt><dd><p>variable in “precode†or “postcode†to define a Python variable -called parameter_name</p> -</dd> -</dl> -</p></li> -<li><p><strong>longname</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <p>Long name of parameter</p> -<p class="rubric">Examples</p> -<p>longname = ‘Primary mass’</p> -</p></li> -<li><p><strong>range</strong> – <p>Range of values to take. Does not get used really, the samplerfunc is used to -get the values from</p> -<p class="rubric">Examples</p> -<p>range = [math.log(m_min), math.log(m_max)]</p> -</p></li> -<li><p><strong>samplerfunc</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <p>Function returning a list or numpy array of samples spaced appropriately. -You can either use a real function, or a string representation of a function call.</p> -<p class="rubric">Examples</p> -<p>samplerfunc = “const(math.log(m_min), math.log(m_max), {})â€.format(resolution[‘M_1’])</p> -</p></li> -<li><p><strong>precode</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – <p>Extra room for some code. This code will be evaluated within the loop of the -sampling function (i.e. a value for lnm1 is chosen already)</p> -<p class="rubric">Examples</p> -<p>precode = ‘M_1=math.exp(lnm1);’</p> -</p></li> -<li><p><strong>postcode</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – Code executed after the probability is calculated.</p></li> -<li><p><strong>probdist</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <p>Function determining the probability that gets assigned to the sampled parameter</p> -<p class="rubric">Examples</p> -<p>probdist = ‘Kroupa2001(M_1)*M_1’</p> -</p></li> -<li><p><strong>dphasevol</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – <p>part of the parameter space that the total probability is calculated with. Put to -1 -if you want to ignore any dphasevol calculations and set the value to 1 -.. rubric:: Examples</p> -<p>dphasevol = ‘dlnm1’</p> -</p></li> -<li><p><strong>condition</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – <p>condition that has to be met in order for the grid generation to continue -.. rubric:: Examples</p> -<p>condition = ‘self.grid_options[‘binary’]==1’</p> -</p></li> -<li><p><strong>gridtype</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – Method on how the value range is sampled. Can be either ‘edge’ (steps starting at -the lower edge of the value range) or ‘centred’ -(steps starting at lower edge + 0.5 * stepsize).</p></li> -<li><p><strong>topcode</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – Code added at the very top of the block.</p></li> -<li><p><strong>bottomcode</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – Code added at the very bottom of the block.</p></li> -</ul> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> -</dd> -</dl> -</dd></dl> - <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.grid.Population.clean"> -<span class="sig-name descname"><span class="pre">clean</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.clean"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.clean" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">clean</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.clean"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.clean" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Clean the contents of the population object so it can be reused.</p> -<p>Calling _pre_run_cleanup()</p> +<p>Calling _pre_run_setup()</p> <p>TODO: decide to deprecate this function</p> <dl class="field-list simple"> <dt class="field-odd">Return type</dt> @@ -326,42 +167,26 @@ the lower edge of the value range) or ‘centred’ </dl> </dd></dl> -<dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.delete_grid_variable"> -<span class="sig-name descname"><span class="pre">delete_grid_variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.delete_grid_variable"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.delete_grid_variable" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> -</dd> -</dl> -</dd></dl> - <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.grid.Population.evolve"> -<span class="sig-name descname"><span class="pre">evolve</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.evolve"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.evolve" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">evolve</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.evolve"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.evolve" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Entry point function of the whole object. From here, based on the settings, -we set up a SLURM or CONDOR grid, or if no setting is given we go straight -to evolving the population.</p> -<dl class="simple"> -<dt>There are no direct arguments to this function, rather it is based on the grid_options settings:</dt><dd><p>grid_options[‘slurm’]: integer Boolean whether to use a slurm_grid evolution -grid_options[‘condor’]: integer Boolean whether to use a condor_grid evolution</p> -</dd> -</dl> -<p>If neither of the above is set, we continue without using HPC routines -(that doesn’t mean this cannot be run on a server with many cores)</p> -<p>Returns an dictionary containing the analytics of the run</p> -<p>TODO: change the way this is done. Slurm & CONDOR should probably do this differently -NOTE: SLURM and CONDOR options are not working properly yet</p> +we set up a grid and (probably) evolve the population.</p> +<p>There are no direct arguments to this function, the grid_options +contain all the relevant settings.</p> <dl class="field-list simple"> <dt class="field-odd">Return type</dt> <dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> </dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>a dictionary containing the analytics of the run.</p> +</dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.grid.Population.evolve_single"> -<span class="sig-name descname"><span class="pre">evolve_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">clean_up_custom_logging_files</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.evolve_single"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.evolve_single" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">evolve_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">clean_up_custom_logging_files</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.evolve_single"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.evolve_single" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to run a single system, based on the settings in the grid_options</p> <p>The output of the run gets returned, unless a parse function is given to this function.</p> <dl class="field-list simple"> @@ -377,18 +202,21 @@ NOTE: SLURM and CONDOR options are not working properly yet</p> </dl> </dd></dl> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.exit"> +<span class="sig-name descname"><span class="pre">exit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">message</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flush</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stacktrace</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.exit"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.exit" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Exit function: use this to exit from a Population object. +Really it’s just a wrapper for sys.exit() to return the correct exit code, +but also to post a message (if message is True, default is True) +and perhaps a stacktrace (if stacktrace is True, default is False).</p> +</dd></dl> + <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.grid.Population.export_all_info"> -<span class="sig-name descname"><span class="pre">export_all_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">use_datadir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">outfile</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_population_settings</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_defaults</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_version_info</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_help_all</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.export_all_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.export_all_info" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">export_all_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">use_datadir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">outfile</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_population_settings</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_defaults</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_version_info</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_help_all</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ensure_ascii</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">4</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.export_all_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.export_all_info" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that exports the all_info to a JSON file</p> <dl class="simple"> <dt>Tasks:</dt><dd><ul class="simple"> -<li><dl class="simple"> -<dt>TODO: if any of the values in the dicts here is of a not-serialisable form, then we</dt><dd><p>need to change that to a string or something so, use a recursive function that -goes over the all_info dict and finds those that fit</p> -</dd> -</dl> -</li> <li><p>TODO: Fix to write things to the directory. which options do which etc</p></li> <li><p>TODO: there’s flawed logic here. rewrite this part pls</p></li> <li><dl class="simple"> @@ -415,6 +243,9 @@ If the custom_options[“base_filenameâ€] is set, the output file will be call <custom_options[“base_filenameâ€]>_settings.json. Otherwise a file called simulation_<date+time>_settings.json will be created</p></li> <li><p><strong>outfile</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – if use_datadir is false, a custom filename will be used</p></li> +<li><p><strong>ensure_ascii</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – the ensure_ascii flag passed to json.dump and/or json.dumps +(Default: False)</p></li> +<li><p><strong>indent</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – indentation passed to json.dump and/or json.dumps (default 4)</p></li> </ul> </dd> <dt class="field-even">Return type</dt> @@ -423,9 +254,17 @@ simulation_<date+time>_settings.json will be created</p></li> </dl> </dd></dl> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.jobID"> +<span class="sig-name descname"><span class="pre">jobID</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.jobID"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.jobID" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return the job ID number of this process as a string.</p> +<p>Normal processes return their process ID (PID) +HPC processes return whatever HPC_jobID() gives.</p> +</dd></dl> + <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.grid.Population.parse_cmdline"> -<span class="sig-name descname"><span class="pre">parse_cmdline</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.parse_cmdline"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.parse_cmdline" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">parse_cmdline</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.parse_cmdline"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.parse_cmdline" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to handle settings values via the command line in the form x=y, w=z, etc.</p> <p>Best to be called after all the .set(..) lines, and just before the .evolve() is called</p> <p>If you input any known parameter (i.e. contained in grid_options, defaults/bse_options @@ -441,30 +280,9 @@ can change to ints.</p> </dl> </dd></dl> -<dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.rename_grid_variable"> -<span class="sig-name descname"><span class="pre">rename_grid_variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">oldname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newname</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.rename_grid_variable"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.rename_grid_variable" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to rename a grid variable.</p> -<p>note: this does NOT alter the order -of the self.grid_options[“_grid_variablesâ€] dictionary.</p> -<p>The order in which the grid variables are loaded into the grid is based on their -<cite>grid_variable_number</cite> property</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>oldname</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – old name of the grid variable</p></li> -<li><p><strong>newname</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – new name of the grid variable</p></li> -</ul> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> -</dd> -</dl> -</dd></dl> - <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.grid.Population.return_all_info"> -<span class="sig-name descname"><span class="pre">return_all_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">include_population_settings</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_defaults</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_version_info</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_help_all</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.return_all_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.return_all_info" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">return_all_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">include_population_settings</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_defaults</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_version_info</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_binary_c_help_all</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.return_all_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.return_all_info" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that returns all the information about the population and binary_c</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -489,19 +307,13 @@ the binary_c parameters (see get_help_all)</p></li> <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.grid.Population.return_binary_c_defaults"> -<span class="sig-name descname"><span class="pre">return_binary_c_defaults</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.return_binary_c_defaults"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.return_binary_c_defaults" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">return_binary_c_defaults</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.return_binary_c_defaults"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.return_binary_c_defaults" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that returns the defaults of the binary_c version that is used.</p> </dd></dl> -<dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.return_binary_c_version_info"> -<span class="sig-name descname"><span class="pre">return_binary_c_version_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parsed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.return_binary_c_version_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.return_binary_c_version_info" title="Permalink to this definition">¶</a></dt> -<dd><p>Function that returns the version information of binary_c</p> -</dd></dl> - <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.grid.Population.return_population_settings"> -<span class="sig-name descname"><span class="pre">return_population_settings</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.return_population_settings"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.return_population_settings" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">return_population_settings</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.return_population_settings"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.return_population_settings" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that returns all the options that have been set.</p> <p>Can be combined with JSON to make a nice file.</p> <dl class="field-list simple"> @@ -516,7 +328,7 @@ the binary_c parameters (see get_help_all)</p></li> <dl class="py method"> <dt class="sig sig-object py" id="binarycpython.utils.grid.Population.set"> -<span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.set" title="Permalink to this definition">¶</a></dt> +<span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.set" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to set the values of the population. This is the preferred method to set values of functions, as it provides checks on the input.</p> <p>the bse_options will get populated with all the those that have a key that is present @@ -538,162 +350,50 @@ in the self.grid_options</p> </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.set_moe_di_stefano_settings"> -<span class="sig-name descname"><span class="pre">set_moe_di_stefano_settings</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.set_moe_di_stefano_settings"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.set_moe_di_stefano_settings" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to set user input configurations for the Moe & di Stefano methods</p> -<p>If nothing is passed then we just use the default options</p> +<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.was_killed"> +<span class="sig-name descname"><span class="pre">was_killed</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.was_killed"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.was_killed" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to determine if the process was killed. Returns True if so, false otherwise.</p> </dd></dl> -<dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.update_grid_variable"> -<span class="sig-name descname"><span class="pre">update_grid_variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.update_grid_variable"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.update_grid_variable" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to update the values of a grid variable.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>name</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – name of the grid variable to be changed.</p></li> -<li><p><strong>**kwargs</strong> – key-value pairs to override the existing grid variable data. See add_grid_variable for these names.</p></li> -</ul> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> -</dd> -</dl> </dd></dl> -<dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.vb1print"> -<span class="sig-name descname"><span class="pre">vb1print</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ID</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">now</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">system_number</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">system_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.vb1print"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.vb1print" title="Permalink to this definition">¶</a></dt> -<dd><p>Verbosity-level 1 printing, to keep an eye on a grid. -:param ID: thread ID for debugging (int) -:param now: the time now as a UNIX-style epoch in seconds (float) -:param system_number: the system number</p> -<p>TODO: add information about the number of cores. the TPR shows the dt/dn but i want to see the number per core too</p> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.vb2print"> -<span class="sig-name descname"><span class="pre">vb2print</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">system_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmdline_string</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.vb2print"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.vb2print" title="Permalink to this definition">¶</a></dt> -<dd></dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.write_binary_c_calls_to_file"> -<span class="sig-name descname"><span class="pre">write_binary_c_calls_to_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_defaults</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.write_binary_c_calls_to_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.write_binary_c_calls_to_file" title="Permalink to this definition">¶</a></dt> -<dd><p>Function that loops over the grid code and writes the generated parameters to a file. -In the form of a command line call</p> -<p>Only useful when you have a variable grid as system_generator. MC wouldn’t be that useful</p> -<p>Also, make sure that in this export there are the basic parameters -like m1,m2,sep, orb-per, ecc, probability etc.</p> -<p>On default this will write to the datadir, if it exists</p> -<dl class="simple"> -<dt>Tasks:</dt><dd><ul class="simple"> -<li><p>TODO: test this function</p></li> -<li><p>TODO: make sure the binary_c_python .. output file has a unique name</p></li> -</ul> -</dd> -</dl> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>output_dir</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – (optional, default = None) directory where to write the file to. If custom_options[‘data_dir’] is present, then that one will be used first, and then the output_dir</p></li> -<li><p><strong>output_filename</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – (optional, default = None) filename of the output. If not set it will be called “binary_c_calls.txtâ€</p></li> -<li><p><strong>include_defaults</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = None) whether to include the defaults of binary_c in the lines that are written. Beware that this will result in very long lines, and it might be better to just export the binary_c defaults and keep them in a separate file.</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>filename that was used to write the calls to</p> -</dd> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>filename</p> -</dd> -</dl> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="binarycpython.utils.grid.Population.write_ensemble"> -<span class="sig-name descname"><span class="pre">write_ensemble</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sort_keys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">4</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid.html#Population.write_ensemble"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid.Population.write_ensemble" title="Permalink to this definition">¶</a></dt> -<dd><blockquote> -<div><p>write_ensemble : Write ensemble results to a file.</p> -</div></blockquote> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>output_file</strong> – <p>the output filename.</p> -<p>If the filename has an extension that we recognise, -e.g. .gz or .bz2, we compress the output appropriately.</p> -<p>The filename should contain .json or .msgpack, the two -currently-supported formats.</p> -<p>Usually you’ll want to output to JSON, but we can -also output to msgpack.</p> -</p></li> -<li><p><strong>data</strong> – the data dictionary to be converted and written to the file. -If not set, this defaults to self.grid_ensemble_results.</p></li> -<li><p><strong>sort_keys</strong> – if True, and output is to JSON, the keys will be sorted. -(default: True, passed to json.dumps)</p></li> -<li><p><strong>indent</strong> – number of space characters used in the JSON indent. (Default: 4, -passed to json.dumps)</p></li> -</ul> -</dd> -</dl> -</dd></dl> - -</dd></dl> - -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="grid_options_defaults.html" class="btn btn-neutral float-right" title="Grid options and descriptions" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="functions.html" class="btn btn-neutral float-left" title="functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="functions.html" class="btn btn-neutral float-left" title="functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="plot_functions.html" class="btn btn-neutral float-right" title="plot_functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/grid_options_defaults.html b/docs/build/html/grid_options_defaults.html deleted file mode 100644 index 5fe71735526ae4a66e6519fea3ca513a5cabb364..0000000000000000000000000000000000000000 --- a/docs/build/html/grid_options_defaults.html +++ /dev/null @@ -1,329 +0,0 @@ - - -<!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> -<head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Grid options and descriptions — binary_c-python documentation</title> - - - - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> - <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> - <script src="_static/jquery.js"></script> - <script src="_static/underscore.js"></script> - <script src="_static/doctools.js"></script> - <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="index" title="Index" href="genindex.html" /> - <link rel="search" title="Search" href="search.html" /> - <link rel="next" title="hpc_functions module" href="hpc_functions.html" /> - <link rel="prev" title="grid_class module" href="grid.html" /> -</head> - -<body class="wy-body-for-nav"> - - - <div class="wy-grid-for-nav"> - - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> - <div class="wy-side-scroll"> - <div class="wy-side-nav-search" > - - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - - </a> - - - - - - - -<div role="search"> - <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> - <input type="text" name="q" placeholder="Search docs" /> - <input type="hidden" name="check_keywords" value="yes" /> - <input type="hidden" name="area" value="default" /> - </form> -</div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - - <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> -<ul class="current"> -<li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> -<li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> -<li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2 current"><a class="current reference internal" href="#">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> -<li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> -</ul> -</li> -<li class="toctree-l1"><a class="reference internal" href="example_notebooks.html">Example notebooks</a></li> -<li class="toctree-l1"><a class="reference internal" href="binary_c_parameters.html">Binary_c parameters</a></li> -<li class="toctree-l1"><a class="reference internal" href="grid_options_descriptions.html">Population grid code options</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> -</ul> - - - - </div> - </div> - </nav> - - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - - <i data-toggle="wy-nav-top" class="fa fa-bars"></i> - <a href="index.html">binary_c-python</a> - - </nav> - - - <div class="wy-nav-content"> - - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - - <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - - <li><a href="modules.html">Binarycpython code</a> »</li> - - <li>Grid options and descriptions</li> - - - <li class="wy-breadcrumbs-aside"> - - - <a href="_sources/grid_options_defaults.rst.txt" rel="nofollow"> View page source</a> - - - </li> - - </ul> - - - <hr/> -</div> - <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> - <div itemprop="articleBody"> - - -<style> -/* CSS overrides for sphinx_rtd_theme */ - -/* 24px margin */ -.nbinput.nblast.container, -.nboutput.nblast.container { - margin-bottom: 19px; /* padding has already 5px */ -} - -/* ... except between code cells! */ -.nblast.container + .nbinput.container { - margin-top: -19px; -} - -.admonition > p:before { - margin-right: 4px; /* make room for the exclamation icon */ -} - -/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ -.math { - text-align: unset; -} -</style> -<div class="section" id="module-binarycpython.utils.grid_options_defaults"> -<span id="grid-options-and-descriptions"></span><h1>Grid options and descriptions<a class="headerlink" href="#module-binarycpython.utils.grid_options_defaults" title="Permalink to this headline">¶</a></h1> -<dl class="simple"> -<dt>Module that contains the default options for the population grid code along with the description for these options, in the form of dictionaries:</dt><dd><ul class="simple"> -<li><p>grid_options_defaults_dict: dictionary containing the default values for all the options</p></li> -<li><p>grid_options_descriptions: dictionary containing the description for these options.</p></li> -</ul> -</dd> -<dt>There are several other functions in this module, mostly to generate help texts or documents:</dt><dd><ul class="simple"> -<li><p>grid_options_help: interactive function for the user to get descriptions for options</p></li> -<li><p>grid_options_description_checker: function that checks that checks which options have a description.</p></li> -<li><p>write_grid_options_to_rst_file: function to generate the .rst document for the docs</p></li> -</ul> -</dd> -</dl> -<p>With this its also possible to automatically generate a document containing all the setting names + descriptions.</p> -<p>All the options starting with _ should not be changed by the user except when you really know what you’re doing (which is probably hacking the code :P)</p> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.grid_options_defaults.grid_options_description_checker"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.grid_options_defaults.</span></span><span class="sig-name descname"><span class="pre">grid_options_description_checker</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">print_info</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid_options_defaults.html#grid_options_description_checker"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid_options_defaults.grid_options_description_checker" title="Permalink to this definition">¶</a></dt> -<dd><p>Function that checks which descriptions are missing</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>print_info</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – whether to print out information about which options contain proper descriptions and which do not</p> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></p> -</dd> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>the number of undescribed keys</p> -</dd> -</dl> -</dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.grid_options_defaults.grid_options_help"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.grid_options_defaults.</span></span><span class="sig-name descname"><span class="pre">grid_options_help</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid_options_defaults.html#grid_options_help"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid_options_defaults.grid_options_help" title="Permalink to this definition">¶</a></dt> -<dd><p>Function that prints out the description of a grid option. Useful function for the user.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>option</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – which option you want to have the description of</p> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> -</dd> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>dict containing the option, the description if its there, otherwise empty string. And if the key doesnt exist, the dict is empty</p> -</dd> -</dl> -</dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.grid_options_defaults.print_option_descriptions"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.grid_options_defaults.</span></span><span class="sig-name descname"><span class="pre">print_option_descriptions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filehandle</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">descriptions</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">title</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extra_text</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid_options_defaults.html#print_option_descriptions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid_options_defaults.print_option_descriptions" title="Permalink to this definition">¶</a></dt> -<dd></dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.grid_options_defaults.write_grid_options_to_rst_file"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.grid_options_defaults.</span></span><span class="sig-name descname"><span class="pre">write_grid_options_to_rst_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output_file</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/grid_options_defaults.html#write_grid_options_to_rst_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.grid_options_defaults.write_grid_options_to_rst_file" title="Permalink to this definition">¶</a></dt> -<dd><p>Function that writes the descriptions of the grid options to a rst file</p> -<dl class="simple"> -<dt>Tasks:</dt><dd><p>TODO: separate things into private and public options</p> -</dd> -</dl> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>output_file</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – target file where the grid options descriptions are written to</p> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> -</dd> -</dl> -</dd></dl> - -</div> - - - </div> - - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="hpc_functions.html" class="btn btn-neutral float-right" title="hpc_functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="grid.html" class="btn btn-neutral float-left" title="grid_class module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - - </div> - - - <hr/> - - <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> - </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. -<br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. -<br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. - - - -</footer> - - </div> - </div> - - </section> - - </div> - - - - <script type="text/javascript"> - jQuery(function () { - SphinxRtdTheme.Navigation.enable(true); - }); - </script> - - - - - - -</body> -</html> \ No newline at end of file diff --git a/docs/build/html/grid_options_descriptions.html b/docs/build/html/grid_options_descriptions.html index 505a219392e02ae2e9fd6465d5752de5603595bf..ef254a3631ea52e1deadd54cefc99cd63666eb57 100644 --- a/docs/build/html/grid_options_descriptions.html +++ b/docs/build/html/grid_options_descriptions.html @@ -1,69 +1,35 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Population grid code options — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population grid code options — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="prev" title="Binary_c parameters" href="binary_c_parameters.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -71,17 +37,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> @@ -98,68 +54,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li>Population grid code options</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/grid_options_descriptions.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -184,12 +102,12 @@ text-align: unset; } </style> -<div class="section" id="population-grid-code-options"> -<h1>Population grid code options<a class="headerlink" href="#population-grid-code-options" title="Permalink to this headline">¶</a></h1> +<section id="population-grid-code-options"> +<h1>Population grid code options<a class="headerlink" href="#population-grid-code-options" title="Permalink to this heading">ïƒ</a></h1> <p>The following chapter contains all grid code options, along with their descriptions -There are 9 options that are not described yet.</p> -<div class="section" id="public-options"> -<h2>Public options<a class="headerlink" href="#public-options" title="Permalink to this headline">¶</a></h2> +There are 29 options that are not described yet.</p> +<section id="public-options"> +<h2>Public options<a class="headerlink" href="#public-options" title="Permalink to this heading">ïƒ</a></h2> <p>The following options are meant to be changed by the user.</p> <div class="line-block"> <div class="line"><strong>C_auto_logging</strong>: Dictionary containing parameters to be logged by binary_c. The structure of this dictionary is as follows: the key is used as the headline which the user can then catch. The value at that key is a list of binary_c system parameters (like star[0].mass)</div> @@ -198,13 +116,103 @@ There are 9 options that are not described yet.</p> <div class="line"><strong>C_logging_code</strong>: Variable to store the exact code that is used for the custom_logging. In this way the user can do more complex logging, as well as putting these logging strings in files.</div> </div> <div class="line-block"> +<div class="line"><strong>HPC_force_join</strong>: Integer, default 0. If 1, and the HPC variable (“slurm†or “condorâ€) is 3, skip checking our own job and force the join.</div> +</div> +<div class="line-block"> +<div class="line"><strong>HPC_rebuild_joinlist</strong>: Integer, default 0. If 1, ignore the joinlist we would usually use and rebuild it automatically</div> +</div> +<div class="line-block"> <div class="line"><strong>Moe2017_options</strong>: No description available yet</div> </div> <div class="line-block"> +<div class="line"><strong>cache_dir</strong>: No description available yet</div> +</div> +<div class="line-block"> <div class="line"><strong>combine_ensemble_with_thread_joining</strong>: Boolean 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</div> </div> <div class="line-block"> -<div class="line"><strong>condor</strong>: Int flag whether to use a condor type population evolution. Not implemented yet.</div> +<div class="line"><strong>command_line</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor</strong>: Integer flag used to control HTCondor (referred to as Condor here) jobs. Default is 0 which means no Condor. 1 means launch Condor jobs. Do not manually set this to 2 (run Condor jobs) or 3 (join Condor job data) unless you know what you are doing, this is usually done for you.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_ClusterID</strong>: Integer. Condor ClusterID variable, equivalent to Slurm’s jobid. Jobs are numbered <ClusterID>.<Process></div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_Process</strong>: Integer. Condor Process variable, equivalent to Slurm’s jobarrayindex. Jobs are numbered <ClusterID>.<Process></div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_bash</strong>: String. Points the location of the “bash†command, e.g. /bin/bash, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_batchname</strong>: String. Condor batchname option: this is what appears in condor_q. Defaults to “binary_c-condorâ€</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_date</strong>: String. Points the location of the “date†command, e.g. /usr/bin/date, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_dir</strong>: String. Working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all jobs). This directory should not exist when you launch the Condor jobs.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_env</strong>: String. Points the location of the “env†command, e.g. /usr/bin/env or /bin/env, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_extra_settings</strong>: Dictionary. Place to put extra configuration for the CONDOR submit file. The key and value of the dict will become the key and value of the line in te slurm batch file. Will be put in after all the other settings (and before the command). Take care not to overwrite something without really meaning to do so.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_getenv</strong>: Boolean. If True, the default, condor takes the environment at submission and copies it to the jobs. You almost certainly want this to be True.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_initial_dir</strong>: String. Directory from which condor scripts are run. If set to the default, None, this is the directory from which your script is run.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_kill_sig</strong>: String. Signal Condor should use to stop a process. Note that grid.py expects this to be “SIGINT†which is the default.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_memory</strong>: Integer. In MB, the memory use (ImageSize) of the job.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_njobs</strong>: Integer. Number of jobs that Condor will run</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_postpone_join</strong>: Integer. Use to delay the joining of Condor grid data. If 1, data is not joined, e.g. if you want to do it off the condor grid (e.g. with more RAM). Default 0.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_postpone_submit</strong>: Integer. Debugging tool. If 1, the condor script is not submitted (useful for debugging). Default 0.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_pwd</strong>: String. Points the location of the “pwd†command, e.g. /bin/pwd, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_q</strong>: String. The Condor_q command, usually “/usr/bin/condor_q†but will depend on your HTCondor installation.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_requirements</strong>: String. Condor job requirements. These are passed to Condor directly, you should read the HTCondor manual to learn about this. If no requirements exist, leave as an string.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_should_transfer_files</strong>: Integer. Condor’s option to transfer files at the end of the job. You should set this to “YESâ€</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_snapshot_on_kill</strong>: Integer. If 1 we save a snapshot on SIGKILL before exit.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_stream_error</strong>: Boolean. If True, we activate Condor’s stderr stream. If False, this data is copied at the end of the job.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_stream_output</strong>: Boolean. If True, we activate Condor’s stdout stream. If False, this data is copied at the end of the job.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_submit</strong>: String. The Condor_submit command, usually “/usr/bin/condor_submit†but will depend on your HTCondor installation.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_universe</strong>: String. The HTCondor “universeâ€: this is “vanilla†by default.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_warn_max_memory</strong>: Integer. In MB, the memory use (ImageSize) of the job.</div> +</div> +<div class="line-block"> +<div class="line"><strong>condor_when_to_transfer_output</strong>: Integer. Condor’s option to decide when output files are transferred. You should usually set this to “ON_EXIT_OR_EVICTâ€</div> </div> <div class="line-block"> <div class="line"><strong>custom_generator</strong>: No description available yet</div> @@ -213,36 +221,69 @@ There are 9 options that are not described yet.</p> <div class="line"><strong>custom_logging_func_memaddr</strong>: Memory address where the custom_logging_function is stored. Input: int</div> </div> <div class="line-block"> +<div class="line"><strong>do_analytics</strong>: No description available yet</div> +</div> +<div class="line-block"> <div class="line"><strong>do_dry_run</strong>: Whether to do a dry run to calculate the total probability for this run</div> </div> <div class="line-block"> +<div class="line"><strong>dry_run_hook</strong>: Function hook to be called for every system in a dry run. The function is passed a dict of the system parameters. Does nothing if None (the default).</div> +</div> +<div class="line-block"> +<div class="line"><strong>dry_run_num_cores</strong>: No description available yet</div> +</div> +<div class="line-block"> <div class="line"><strong>ensemble_factor_in_probability_weighted_mass</strong>: Flag to multiply all the ensemble results with 1/probability_weighted_mass</div> </div> <div class="line-block"> -<div class="line"><strong>evolution_type</strong>: Variable containing the type of evolution used of the grid. Multiprocessing or linear processing</div> +<div class="line"><strong>evolution_type</strong>: Variable containing the type of evolution used of the grid. Multiprocessing, linear processing or possibly something else (e.g. for Slurm or Condor).</div> +</div> +<div class="line-block"> +<div class="line"><strong>exit_after_dry_run</strong>: If True, exits after a dry run. Default is False.</div> </div> <div class="line-block"> -<div class="line"><strong>exit_after_dry_run</strong>: No description available yet</div> +<div class="line"><strong>exit_code</strong>: No description available yet</div> </div> <div class="line-block"> <div class="line"><strong>failed_systems_threshold</strong>: Variable storing the maximum number of systems that are allowed to fail before logging their command line arguments to failed_systems log files</div> </div> <div class="line-block"> +<div class="line"><strong>function_cache</strong>: Boolean, default True. If True, we use a cache for certain function calls.</div> +</div> +<div class="line-block"> +<div class="line"><strong>function_cache_TTL</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>function_cache_default_maxsize</strong>: Integer, default 256. The default maxsize of the cache. Should be a power of 2.</div> +</div> +<div class="line-block"> +<div class="line"><strong>function_cache_default_type</strong>: String. One of the following types: LRUCache, LFUCache, FIFOCache, MRUCache, RRCache, TTLCache, NullCache, NoCache. You can find details of what these mean in the Python cachetools manual, except fo NoCache which means no cache is used at all, and NullCache is a dummy cache that never matches, used for testing overheads.</div> +</div> +<div class="line-block"> +<div class="line"><strong>function_cache_functions</strong>: No description available yet</div> +</div> +<div class="line-block"> <div class="line"><strong>gridcode_filename</strong>: Filename for the grid code. Set and used by the population object. TODO: allow the user to provide their own function, rather than only a generated function.</div> </div> <div class="line-block"> -<div class="line"><strong>log_args</strong>: Boolean to log the arguments. Unused</div> +<div class="line"><strong>joinlist</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>log_args</strong>: Boolean to log the arguments.</div> </div> <div class="line-block"> -<div class="line"><strong>log_args_dir</strong>: Directory to log the arguments to. Unused</div> +<div class="line"><strong>log_args_dir</strong>: Directory to log the arguments to.</div> </div> <div class="line-block"> -<div class="line"><strong>log_dt</strong>: No description available yet</div> +<div class="line"><strong>log_dt</strong>: Time between verbose logging output.</div> </div> <div class="line-block"> <div class="line"><strong>log_file</strong>: Log file for the population object. Unused</div> </div> <div class="line-block"> +<div class="line"><strong>log_newline</strong>: Newline character used at the end of verbose logging statements. This is n (newline) by default, but x0d (carriage return) might also be what you want.</div> +</div> +<div class="line-block"> <div class="line"><strong>log_runtime_systems</strong>: Whether to log the runtime of the systems . Each systems run by the thread is logged to a file and is stored in the tmp_dir. (1 file per thread). Don’t use this if you are planning to run a lot of systems. This is mostly for debugging and finding systems that take long to run. Integer, default = 0. if value is 1 then the systems are logged</div> </div> <div class="line-block"> @@ -255,25 +296,121 @@ There are 9 options that are not described yet.</p> <div class="line"><strong>multiplicity_fraction_function</strong>: Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: Moe and di Stefano (2017) 2017</div> </div> <div class="line-block"> -<div class="line"><strong>n_logging_stats</strong>: No description available yet</div> +<div class="line"><strong>n_logging_stats</strong>: Number of logging statistics used to calculate time remaining (etc.). E.g., if you set this to 10 the previous 10 calls to the verbose log will be used to construct an estimate of the time remaining.</div> +</div> +<div class="line-block"> +<div class="line"><strong>num_cores</strong>: The number of cores that the population grid will use. You can set this manually by entering an integer great than 0. When 0 uses all logical cores. When -1 uses all physical cores. Input: int</div> +</div> +<div class="line-block"> +<div class="line"><strong>num_cores_available</strong>: No description available yet</div> </div> <div class="line-block"> -<div class="line"><strong>num_cores</strong>: The number of cores that the population grid will use. The multiprocessing is useful but make sure to figure out how many logical cores the machine has (use e.g. psutil.cpu_count(logical=False) to find the true number of cores, psutil.cpu_count(logical=True) to find the number of logical cores). The core is multi processed, not multi threaded, and will gain no extra speed when num_cores exceeds the number of logical cores. Input: int</div> +<div class="line"><strong>original_command_line</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>original_submission_time</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>original_working_diretory</strong>: No description available yet</div> </div> <div class="line-block"> <div class="line"><strong>parse_function</strong>: Function that the user can provide to handle the output the binary_c. This function has to take the arguments (self, output). Its best not to return anything in this function, and just store stuff in the self.grid_results dictionary, or just output results to a file</div> </div> <div class="line-block"> +<div class="line"><strong>print_stack_on_exit</strong>: If True, prints a stack trace when the population’s exit method is called.</div> +</div> +<div class="line-block"> <div class="line"><strong>repeat</strong>: Factor of how many times a system should be repeated. Consider the evolution splitting binary_c argument for supernovae kick repeating.</div> </div> <div class="line-block"> +<div class="line"><strong>restore_from_snapshot_dir</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>restore_from_snapshot_file</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>return_after_dry_run</strong>: If True, return immediately after a dry run (and don’t run actual stars). Default is False.</div> +</div> +<div class="line-block"> <div class="line"><strong>run_zero_probability_system</strong>: Whether to run the zero probability systems. Default: True. Input: Boolean</div> </div> <div class="line-block"> +<div class="line"><strong>rungrid</strong>: No description available yet</div> +</div> +<div class="line-block"> <div class="line"><strong>save_ensemble_chunks</strong>: No description available yet</div> </div> <div class="line-block"> -<div class="line"><strong>slurm</strong>: Int flag whether to use a Slurm type population evolution.</div> +<div class="line"><strong>save_population_object</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>save_snapshots</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>skip_before</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm</strong>: Integer flag used to control Slurm jobs. Default is 0 which means no Slurm. 1 means launch Slurm jobs. Do not manually set this to 2 (run Slurm jobs) or 3 (join Slurm job data) unless you know what you are doing, this is usually done for you.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_array</strong>: String. Override for Slurm’s –array option, useful for rerunning jobs manually. Default None.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_array_max_jobs</strong>: Integer. Override for the max number of concurrent Slurm array jobs. Default None.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_bash</strong>: String. Points the location of the “bash†command, e.g. /bin/bash, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_date</strong>: String. Points the location of the “date†command, e.g. /usr/bin/date, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_dir</strong>: String. Working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all jobs). This directory should not exist when you launch the Slurm jobs.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_env</strong>: String. Points the location of the “env†command, e.g. /usr/bin/env or /bin/env, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_extra_settings</strong>: Dictionary of extra settings for Slurm to put in its launch script. Please see the Slurm documentation for the many options that are available to you.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_jobarrayindex</strong>: Integer. Slurm job array index. Each job is numbered <slurm_jobid>.<slurm_jobarrayindex>.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_jobid</strong>: Integer. Slurm job id. Each job is numbered <slurm_jobid>.<slurm_jobarrayindex>.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_jobname</strong>: String which names the Slurm jobs, default “binary_c-pythonâ€.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_memory</strong>: String. Memory required for the job. Should be in megabytes in a format that Slurm understands, e.g. “512MB†(the default).</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_njobs</strong>: Integer. Number of Slurm jobs to be launched.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_ntasks</strong>: Integer. Number of CPUs required per array job: usually only need this to be 1 (the default).</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_partition</strong>: String containing the Slurm partition name. You should check your local Slurm installation to find out partition information, e.g. using the sview command.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_postpone_join</strong>: Integer, default 0. If 1 do not join job results with Slurm, instead you have to do it later manually.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_postpone_sbatch</strong>: Integer, default 0. If set to 1, do not launch Slurm jobs with sbatch, just make the scripts that would have.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_pwd</strong>: String. Points the location of the “pwd†command, e.g. /bin/pwd, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_sbatch</strong>: String. The Slurm “sbatch†submission command, usually “/usr/bin/sbatch†but will depend on your Slurm installation. By default is set automatically.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_time</strong>: String. The time a Slurm job is allowed to take. Default is 0 which means no limit. Please check the Slurm documentation for required format of this option.</div> +</div> +<div class="line-block"> +<div class="line"><strong>slurm_warn_max_memory</strong>: String. If we set slurm_memory in excess of this, warn the user because this is usually a mistake. Default “1024MBâ€.</div> </div> <div class="line-block"> <div class="line"><strong>source_file_filename</strong>: Variable containing the source file containing lines of binary_c command line calls. These all have to start with binary_c.</div> @@ -282,7 +419,16 @@ There are 9 options that are not described yet.</p> <div class="line"><strong>start_at</strong>: No description available yet</div> </div> <div class="line-block"> -<div class="line"><strong>symlink latest gridcode</strong>: No description available yet</div> +<div class="line"><strong>start_time</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>status_dir</strong>: Directory where grid status is stored</div> +</div> +<div class="line-block"> +<div class="line"><strong>stop_queue</strong>: No description available yet</div> +</div> +<div class="line-block"> +<div class="line"><strong>symlink_latest_gridcode</strong>: No description available yet</div> </div> <div class="line-block"> <div class="line"><strong>tmp_dir</strong>: Directory where certain types of output are stored. The grid code is stored in that directory, as well as the custom logging libraries. Log files and other diagnostics will usually be written to this location, unless specified otherwise</div> @@ -293,9 +439,12 @@ There are 9 options that are not described yet.</p> <div class="line-block"> <div class="line"><strong>weight</strong>: Weight factor for each system. The calculated probability is multiplied by this. If the user wants each system to be repeated several times, then this variable should not be changed, rather change the _repeat variable instead, as that handles the reduction in probability per system. This is useful for systems that have a process with some random element in it.</div> </div> +<div class="line-block"> +<div class="line"><strong>working_diretory</strong>: No description available yet</div> </div> -<div class="section" id="moe-di-stefano-sampler-options"> -<h2>Moe & di Stefano sampler options<a class="headerlink" href="#moe-di-stefano-sampler-options" title="Permalink to this headline">¶</a></h2> +</section> +<section id="moe-di-stefano-sampler-options"> +<h2>Moe & di Stefano sampler options<a class="headerlink" href="#moe-di-stefano-sampler-options" title="Permalink to this heading">ïƒ</a></h2> <p>The following options are meant to be changed by the user.</p> <div class="line-block"> <div class="line"><strong>JSON</strong>: No description available yet</div> @@ -380,9 +529,9 @@ q extrapolation (below 0.15) method <div class="line-block"> <div class="line"><strong>samplerfuncs</strong>: No description available yet</div> </div> -</div> -<div class="section" id="private-options"> -<h2>Private options<a class="headerlink" href="#private-options" title="Permalink to this headline">¶</a></h2> +</section> +<section id="private-options"> +<h2>Private options<a class="headerlink" href="#private-options" title="Permalink to this heading">ïƒ</a></h2> <p>The following options are not meant to be changed by the user, as these options are used and set internally by the object itself. The description still is provided, but just for documentation purposes.</p> <div class="line-block"> <div class="line"><strong>_Moe2017_JSON_data</strong>: Location to store the loaded Moe&diStefano2017 dataset</div> @@ -436,6 +585,9 @@ q extrapolation (below 0.15) method <div class="line"><strong>_grid_variables</strong>: Dictionary storing the grid_variables. These contain properties which are accessed by the _generate_grid_code function</div> </div> <div class="line-block"> +<div class="line"><strong>_killed</strong>: No description available yet</div> +</div> +<div class="line-block"> <div class="line"><strong>_loaded_Moe2017_data</strong>: Internal variable storing whether the Moe and di Stefano (2017) data has been loaded into memory</div> </div> <div class="line-block"> @@ -448,6 +600,9 @@ q extrapolation (below 0.15) method <div class="line"><strong>_probtot</strong>: Total probability of the population.</div> </div> <div class="line-block"> +<div class="line"><strong>_queue_done</strong>: No description available yet</div> +</div> +<div class="line-block"> <div class="line"><strong>_set_Moe2017_grid</strong>: Internal flag whether the Moe and di Stefano (2017) grid has been loaded</div> </div> <div class="line-block"> @@ -471,60 +626,43 @@ q extrapolation (below 0.15) method <div class="line-block"> <div class="line"><strong>_zero_prob_stars_skipped</strong>: Internal counter to track how many systems are skipped because they have 0 probability</div> </div> -</div> -</div> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - - <a href="binary_c_parameters.html" class="btn btn-neutral float-left" title="Binary_c parameters" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="binary_c_parameters.html" class="btn btn-neutral float-left" title="Binary_c parameters" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/hpc_functions.html b/docs/build/html/hpc_functions.html deleted file mode 100644 index 58582fd2bfb4e67eb24cf0d3103d5fd1cd2505aa..0000000000000000000000000000000000000000 --- a/docs/build/html/hpc_functions.html +++ /dev/null @@ -1,260 +0,0 @@ - - -<!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> -<head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>hpc_functions module — binary_c-python documentation</title> - - - - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> - <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> - <script src="_static/jquery.js"></script> - <script src="_static/underscore.js"></script> - <script src="_static/doctools.js"></script> - <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="index" title="Index" href="genindex.html" /> - <link rel="search" title="Search" href="search.html" /> - <link rel="next" title="plot_functions module" href="plot_functions.html" /> - <link rel="prev" title="Grid options and descriptions" href="grid_options_defaults.html" /> -</head> - -<body class="wy-body-for-nav"> - - - <div class="wy-grid-for-nav"> - - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> - <div class="wy-side-scroll"> - <div class="wy-side-nav-search" > - - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - - </a> - - - - - - - -<div role="search"> - <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> - <input type="text" name="q" placeholder="Search docs" /> - <input type="hidden" name="check_keywords" value="yes" /> - <input type="hidden" name="area" value="default" /> - </form> -</div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - - <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> -<ul class="current"> -<li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> -<li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> -<li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2 current"><a class="current reference internal" href="#">hpc_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> -<li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> -</ul> -</li> -<li class="toctree-l1"><a class="reference internal" href="example_notebooks.html">Example notebooks</a></li> -<li class="toctree-l1"><a class="reference internal" href="binary_c_parameters.html">Binary_c parameters</a></li> -<li class="toctree-l1"><a class="reference internal" href="grid_options_descriptions.html">Population grid code options</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> -</ul> - - - - </div> - </div> - </nav> - - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - - <i data-toggle="wy-nav-top" class="fa fa-bars"></i> - <a href="index.html">binary_c-python</a> - - </nav> - - - <div class="wy-nav-content"> - - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - - <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - - <li><a href="modules.html">Binarycpython code</a> »</li> - - <li>hpc_functions module</li> - - - <li class="wy-breadcrumbs-aside"> - - - <a href="_sources/hpc_functions.rst.txt" rel="nofollow"> View page source</a> - - - </li> - - </ul> - - - <hr/> -</div> - <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> - <div itemprop="articleBody"> - - -<style> -/* CSS overrides for sphinx_rtd_theme */ - -/* 24px margin */ -.nbinput.nblast.container, -.nboutput.nblast.container { - margin-bottom: 19px; /* padding has already 5px */ -} - -/* ... except between code cells! */ -.nblast.container + .nbinput.container { - margin-top: -19px; -} - -.admonition > p:before { - margin-right: 4px; /* make room for the exclamation icon */ -} - -/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ -.math { - text-align: unset; -} -</style> -<div class="section" id="module-binarycpython.utils.hpc_functions"> -<span id="hpc-functions-module"></span><h1>hpc_functions module<a class="headerlink" href="#module-binarycpython.utils.hpc_functions" title="Permalink to this headline">¶</a></h1> -<p>File containing functions for HPC computing, distributed tasks on clusters etc.</p> -<p>Functions that the Slurm and Condor subroutines of the population object use.</p> -<p>Mainly divided in 2 sections: Slurm and Condor</p> -</div> - - - </div> - - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="plot_functions.html" class="btn btn-neutral float-right" title="plot_functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="grid_options_defaults.html" class="btn btn-neutral float-left" title="Grid options and descriptions" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - - </div> - - - <hr/> - - <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> - </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. -<br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. -<br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. - - - -</footer> - - </div> - </div> - - </section> - - </div> - - - - <script type="text/javascript"> - jQuery(function () { - SphinxRtdTheme.Navigation.enable(true); - }); - </script> - - - - - - -</body> -</html> \ No newline at end of file diff --git a/docs/build/html/index.html b/docs/build/html/index.html index ef200e59e68c6403948186b03885632c1905986e..768872082897c1b3da15cbf69b87bf384e49e31f 100644 --- a/docs/build/html/index.html +++ b/docs/build/html/index.html @@ -1,69 +1,35 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Welcome to binary_c-python’s documentation! — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Welcome to binary_c-python’s documentation! — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Python module for binary_c" href="readme_link.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="#" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -71,17 +37,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> @@ -93,68 +49,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="#">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="#">Docs</a> »</li> - + <li><a href="#" class="icon icon-home"></a> »</li> <li>Welcome to binary_c-python’s documentation!</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/index.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -179,38 +97,34 @@ text-align: unset; } </style> -<div class="section" id="welcome-to-binary-c-python-s-documentation"> -<h1>Welcome to binary_c-python’s documentation!<a class="headerlink" href="#welcome-to-binary-c-python-s-documentation" title="Permalink to this headline">¶</a></h1> -</div> -<div class="section" id="python-module-for-binary-c"> -<h1>Python module for binary_c<a class="headerlink" href="#python-module-for-binary-c" title="Permalink to this headline">¶</a></h1> +<section id="welcome-to-binary-c-python-s-documentation"> +<h1>Welcome to binary_c-python’s documentation!<a class="headerlink" href="#welcome-to-binary-c-python-s-documentation" title="Permalink to this heading">ïƒ</a></h1> +</section> +<section id="python-module-for-binary-c"> +<h1>Python module for binary_c<a class="headerlink" href="#python-module-for-binary-c" title="Permalink to this heading">ïƒ</a></h1> <p>Docstring coverage:</p> <a class="reference external image-reference" href="./badges/docstring_coverage.svg"><img alt="docstring coverage" src="_images/docstring_coverage.svg" /></a> <p>Test coverage:</p> <a class="reference external image-reference" href="./badges/test_coverage.svg"><img alt="test coverage" src="_images/test_coverage.svg" /></a> -<p>Binary population synthesis code that interfaces with binary_c. Based on a original work by Jeff Andrews (can be found in old_solution/ directory). Updated and extended for Python3 by David Hendriks, Robert Izzard.</p> -<p>The current release is version <a class="reference external" href="VERSION">version</a>, make sure to use that version number when installing!</p> -<div class="section" id="requirements"> -<h2>Requirements<a class="headerlink" href="#requirements" title="Permalink to this headline">¶</a></h2> +<p>Powered by:</p> +<a class="reference external image-reference" href="http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat"><img alt="astropy" src="http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat" /></a> +<p>We present our package <a class="reference external" href="https://ri0005.pages.surrey.ac.uk/binary_c-python/">binary-c-python</a>, a population synthesis code which is aimed to provide a convenient and easy-to-use interface to the <a class="reference external" href="http://personal.ph.surrey.ac.uk/~ri0005/doc/binary_c/binary_c.html">binary_c</a> framework, allowing the user to rapidly evolve single stellar systems and populations of star systems. Based on a early work by Jeff Andrews. Updated and extended for Python3 by David Hendriks, Robert Izzard.</p> +<p>binary_c-python is developed for students and scientists in the field of stellar astrophysics, who want to study the evolution of individual or populations of single and binary star systems (see the example use-case notebooks in the <a class="reference external" href="https://ri0005.pages.surrey.ac.uk/binary_c-python/example_notebooks.html">online documentation</a>.</p> +<p>The current release is version <a class="reference external" href="VERSION">version</a>, and is designed and tested to work with binary_c version 2.2.1 (for older or newer versions we can’t guarantee correct behaviour).</p> +<section id="installation"> +<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this heading">ïƒ</a></h2> +<p>To install binary_c-python we need to make sure we meet the requirements of installation, and</p> +<section id="python-requirements"> +<h3>Python requirements<a class="headerlink" href="#python-requirements" title="Permalink to this heading">ïƒ</a></h3> <p>To run this code you need to at least have installations of:</p> <ul class="simple"> -<li><p>Python 3.6 or higher</p></li> -<li><p>binary_c version 2.1.7 or higher</p></li> +<li><p>Python 3.7 or higher (3.6 is EOL, and we are using 3.9 for development)</p></li> +<li><p>binary_c version 2.2.0 or higher</p></li> </ul> -<p>And the following python packages (which will get installed automatically when installing with pip):</p> -<ul class="simple"> -<li><p>numpy</p></li> -<li><p>pytest</p></li> -<li><p>h5py</p></li> -<li><p>pathos</p></li> -<li><p>pandas</p></li> -<li><p>astropy</p></li> -<li><p>matplotlib</p></li> -<li><p>py_rinterpolate</p></li> -</ul> -</div> -<div class="section" id="environment-variables"> -<h2>Environment variables<a class="headerlink" href="#environment-variables" title="Permalink to this headline">¶</a></h2> +<p>The packages that are required for this code to run are listed in the requirements.txt, which automatically gets read out by setup.py</p> +</section> +<section id="environment-variables"> +<h3>Environment variables<a class="headerlink" href="#environment-variables" title="Permalink to this heading">ïƒ</a></h3> <p>Before compilation you need to have certain environment variables:</p> <p>Required:</p> <ul class="simple"> @@ -219,57 +133,86 @@ <li><p><code class="docutils literal notranslate"><span class="pre">LIBRARY_PATH</span></code> should include whatever directories are required to build binary_c (e.g. locations of libgsl, libmemoize, librinterpolate, etc.)</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">GSL_DIR</span></code> should point to the root location where you installed GSL to. This root dir should contain <code class="docutils literal notranslate"><span class="pre">bin/</span></code>, <code class="docutils literal notranslate"><span class="pre">lib/</span></code> etc</p></li> </ul> -</div> -<div class="section" id="build-instructions"> -<h2>Build instructions<a class="headerlink" href="#build-instructions" title="Permalink to this headline">¶</a></h2> +</section> +<section id="build-instructions"> +<h3>Build instructions<a class="headerlink" href="#build-instructions" title="Permalink to this heading">ïƒ</a></h3> <p>First, make sure you have built binary_c (See <code class="docutils literal notranslate"><span class="pre">$BINARY_C/doc/binary_c2.pdf</span></code> section: installation for all the installation instructions for <code class="docutils literal notranslate"><span class="pre">binary_c</span></code>)) and that it functions correctly.</p> -<div class="section" id="installation-via-pip"> -<h3>Installation via PIP:<a class="headerlink" href="#installation-via-pip" title="Permalink to this headline">¶</a></h3> +</section> +<section id="installation-via-pip"> +<h3>Installation via PIP:<a class="headerlink" href="#installation-via-pip" title="Permalink to this heading">ïƒ</a></h3> <p>To install this package via pip:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">binarycpython</span> </pre></div> </div> -<p>This will install the latest stable installation that is available on pip.</p> -</div> -<div class="section" id="installation-from-source"> -<h3>Installation from source:<a class="headerlink" href="#installation-from-source" title="Permalink to this headline">¶</a></h3> -<p>We can also install the package from source, which is useful for development versions and when you want to modify the code. It is recommended that you install this into a virtual environment. From within the root directory, run</p> +<p>This will install the latest stable installation that is available on Pip. The version on the master branch should be the same version as the latest stable version on Pip</p> +</section> +<section id="installation-from-source"> +<h3>Installation from source:<a class="headerlink" href="#installation-from-source" title="Permalink to this heading">ïƒ</a></h3> +<p>We can also install the package from source, which is useful for development versions and when you want to modify the code. It is recommended that you install this into a virtual environment. From within the <code class="docutils literal notranslate"><span class="pre">commands/</span></code> directory, run</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">install</span><span class="o">.</span><span class="n">sh</span> </pre></div> </div> -<p>This will install the package, along with all the dependencies.</p> -<p>If this is not the first time you install the package, but rather rebuild it because you made changes in either binary_c or binarycpython, you can run</p> -<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">install_without_dependencies</span><span class="o">.</span><span class="n">sh</span> -</pre></div> -</div> -<p>to reinstall just binarycpython.</p> -<div class="section" id="after-installation"> -<h4>After installation<a class="headerlink" href="#after-installation" title="Permalink to this headline">¶</a></h4> +<p>This will install the package, along with all the dependencies, into the current active (virtual) python environment.</p> +<section id="after-installation-from-source"> +<h4>After installation from source<a class="headerlink" href="#after-installation-from-source" title="Permalink to this heading">ïƒ</a></h4> <p>After installing the code via source it is useful to run the test suite before doing any programming with it. The test suite is stored in <code class="docutils literal notranslate"><span class="pre">binarycpython/tests</span></code> and running <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">main.py</span></code> in there will run all the tests.</p> -</div> -</div> -</div> -<div class="section" id="examples"> -<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2> +</section> +</section> +<section id="use-of-code-without-installation"> +<h3>Use of code without installation<a class="headerlink" href="#use-of-code-without-installation" title="Permalink to this heading">ïƒ</a></h3> +<p>Because installing <code class="docutils literal notranslate"><span class="pre">binary_c-python</span></code> requires a working installation of <code class="docutils literal notranslate"><span class="pre">binary_c</span></code>, installing via pip or from source without this working installation of <code class="docutils literal notranslate"><span class="pre">binary_c</span></code> won’t work. To still make use of some of the functions provided by <code class="docutils literal notranslate"><span class="pre">binary_c-python</span></code>, you can add the path to the code-base to your <code class="docutils literal notranslate"><span class="pre">PYTHONPATH</span></code>:</p> +<ul class="simple"> +<li><p>Download <code class="docutils literal notranslate"><span class="pre">binary_c-python</span></code>, via e.g. <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">clone</span> <span class="pre">https://gitlab.com/binary_c/binary_c-python.git</span></code></p></li> +<li><p>Add the path to the downloaded repo to your <code class="docutils literal notranslate"><span class="pre">$PYTHONPATH</span></code>, via e.g. <code class="docutils literal notranslate"><span class="pre">export</span> <span class="pre">PYTHONPATH="~/binary_c-python:$PYTHONPATH"</span></code></p></li> +</ul> +</section> +</section> +<section id="usage"> +<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this heading">ïƒ</a></h2> +<section id="examples"> +<h3>Examples<a class="headerlink" href="#examples" title="Permalink to this heading">ïƒ</a></h3> <p>See the examples/ directory for example scripts and notebooks. The documentation contains example pages as well.</p> -</div> -<div class="section" id="usage-notes"> -<h2>Usage notes<a class="headerlink" href="#usage-notes" title="Permalink to this headline">¶</a></h2> +</section> +<section id="usage-notes"> +<h3>Usage notes<a class="headerlink" href="#usage-notes" title="Permalink to this heading">ïƒ</a></h3> <p>Make sure that with every change/recompilation you make in <code class="docutils literal notranslate"><span class="pre">binary_c</span></code>, you also rebuild this package. Whenever you change the sourcecode of this package, you need to reinstall it into your virtualenvironment as well</p> -</div> -<div class="section" id="documentation"> -<h2>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline">¶</a></h2> -<p>Look in the docs/ directory. Within the build/html/ there is the html version of the documentation. The</p> -</div> -<div class="section" id="development"> -<h2>Development:<a class="headerlink" href="#development" title="Permalink to this headline">¶</a></h2> +</section> +<section id="documentation"> +<h3>Documentation<a class="headerlink" href="#documentation" title="Permalink to this heading">ïƒ</a></h3> +<p>Look in the docs/ directory. Within the build/html/ there is the html version of the documentation. The documentation is also hosted on <a class="reference external" href="http://personal.ph.surrey.ac.uk/~ri0005/doc/binary_c/binary_c.html">http://personal.ph.surrey.ac.uk/~ri0005/doc/binary_c/binary_c.html</a> but only for the most recent stable release.</p> +</section> +</section> +<section id="development"> +<h2>Development:<a class="headerlink" href="#development" title="Permalink to this heading">ïƒ</a></h2> <p>If you want to contribute to the code, then it is recommended that you install the packages in <code class="docutils literal notranslate"><span class="pre">development_requirements.txt</span></code>:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="o">-</span><span class="n">r</span> <span class="n">development_requirements</span><span class="o">.</span><span class="n">txt</span> </pre></div> </div> +<p>Please do not hesitate to contact us to discuss any developments.</p> +<section id="generating-documentation"> +<h3>Generating documentation<a class="headerlink" href="#generating-documentation" title="Permalink to this heading">ïƒ</a></h3> +<p>To build the documentation manually, run</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">generate_docs</span><span class="o">.</span><span class="n">sh</span> +</pre></div> +</div> +<p>from within the <code class="docutils literal notranslate"><span class="pre">commands/</span></code> directory</p> +</section> +<section id="generating-docstring-and-test-coverage-report"> +<h3>Generating docstring and test coverage report<a class="headerlink" href="#generating-docstring-and-test-coverage-report" title="Permalink to this heading">ïƒ</a></h3> +<p>To generate the unit test and docstring coverage report, run</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">generate_reports</span><span class="o">.</span><span class="n">sh</span> +</pre></div> </div> -<div class="section" id="faq-issues"> -<h2>FAQ/Issues:<a class="headerlink" href="#faq-issues" title="Permalink to this headline">¶</a></h2> +<p>from within the <code class="docutils literal notranslate"><span class="pre">commands/</span></code> directory</p> +</section> +<section id="running-unit-tests"> +<h3>Running unit tests<a class="headerlink" href="#running-unit-tests" title="Permalink to this heading">ïƒ</a></h3> +<p>There are two versions of the general unit tests. The first includes only the actual code of the project, and is located at <code class="docutils literal notranslate"><span class="pre">binarycpython/test/main.py</span></code>. The second includes the tutorial notebooks, and is located at <code class="docutils literal notranslate"><span class="pre">binarycpython/test/main_with_notebooks.py</span></code>. To run just the notebook tests run <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">binarycpython/tests/test_notebooks.py</span></code></p> +</section> +</section> +<section id="faq-issues"> +<h2>FAQ/Issues:<a class="headerlink" href="#faq-issues" title="Permalink to this heading">ïƒ</a></h2> +<p>Here we provide a non-exhaustive list of some issues we encountered and solutions for these:</p> <p>Building issues with binary_c itself:</p> <ul class="simple"> <li><p>see the documentation of binary_c (in doc/).</p></li> @@ -291,26 +234,34 @@ <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a><ul> -<li class="toctree-l2"><a class="reference internal" href="readme_link.html#requirements">Requirements</a></li> -<li class="toctree-l2"><a class="reference internal" href="readme_link.html#environment-variables">Environment variables</a></li> -<li class="toctree-l2"><a class="reference internal" href="readme_link.html#build-instructions">Build instructions</a></li> -<li class="toctree-l2"><a class="reference internal" href="readme_link.html#examples">Examples</a></li> -<li class="toctree-l2"><a class="reference internal" href="readme_link.html#usage-notes">Usage notes</a></li> -<li class="toctree-l2"><a class="reference internal" href="readme_link.html#documentation">Documentation</a></li> +<li class="toctree-l2"><a class="reference internal" href="readme_link.html#installation">Installation</a></li> +<li class="toctree-l2"><a class="reference internal" href="readme_link.html#usage">Usage</a></li> <li class="toctree-l2"><a class="reference internal" href="readme_link.html#development">Development:</a></li> <li class="toctree-l2"><a class="reference internal" href="readme_link.html#faq-issues">FAQ/Issues:</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="modules.html">Binarycpython code</a><ul> <li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="ensemble.html">ensemble module</a></li> <li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid.html">Population class module</a></li> <li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> <li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> <li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> <li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> </ul> @@ -321,6 +272,7 @@ <li class="toctree-l2"><a class="reference internal" href="examples/notebook_population.html">Tutorial: Running populations with binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_extra_features.html">Tutorial: Extra features and functionality of binary_c-python</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_api_functionality.html">Tutorial: Using the API functionality of binary_c-python</a></li> +<li class="toctree-l2"><a class="reference internal" href="examples/notebook_ensembles.html">Tutorial: Generating and handling ensemble data</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_luminosity_function_single.html">Example use case: Zero-age stellar luminosity function</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_luminosity_function_binaries.html">Example use case: Zero-age stellar luminosity function in binaries</a></li> <li class="toctree-l2"><a class="reference internal" href="examples/notebook_HRD.html">Example use case: Hertzsprung-Russell diagrams</a></li> @@ -351,68 +303,51 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> </div> -</div> -</div> -<div class="section" id="indices-and-tables"> -<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1> +</section> +</section> +<section id="indices-and-tables"> +<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this heading">ïƒ</a></h1> <ul class="simple"> <li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li> <li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li> <li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li> </ul> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="readme_link.html" class="btn btn-neutral float-right" title="Python module for binary_c" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="readme_link.html" class="btn btn-neutral float-right" title="Python module for binary_c" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/modules.html b/docs/build/html/modules.html index 30e0b35755cb77c7b7917adc494b0b96550e455b..1f285bc9e13cf1eace0d06b840a172630ea40832 100644 --- a/docs/build/html/modules.html +++ b/docs/build/html/modules.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Binarycpython code — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Binarycpython code — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="custom_logging_functions module" href="custom_logging_functions.html" /> <link rel="prev" title="Python module for binary_c" href="readme_link.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,30 +38,32 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">Binarycpython code</a><ul> <li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="ensemble.html">ensemble module</a></li> <li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid.html">Population class module</a></li> <li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> <li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> <li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> <li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> </ul> @@ -107,68 +75,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li>Binarycpython code</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/modules.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -193,79 +123,73 @@ text-align: unset; } </style> -<div class="section" id="binarycpython-code"> -<h1>Binarycpython code<a class="headerlink" href="#binarycpython-code" title="Permalink to this headline">¶</a></h1> +<section id="binarycpython-code"> +<h1>Binarycpython code<a class="headerlink" href="#binarycpython-code" title="Permalink to this heading">ïƒ</a></h1> <p>This chapter contains the (auto)documentation for all the functions and modules in the source code of binarycpython</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l1"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> +<li class="toctree-l1"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l1"><a class="reference internal" href="ensemble.html">ensemble module</a></li> <li class="toctree-l1"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l1"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l1"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l1"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> +<li class="toctree-l1"><a class="reference internal" href="grid.html">Population class module</a></li> <li class="toctree-l1"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l1"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> <li class="toctree-l1"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l1"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> <li class="toctree-l1"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> <li class="toctree-l1"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> </ul> </div> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="custom_logging_functions.html" class="btn btn-neutral float-right" title="custom_logging_functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="readme_link.html" class="btn btn-neutral float-left" title="Python module for binary_c" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="readme_link.html" class="btn btn-neutral float-left" title="Python module for binary_c" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="custom_logging_functions.html" class="btn btn-neutral float-right" title="custom_logging_functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/objects.inv b/docs/build/html/objects.inv index d4677ce1197f13c1393a5b5853226a47f326189f..7f1ed59e412b73486beabbe95414d03a21a0eadd 100644 Binary files a/docs/build/html/objects.inv and b/docs/build/html/objects.inv differ diff --git a/docs/build/html/plot_functions.html b/docs/build/html/plot_functions.html index 3c7dca58a6e7af9eabd7d0297f39269d173a4e4c..7d1b941063cb330f71f79117e4bc94f8f74b2b43 100644 --- a/docs/build/html/plot_functions.html +++ b/docs/build/html/plot_functions.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>plot_functions module — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>plot_functions module — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> - <link rel="next" title="run_system_wrapper module" href="run_system_wrapper.html" /> - <link rel="prev" title="hpc_functions module" href="hpc_functions.html" /> + <link rel="next" title="Population class extension: analytics module" href="population_extensions/analytics.html" /> + <link rel="prev" title="Population class module" href="grid.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,30 +38,32 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> <li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="ensemble.html">ensemble module</a></li> <li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid.html">Population class module</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> <li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> <li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> <li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> </ul> @@ -107,70 +75,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li><a href="modules.html">Binarycpython code</a> »</li> - <li>plot_functions module</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/plot_functions.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -195,8 +124,8 @@ text-align: unset; } </style> -<div class="section" id="module-binarycpython.utils.plot_functions"> -<span id="plot-functions-module"></span><h1>plot_functions module<a class="headerlink" href="#module-binarycpython.utils.plot_functions" title="Permalink to this headline">¶</a></h1> +<section id="module-binarycpython.utils.plot_functions"> +<span id="plot-functions-module"></span><h1>plot_functions module<a class="headerlink" href="#module-binarycpython.utils.plot_functions" title="Permalink to this heading">ïƒ</a></h1> <p>Module that contains functionality to plot some properties of (binary) systems.</p> <p>Different routines are defined here to plot orbits, masses, angular momenta etc.</p> <dl class="simple"> @@ -219,19 +148,19 @@ TODO: Put all the plotting functions in here</p> </dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.plot_functions.color_by_index"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">color_by_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">row</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">column</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">colors</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#color_by_index"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.color_by_index" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">color_by_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">row</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">column</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">colors</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#color_by_index"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.color_by_index" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that returns a color based on row and column information. Used to color the stellar types</p> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.plot_functions.dummy"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">dummy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#dummy"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.dummy" title="Permalink to this definition">¶</a></dt> -<dd><p>Placeholder</p> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">dummy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#dummy"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.dummy" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Placeholder function</p> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.plot_functions.parse_function_hr_diagram"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">parse_function_hr_diagram</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#parse_function_hr_diagram"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.parse_function_hr_diagram" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">parse_function_hr_diagram</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#parse_function_hr_diagram"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.parse_function_hr_diagram" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Parsing function for the HR plotting routine</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -245,7 +174,7 @@ TODO: Put all the plotting functions in here</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.plot_functions.parse_function_masses"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">parse_function_masses</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#parse_function_masses"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.parse_function_masses" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">parse_function_masses</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#parse_function_masses"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.parse_function_masses" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Parsing function for the orbit plotting routine</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -259,7 +188,7 @@ TODO: Put all the plotting functions in here</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.plot_functions.parse_function_orbit"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">parse_function_orbit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#parse_function_orbit"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.parse_function_orbit" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">parse_function_orbit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#parse_function_orbit"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.parse_function_orbit" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Parsing function for the orbit plotting routine</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -273,7 +202,7 @@ TODO: Put all the plotting functions in here</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.plot_functions.plot_HR_diagram"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">plot_HR_diagram</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_stellar_types</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_plot</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_astropy_values</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#plot_HR_diagram"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.plot_HR_diagram" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">plot_HR_diagram</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_stellar_types</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_plot</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_astropy_values</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#plot_HR_diagram"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.plot_HR_diagram" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to plot the HR diagram evolution of the system. Assumes its a binary system.</p> <p>For a single star see plot_HR_diagram_single</p> <p>Plot shows Log luminosity on y axis, @@ -318,7 +247,7 @@ log temperature on x axis (reversed)</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.plot_functions.plot_masses"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">plot_masses</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_stellar_types</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_plot</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#plot_masses"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.plot_masses" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">plot_masses</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_stellar_types</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_plot</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#plot_masses"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.plot_masses" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to plot the masses of the system.</p> <dl class="simple"> <dt>Function requires the following keys:</dt><dd><ul class="simple"> @@ -358,7 +287,7 @@ log temperature on x axis (reversed)</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.plot_functions.plot_orbit"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">plot_orbit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_stellar_types</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_plot</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#plot_orbit"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.plot_orbit" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">plot_orbit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_stellar_types</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_plot</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#plot_orbit"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.plot_orbit" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to plot the orbital elements of the system</p> <dl class="simple"> <dt>Plots the following quantities:</dt><dd><ul class="simple"> @@ -386,7 +315,7 @@ log temperature on x axis (reversed)</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.plot_functions.plot_system"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">plot_system</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">plot_type</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#plot_system"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.plot_system" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.plot_functions.</span></span><span class="sig-name descname"><span class="pre">plot_system</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">plot_type</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/plot_functions.html#plot_system"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.plot_functions.plot_system" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to plot the different quantities of a system.</p> <dl class="simple"> <dt>This goes (in general) via the following steps:</dt><dd><ul class="simple"> @@ -407,12 +336,6 @@ log temperature on x axis (reversed)</p> <li><p>hr_diagram</p></li> </ul> </dd> -<dt>Tasks:</dt><dd><ul class="simple"> -<li><p>TODO: Complex Function!</p></li> -<li><p>TODO: make sure this way of passing args works correctly.</p></li> -<li><p>TODO: make the plotting specific keywords available via the inspect stuff</p></li> -</ul> -</dd> </dl> <p>All keywords are considered kwargs, except for plot_type</p> <dl class="field-list simple"> @@ -434,61 +357,43 @@ This is not included in all the plotting routines.</p></li> </dl> </dd></dl> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="run_system_wrapper.html" class="btn btn-neutral float-right" title="run_system_wrapper module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="hpc_functions.html" class="btn btn-neutral float-left" title="hpc_functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="grid.html" class="btn btn-neutral float-left" title="Population class module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="population_extensions/analytics.html" class="btn btn-neutral float-right" title="Population class extension: analytics module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/HPC.html b/docs/build/html/population_extensions/HPC.html new file mode 100644 index 0000000000000000000000000000000000000000..a8bf37876ebb3707187005554baa146017ada558 --- /dev/null +++ b/docs/build/html/population_extensions/HPC.html @@ -0,0 +1,396 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: HPC module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: metadata module" href="metadata.html" /> + <link rel="prev" title="Population class extension: grid_options_defaults module" href="grid_options_defaults.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: HPC module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/HPC.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.HPC"> +<span id="population-class-extension-hpc-module"></span><h1>Population class extension: HPC module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.HPC" title="Permalink to this heading">ïƒ</a></h1> +<p>Module containing the functions to HPC functionality</p> +<p>These functions form a single API through which you can access HPC resources.</p> +<p>Generally, you should call an HPC function rather than the Slurm or Condor interface +directly. The HPC function then decides which interface to use, so that all the +other modules can use a single API rather than have to choose to use the Slurm or +Condor API.</p> +<p>This class object is an extension to the population grid object</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.HPC.</span></span><span class="sig-name descname"><span class="pre">HPC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <a class="reference internal" href="condor.html#binarycpython.utils.population_extensions.condor.condor" title="binarycpython.utils.population_extensions.condor.condor"><code class="xref py py-class docutils literal notranslate"><span class="pre">condor</span></code></a>, <a class="reference internal" href="slurm.html#binarycpython.utils.population_extensions.slurm.slurm" title="binarycpython.utils.population_extensions.slurm.slurm"><code class="xref py py-class docutils literal notranslate"><span class="pre">slurm</span></code></a></p> +<p>Extension to the population grid object that contains functionality to handle handle the Moe & distefano distributions</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_can_join"> +<span class="sig-name descname"><span class="pre">HPC_can_join</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">joinfiles</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">joiningfile</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vb</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_can_join"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_can_join" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Check the joinfiles to make sure they all exist +and their .saved equivalents also exist</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_check_requirements"> +<span class="sig-name descname"><span class="pre">HPC_check_requirements</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_check_requirements"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_check_requirements" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to check HPC option requirements have been met. Returns a tuple: (True,â€â€) if all is ok, (False,<warning string>) otherwise.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_dir"> +<span class="sig-name descname"><span class="pre">HPC_dir</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_dir"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_dir" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return an HPC job’s directory.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_dirs"> +<span class="sig-name descname"><span class="pre">HPC_dirs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_dirs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_dirs" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return a list of directories required for this HPC job.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_dump_status"> +<span class="sig-name descname"><span class="pre">HPC_dump_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_dump_status"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_dump_status" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to print the status of the HPC grid</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_get_status"> +<span class="sig-name descname"><span class="pre">HPC_get_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">job_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">job_index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hpc_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_get_status"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_get_status" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Get and return the appropriate HPC job (Condor or Slurm) status string for this job (or, if given, the job at id.index)</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>hpc_dir</strong> – optional HPC run directory. If not set, the default (e.g. slurm_dir or condor_dir) +is used.</p></li> +<li><p><strong>job_id</strong> – the id and index of the job to be queried</p></li> +<li><p><strong>job_index</strong> – the id and index of the job to be queried</p></li> +</ul> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_grid"> +<span class="sig-name descname"><span class="pre">HPC_grid</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">makejoiningfile</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_grid"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_grid" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to call the appropriate HPC grid function +(e.g. Slurm or Condor) and return what it returns.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>makejoiningfile</strong> – if True, and we’re the first job with self.HPC_task() == 2, we build the joiningfile. (default=True) This option exists in case you don’t want to overwrite an existing joiningfile, or want to build it in another way (e.g. in the HPC scripts).</p> +</dd> +</dl> +<p>TODO: Exclude this function from testing for now +TODO: Comment this function better</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_id_filename"> +<span class="sig-name descname"><span class="pre">HPC_id_filename</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_id_filename"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_id_filename" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>HPC jobs have a filename in their directory which specifies the job id. This function returns the contents of that file as a string, or None on failure.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_id_from_dir"> +<span class="sig-name descname"><span class="pre">HPC_id_from_dir</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">hpc_dir</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_id_from_dir"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_id_from_dir" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return the ID of an HPC run given its (already existing) directory.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_job"> +<span class="sig-name descname"><span class="pre">HPC_job</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_job"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_job" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return True if we’re running an HPC (Slurm or Condor) job, False otherwise.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_jobID"> +<span class="sig-name descname"><span class="pre">HPC_jobID</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_jobID"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_jobID" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return an HPC (Slurm or Condor) job id in the form of a string, x.y. Returns None if not an HPC job.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_jobID_tuple"> +<span class="sig-name descname"><span class="pre">HPC_jobID_tuple</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_jobID_tuple"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_jobID_tuple" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return the job ID as a tuple of ints, (x,y), or (None,None) on failure</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_job_id_range"> +<span class="sig-name descname"><span class="pre">HPC_job_id_range</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_job_id_range"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_job_id_range" title="Permalink to this definition">ïƒ</a></dt> +<dd></dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_job_task"> +<span class="sig-name descname"><span class="pre">HPC_job_task</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_job_task"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_job_task" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return the HPC task number, which is 1 when setting +up and running the scripts, 2 when joining data.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_job_type"> +<span class="sig-name descname"><span class="pre">HPC_job_type</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_job_type"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_job_type" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return a string telling us the type of an HPC job, i.e. +“slurmâ€, “condor†or “Noneâ€.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_join_from_files"> +<span class="sig-name descname"><span class="pre">HPC_join_from_files</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newobj</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">joinfiles</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_join_from_files"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_join_from_files" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Merge the results from the list joinfiles into newobj.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_join_previous"> +<span class="sig-name descname"><span class="pre">HPC_join_previous</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_join_previous"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_join_previous" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to join previously generated datasets.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_joinlist"> +<span class="sig-name descname"><span class="pre">HPC_joinlist</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">joinlist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_joinlist"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_joinlist" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return the default HPC joinlist file.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_load_joinfiles_list"> +<span class="sig-name descname"><span class="pre">HPC_load_joinfiles_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">joinlist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_load_joinfiles_list"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_load_joinfiles_list" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to load in the list of files we should join, and return it.</p> +<p>If grid_options[‘HPC_rebuild_joinlist’] is True, we rebuild it.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_make_joiningfile"> +<span class="sig-name descname"><span class="pre">HPC_make_joiningfile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">hpc_jobid</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hpc_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">overwrite</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">error_on_overwrite</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_make_joiningfile"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_make_joiningfile" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to make the joiningfile file that contains the filenames of results from each job. When all these exist, we can join.</p> +<p>Note: you normally don’t need to set any of the option arguments.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>hpc_jobid</strong> – the job ID number, or self.HPC_jobID_tuple()[0] if None (default=None).</p></li> +<li><p><strong>hpc_dir</strong> – the HPC directory, or self.HPC_dir() if None (default=None).</p></li> +<li><p><strong>n</strong> – the number of jobs, or self.HPC_njobs() if None (default=None).</p></li> +<li><p><strong>overwrite</strong> – if True, overwrite an existing joiningfile (default=False)</p></li> +<li><p><strong>error_on_overwite</strong> – if True, and we try to overwrite, issue and error and exit (default=False)</p></li> +</ul> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>True if the file is made, False otherwise.</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_njobs"> +<span class="sig-name descname"><span class="pre">HPC_njobs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_njobs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_njobs" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return the number of jobs this HPC jobs will use, as an int.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_path"> +<span class="sig-name descname"><span class="pre">HPC_path</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_path"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_path" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to file the filename of this HPC job’s file at path.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_queue_stats"> +<span class="sig-name descname"><span class="pre">HPC_queue_stats</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_queue_stats"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_queue_stats" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that returns the queue stats for the HPC grid</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_restore"> +<span class="sig-name descname"><span class="pre">HPC_restore</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_restore"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_restore" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Set grid_options[‘restore_from_snapshot_file’] so that we restore data from existing +an HPC run if self.grid_options[hpc_job_type+’_restart_dir’], where hpc_job_type is “slurm†or “condorâ€, +is provided, otherwise do nothing. This only works if grid_options[hpc_job_type] == self.HPC_job_task() == 2, which is +the run-grid stage of the process.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_set_status"> +<span class="sig-name descname"><span class="pre">HPC_set_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_set_status"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_set_status" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Set the appropriate HPC job (Condor or Slurm) status file to whatever is given in string.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>string</strong> – the new contents of the status file</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_snapshot_filename"> +<span class="sig-name descname"><span class="pre">HPC_snapshot_filename</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_snapshot_filename"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_snapshot_filename" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return an HPC job’s snapshot filename.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_status"> +<span class="sig-name descname"><span class="pre">HPC_status</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_status"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_status" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return a dict of useful information about the current status +of this HPC run.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.HPC.HPC.HPC_touch"> +<span class="sig-name descname"><span class="pre">HPC_touch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">string</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/HPC.html#HPC.HPC_touch"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.HPC.HPC.HPC_touch" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to touch the file at filename, put into it the job number +and (if given) the string passed in.</p> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="grid_options_defaults.html" class="btn btn-neutral float-left" title="Population class extension: grid_options_defaults module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="metadata.html" class="btn btn-neutral float-right" title="Population class extension: metadata module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/Moe_di_Stefano_2017.html b/docs/build/html/population_extensions/Moe_di_Stefano_2017.html new file mode 100644 index 0000000000000000000000000000000000000000..97083e1d21074569f790d8472e670d164c2a4bf0 --- /dev/null +++ b/docs/build/html/population_extensions/Moe_di_Stefano_2017.html @@ -0,0 +1,214 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: Moe_di_Stefano_2017 module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: slurm module" href="slurm.html" /> + <link rel="prev" title="Population class extension: metadata module" href="metadata.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: Moe_di_Stefano_2017 module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/Moe_di_Stefano_2017.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.Moe_di_Stefano_2017"> +<span id="population-class-extension-moe-di-stefano-2017-module"></span><h1>Population class extension: Moe_di_Stefano_2017 module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.Moe_di_Stefano_2017" title="Permalink to this heading">ïƒ</a></h1> +<p>Module containing the functions to handle the Moe&Distrefano data</p> +<p>This class object is an extension to the population grid object</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.Moe_di_Stefano_2017.</span></span><span class="sig-name descname"><span class="pre">Moe_di_Stefano_2017</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.html#Moe_di_Stefano_2017"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Extension to the population grid object that contains functionality to handle handle the Moe & distefano distributions</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.Moe_di_Stefano_2017"> +<span class="sig-name descname"><span class="pre">Moe_di_Stefano_2017</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.html#Moe_di_Stefano_2017.Moe_di_Stefano_2017"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.Moe_di_Stefano_2017" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to handle setting the user input settings, +set up the data and load that into interpolators and +then set the distribution functions</p> +<p>Takes a dictionary as its only argument</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options"> +<span class="sig-name descname"><span class="pre">get_Moe_di_Stefano_2017_default_options</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.html#Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that returns the default options for the Moe & diStefano grid options</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options_description"> +<span class="sig-name descname"><span class="pre">get_Moe_di_Stefano_2017_default_options_description</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.html#Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options_description"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_Moe_di_Stefano_2017_default_options_description" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return the descriptions for all the Moe & diStefano grid options</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_moe_di_stefano_dataset"> +<span class="sig-name descname"><span class="pre">get_moe_di_stefano_dataset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.html#Moe_di_Stefano_2017.get_moe_di_stefano_dataset"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.get_moe_di_stefano_dataset" title="Permalink to this definition">ïƒ</a></dt> +<dd><blockquote> +<div><p>Function to get the default Moe and di Stefano dataset or accept a user input.</p> +</div></blockquote> +<p>Returns a dict containing the (JSON) data.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.set_moe_di_stefano_settings"> +<span class="sig-name descname"><span class="pre">set_moe_di_stefano_settings</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/Moe_di_Stefano_2017.html#Moe_di_Stefano_2017.set_moe_di_stefano_settings"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017.set_moe_di_stefano_settings" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to set user input configurations for the Moe & di Stefano methods</p> +<p>If nothing is passed then we just use the default options</p> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="metadata.html" class="btn btn-neutral float-left" title="Population class extension: metadata module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="slurm.html" class="btn btn-neutral float-right" title="Population class extension: slurm module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/analytics.html b/docs/build/html/population_extensions/analytics.html new file mode 100644 index 0000000000000000000000000000000000000000..d58bf110cd330f95dc6908c0b187b16a3066f492 --- /dev/null +++ b/docs/build/html/population_extensions/analytics.html @@ -0,0 +1,203 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: analytics module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: cache module" href="cache.html" /> + <link rel="prev" title="plot_functions module" href="../plot_functions.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: analytics module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/analytics.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.analytics"> +<span id="population-class-extension-analytics-module"></span><h1>Population class extension: analytics module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.analytics" title="Permalink to this heading">ïƒ</a></h1> +<p>The class extension for the population object that contains analytics functionality</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.analytics.analytics"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.analytics.</span></span><span class="sig-name descname"><span class="pre">analytics</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/analytics.html#analytics"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.analytics.analytics" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Extension for the Population class containing the functions for analytics</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.analytics.analytics.CPU_time"> +<span class="sig-name descname"><span class="pre">CPU_time</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/analytics.html#analytics.CPU_time"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.analytics.analytics.CPU_time" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return how much CPU time we’ve used</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.analytics.analytics.make_analytics_dict"> +<span class="sig-name descname"><span class="pre">make_analytics_dict</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/analytics.html#analytics.make_analytics_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.analytics.analytics.make_analytics_dict" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to create the analytics dictionary</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.analytics.analytics.set_time"> +<span class="sig-name descname"><span class="pre">set_time</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">when</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/analytics.html#analytics.set_time"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.analytics.analytics.set_time" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to set the timestamp at when, where when is ‘start’ or ‘end’.</p> +<p>If when == end, we also calculate the time elapsed.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.analytics.analytics.time_elapsed"> +<span class="sig-name descname"><span class="pre">time_elapsed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">force</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/analytics.html#analytics.time_elapsed"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.analytics.analytics.time_elapsed" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return how long a population object has been running.</p> +<p>We return the cached value if it’s available, and calculate +the time elapsed if otherwise or if force is True</p> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="../plot_functions.html" class="btn btn-neutral float-left" title="plot_functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="cache.html" class="btn btn-neutral float-right" title="Population class extension: cache module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/cache.html b/docs/build/html/population_extensions/cache.html new file mode 100644 index 0000000000000000000000000000000000000000..e85b2a4af4df0aa03e513290c62c872e1b5abd73 --- /dev/null +++ b/docs/build/html/population_extensions/cache.html @@ -0,0 +1,237 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: cache module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: condor module" href="condor.html" /> + <link rel="prev" title="Population class extension: analytics module" href="analytics.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: cache module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/cache.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.cache"> +<span id="population-class-extension-cache-module"></span><h1>Population class extension: cache module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.cache" title="Permalink to this heading">ïƒ</a></h1> +<p>File containing the class extension for the population object that contains cache functionality</p> +<p>Module containing (e.g. LRU) cache functionality for binary_c-python.</p> +<p>We use cachetools when possible because this allows us to set up the +cache of the appropriate size for the task in the grid_options dict. +Please see the LRU_* options in there.</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.cache.cache"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.cache.</span></span><span class="sig-name descname"><span class="pre">cache</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/cache.html#cache"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.cache.cache" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Class extension for the population object that contains cache functionality</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.cache.cache.NullCache"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">NullCache</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/cache.html#cache.NullCache"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.cache.cache.NullCache" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">Cache</span></code></p> +<p>A cachetools cache object that does as little as possible and never matches.</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.cache.cache.NullCache.__delitem__"> +<span class="sig-name descname"><span class="pre">__delitem__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">key</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/cache.html#cache.NullCache.__delitem__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.cache.cache.NullCache.__delitem__" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>deleter function placeholder</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.cache.cache.NullCache.__getitem__"> +<span class="sig-name descname"><span class="pre">__getitem__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">key</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/cache.html#cache.NullCache.__getitem__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.cache.cache.NullCache.__getitem__" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>getter function placeholder</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.cache.cache.NullCache.__setitem__"> +<span class="sig-name descname"><span class="pre">__setitem__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/cache.html#cache.NullCache.__setitem__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.cache.cache.NullCache.__setitem__" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Setter function placeholder</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.cache.cache.NullCache.popitem"> +<span class="sig-name descname"><span class="pre">popitem</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/cache.html#cache.NullCache.popitem"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.cache.cache.NullCache.popitem" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>pop function placeholder</p> +</dd></dl> + +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.cache.cache.default_cache_dir"> +<span class="sig-name descname"><span class="pre">default_cache_dir</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/cache.html#cache.default_cache_dir"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.cache.cache.default_cache_dir" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return a default cache directory path for binary_c-python, or None if we cannot find one. This is used in grid_options_defaults.py</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.cache.cache.setup_function_cache"> +<span class="sig-name descname"><span class="pre">setup_function_cache</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">vb</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cachetype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/cache.html#cache.setup_function_cache"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.cache.cache.setup_function_cache" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to wrap binary_c-python’s functions in function cache.</p> +<p>The functions listed in self.grid_options[‘function_cache_functions’] are +given caches of size self.grid_options[‘function_cache_size’][func]</p> +<p>Args: None</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.cache.cache.test_caches"> +<span class="sig-name descname"><span class="pre">test_caches</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">5.0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/cache.html#cache.test_caches"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.cache.cache.test_caches" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to test cache speeds of the functions that binary_c-python automatically caches.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>dt</strong> (<em>default 5</em>) – </p> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="analytics.html" class="btn btn-neutral float-left" title="Population class extension: analytics module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="condor.html" class="btn btn-neutral float-right" title="Population class extension: condor module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/condor.html b/docs/build/html/population_extensions/condor.html new file mode 100644 index 0000000000000000000000000000000000000000..bc8a3fac88cea01e889982247d3af80ac7c87fbc --- /dev/null +++ b/docs/build/html/population_extensions/condor.html @@ -0,0 +1,256 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: condor module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: dataIO module" href="dataIO.html" /> + <link rel="prev" title="Population class extension: cache module" href="cache.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: condor module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/condor.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.condor"> +<span id="population-class-extension-condor-module"></span><h1>Population class extension: condor module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.condor" title="Permalink to this heading">ïƒ</a></h1> +<p>The class extension for the population object that contains the Condor functionality</p> +<p>TODO: there are many uses of $<variable name> in this file but this is not perl and we should replace them by actual format placeholders</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.condor.</span></span><span class="sig-name descname"><span class="pre">condor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Extension for the Population class containing the code for Condor grid runs</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.condorID"> +<span class="sig-name descname"><span class="pre">condorID</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ClusterID</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Process</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.condorID"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.condorID" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return a Condor job ID as a string, [ClusterID].[Process]. The ClusterID and Process passed in are used if given, otherwise we default to the condor_ClusterID and condor_Process in grid_options.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.condor_check_requirements"> +<span class="sig-name descname"><span class="pre">condor_check_requirements</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.condor_check_requirements"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.condor_check_requirements" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to check whether the condor parameters in grid_options have been set appropriately.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.condor_dirs"> +<span class="sig-name descname"><span class="pre">condor_dirs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.condor_dirs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.condor_dirs" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Directories associated specifically with this condor job.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.condor_grid"> +<span class="sig-name descname"><span class="pre">condor_grid</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.condor_grid"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.condor_grid" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>function to be called when running grids when grid_options[‘condor’]>=1</p> +<p>if grid_options[‘condor’]==1, we set up the condor script and launch the jobs, then return True to exit. +if grid_options[‘condor’]==2, we run the stars, which means we return False to continue. +if grid_options[‘condor’]==3, we are being called from the jobs to run the grids, return False to continue.</p> +<p>TODO: split this function into some parts +TODO: Comment this function better</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.condor_outfile"> +<span class="sig-name descname"><span class="pre">condor_outfile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">condor_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.condor_outfile"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.condor_outfile" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>return a standard filename for the condor chunk files</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.condor_queue_stats"> +<span class="sig-name descname"><span class="pre">condor_queue_stats</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.condor_queue_stats"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.condor_queue_stats" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return condor queue statistics for this job</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.condor_status_file"> +<span class="sig-name descname"><span class="pre">condor_status_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ClusterID</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Process</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condor_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.condor_status_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.condor_status_file" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return the condor status file corresponding to the ClusterID and Process, which default to grid_options condor_ClusterID and condor_Process, respectively.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.condorpath"> +<span class="sig-name descname"><span class="pre">condorpath</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condor_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.condorpath"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.condorpath" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return the full condor directory path.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.get_condor_status"> +<span class="sig-name descname"><span class="pre">get_condor_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ClusterID</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Process</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condor_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.get_condor_status"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.get_condor_status" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Get and return the condor status corresponing to the self object, or ClusterID.Process if they are passed in. If no status is found, returns an empty string..</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.make_condor_dirs"> +<span class="sig-name descname"><span class="pre">make_condor_dirs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">condor_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.make_condor_dirs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.make_condor_dirs" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to make the condor directories</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.condor.condor.set_condor_status"> +<span class="sig-name descname"><span class="pre">set_condor_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condor_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/condor.html#condor.set_condor_status"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.condor.condor.set_condor_status" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Set the condor status corresponing to the self object, which should have condor_ClusterID and condor_Process set.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>string</strong> – the status string to be set</p></li> +<li><p><strong>dir</strong> – the directory in which the status directory is held. If not set, this defaults to the HPC directory (e.g. slurm_dir or condor_dir).</p></li> +</ul> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="cache.html" class="btn btn-neutral float-left" title="Population class extension: cache module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="dataIO.html" class="btn btn-neutral float-right" title="Population class extension: dataIO module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/dataIO.html b/docs/build/html/population_extensions/dataIO.html new file mode 100644 index 0000000000000000000000000000000000000000..a6ea7747e2ef164a9c5a71179aee71bbdb87f0af --- /dev/null +++ b/docs/build/html/population_extensions/dataIO.html @@ -0,0 +1,415 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: dataIO module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: distribution_functions module" href="distribution_functions.html" /> + <link rel="prev" title="Population class extension: condor module" href="condor.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: dataIO module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/dataIO.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.dataIO"> +<span id="population-class-extension-dataio-module"></span><h1>Population class extension: dataIO module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.dataIO" title="Permalink to this heading">ïƒ</a></h1> +<p>File containing the class extension for the population object that contains data input-output (IO) functions</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.dataIO.</span></span><span class="sig-name descname"><span class="pre">dataIO</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Class extension for the population object that contains data input-output (IO) functions</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.NFS_flush_hack"> +<span class="sig-name descname"><span class="pre">NFS_flush_hack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.NFS_flush_hack"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.NFS_flush_hack" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Use opendir()/closedir() to flush NFS access to a file.</p> +<p>NOTE: this may or may not work!</p> +<p>TODO: This function leads to a complaint about unclosed scandir operators. Check if that can be resolved.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.NFSpath"> +<span class="sig-name descname"><span class="pre">NFSpath</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.NFSpath"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.NFSpath" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Test path to see if it’s on an NFS mount.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>path</strong> – the path to be tested</p> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>if on an NFS mount point. +False : if not. +None : if the path does not exist.</p> +</dd> +<dt class="field-odd">Return type</dt> +<dd class="field-odd"><p>True</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.compression_type"> +<span class="sig-name descname"><span class="pre">compression_type</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.compression_type"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.compression_type" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return the compression type of the ensemble file, based on its filename extension.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.dir_ok"> +<span class="sig-name descname"><span class="pre">dir_ok</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">directory</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.dir_ok"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.dir_ok" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to test if we can read and write to a directory that must exist. Return True if all is ok, False otherwise.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.load_population_object"> +<span class="sig-name descname"><span class="pre">load_population_object</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.load_population_object"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.load_population_object" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>returns the Population object loaded from filename</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.load_snapshot"> +<span class="sig-name descname"><span class="pre">load_snapshot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.load_snapshot"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.load_snapshot" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Load a snapshot from file and set it in the preloaded_population placeholder.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.locked_close"> +<span class="sig-name descname"><span class="pre">locked_close</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lock</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.locked_close"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.locked_close" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Partner function to locked_open_for_write()</p> +<p>Closes and unlocks the file</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.locked_open_for_write"> +<span class="sig-name descname"><span class="pre">locked_open_for_write</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'utf-8'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lock_suffix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'.lock'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lock_timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lock_lifetime</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">60</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exists_ok</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fatal_open_errors</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vb</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.locked_open_for_write"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.locked_open_for_write" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Wrapper for Python’s open(filename) which opens a file at +filename for writing (mode “wâ€) and locks it.</p> +<p>We check whether the file’s lockfile already exists, in which +case just return (None,None), and if we cannot obtain a +lock on the file we also return (None,None).</p> +<p>If the file does not exist, we keep trying to lock until it does.</p> +<p>To do the locking, we use flufl.lock which is NFS safe.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>lock_lifetime</strong> – (passed to flufl.lock.Lock()) default 60 seconds. +It should take less than this time to write the file.</p></li> +<li><p><strong>lock_timeout</strong> – (passed to flufl.lock.Lock()) default 5 seconds. +This should be non-zero.</p></li> +<li><p><strong>fatal_open_errors</strong> – if open() fails and fatal_open_errors is True, exit.</p></li> +<li><p><strong>exists_ok</strong> – if False and the file at filename exists, return (None,None) (default False)</p></li> +<li><p><strong>vb</strong> – verbose logging if True, defaults to False</p></li> +</ul> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>(file_object, lock_object) tuple. +If the file was not opened, returns (None,None).</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.merge_populations"> +<span class="sig-name descname"><span class="pre">merge_populations</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">refpop</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newpop</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.merge_populations"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.merge_populations" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>merge newpop’s results data into refpop’s results data</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>refpop</strong> – the original “reference†Population object to be added to</p></li> +<li><p><strong>newpop</strong> – Population object containing the new data</p></li> +</ul> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>nothing</p> +</dd> +</dl> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>The file should be saved using save_population_object()</p> +</div> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.merge_populations_from_file"> +<span class="sig-name descname"><span class="pre">merge_populations_from_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">refpop</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.merge_populations_from_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.merge_populations_from_file" title="Permalink to this definition">ïƒ</a></dt> +<dd><blockquote> +<div><p>Wrapper for merge_populations so it can be done directly +from a file.</p> +</div></blockquote> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>refpop</strong> – the original “reference†Population object to be added to</p></li> +<li><p><strong>filename</strong> – file containing the Population object containing the new data</p></li> +</ul> +</dd> +</dl> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>The file should be saved using save_population_object()</p> +</div> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.open"> +<span class="sig-name descname"><span class="pre">open</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'r'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">buffering</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">errors</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newline</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">closefd</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">opener</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compression</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compresslevel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vb</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.open"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.open" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Wrapper for open() with automatic compression based on the file extension.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.save_population_object"> +<span class="sig-name descname"><span class="pre">save_population_object</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">population_object</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">confirmation</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compression</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'gzip'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.save_population_object"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.save_population_object" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Save pickled Population object to file at filename or, if filename is None, whatever is set at self.grid_options[‘save_population_object’]</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>population_object</strong> – the object to be saved to the file. If population_object is None, use self.</p></li> +<li><p><strong>filename</strong> – the name of the file to be saved. If not set, use self.grid_options[‘save_population_object’]</p></li> +<li><p><strong>confirmation</strong> – if True, a file “filename.saved†is touched just after the dump, so we know it is finished. TODO: fix this</p></li> +<li><p><strong>compression</strong> (<em>optional</em><em>, </em><em>default = "gzip"</em>) – TODO: fix this</p></li> +</ul> +</dd> +</dl> +<p>Compression is performed according to the filename, as stated in the +compress_pickle documentation at +<a class="reference external" href="https://lucianopaz.github.io/compress_pickle/html/">https://lucianopaz.github.io/compress_pickle/html/</a></p> +<p>Shared memory, stored in the population_object.shared_memory dict, is not saved.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.save_snapshot"> +<span class="sig-name descname"><span class="pre">save_snapshot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.save_snapshot"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.save_snapshot" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Save the population object to a snapshot file, automatically choosing the filename if none is given.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.set_status"> +<span class="sig-name descname"><span class="pre">set_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">format_statment</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'process_{}.txt'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ID</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.set_status"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.set_status" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to set the status string in its appropriate file</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.snapshot_filename"> +<span class="sig-name descname"><span class="pre">snapshot_filename</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.snapshot_filename"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.snapshot_filename" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Automatically choose the snapshot filename.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.wait_for_unlock"> +<span class="sig-name descname"><span class="pre">wait_for_unlock</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lock_suffix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'.lock'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.wait_for_unlock"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.wait_for_unlock" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Companion to locked_open_for_write that waits for a filename +to a) exist and b) be unlocked.</p> +<p>This should work because the lock file is created before the file +is created.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.write_binary_c_calls_to_file"> +<span class="sig-name descname"><span class="pre">write_binary_c_calls_to_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_defaults</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'utf-8'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.write_binary_c_calls_to_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.write_binary_c_calls_to_file" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that loops over the grid code and writes the generated parameters to a file. +In the form of a command line call</p> +<p>Only useful when you have a variable grid as system_generator. MC wouldn’t be that useful</p> +<p>Also, make sure that in this export there are the basic parameters +like m1,m2,sep, orb-per, ecc, probability etc.</p> +<p>On default this will write to the datadir, if it exists</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>output_dir</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – (optional, default = None) directory where to write the file to. If custom_options[‘data_dir’] is present, then that one will be used first, and then the output_dir</p></li> +<li><p><strong>output_filename</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – (optional, default = None) filename of the output. If not set it will be called “binary_c_calls.txtâ€</p></li> +<li><p><strong>include_defaults</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = None) whether to include the defaults of binary_c in the lines that are written. Beware that this will result in very long lines, and it might be better to just export the binary_c defaults and keep them in a separate file.</p></li> +</ul> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>filename that was used to write the calls to</p> +</dd> +<dt class="field-odd">Return type</dt> +<dd class="field-odd"><p>filename</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.dataIO.dataIO.write_ensemble"> +<span class="sig-name descname"><span class="pre">write_ensemble</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sort_keys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'utf-8'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ensure_ascii</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/dataIO.html#dataIO.write_ensemble"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.dataIO.dataIO.write_ensemble" title="Permalink to this definition">ïƒ</a></dt> +<dd><blockquote> +<div><p>write_ensemble : Write ensemble results to a file.</p> +</div></blockquote> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>output_file</strong> – <p>the output filename.</p> +<p>If the filename has an extension that we recognise, +e.g. .gz or .bz2, we compress the output appropriately.</p> +<p>The filename should contain .json or .msgpack, the two +currently-supported formats.</p> +<p>Usually you’ll want to output to JSON, but we can +also output to msgpack.</p> +</p></li> +<li><p><strong>data</strong> – the data dictionary to be converted and written to the file. +If not set, this defaults to self.grid_ensemble_results.</p></li> +<li><p><strong>sort_keys</strong> – if True, and output is to JSON, the keys will be sorted. +(default: True, passed to json.dumps)</p></li> +<li><p><strong>indent</strong> – number of space characters used in the JSON indent. (Default: 4, +passed to json.dumps)</p></li> +<li><p><strong>encoding</strong> – file encoding method, usually defaults to ‘utf-8’</p></li> +<li><p><strong>ensure_ascii</strong> – the ensure_ascii flag passed to json.dump and/or json.dumps +(Default: False)</p></li> +</ul> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="condor.html" class="btn btn-neutral float-left" title="Population class extension: condor module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="distribution_functions.html" class="btn btn-neutral float-right" title="Population class extension: distribution_functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/distribution_functions.html b/docs/build/html/population_extensions/distribution_functions.html similarity index 50% rename from docs/build/html/distribution_functions.html rename to docs/build/html/population_extensions/distribution_functions.html index 5204886efe814d4f5403471ffb8d281b1bde76c0..94573485a384bee53e01ab6b090fcbcedc288215 100644 --- a/docs/build/html/distribution_functions.html +++ b/docs/build/html/population_extensions/distribution_functions.html @@ -1,176 +1,105 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>distribution_functions module — binary_c-python documentation</title> - - - - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: distribution_functions module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> - <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> - <script src="_static/jquery.js"></script> - <script src="_static/underscore.js"></script> - <script src="_static/doctools.js"></script> + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="index" title="Index" href="genindex.html" /> - <link rel="search" title="Search" href="search.html" /> - <link rel="next" title="functions module" href="functions.html" /> - <link rel="prev" title="custom_logging_functions module" href="custom_logging_functions.html" /> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: gridcode module" href="gridcode.html" /> + <link rel="prev" title="Population class extension: dataIO module" href="dataIO.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - + <a href="../index.html" class="icon icon-home"> binary_c-python </a> - - - - - - - <div role="search"> - <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> -<li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> -<li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> -<li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2 current"><a class="current reference internal" href="#">distribution_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> -<li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> </ul> </li> -<li class="toctree-l1"><a class="reference internal" href="example_notebooks.html">Example notebooks</a></li> -<li class="toctree-l1"><a class="reference internal" href="binary_c_parameters.html">Binary_c parameters</a></li> -<li class="toctree-l1"><a class="reference internal" href="grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> - <a href="index.html">binary_c-python</a> - + <a href="../index.html">binary_c-python</a> </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - - <li><a href="modules.html">Binarycpython code</a> »</li> - - <li>distribution_functions module</li> - - + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: distribution_functions module</li> <li class="wy-breadcrumbs-aside"> - - - <a href="_sources/distribution_functions.rst.txt" rel="nofollow"> View page source</a> - - + <a href="../_sources/population_extensions/distribution_functions.rst.txt" rel="nofollow"> View page source</a> </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -195,11 +124,13 @@ text-align: unset; } </style> -<div class="section" id="module-binarycpython.utils.distribution_functions"> -<span id="distribution-functions-module"></span><h1>distribution_functions module<a class="headerlink" href="#module-binarycpython.utils.distribution_functions" title="Permalink to this headline">¶</a></h1> +<section id="module-binarycpython.utils.population_extensions.distribution_functions"> +<span id="population-class-extension-distribution-functions-module"></span><h1>Population class extension: distribution_functions module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.distribution_functions" title="Permalink to this heading">ïƒ</a></h1> <p>Module containing the predefined distribution functions</p> <p>The user can use any of these distribution functions to generate probability distributions for sampling populations</p> +<p>To add custom functions you can take any function and add it to the class instance before running the code. +See <a class="reference external" href="https://stackoverflow.com/a/28060251">https://stackoverflow.com/a/28060251</a> for some tips on how to do that</p> <dl class="simple"> <dt>There are distributions for the following parameters:</dt><dd><ul class="simple"> <li><p>mass</p></li> @@ -214,7 +145,7 @@ generate probability distributions for sampling populations</p> </dd> </dl> </li> -<li><p>TODO: add eccentricity distribution: thermal</p></li> +<li><p>TODO: add eccentricity distribution: thermal, Mathieu eccentricity</p></li> <li><p>TODO: Add SFH distributions depending on redshift</p></li> <li><p>TODO: Add metallicity distributions depending on redshift</p></li> <li><p>TODO: Add initial rotational velocity distributions</p></li> @@ -222,9 +153,14 @@ generate probability distributions for sampling populations</p> </ul> </dd> </dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.Arenou2010_binary_fraction"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">Arenou2010_binary_fraction</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#Arenou2010_binary_fraction"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.Arenou2010_binary_fraction" title="Permalink to this definition">¶</a></dt> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">distribution_functions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Extension for the Population grid object that contains the distribution functions</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Arenou2010_binary_fraction"> +<span class="sig-name descname"><span class="pre">Arenou2010_binary_fraction</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.Arenou2010_binary_fraction"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Arenou2010_binary_fraction" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Arenou 2010 function for the binary fraction as f(M1)</p> <p>GAIA-C2-SP-OPM-FA-054 www.rssd.esa.int/doc_fetch.php?id=2969346</p> @@ -241,9 +177,9 @@ www.rssd.esa.int/doc_fetch.php?id=2969346</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.Izzard2012_period_distribution"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">Izzard2012_period_distribution</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">P</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">log10Pmin</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1.0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#Izzard2012_period_distribution"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.Izzard2012_period_distribution" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Izzard2012_period_distribution"> +<span class="sig-name descname"><span class="pre">Izzard2012_period_distribution</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">P</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">log10Pmin</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1.0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.Izzard2012_period_distribution"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Izzard2012_period_distribution" title="Permalink to this definition">ïƒ</a></dt> <dd><p>period distribution which interpolates between Duquennoy and Mayor 1991 at low mass (G/K spectral type <~1.15Msun) and Sana et al 2012 at high mass (O spectral type >~16.3Msun)</p> @@ -267,11 +203,22 @@ and Sana’s power law (as a function of logP) at high mass</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.Kroupa2001"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">Kroupa2001</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newopts</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#Kroupa2001"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.Kroupa2001" title="Permalink to this definition">¶</a></dt> -<dd><p>Probability distribution function for Kroupa 2001 IMF, where the default values to the -three_part_powerlaw are: default = {“m0â€: 0.1, “m1â€: 0.5, “m2â€: 1, “mmaxâ€: 100, “p1â€: -1.3, “p2â€: -2.3,â€p3â€: -2.3}</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Kroupa2001"> +<span class="sig-name descname"><span class="pre">Kroupa2001</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newopts</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.Kroupa2001"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Kroupa2001" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Probability distribution function for Kroupa 2001 IMF.</p> +<p>The (default) values for this is:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">default</span> <span class="o">=</span> <span class="p">{</span> + <span class="s2">"m0"</span><span class="p">:</span> <span class="mf">0.1</span><span class="p">,</span> + <span class="s2">"m1"</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">,</span> + <span class="s2">"m2"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> + <span class="s2">"mmax"</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span> + <span class="s2">"p1"</span><span class="p">:</span> <span class="o">-</span><span class="mf">1.3</span><span class="p">,</span> + <span class="s2">"p2"</span><span class="p">:</span> <span class="o">-</span><span class="mf">2.3</span><span class="p">,</span> + <span class="s2">"p3"</span><span class="p">:</span> <span class="o">-</span><span class="mf">2.3</span> +<span class="p">}</span> +</pre></div> +</div> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> @@ -288,21 +235,21 @@ three_part_powerlaw are: default = {“m0â€: 0.1, “m1â€: 0.5, “m2â€: 1, </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.Moe_di_Stefano_2017_multiplicity_fractions"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">Moe_di_Stefano_2017_multiplicity_fractions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#Moe_di_Stefano_2017_multiplicity_fractions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.Moe_di_Stefano_2017_multiplicity_fractions" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Moe_di_Stefano_2017_multiplicity_fractions"> +<span class="sig-name descname"><span class="pre">Moe_di_Stefano_2017_multiplicity_fractions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.Moe_di_Stefano_2017_multiplicity_fractions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Moe_di_Stefano_2017_multiplicity_fractions" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that creates a list of probability fractions and normalises and merges them according to the users choice.</p> <p>TODO: make an extrapolation functionality in this. log10(1.6e1) -is low, we can probably go a bit further</p> +is quite low.</p> <p>The default result that is returned when sampling the mass outside of the mass range is now the last known value</p> <p>Returns a list of multiplicity fractions for a given input of mass</p> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.Moe_di_Stefano_2017_pdf"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">Moe_di_Stefano_2017_pdf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#Moe_di_Stefano_2017_pdf"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.Moe_di_Stefano_2017_pdf" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Moe_di_Stefano_2017_pdf"> +<span class="sig-name descname"><span class="pre">Moe_di_Stefano_2017_pdf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.Moe_di_Stefano_2017_pdf"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.Moe_di_Stefano_2017_pdf" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Moe & diStefano function to calculate the probability density.</p> <p>takes a dictionary as input (in options) with options:</p> <p>M1, M2, M3, M4 => masses (Msun) [M1 required, rest optional] @@ -312,34 +259,50 @@ ecc, ecc2, ecc3 => eccentricities [numbering as for P above]</p> mmax => maximum allowed stellar mass (default 80.0)</p> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.build_q_table"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">build_q_table</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#build_q_table"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.build_q_table" title="Permalink to this definition">¶</a></dt> -<dd></dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.calc_P_integral"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">calc_P_integral</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_logP</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_logP</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">integrals_string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">interpolator_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mass_string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#calc_P_integral"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.calc_P_integral" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.build_q_table"> +<span class="sig-name descname"><span class="pre">build_q_table</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.build_q_table"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.build_q_table" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Build an interpolation table for q, given a mass and +orbital period.</p> +<p>m and p are labels which determine which system(s) +to look up from Moe’s data:</p> +<p>m can be M1, M2, M3, M4, or if set M1+M2 etc. +p can be P, P2, P3</p> +<p>The actual values are in $opts:</p> +<p>mass is in $opts->{m} +period is $opts->{p}</p> +<p>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. +If we are below the lowest value of qmin in the table we need to extrapolate the data</p> +<p>Anyway, the goal of this function is to provide some extrapolated values for q when we should sample outside of the boundaries +TODO: fix description to be correct for python</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_P_integral"> +<span class="sig-name descname"><span class="pre">calc_P_integral</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_logP</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_logP</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">integrals_string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">interpolator_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mass_string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.calc_P_integral"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_P_integral" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to calculate the P integral</p> <p>We need to renormalise this because min_per > 0, and not all periods should be included</p> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.calc_e_integral"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">calc_e_integral</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">integrals_string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">interpolator_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mass_string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">period_string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#calc_e_integral"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.calc_e_integral" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to calculate the P integral</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_e_integral"> +<span class="sig-name descname"><span class="pre">calc_e_integral</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">integrals_string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">interpolator_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mass_string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">period_string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.calc_e_integral"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_e_integral" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to calculate the e integral</p> <p>We need to renormalise this because min_per > 0, and not all periods should be included</p> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.calc_total_probdens"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">calc_total_probdens</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prob_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#calc_total_probdens"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.calc_total_probdens" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_total_probdens"> +<span class="sig-name descname"><span class="pre">calc_total_probdens</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prob_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.calc_total_probdens"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calc_total_probdens" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to calculate the total probability density</p> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.calculate_constants_three_part_powerlaw"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">calculate_constants_three_part_powerlaw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m_max</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p3</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#calculate_constants_three_part_powerlaw"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.calculate_constants_three_part_powerlaw" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calculate_constants_three_part_powerlaw"> +<span class="sig-name descname"><span class="pre">calculate_constants_three_part_powerlaw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m_max</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p3</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.calculate_constants_three_part_powerlaw"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.calculate_constants_three_part_powerlaw" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to calculate the constants for a three-part power law</p> <p>TODO: use the power law_constant function to calculate all these values</p> <dl class="field-list simple"> @@ -363,9 +326,9 @@ mmax => maximum allowed stellar mass (default 80.0)</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.const"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">const</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#const"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.const" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.const_distribution"> +<span class="sig-name descname"><span class="pre">const_distribution</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.const_distribution"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.const_distribution" title="Permalink to this definition">ïƒ</a></dt> <dd><p>a constant distribution function between min=min_bound and max=max_bound.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -378,14 +341,14 @@ mmax => maximum allowed stellar mass (default 80.0)</p> <dd class="field-even"><p>returns 0</p> </dd> <dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>returns the value of 1/(max_bound-min_bound) If val is provided, it will check whether min_bound < val <= max_bound. if not</p> +<dd class="field-odd"><p>returns the value of 1/(max_bound-min_bound). If val is provided, it will check whether min_bound < val <= max_bound. if not</p> </dd> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.cosmic_SFH_madau_dickinson2014"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">cosmic_SFH_madau_dickinson2014</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">z</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#cosmic_SFH_madau_dickinson2014"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.cosmic_SFH_madau_dickinson2014" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.cosmic_SFH_madau_dickinson2014"> +<span class="sig-name descname"><span class="pre">cosmic_SFH_madau_dickinson2014</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">z</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.cosmic_SFH_madau_dickinson2014"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.cosmic_SFH_madau_dickinson2014" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Cosmic star formation history distribution from Madau & Dickonson 2014 (<a class="reference external" href="https://arxiv.org/pdf/1403.0007.pdf">https://arxiv.org/pdf/1403.0007.pdf</a>)</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -397,10 +360,10 @@ mmax => maximum allowed stellar mass (default 80.0)</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.duquennoy1991"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">duquennoy1991</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">logper</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#duquennoy1991"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.duquennoy1991" title="Permalink to this definition">¶</a></dt> -<dd><p>Period distribution from Duquennoy + Mayor 1991. Evaluated the function gaussian(logper, 4.8, 2.3, -2, 12)</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.duquennoy1991"> +<span class="sig-name descname"><span class="pre">duquennoy1991</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">logper</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.duquennoy1991"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.duquennoy1991" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Period distribution from Duquennoy + Mayor 1991. Evaluated the function self.gaussian(logper, 4.8, 2.3, -2, 12)</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>logper</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – logarithm of period to evaluate the distribution at</p> @@ -409,22 +372,22 @@ mmax => maximum allowed stellar mass (default 80.0)</p> <dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]</p> </dd> <dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>‘probability’ at gaussian(logper, 4.8, 2.3, -2, 12)</p> +<dd class="field-odd"><p>‘probability’ at self.gaussian(logper, 4.8, 2.3, -2, 12)</p> </dd> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.fill_data"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">fill_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sample_values</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#fill_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.fill_data" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.fill_data"> +<span class="sig-name descname"><span class="pre">fill_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sample_values</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.fill_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.fill_data" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that returns the normalised array of values for given logmass and logperiod used for the e and q values</p> <p>TODO: make sure we do the correct thing with the dstep</p> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.flat"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">flat</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#flat"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.flat" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.flat"> +<span class="sig-name descname"><span class="pre">flat</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.flat"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.flat" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Dummy distribution function that returns 1</p> <dl class="field-list simple"> <dt class="field-odd">Returns</dt> @@ -436,9 +399,9 @@ used for the e and q values</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.flatsections"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">flatsections</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">opts</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#flatsections"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.flatsections" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.flatsections"> +<span class="sig-name descname"><span class="pre">flatsections</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">opts</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.flatsections"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.flatsections" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to generate flat distributions, possibly in multiple sections</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -456,9 +419,9 @@ used for the e and q values</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.gaussian"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">gaussian</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mean</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sigma</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gmin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gmax</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#gaussian"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.gaussian" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian"> +<span class="sig-name descname"><span class="pre">gaussian</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mean</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sigma</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gmin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gmax</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.gaussian"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Gaussian distribution function. used for e.g. Duquennoy + Mayor 1991</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -479,9 +442,9 @@ used for the e and q values</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.gaussian_func"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">gaussian_func</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mean</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sigma</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#gaussian_func"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.gaussian_func" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian_func"> +<span class="sig-name descname"><span class="pre">gaussian_func</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mean</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sigma</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.gaussian_func"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian_func" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to evaluate a Gaussian at a given point, but this time without any boundaries.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -500,9 +463,9 @@ used for the e and q values</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.gaussian_normalizing_const"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">gaussian_normalizing_const</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mean</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sigma</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gmin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gmax</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#gaussian_normalizing_const"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.gaussian_normalizing_const" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian_normalizing_const"> +<span class="sig-name descname"><span class="pre">gaussian_normalizing_const</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mean</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sigma</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gmin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gmax</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.gaussian_normalizing_const"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.gaussian_normalizing_const" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to calculate the normalisation constant for the Gaussian</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -522,21 +485,21 @@ used for the e and q values</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.get_integration_constant_q"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">get_integration_constant_q</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">q_interpolator</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tmp_table</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qdata</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#get_integration_constant_q"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.get_integration_constant_q" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.get_integration_constant_q"> +<span class="sig-name descname"><span class="pre">get_integration_constant_q</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">q_interpolator</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tmp_table</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qdata</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.get_integration_constant_q"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.get_integration_constant_q" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to integrate the q interpolator and return the integration constant</p> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.get_max_multiplicity"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">get_max_multiplicity</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">multiplicity_array</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#get_max_multiplicity"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.get_max_multiplicity" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.get_max_multiplicity"> +<span class="sig-name descname"><span class="pre">get_max_multiplicity</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">multiplicity_array</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.get_max_multiplicity"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.get_max_multiplicity" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to get the maximum multiplicity</p> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.imf_chabrier2003"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">imf_chabrier2003</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#imf_chabrier2003"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.imf_chabrier2003" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_chabrier2003"> +<span class="sig-name descname"><span class="pre">imf_chabrier2003</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.imf_chabrier2003"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_chabrier2003" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Probability distribution function for IMF of Chabrier 2003 PASP 115:763-795</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -551,10 +514,10 @@ used for the e and q values</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.imf_scalo1986"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">imf_scalo1986</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#imf_scalo1986"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.imf_scalo1986" title="Permalink to this definition">¶</a></dt> -<dd><p>Probability distribution function for Scalo 1986 IMF (defined up until 80Msol): three_part_powerlaw(m, 0.1, 1.0, 2.0, 80.0, -2.35, -2.35, -2.70)</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_scalo1986"> +<span class="sig-name descname"><span class="pre">imf_scalo1986</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.imf_scalo1986"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_scalo1986" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Probability distribution function for Scalo 1986 IMF (defined up until 80Msol): self.three_part_powerlaw(m, 0.1, 1.0, 2.0, 80.0, -2.35, -2.35, -2.70)</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>m</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – mass to evaluate the distribution at</p> @@ -568,11 +531,11 @@ used for the e and q values</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.imf_scalo1998"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">imf_scalo1998</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#imf_scalo1998"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.imf_scalo1998" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_scalo1998"> +<span class="sig-name descname"><span class="pre">imf_scalo1998</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.imf_scalo1998"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_scalo1998" title="Permalink to this definition">ïƒ</a></dt> <dd><p>From Scalo 1998</p> -<p>Probability distribution function for Scalo 1998 IMF (defined up until 80Msol): three_part_powerlaw(m, 0.1, 1.0, 10.0, 80.0, -1.2, -2.7, -2.3)</p> +<p>Probability distribution function for Scalo 1998 IMF (defined up until 80Msol): self.three_part_powerlaw(m, 0.1, 1.0, 10.0, 80.0, -1.2, -2.7, -2.3)</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>m</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – mass to evaluate the distribution at</p> @@ -586,10 +549,10 @@ used for the e and q values</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.imf_tinsley1980"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">imf_tinsley1980</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#imf_tinsley1980"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.imf_tinsley1980" title="Permalink to this definition">¶</a></dt> -<dd><p>Probability distribution function for Tinsley 1980 IMF (defined up until 80Msol): three_part_powerlaw(m, 0.1, 2.0, 10.0, 80.0, -2.0, -2.3, -3.3)</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_tinsley1980"> +<span class="sig-name descname"><span class="pre">imf_tinsley1980</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.imf_tinsley1980"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.imf_tinsley1980" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Probability distribution function for Tinsley 1980 IMF (defined up until 80Msol): self.three_part_powerlaw(m, 0.1, 2.0, 10.0, 80.0, -2.0, -2.3, -3.3)</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>m</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – mass to evaluate the distribution at</p> @@ -603,9 +566,9 @@ used for the e and q values</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.interpolate_in_mass_izzard2012"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">interpolate_in_mass_izzard2012</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">high</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">low</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#interpolate_in_mass_izzard2012"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.interpolate_in_mass_izzard2012" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.interpolate_in_mass_izzard2012"> +<span class="sig-name descname"><span class="pre">interpolate_in_mass_izzard2012</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">high</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">low</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.interpolate_in_mass_izzard2012"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.interpolate_in_mass_izzard2012" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to interpolate in mass</p> <p>TODO: fix this function. TODO: describe the args @@ -628,9 +591,9 @@ low: at 1.15</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.ktg93"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">ktg93</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newopts</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#ktg93"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.ktg93" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.ktg93"> +<span class="sig-name descname"><span class="pre">ktg93</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newopts</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.ktg93"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.ktg93" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Probability distribution function for KTG93 IMF, where the default values to the three_part_powerlaw are: default = {“m0â€: 0.1, “m1â€: 0.5, “m2â€: 1, “mmaxâ€: 80, “p1â€: -1.3, “p2â€: -2.2,â€p3â€: -2.7}</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -648,15 +611,15 @@ low: at 1.15</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.linear_extrapolation_q"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">linear_extrapolation_q</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">qs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qlimit</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qdata</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end_index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#linear_extrapolation_q"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.linear_extrapolation_q" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.linear_extrapolation_q"> +<span class="sig-name descname"><span class="pre">linear_extrapolation_q</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">qs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qlimit</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qdata</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end_index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.linear_extrapolation_q"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.linear_extrapolation_q" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to do the linear extrapolation for q.</p> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.merge_multiplicities"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">merge_multiplicities</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">result_array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_multiplicity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#merge_multiplicities"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.merge_multiplicities" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.merge_multiplicities"> +<span class="sig-name descname"><span class="pre">merge_multiplicities</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">result_array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_multiplicity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.merge_multiplicities"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.merge_multiplicities" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to fold the multiplicities higher than the max_multiplicity onto the max_multiplicity</p> <dl class="simple"> <dt>if max_multiplicity == 1:</dt><dd><p>All the multiplicities are folded onto multiplicity == 1. This will always total to 1</p> @@ -668,15 +631,9 @@ low: at 1.15</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.normalize_dict"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">normalize_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">result_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#normalize_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.normalize_dict" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to normalise a dictionary</p> -</dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.number"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">number</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#number"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.number" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.number"> +<span class="sig-name descname"><span class="pre">number</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.number"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.number" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Dummy distribution function that returns the input</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -691,16 +648,16 @@ low: at 1.15</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.poisson"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">poisson</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lambda_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nmax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#poisson"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.poisson" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.poisson"> +<span class="sig-name descname"><span class="pre">poisson</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lambda_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nmax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.poisson"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.poisson" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that calculates the Poisson value and normalises TODO: improve the description</p> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.powerlaw"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">powerlaw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#powerlaw"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.powerlaw" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw"> +<span class="sig-name descname"><span class="pre">powerlaw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.powerlaw"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Single power law with index k at x from min to max</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -720,9 +677,9 @@ TODO: improve the description</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.powerlaw_constant"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">powerlaw_constant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#powerlaw_constant"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.powerlaw_constant" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_constant"> +<span class="sig-name descname"><span class="pre">powerlaw_constant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.powerlaw_constant"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_constant" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that returns the constant to normalise a power law</p> <p>TODO: what if k is -1?</p> <dl class="field-list simple"> @@ -742,34 +699,37 @@ TODO: improve the description</p> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.powerlaw_extrapolation_q"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">powerlaw_extrapolation_q</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">qdata</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#powerlaw_extrapolation_q"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.powerlaw_extrapolation_q" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to do the power law extrapolation at the lower end of the q range</p> -</dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.prepare_dict"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">prepare_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">global_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">list_of_sub_keys</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#prepare_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.prepare_dict" title="Permalink to this definition">¶</a></dt> -<dd><p>Function that makes sure that the global dict is prepared to have a value set there. -This dictionary will store values and factors for the distribution functions, -so that they don’t have to be calculated each time.</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_constant_nocache"> +<span class="sig-name descname"><span class="pre">powerlaw_constant_nocache</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.powerlaw_constant_nocache"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_constant_nocache" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that returns the constant to normalise a power law</p> +<p>TODO: what if k is -1?</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> -<li><p><strong>global_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – globally accessible dictionary where factors are stored in</p></li> -<li><p><strong>list_of_sub_keys</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code>) – List of keys that must become be(come) present in the global_dict</p></li> +<li><p><strong>min_val</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – lower bound of the range</p></li> +<li><p><strong>max_val</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – upper bound of the range</p></li> +<li><p><strong>k</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – power law slope</p></li> </ul> </dd> <dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> +<dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]</p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>constant to normalise the given power law between the min_val and max_val range</p> </dd> </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.raghavan2010_binary_fraction"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">raghavan2010_binary_fraction</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#raghavan2010_binary_fraction"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.raghavan2010_binary_fraction" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_extrapolation_q"> +<span class="sig-name descname"><span class="pre">powerlaw_extrapolation_q</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">qdata</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indices</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.powerlaw_extrapolation_q"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.powerlaw_extrapolation_q" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to do the power-law extrapolation at the lower end of the q range</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.raghavan2010_binary_fraction"> +<span class="sig-name descname"><span class="pre">raghavan2010_binary_fraction</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.raghavan2010_binary_fraction"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.raghavan2010_binary_fraction" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Fit to the Raghavan 2010 binary fraction as a function of spectral type (Fig 12). Valid for local stars (Z=Zsolar).</p> <p>The spectral type is converted mass by use of the ZAMS @@ -790,9 +750,9 @@ and the new “long_spectral_type†function of binary_c </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.sana12"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">sana12</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">P</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">amin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">amax</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#sana12"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.sana12" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.sana12"> +<span class="sig-name descname"><span class="pre">sana12</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">P</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">amin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">amax</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.sana12"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.sana12" title="Permalink to this definition">ïƒ</a></dt> <dd><p>distribution of initial orbital periods as found by Sana et al. (2012) which is a flat distribution in ln(a) and ln(P) respectively for stars * less massive than 15Msun (no O-stars) @@ -801,7 +761,7 @@ which is a flat distribution in ln(a) and ln(P) respectively for stars and is be given by dp/dlogP ~ (logP)^p for all other binary configurations (default p=-0.55)</p> <p>arguments are M1, M2, a, Period P, amin, amax, x0=log P0, x1=log P1, p</p> <p>example args: 10, 5, sep(M1, M2, P), sep, ?, -2, 12, -0.55</p> -<p># TODO: Fix this function!</p> +<p># TODO: Fix this function! Half of the input here can be taken out and calculated within the function itself.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> @@ -825,30 +785,9 @@ and is be given by dp/dlogP ~ (logP)^p for all other binary configurations (defa </dl> </dd></dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.set_opts"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">set_opts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">opts</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newopts</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#set_opts"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.set_opts" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to take a default dict and override it with newer values.</p> -<p># TODO: consider changing this to just a dict.update</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>opts</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary with default values</p></li> -<li><p><strong>newopts</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary with new values</p></li> -</ul> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> -</dd> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>returns an updated dictionary</p> -</dd> -</dl> -</dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.distribution_functions.three_part_powerlaw"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.distribution_functions.</span></span><span class="sig-name descname"><span class="pre">three_part_powerlaw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m_max</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p3</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/distribution_functions.html#three_part_powerlaw"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.distribution_functions.three_part_powerlaw" title="Permalink to this definition">¶</a></dt> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.distribution_functions.distribution_functions.three_part_powerlaw"> +<span class="sig-name descname"><span class="pre">three_part_powerlaw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m_max</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p3</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/distribution_functions.html#distribution_functions.three_part_powerlaw"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.distribution_functions.distribution_functions.three_part_powerlaw" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Generalised three-part power law, usually used for mass distributions</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -872,61 +811,45 @@ and is be given by dp/dlogP ~ (logP)^p for all other binary configurations (defa </dl> </dd></dl> -</div> +</dd></dl> + +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="functions.html" class="btn btn-neutral float-right" title="functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="custom_logging_functions.html" class="btn btn-neutral float-left" title="custom_logging_functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="dataIO.html" class="btn btn-neutral float-left" title="Population class extension: dataIO module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="gridcode.html" class="btn btn-neutral float-right" title="Population class extension: gridcode module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/grid_logging.html b/docs/build/html/population_extensions/grid_logging.html new file mode 100644 index 0000000000000000000000000000000000000000..4c4070aa891307834691be4734aff04a7d0c5a74 --- /dev/null +++ b/docs/build/html/population_extensions/grid_logging.html @@ -0,0 +1,201 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: grid_logging module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: grid_options_defaults module" href="grid_options_defaults.html" /> + <link rel="prev" title="Population class extension: gridcode module" href="gridcode.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: grid_logging module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/grid_logging.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.grid_logging"> +<span id="population-class-extension-grid-logging-module"></span><h1>Population class extension: grid_logging module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.grid_logging" title="Permalink to this heading">ïƒ</a></h1> +<p>The class extension for the population object that contains logging functionality</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_logging.grid_logging"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.grid_logging.</span></span><span class="sig-name descname"><span class="pre">grid_logging</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_logging.html#grid_logging"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_logging.grid_logging" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>The class extension for the population object that contains logging functionality</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_logging.grid_logging.vb1print"> +<span class="sig-name descname"><span class="pre">vb1print</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ID</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">now</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">system_number</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">system_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_logging.html#grid_logging.vb1print"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_logging.grid_logging.vb1print" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Verbosity-level 1 printing, to keep an eye on a grid.</p> +<dl class="simple"> +<dt>Input:</dt><dd><p>ID: thread ID for debugging (int): TODO fix this +now: the time now as a UNIX-style epoch in seconds (float) +system_number: the system number</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_logging.grid_logging.vb2print"> +<span class="sig-name descname"><span class="pre">vb2print</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">system_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmdline_string</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_logging.html#grid_logging.vb2print"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_logging.grid_logging.vb2print" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Extra function for verbose printing</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_logging.grid_logging.verbose_print"> +<span class="sig-name descname"><span class="pre">verbose_print</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_logging.html#grid_logging.verbose_print"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_logging.grid_logging.verbose_print" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Wrapper method for the verbose print that calls the verbose print with the correct newline</p> +<p>TODO: consider merging the two</p> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="gridcode.html" class="btn btn-neutral float-left" title="Population class extension: gridcode module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="grid_options_defaults.html" class="btn btn-neutral float-right" title="Population class extension: grid_options_defaults module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/grid_options_defaults.html b/docs/build/html/population_extensions/grid_options_defaults.html new file mode 100644 index 0000000000000000000000000000000000000000..8cbb156baa9ef1e9dcb7ed38e733c0dbfc034763 --- /dev/null +++ b/docs/build/html/population_extensions/grid_options_defaults.html @@ -0,0 +1,264 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: grid_options_defaults module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: HPC module" href="HPC.html" /> + <link rel="prev" title="Population class extension: grid_logging module" href="grid_logging.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: grid_options_defaults module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/grid_options_defaults.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.grid_options_defaults"> +<span id="population-class-extension-grid-options-defaults-module"></span><h1>Population class extension: grid_options_defaults module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.grid_options_defaults" title="Permalink to this heading">ïƒ</a></h1> +<dl class="simple"> +<dt>Module that contains the default options for the population grid code along with the description for these options, in the form of dictionaries:</dt><dd><ul class="simple"> +<li><p>grid_options_defaults_dict: dictionary containing the default values for all the options</p></li> +<li><p>grid_options_descriptions: dictionary containing the description for these options.</p></li> +</ul> +</dd> +<dt>There are several other functions in this module, mostly to generate help texts or documents:</dt><dd><ul class="simple"> +<li><p>grid_options_help: interactive function for the user to get descriptions for options</p></li> +<li><p>grid_options_description_checker: function that checks that checks which options have a description.</p></li> +<li><p>write_grid_options_to_rst_file: function to generate the .rst document for the docs</p></li> +</ul> +</dd> +</dl> +<p>With this its also possible to automatically generate a document containing all the setting names + descriptions.</p> +<p>All the options starting with _ should not be changed by the user except when you really know what you’re doing (which is probably hacking the code :P)</p> +<p>TODO: reconsider having this all as class methods. It seems unnecessary to have all these functions as class methods.</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.grid_options_defaults.</span></span><span class="sig-name descname"><span class="pre">grid_options_defaults</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_options_defaults.html#grid_options_defaults"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Class extension to Population grid containing all the functionality for the options and defaults</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.default_cache_dir"> +<span class="sig-name descname"><span class="pre">default_cache_dir</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_options_defaults.html#grid_options_defaults.default_cache_dir"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.default_cache_dir" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return a default cache directory path, or None if we cannot find one.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.get_grid_options_defaults_dict"> +<span class="sig-name descname"><span class="pre">get_grid_options_defaults_dict</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_options_defaults.html#grid_options_defaults.get_grid_options_defaults_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.get_grid_options_defaults_dict" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return the default values for the grid options</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.get_grid_options_descriptions"> +<span class="sig-name descname"><span class="pre">get_grid_options_descriptions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_options_defaults.html#grid_options_defaults.get_grid_options_descriptions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.get_grid_options_descriptions" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that returns the descriptions for all the grid options</p> +<p>TODO: consider putting input types for all of them</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.grid_options_description_checker"> +<span class="sig-name descname"><span class="pre">grid_options_description_checker</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">print_info</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_options_defaults.html#grid_options_defaults.grid_options_description_checker"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.grid_options_description_checker" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that checks which descriptions are missing</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>print_info</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – whether to print out information about which options contain proper descriptions and which do not</p> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>the number of undescribed keys</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.grid_options_help"> +<span class="sig-name descname"><span class="pre">grid_options_help</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_options_defaults.html#grid_options_defaults.grid_options_help"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.grid_options_help" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that prints out the description of a grid option. Useful function for the user.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>option</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – which option you want to have the description of</p> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>dict containing the option, the description if its there, otherwise empty string. And if the key doesnt exist, the dict is empty</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.print_option_descriptions"> +<span class="sig-name descname"><span class="pre">print_option_descriptions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filehandle</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">descriptions</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">title</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extra_text</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_options_defaults.html#grid_options_defaults.print_option_descriptions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.print_option_descriptions" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to print the description of an option</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.write_grid_options_to_rst_file"> +<span class="sig-name descname"><span class="pre">write_grid_options_to_rst_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output_file</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/grid_options_defaults.html#grid_options_defaults.write_grid_options_to_rst_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults.write_grid_options_to_rst_file" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that writes the descriptions of the grid options to an rst file</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>output_file</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – target file where the grid options descriptions are written to</p> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="grid_logging.html" class="btn btn-neutral float-left" title="Population class extension: grid_logging module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="HPC.html" class="btn btn-neutral float-right" title="Population class extension: HPC module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/gridcode.html b/docs/build/html/population_extensions/gridcode.html new file mode 100644 index 0000000000000000000000000000000000000000..a2f3ee6df75fe2593109854bcb96c4dee5eb6c8b --- /dev/null +++ b/docs/build/html/population_extensions/gridcode.html @@ -0,0 +1,320 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: gridcode module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: grid_logging module" href="grid_logging.html" /> + <link rel="prev" title="Population class extension: distribution_functions module" href="distribution_functions.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: gridcode module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/gridcode.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.gridcode"> +<span id="population-class-extension-gridcode-module"></span><h1>Population class extension: gridcode module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.gridcode" title="Permalink to this heading">ïƒ</a></h1> +<p>Module containing the gridcode generation functions for the binarycpython package.</p> +<p>This class object is an extension to the population grid object</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.gridcode.gridcode"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.gridcode.</span></span><span class="sig-name descname"><span class="pre">gridcode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/gridcode.html#gridcode"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.gridcode.gridcode" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Extension to the population grid object that contains functionality to handle the metadata that will be put in the ensemble</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.gridcode.gridcode.add_grid_variable"> +<span class="sig-name descname"><span class="pre">add_grid_variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parameter_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">longname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">valuerange</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">samplerfunc</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">probdist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dphasevol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gridtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'centred'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">branchpoint</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">branchcode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">precode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">postcode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">topcode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bottomcode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">condition</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dry_parallel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/gridcode.html#gridcode.add_grid_variable"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.gridcode.gridcode.add_grid_variable" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to add grid variables to the grid_options.</p> +<p>The execution of the grid generation will be through a nested for loop. +Each of the grid variables will get create a deeper for loop.</p> +<p>The real function that generates the numbers will get written to a new file in the TMP_DIR, +and then loaded imported and evaluated. +beware that if you insert some destructive piece of code, it will be executed anyway. +Use at own risk.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>name</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <p>name of parameter used in the grid Python code. +This is evaluated as a parameter and you can use it throughout +the rest of the function</p> +<p>Examples:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">name</span> <span class="o">=</span> <span class="s1">'lnM_1'</span> +</pre></div> +</div> +</p></li> +<li><p><strong>parameter_name</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <p>name of the parameter in binary_c</p> +<p>This name must correspond to a Python variable of the same name, +which is automatic if parameter_name == name.</p> +<dl class="simple"> +<dt>Note: if parameter_name != name, you must set a</dt><dd><p>variable in “precode†or “postcode†to define a Python variable +called parameter_name</p> +</dd> +</dl> +</p></li> +<li><p><strong>longname</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <p>Long name of parameter</p> +<p>Examples:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">longname</span> <span class="o">=</span> <span class="s1">'Primary mass'</span> +</pre></div> +</div> +</p></li> +<li><p><strong>range</strong> – <p>Range of values to take. Does not get used really, the samplerfunc is used to +get the values from</p> +<p>Examples:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">range</span> <span class="o">=</span> <span class="p">[</span><span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">m_min</span><span class="p">),</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">m_max</span><span class="p">)]</span> +</pre></div> +</div> +</p></li> +<li><p><strong>samplerfunc</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <p>Function returning a list or numpy array of samples spaced appropriately. +You can either use a real function, or a string representation of a function call.</p> +<p>Examples:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">samplerfunc</span> <span class="o">=</span> <span class="s2">"self.const_linear(math.log(m_min), math.log(m_max), </span><span class="si">{}</span><span class="s2">)"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">[</span><span class="s1">'M_1'</span><span class="p">])</span> +</pre></div> +</div> +</p></li> +<li><p><strong>precode</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – <p>Extra room for some code. This code will be evaluated within the loop of the +sampling function (i.e. a value for lnM_1 is chosen already)</p> +<p>Examples:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">precode</span> <span class="o">=</span> <span class="s1">'M_1=math.exp(lnM_1);'</span> +</pre></div> +</div> +</p></li> +<li><p><strong>postcode</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – Code executed after the probability is calculated.</p></li> +<li><p><strong>probdist</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – <p>Function determining the probability that gets assigned to the sampled parameter</p> +<p>Examples:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">probdist</span> <span class="o">=</span> <span class="s1">'self.Kroupa2001(M_1)*M_1'</span> +</pre></div> +</div> +</p></li> +<li><p><strong>dphasevol</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – <p>part of the parameter space that the total probability is calculated with. Put to -1 +if you want to ignore any dphasevol calculations and set the value to 1</p> +<p>Examples:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">dphasevol</span> <span class="o">=</span> <span class="s1">'dlnM_1'</span> +</pre></div> +</div> +</p></li> +<li><p><strong>condition</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – <p>condition that has to be met in order for the grid generation to continue</p> +<p>Examples:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">condition</span> <span class="o">=</span> <span class="s2">"self.grid_options['binary']==1"</span> +</pre></div> +</div> +</p></li> +<li><p><strong>gridtype</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – Method on how the value range is sampled. Can be either ‘edge’ (steps starting at +the lower edge of the value range) or ‘centred’ +(steps starting at <code class="docutils literal notranslate"><span class="pre">lower</span> <span class="pre">edge</span> <span class="pre">+</span> <span class="pre">0.5</span> <span class="pre">*</span> <span class="pre">stepsize</span></code>).</p></li> +<li><p><strong>dry_parallel</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>]) – If True, try to parallelize this variable in dry runs.</p></li> +<li><p><strong>topcode</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – Code added at the very top of the block.</p></li> +<li><p><strong>bottomcode</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>]) – Code added at the very bottom of the block.</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.gridcode.gridcode.delete_grid_variable"> +<span class="sig-name descname"><span class="pre">delete_grid_variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/gridcode.html#gridcode.delete_grid_variable"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.gridcode.gridcode.delete_grid_variable" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to delete a grid variable with the given name.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>name</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – name of the grid variable to be deleted.</p> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.gridcode.gridcode.rename_grid_variable"> +<span class="sig-name descname"><span class="pre">rename_grid_variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">oldname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newname</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/gridcode.html#gridcode.rename_grid_variable"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.gridcode.gridcode.rename_grid_variable" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to rename a grid variable.</p> +<p>note: this does NOT alter the order +of the self.grid_options[“_grid_variablesâ€] dictionary.</p> +<p>The order in which the grid variables are loaded into the grid is based on their +<cite>grid_variable_number</cite> property</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>oldname</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – old name of the grid variable</p></li> +<li><p><strong>newname</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – new name of the grid variable</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.gridcode.gridcode.update_grid_variable"> +<span class="sig-name descname"><span class="pre">update_grid_variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/gridcode.html#gridcode.update_grid_variable"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.gridcode.gridcode.update_grid_variable" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to update the values of a grid variable.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>name</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – name of the grid variable to be changed.</p></li> +<li><p><strong>**kwargs</strong> – key-value pairs to override the existing grid variable data. See add_grid_variable for these names.</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="distribution_functions.html" class="btn btn-neutral float-left" title="Population class extension: distribution_functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="grid_logging.html" class="btn btn-neutral float-right" title="Population class extension: grid_logging module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/metadata.html b/docs/build/html/population_extensions/metadata.html new file mode 100644 index 0000000000000000000000000000000000000000..6d01e184967d69c0667e1d36ce5a33758894cab7 --- /dev/null +++ b/docs/build/html/population_extensions/metadata.html @@ -0,0 +1,189 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: metadata module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: Moe_di_Stefano_2017 module" href="Moe_di_Stefano_2017.html" /> + <link rel="prev" title="Population class extension: HPC module" href="HPC.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: metadata module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/metadata.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.metadata"> +<span id="population-class-extension-metadata-module"></span><h1>Population class extension: metadata module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.metadata" title="Permalink to this heading">ïƒ</a></h1> +<p>Module containing the metadata functions for the binarycpython package.</p> +<p>This class object is an extension to the population grid object</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.metadata.metadata"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.metadata.</span></span><span class="sig-name descname"><span class="pre">metadata</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/metadata.html#metadata"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.metadata.metadata" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Extension to the population grid object that contains functionality to handle the metadata that will be put in the ensemble</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.metadata.metadata.add_ensemble_metadata"> +<span class="sig-name descname"><span class="pre">add_ensemble_metadata</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">combined_output_dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/metadata.html#metadata.add_ensemble_metadata"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.metadata.metadata.add_ensemble_metadata" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to add metadata to the grid_ensemble_results and grid_options</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.metadata.metadata.add_system_metadata"> +<span class="sig-name descname"><span class="pre">add_system_metadata</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/metadata.html#metadata.add_system_metadata"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.metadata.metadata.add_system_metadata" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Add system’s metadata to the grid_ensemble_results, and add some system information to metadata.</p> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="HPC.html" class="btn btn-neutral float-left" title="Population class extension: HPC module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="Moe_di_Stefano_2017.html" class="btn btn-neutral float-right" title="Population class extension: Moe_di_Stefano_2017 module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/slurm.html b/docs/build/html/population_extensions/slurm.html new file mode 100644 index 0000000000000000000000000000000000000000..ea81ed221f3db24b53dcf057cbdf10f88364e6fe --- /dev/null +++ b/docs/build/html/population_extensions/slurm.html @@ -0,0 +1,257 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: slurm module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: spacing_functions module" href="spacing_functions.html" /> + <link rel="prev" title="Population class extension: Moe_di_Stefano_2017 module" href="Moe_di_Stefano_2017.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: slurm module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/slurm.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.slurm"> +<span id="population-class-extension-slurm-module"></span><h1>Population class extension: slurm module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.slurm" title="Permalink to this heading">ïƒ</a></h1> +<p>Module containing the Slurm functions for the binarycpython package.</p> +<p>This class object is an extension to the population grid object</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.slurm.</span></span><span class="sig-name descname"><span class="pre">slurm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Extension for the Population class containing the code for Slurm grid simulations</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.get_slurm_status"> +<span class="sig-name descname"><span class="pre">get_slurm_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">jobid</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">jobarrayindex</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">slurm_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.get_slurm_status"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.get_slurm_status" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Get and return the slurm status string corresponing to the self object, or jobid.jobarrayindex if they are passed in. If no status is found, returns an empty string.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.make_slurm_dirs"> +<span class="sig-name descname"><span class="pre">make_slurm_dirs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">slurm_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.make_slurm_dirs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.make_slurm_dirs" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to create the necessary slurm directories</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.set_slurm_status"> +<span class="sig-name descname"><span class="pre">set_slurm_status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">slurm_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.set_slurm_status"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.set_slurm_status" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Set the slurm status corresponing to the self object, which should have slurm_jobid and slurm_jobarrayindex set.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>string</strong> – the status string to be set</p></li> +<li><p><strong>slurm_dir</strong> – the directory in which the status directory is held. If not set, this defaults to the HPC directory (e.g. slurm_dir or condor_dir).</p></li> +</ul> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.slurmID"> +<span class="sig-name descname"><span class="pre">slurmID</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">jobid</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">jobarrayindex</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.slurmID"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.slurmID" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return a Slurm job ID as a string, [jobid].[jobarrayindex]. The jobid and jobarrayindex passed in are used if given, otherwise we default to the jobid and jobarrayindex in grid_options.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.slurm_check_requirements"> +<span class="sig-name descname"><span class="pre">slurm_check_requirements</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.slurm_check_requirements"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.slurm_check_requirements" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to check whether the slurm parameters in grid_options have been set appropriately.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.slurm_dirs"> +<span class="sig-name descname"><span class="pre">slurm_dirs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.slurm_dirs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.slurm_dirs" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Directories associated specifically with this slurm job.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.slurm_grid"> +<span class="sig-name descname"><span class="pre">slurm_grid</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.slurm_grid"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.slurm_grid" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>function to be called when running grids when grid_options[‘slurm’]>=1</p> +<p>if grid_options[‘slurm’]==1, we set up the slurm script and launch the jobs, then return True to exit. +if grid_options[‘slurm’]==2, we run the stars, which means we return False to continue. +if grid_options[‘slurm’]==3, we are being called from the jobs to run the grids, return False to continue.</p> +<p>TODO: split this function into some parts +TODO: Comment this function better</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.slurm_outfile"> +<span class="sig-name descname"><span class="pre">slurm_outfile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">slurm_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.slurm_outfile"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.slurm_outfile" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>return a standard filename for the slurm chunk files</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.slurm_queue_stats"> +<span class="sig-name descname"><span class="pre">slurm_queue_stats</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.slurm_queue_stats"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.slurm_queue_stats" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to XXX</p> +<p>TODO</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.slurm_status_file"> +<span class="sig-name descname"><span class="pre">slurm_status_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">jobid</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">jobarrayindex</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">slurm_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.slurm_status_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.slurm_status_file" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return the slurm status file corresponding to the jobid and jobarrayindex, which default to grid_options slurm_jobid and slurm_jobarrayindex, respectively.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.slurm.slurm.slurmpath"> +<span class="sig-name descname"><span class="pre">slurmpath</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">slurm_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/slurm.html#slurm.slurmpath"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.slurm.slurm.slurmpath" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return the full slurm directory path.</p> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="Moe_di_Stefano_2017.html" class="btn btn-neutral float-left" title="Population class extension: Moe_di_Stefano_2017 module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="spacing_functions.html" class="btn btn-neutral float-right" title="Population class extension: spacing_functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/spacing_functions.html b/docs/build/html/population_extensions/spacing_functions.html new file mode 100644 index 0000000000000000000000000000000000000000..f71fe688a1ee7441c15a50c1f6d76ab8c0fd1d21 --- /dev/null +++ b/docs/build/html/population_extensions/spacing_functions.html @@ -0,0 +1,344 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: spacing_functions module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="Population class extension: version_info module" href="version_info.html" /> + <link rel="prev" title="Population class extension: slurm module" href="slurm.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="version_info.html">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: spacing_functions module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/spacing_functions.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.spacing_functions"> +<span id="population-class-extension-spacing-functions-module"></span><h1>Population class extension: spacing_functions module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.spacing_functions" title="Permalink to this heading">ïƒ</a></h1> +<p>Module containing the spacing functions for the binarycpython package. Very under-populated at the moment, but more are likely to come soon</p> +<p>This class object is an extension to the population grid object</p> +<dl class="simple"> +<dt>Tasks:</dt><dd><p>TODO: add more spacing functions to this module.</p> +</dd> +</dl> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.spacing_functions.spacing_functions"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.spacing_functions.</span></span><span class="sig-name descname"><span class="pre">spacing_functions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/spacing_functions.html#spacing_functions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.spacing_functions.spacing_functions" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Extension for the Population class containing the code for spacing functions</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_dt"> +<span class="sig-name descname"><span class="pre">const_dt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cachedir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">usecache</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/spacing_functions.html#spacing_functions.const_dt"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_dt" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>const_dt returns a list of masses spaced at a constant age difference</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>dt</strong> – the time difference between the masses (1000.0 Myr, used when logspacing==False)</p></li> +<li><p><strong>dlogt</strong> – the delta log10(time) difference between masses (0.1 dex, used when logspacing==True)</p></li> +<li><p><strong>mmin</strong> – the minimum mass to be considered in the stellar lifetime interpolation table (0.07 Msun)</p></li> +<li><p><strong>mmax</strong> – the maximum mass to be considered in the stellar lifetime interpolation table (100.0 Msun)</p></li> +<li><p><strong>nres</strong> – the resolution of the stellar lifetime interpolation table (100)</p></li> +<li><p><strong>logspacing</strong> – whether to use log-spaced time, in which case dt is actually d(log10(t))</p></li> +<li><p><strong>tmin</strong> – the minimum time to consider (Myr, default 3.0 Myr)</p></li> +<li><p><strong>tmax</strong> – the maximum time to consider (Myr, default None which means we use the grid option ‘max_evolution_time’)</p></li> +<li><p><strong>max_evolution_time</strong> – overrides bse_options[‘max_evolution_time’] if set</p></li> +<li><p><strong>mindm</strong> – a tuple of tuples containing a mass range and minimum mass spacing in that range. The default is ((0.07,1.0,0.1),(1.0,300.0,1.0)) allocated a minimum dm of 0.1Msun in the mass range 0.07 to 1.0 Msun and 1.0Msun in the range 1.0 to 300.0 Msun. Anything you set overrides this. Note, if you use only one tuple, you must set it with a trailing comma, thus, e.g. ((0.07,1.0,0.1),). (default None)</p></li> +<li><p><strong>maxdm</strong> – a list of tuples similar to mindm but specifying a maximum mass spacing. In the case of maxdm, if the third option in each tuple is negative it is treated as a log step (its absolute value is used as the step). (default None)</p></li> +<li><p><strong>fsample</strong> – a global sampling (Shannon-like) factor (<1) to improve resolution (default 1.0, set to smaller to improve resolution)</p></li> +<li><p><strong>factor</strong> – all masses generated are multiplied by this after generation</p></li> +<li><p><strong>showtable</strong> – if True, the mass list and times are shown to stdout after generation</p></li> +<li><p><strong>showlist</strong> – if True, show the mass list once generated</p></li> +<li><p><strong>logmasses</strong> – if True, the masses are logged with math.log()</p></li> +<li><p><strong>log10masses</strong> – if True, the masses are logged with math.log10()</p></li> +<li><p><strong>usecache</strong> – if True (the default) uses cached results if they are saved (in cachedir) and cachedir is not None</p></li> +<li><p><strong>cachedir</strong> – where the cache is stored. if None, defaults to grid_options[‘cache_dir’]+’/const_dt_cache’</p></li> +<li><p><strong>vb</strong> – verbose logging flag (default False)</p></li> +</ul> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>Array of masses.</p> +</dd> +</dl> +<p class="rubric">Example</p> +<p>these are lines set as options to Population.add_grid_value(…):</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># linear time bins of 1Gyr</span> +<span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_dt(self,dt=1000,nres=100,mmin=0.07,mmax=2.0,showtable=True)"</span> + +<span class="c1"># logarithmic spacing in time, generally suitable for Galactic chemical evolution yield grids.</span> +<span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"self.const_dt(self,dlogt=0.1,nres=100,mmin=0.07,mmax=80.0,maxdm=((0.07,1.0,0.1),(1.0,10.0,1.0),(10.0,80.0,2.0)),showtable=True,logspacing=True,fsample=1.0/4.0)"</span> +</pre></div> +</div> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_int"> +<span class="sig-name descname"><span class="pre">const_int</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/spacing_functions.html#spacing_functions.const_int"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_int" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Samples an integer range linearly. Returns a list of ints.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>min_bound</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – lower bound of range, must be an integer (is converted to int)</p></li> +<li><p><strong>max_bound</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – upper bound of range, must be an integer (is converted to int)</p></li> +<li><p><strong>steps</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – number of segments between min_bound and max_bound</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p><p>range(min_bound,max_bound,step)</p> +<p>where step is int((int(max_bound)-int(min_bound))/steps)</p> +</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_linear"> +<span class="sig-name descname"><span class="pre">const_linear</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/spacing_functions.html#spacing_functions.const_linear"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_linear" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Samples a range linearly. Uses numpy linspace, and returns an array of floats. Do NOT use this for integers.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>min_bound</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – lower bound of range</p></li> +<li><p><strong>max_bound</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – upper bound of range</p></li> +<li><p><strong>steps</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – number of segments between min_bound and max_bound</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>np.linspace(min_bound, max_bound, steps)</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_ranges"> +<span class="sig-name descname"><span class="pre">const_ranges</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ranges</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/spacing_functions.html#spacing_functions.const_ranges"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.const_ranges" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Samples a series of ranges linearly.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>ranges</strong> – a tuple of tuples passed to the self.const_linear() spacing function.</p> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>numpy array of masses</p> +</dd> +</dl> +<p class="rubric">Example</p> +<p>The following allocates 10 stars between 0.1 and 0.65, 20 stars between 0.65 +and 0.85, and 10 stars between 0.85 and 10.0 Msun:</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">samplerfunc</span><span class="o">=</span><span class="s2">"const_ranges(((</span><span class="si">{}</span><span class="s2">,</span><span class="si">{}</span><span class="s2">,</span><span class="si">{}</span><span class="s2">),(</span><span class="si">{}</span><span class="s2">,</span><span class="si">{}</span><span class="s2">,</span><span class="si">{}</span><span class="s2">),(</span><span class="si">{}</span><span class="s2">,</span><span class="si">{}</span><span class="s2">,</span><span class="si">{}</span><span class="s2">)))"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.65</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> + <span class="mf">0.65</span><span class="p">,</span> <span class="mf">0.85</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> + <span class="mf">0.85</span><span class="p">,</span> <span class="mf">10.0</span><span class="p">,</span> <span class="mi">10</span> +<span class="p">)</span> +</pre></div> +</div> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.spacing_functions.spacing_functions.gaussian_zoom"> +<span class="sig-name descname"><span class="pre">gaussian_zoom</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">zoom_mean</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">zoom_dispersion</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">zoom_magnitude</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/spacing_functions.html#spacing_functions.gaussian_zoom"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.gaussian_zoom" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Samples such that a region is zoomed in according to a 1-Gaussian function</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>min_bound</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – lower bound of range</p></li> +<li><p><strong>max_bound</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – upper bound of range</p></li> +<li><p><strong>zoom_mean</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – mean of the Gaussian zoom location</p></li> +<li><p><strong>zoom_dispersion</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – dispersion of the Gaussian</p></li> +<li><p><strong>zoom_magnitude</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – depth of the Gaussian (should be 0<= zoom_magntiude <1)</p></li> +<li><p><strong>steps</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – number of segments between min_bound and max_bound assuming a linear step +this is what you’d normally call “resolutionâ€</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>Numpy array of sample values</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.spacing_functions.spacing_functions.peak_normalized_gaussian_func"> +<span class="sig-name descname"><span class="pre">peak_normalized_gaussian_func</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mean</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sigma</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/spacing_functions.html#spacing_functions.peak_normalized_gaussian_func"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.spacing_functions.spacing_functions.peak_normalized_gaussian_func" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to evaluate a Gaussian at a given point, note +that the normalization is such that the peak is always 1.0, +not that the integral is 1.0</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>x</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – location at which to evaluate the distribution</p></li> +<li><p><strong>mean</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – mean of the Gaussian</p></li> +<li><p><strong>sigma</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – standard deviation of the Gaussian</p></li> +</ul> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]</p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>value of the Gaussian at x</p> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="slurm.html" class="btn btn-neutral float-left" title="Population class extension: slurm module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="version_info.html" class="btn btn-neutral float-right" title="Population class extension: version_info module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/population_extensions/version_info.html b/docs/build/html/population_extensions/version_info.html new file mode 100644 index 0000000000000000000000000000000000000000..ce7ca146df43f701675a6d479eeeea5110dcc811 --- /dev/null +++ b/docs/build/html/population_extensions/version_info.html @@ -0,0 +1,221 @@ +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Population class extension: version_info module — binary_c-python documentation</title> + <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="../_static/js/html5shiv.min.js"></script> + <![endif]--> + + <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> + <script src="../_static/jquery.js"></script> + <script src="../_static/underscore.js"></script> + <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> + <script src="../_static/doctools.js"></script> + <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> + <script src="../_static/js/theme.js"></script> + <link rel="index" title="Index" href="../genindex.html" /> + <link rel="search" title="Search" href="../search.html" /> + <link rel="next" title="run_system_wrapper module" href="../run_system_wrapper.html" /> + <link rel="prev" title="Population class extension: spacing_functions module" href="spacing_functions.html" /> +</head> + +<body class="wy-body-for-nav"> + <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + <a href="../index.html" class="icon icon-home"> binary_c-python + </a> +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> + <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> +<ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../readme_link.html">Python module for binary_c</a></li> +<li class="toctree-l1 current"><a class="reference internal" href="../modules.html">Binarycpython code</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../custom_logging_functions.html">custom_logging_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../ensemble.html">ensemble module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html">functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../grid.html">Population class module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Population class extension: version_info module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../run_system_wrapper.html">run_system_wrapper module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../stellar_types.html">stellar_types module</a></li> +<li class="toctree-l2"><a class="reference internal" href="../useful_funcs.html">useful_funcs module</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../example_notebooks.html">Example notebooks</a></li> +<li class="toctree-l1"><a class="reference internal" href="../binary_c_parameters.html">Binary_c parameters</a></li> +<li class="toctree-l1"><a class="reference internal" href="../grid_options_descriptions.html">Population grid code options</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> +<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> +</ul> + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">binary_c-python</a> + </nav> + + <div class="wy-nav-content"> + <div class="rst-content"> + <div role="navigation" aria-label="Page navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../index.html" class="icon icon-home"></a> »</li> + <li><a href="../modules.html">Binarycpython code</a> »</li> + <li>Population class extension: version_info module</li> + <li class="wy-breadcrumbs-aside"> + <a href="../_sources/population_extensions/version_info.rst.txt" rel="nofollow"> View page source</a> + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + +<style> +/* CSS overrides for sphinx_rtd_theme */ + +/* 24px margin */ +.nbinput.nblast.container, +.nboutput.nblast.container { + margin-bottom: 19px; /* padding has already 5px */ +} + +/* ... except between code cells! */ +.nblast.container + .nbinput.container { + margin-top: -19px; +} + +.admonition > p:before { + margin-right: 4px; /* make room for the exclamation icon */ +} + +/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ +.math { + text-align: unset; +} +</style> +<section id="module-binarycpython.utils.population_extensions.version_info"> +<span id="population-class-extension-version-info-module"></span><h1>Population class extension: version_info module<a class="headerlink" href="#module-binarycpython.utils.population_extensions.version_info" title="Permalink to this heading">ïƒ</a></h1> +<p>File containing the class object containing the functions to handle binary_c version info.</p> +<p>This class will be used to extend the population object</p> +<p>NOTE: could these functions not just be normal functions rather than class methods? I see hardly any use of the self</p> +<dl class="py class"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.version_info.version_info"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">binarycpython.utils.population_extensions.version_info.</span></span><span class="sig-name descname"><span class="pre">version_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/version_info.html#version_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.version_info.version_info" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> +<p>Class object containing the functions to handle binary_c version info.</p> +<p>This class will be used to extend the population object</p> +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.version_info.version_info.minimum_stellar_mass"> +<span class="sig-name descname"><span class="pre">minimum_stellar_mass</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/version_info.html#version_info.minimum_stellar_mass"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.version_info.version_info.minimum_stellar_mass" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function to return the minimum stellar mass (in Msun) from binary_c.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.version_info.version_info.parse_binary_c_version_info"> +<span class="sig-name descname"><span class="pre">parse_binary_c_version_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">version_info_string</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/version_info.html#version_info.parse_binary_c_version_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.version_info.version_info.parse_binary_c_version_info" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that parses the binary_c version info. Long function with a lot of branches</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>version_info_string</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – raw output of version_info call to binary_c</p> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>‘isotopes’ for isotope info, ‘argpairs’ for argument pair info (TODO: explain), ‘ensembles’ for ensemble settings/info, ‘macros’ for macros, ‘elements’ for atomic element info, ‘DTlimit’ for (TODO: explain), ‘nucleosynthesis_sources’ for nucleosynthesis sources, and ‘miscellaneous’ for all those that were not caught by the previous groups. ‘git_branch’, ‘git_build’, ‘revision’ and ‘email’ are also keys, but its clear what those contain.</p> +</dd> +<dt class="field-odd">Return type</dt> +<dd class="field-odd"><p>Parsed version of the version info, which is a dictionary containing the keys</p> +</dd> +</dl> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="binarycpython.utils.population_extensions.version_info.version_info.return_binary_c_version_info"> +<span class="sig-name descname"><span class="pre">return_binary_c_version_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parsed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/binarycpython/utils/population_extensions/version_info.html#version_info.return_binary_c_version_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.population_extensions.version_info.version_info.return_binary_c_version_info" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Function that returns the version information of binary_c. This function calls the function +_binary_c_bindings.return_version_info()</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>parsed</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – Boolean flag whether to parse the version_info output of binary_c. default = False</p> +</dd> +<dt class="field-even">Return type</dt> +<dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>]</p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>Either the raw string of binary_c or a parsed version of this in the form of a nested +dictionary</p> +</dd> +</dl> +</dd></dl> + +</dd></dl> + +</section> + + + </div> + </div> + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="spacing_functions.html" class="btn btn-neutral float-left" title="Population class extension: spacing_functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="../run_system_wrapper.html" class="btn btn-neutral float-right" title="run_system_wrapper module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> + </div> + + <hr/> + + <div role="contentinfo"> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> + </div> + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +<br><br> +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. +<br><br> +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. + + + +</footer> + </div> + </div> + </section> + </div> + <script> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + +</body> +</html> \ No newline at end of file diff --git a/docs/build/html/py-modindex.html b/docs/build/html/py-modindex.html index da95acbeda14542e61e7987aa409ebc08649f027..c399b18c8d893acb8d8bc72df03486aef00ca4ec 100644 --- a/docs/build/html/py-modindex.html +++ b/docs/build/html/py-modindex.html @@ -1,41 +1,22 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Python Module Index — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> @@ -43,29 +24,13 @@ </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -73,17 +38,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> @@ -95,64 +50,29 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li>Python Module Index</li> - - <li class="wy-breadcrumbs-aside"> - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <h1>Python Module Index</h1> @@ -178,7 +98,12 @@ <tr class="cg-1"> <td></td> <td>    - <a href="distribution_functions.html#module-binarycpython.utils.distribution_functions"><code class="xref">binarycpython.utils.distribution_functions</code></a></td><td> + <a href="dicts.html#module-binarycpython.utils.dicts"><code class="xref">binarycpython.utils.dicts</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="ensemble.html#module-binarycpython.utils.ensemble"><code class="xref">binarycpython.utils.ensemble</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> @@ -193,27 +118,82 @@ <tr class="cg-1"> <td></td> <td>    - <a href="grid_options_defaults.html#module-binarycpython.utils.grid_options_defaults"><code class="xref">binarycpython.utils.grid_options_defaults</code></a></td><td> + <a href="plot_functions.html#module-binarycpython.utils.plot_functions"><code class="xref">binarycpython.utils.plot_functions</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> <td>    - <a href="hpc_functions.html#module-binarycpython.utils.hpc_functions"><code class="xref">binarycpython.utils.hpc_functions</code></a></td><td> + <a href="population_extensions/analytics.html#module-binarycpython.utils.population_extensions.analytics"><code class="xref">binarycpython.utils.population_extensions.analytics</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> <td>    - <a href="plot_functions.html#module-binarycpython.utils.plot_functions"><code class="xref">binarycpython.utils.plot_functions</code></a></td><td> + <a href="population_extensions/cache.html#module-binarycpython.utils.population_extensions.cache"><code class="xref">binarycpython.utils.population_extensions.cache</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> <td>    - <a href="run_system_wrapper.html#module-binarycpython.utils.run_system_wrapper"><code class="xref">binarycpython.utils.run_system_wrapper</code></a></td><td> + <a href="population_extensions/condor.html#module-binarycpython.utils.population_extensions.condor"><code class="xref">binarycpython.utils.population_extensions.condor</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="population_extensions/dataIO.html#module-binarycpython.utils.population_extensions.dataIO"><code class="xref">binarycpython.utils.population_extensions.dataIO</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> <td>    - <a href="spacing_functions.html#module-binarycpython.utils.spacing_functions"><code class="xref">binarycpython.utils.spacing_functions</code></a></td><td> + <a href="population_extensions/distribution_functions.html#module-binarycpython.utils.population_extensions.distribution_functions"><code class="xref">binarycpython.utils.population_extensions.distribution_functions</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="population_extensions/grid_logging.html#module-binarycpython.utils.population_extensions.grid_logging"><code class="xref">binarycpython.utils.population_extensions.grid_logging</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="population_extensions/grid_options_defaults.html#module-binarycpython.utils.population_extensions.grid_options_defaults"><code class="xref">binarycpython.utils.population_extensions.grid_options_defaults</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="population_extensions/gridcode.html#module-binarycpython.utils.population_extensions.gridcode"><code class="xref">binarycpython.utils.population_extensions.gridcode</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="population_extensions/HPC.html#module-binarycpython.utils.population_extensions.HPC"><code class="xref">binarycpython.utils.population_extensions.HPC</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="population_extensions/metadata.html#module-binarycpython.utils.population_extensions.metadata"><code class="xref">binarycpython.utils.population_extensions.metadata</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="population_extensions/Moe_di_Stefano_2017.html#module-binarycpython.utils.population_extensions.Moe_di_Stefano_2017"><code class="xref">binarycpython.utils.population_extensions.Moe_di_Stefano_2017</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="population_extensions/slurm.html#module-binarycpython.utils.population_extensions.slurm"><code class="xref">binarycpython.utils.population_extensions.slurm</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="population_extensions/spacing_functions.html#module-binarycpython.utils.population_extensions.spacing_functions"><code class="xref">binarycpython.utils.population_extensions.spacing_functions</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="population_extensions/version_info.html#module-binarycpython.utils.population_extensions.version_info"><code class="xref">binarycpython.utils.population_extensions.version_info</code></a></td><td> + <em></em></td></tr> + <tr class="cg-1"> + <td></td> + <td>    + <a href="run_system_wrapper.html#module-binarycpython.utils.run_system_wrapper"><code class="xref">binarycpython.utils.run_system_wrapper</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> @@ -229,48 +209,36 @@ </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/readme_link.html b/docs/build/html/readme_link.html index 61b7b3aaff7393fd1e10d251cc40d327a07d3a88..4c515ce32ab0d81446ed16d183ffa2a936cf0b2b 100644 --- a/docs/build/html/readme_link.html +++ b/docs/build/html/readme_link.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>Python module for binary_c — binary_c-python documentation</title> - - - - - - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Python module for binary_c — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Binarycpython code" href="modules.html" /> <link rel="prev" title="Welcome to binary_c-python’s documentation!" href="index.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,34 +38,34 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1 current"><a class="current reference internal" href="#">Python module for binary_c</a><ul> -<li class="toctree-l2"><a class="reference internal" href="#requirements">Requirements</a></li> -<li class="toctree-l2"><a class="reference internal" href="#environment-variables">Environment variables</a></li> -<li class="toctree-l2"><a class="reference internal" href="#build-instructions">Build instructions</a><ul> +<li class="toctree-l2"><a class="reference internal" href="#installation">Installation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#python-requirements">Python requirements</a></li> +<li class="toctree-l3"><a class="reference internal" href="#environment-variables">Environment variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="#build-instructions">Build instructions</a></li> <li class="toctree-l3"><a class="reference internal" href="#installation-via-pip">Installation via PIP:</a></li> <li class="toctree-l3"><a class="reference internal" href="#installation-from-source">Installation from source:</a><ul> -<li class="toctree-l4"><a class="reference internal" href="#after-installation">After installation</a></li> +<li class="toctree-l4"><a class="reference internal" href="#after-installation-from-source">After installation from source</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="#use-of-code-without-installation">Use of code without installation</a></li> </ul> </li> +<li class="toctree-l2"><a class="reference internal" href="#usage">Usage</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#examples">Examples</a></li> +<li class="toctree-l3"><a class="reference internal" href="#usage-notes">Usage notes</a></li> +<li class="toctree-l3"><a class="reference internal" href="#documentation">Documentation</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="#development">Development:</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#generating-documentation">Generating documentation</a></li> +<li class="toctree-l3"><a class="reference internal" href="#generating-docstring-and-test-coverage-report">Generating docstring and test coverage report</a></li> +<li class="toctree-l3"><a class="reference internal" href="#running-unit-tests">Running unit tests</a></li> </ul> </li> -<li class="toctree-l2"><a class="reference internal" href="#examples">Examples</a></li> -<li class="toctree-l2"><a class="reference internal" href="#usage-notes">Usage notes</a></li> -<li class="toctree-l2"><a class="reference internal" href="#documentation">Documentation</a></li> -<li class="toctree-l2"><a class="reference internal" href="#development">Development:</a></li> <li class="toctree-l2"><a class="reference internal" href="#faq-issues">FAQ/Issues:</a></li> </ul> </li> @@ -111,68 +77,30 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li>Python module for binary_c</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/readme_link.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -197,35 +125,31 @@ text-align: unset; } </style> -<div class="section" id="python-module-for-binary-c"> -<h1>Python module for binary_c<a class="headerlink" href="#python-module-for-binary-c" title="Permalink to this headline">¶</a></h1> +<section id="python-module-for-binary-c"> +<h1>Python module for binary_c<a class="headerlink" href="#python-module-for-binary-c" title="Permalink to this heading">ïƒ</a></h1> <p>Docstring coverage:</p> <a class="reference external image-reference" href="./badges/docstring_coverage.svg"><img alt="docstring coverage" src="_images/docstring_coverage.svg" /></a> <p>Test coverage:</p> <a class="reference external image-reference" href="./badges/test_coverage.svg"><img alt="test coverage" src="_images/test_coverage.svg" /></a> -<p>Binary population synthesis code that interfaces with binary_c. Based on a original work by Jeff Andrews (can be found in old_solution/ directory). Updated and extended for Python3 by David Hendriks, Robert Izzard.</p> -<p>The current release is version <a class="reference external" href="VERSION">version</a>, make sure to use that version number when installing!</p> -<div class="section" id="requirements"> -<h2>Requirements<a class="headerlink" href="#requirements" title="Permalink to this headline">¶</a></h2> +<p>Powered by:</p> +<a class="reference external image-reference" href="http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat"><img alt="astropy" src="http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat" /></a> +<p>We present our package <a class="reference external" href="https://ri0005.pages.surrey.ac.uk/binary_c-python/">binary-c-python</a>, a population synthesis code which is aimed to provide a convenient and easy-to-use interface to the <a class="reference external" href="http://personal.ph.surrey.ac.uk/~ri0005/doc/binary_c/binary_c.html">binary_c</a> framework, allowing the user to rapidly evolve single stellar systems and populations of star systems. Based on a early work by Jeff Andrews. Updated and extended for Python3 by David Hendriks, Robert Izzard.</p> +<p>binary_c-python is developed for students and scientists in the field of stellar astrophysics, who want to study the evolution of individual or populations of single and binary star systems (see the example use-case notebooks in the <a class="reference external" href="https://ri0005.pages.surrey.ac.uk/binary_c-python/example_notebooks.html">online documentation</a>.</p> +<p>The current release is version <a class="reference external" href="VERSION">version</a>, and is designed and tested to work with binary_c version 2.2.1 (for older or newer versions we can’t guarantee correct behaviour).</p> +<section id="installation"> +<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this heading">ïƒ</a></h2> +<p>To install binary_c-python we need to make sure we meet the requirements of installation, and</p> +<section id="python-requirements"> +<h3>Python requirements<a class="headerlink" href="#python-requirements" title="Permalink to this heading">ïƒ</a></h3> <p>To run this code you need to at least have installations of:</p> <ul class="simple"> -<li><p>Python 3.6 or higher</p></li> -<li><p>binary_c version 2.1.7 or higher</p></li> -</ul> -<p>And the following python packages (which will get installed automatically when installing with pip):</p> -<ul class="simple"> -<li><p>numpy</p></li> -<li><p>pytest</p></li> -<li><p>h5py</p></li> -<li><p>pathos</p></li> -<li><p>pandas</p></li> -<li><p>astropy</p></li> -<li><p>matplotlib</p></li> -<li><p>py_rinterpolate</p></li> +<li><p>Python 3.7 or higher (3.6 is EOL, and we are using 3.9 for development)</p></li> +<li><p>binary_c version 2.2.0 or higher</p></li> </ul> -</div> -<div class="section" id="environment-variables"> -<h2>Environment variables<a class="headerlink" href="#environment-variables" title="Permalink to this headline">¶</a></h2> +<p>The packages that are required for this code to run are listed in the requirements.txt, which automatically gets read out by setup.py</p> +</section> +<section id="environment-variables"> +<h3>Environment variables<a class="headerlink" href="#environment-variables" title="Permalink to this heading">ïƒ</a></h3> <p>Before compilation you need to have certain environment variables:</p> <p>Required:</p> <ul class="simple"> @@ -234,57 +158,86 @@ <li><p><code class="docutils literal notranslate"><span class="pre">LIBRARY_PATH</span></code> should include whatever directories are required to build binary_c (e.g. locations of libgsl, libmemoize, librinterpolate, etc.)</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">GSL_DIR</span></code> should point to the root location where you installed GSL to. This root dir should contain <code class="docutils literal notranslate"><span class="pre">bin/</span></code>, <code class="docutils literal notranslate"><span class="pre">lib/</span></code> etc</p></li> </ul> -</div> -<div class="section" id="build-instructions"> -<h2>Build instructions<a class="headerlink" href="#build-instructions" title="Permalink to this headline">¶</a></h2> +</section> +<section id="build-instructions"> +<h3>Build instructions<a class="headerlink" href="#build-instructions" title="Permalink to this heading">ïƒ</a></h3> <p>First, make sure you have built binary_c (See <code class="docutils literal notranslate"><span class="pre">$BINARY_C/doc/binary_c2.pdf</span></code> section: installation for all the installation instructions for <code class="docutils literal notranslate"><span class="pre">binary_c</span></code>)) and that it functions correctly.</p> -<div class="section" id="installation-via-pip"> -<h3>Installation via PIP:<a class="headerlink" href="#installation-via-pip" title="Permalink to this headline">¶</a></h3> +</section> +<section id="installation-via-pip"> +<h3>Installation via PIP:<a class="headerlink" href="#installation-via-pip" title="Permalink to this heading">ïƒ</a></h3> <p>To install this package via pip:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">binarycpython</span> </pre></div> </div> -<p>This will install the latest stable installation that is available on pip.</p> -</div> -<div class="section" id="installation-from-source"> -<h3>Installation from source:<a class="headerlink" href="#installation-from-source" title="Permalink to this headline">¶</a></h3> -<p>We can also install the package from source, which is useful for development versions and when you want to modify the code. It is recommended that you install this into a virtual environment. From within the root directory, run</p> +<p>This will install the latest stable installation that is available on Pip. The version on the master branch should be the same version as the latest stable version on Pip</p> +</section> +<section id="installation-from-source"> +<h3>Installation from source:<a class="headerlink" href="#installation-from-source" title="Permalink to this heading">ïƒ</a></h3> +<p>We can also install the package from source, which is useful for development versions and when you want to modify the code. It is recommended that you install this into a virtual environment. From within the <code class="docutils literal notranslate"><span class="pre">commands/</span></code> directory, run</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">install</span><span class="o">.</span><span class="n">sh</span> </pre></div> </div> -<p>This will install the package, along with all the dependencies.</p> -<p>If this is not the first time you install the package, but rather rebuild it because you made changes in either binary_c or binarycpython, you can run</p> -<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">install_without_dependencies</span><span class="o">.</span><span class="n">sh</span> -</pre></div> -</div> -<p>to reinstall just binarycpython.</p> -<div class="section" id="after-installation"> -<h4>After installation<a class="headerlink" href="#after-installation" title="Permalink to this headline">¶</a></h4> +<p>This will install the package, along with all the dependencies, into the current active (virtual) python environment.</p> +<section id="after-installation-from-source"> +<h4>After installation from source<a class="headerlink" href="#after-installation-from-source" title="Permalink to this heading">ïƒ</a></h4> <p>After installing the code via source it is useful to run the test suite before doing any programming with it. The test suite is stored in <code class="docutils literal notranslate"><span class="pre">binarycpython/tests</span></code> and running <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">main.py</span></code> in there will run all the tests.</p> -</div> -</div> -</div> -<div class="section" id="examples"> -<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2> +</section> +</section> +<section id="use-of-code-without-installation"> +<h3>Use of code without installation<a class="headerlink" href="#use-of-code-without-installation" title="Permalink to this heading">ïƒ</a></h3> +<p>Because installing <code class="docutils literal notranslate"><span class="pre">binary_c-python</span></code> requires a working installation of <code class="docutils literal notranslate"><span class="pre">binary_c</span></code>, installing via pip or from source without this working installation of <code class="docutils literal notranslate"><span class="pre">binary_c</span></code> won’t work. To still make use of some of the functions provided by <code class="docutils literal notranslate"><span class="pre">binary_c-python</span></code>, you can add the path to the code-base to your <code class="docutils literal notranslate"><span class="pre">PYTHONPATH</span></code>:</p> +<ul class="simple"> +<li><p>Download <code class="docutils literal notranslate"><span class="pre">binary_c-python</span></code>, via e.g. <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">clone</span> <span class="pre">https://gitlab.com/binary_c/binary_c-python.git</span></code></p></li> +<li><p>Add the path to the downloaded repo to your <code class="docutils literal notranslate"><span class="pre">$PYTHONPATH</span></code>, via e.g. <code class="docutils literal notranslate"><span class="pre">export</span> <span class="pre">PYTHONPATH="~/binary_c-python:$PYTHONPATH"</span></code></p></li> +</ul> +</section> +</section> +<section id="usage"> +<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this heading">ïƒ</a></h2> +<section id="examples"> +<h3>Examples<a class="headerlink" href="#examples" title="Permalink to this heading">ïƒ</a></h3> <p>See the examples/ directory for example scripts and notebooks. The documentation contains example pages as well.</p> -</div> -<div class="section" id="usage-notes"> -<h2>Usage notes<a class="headerlink" href="#usage-notes" title="Permalink to this headline">¶</a></h2> +</section> +<section id="usage-notes"> +<h3>Usage notes<a class="headerlink" href="#usage-notes" title="Permalink to this heading">ïƒ</a></h3> <p>Make sure that with every change/recompilation you make in <code class="docutils literal notranslate"><span class="pre">binary_c</span></code>, you also rebuild this package. Whenever you change the sourcecode of this package, you need to reinstall it into your virtualenvironment as well</p> -</div> -<div class="section" id="documentation"> -<h2>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline">¶</a></h2> -<p>Look in the docs/ directory. Within the build/html/ there is the html version of the documentation. The</p> -</div> -<div class="section" id="development"> -<h2>Development:<a class="headerlink" href="#development" title="Permalink to this headline">¶</a></h2> +</section> +<section id="documentation"> +<h3>Documentation<a class="headerlink" href="#documentation" title="Permalink to this heading">ïƒ</a></h3> +<p>Look in the docs/ directory. Within the build/html/ there is the html version of the documentation. The documentation is also hosted on <a class="reference external" href="http://personal.ph.surrey.ac.uk/~ri0005/doc/binary_c/binary_c.html">http://personal.ph.surrey.ac.uk/~ri0005/doc/binary_c/binary_c.html</a> but only for the most recent stable release.</p> +</section> +</section> +<section id="development"> +<h2>Development:<a class="headerlink" href="#development" title="Permalink to this heading">ïƒ</a></h2> <p>If you want to contribute to the code, then it is recommended that you install the packages in <code class="docutils literal notranslate"><span class="pre">development_requirements.txt</span></code>:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="o">-</span><span class="n">r</span> <span class="n">development_requirements</span><span class="o">.</span><span class="n">txt</span> </pre></div> </div> +<p>Please do not hesitate to contact us to discuss any developments.</p> +<section id="generating-documentation"> +<h3>Generating documentation<a class="headerlink" href="#generating-documentation" title="Permalink to this heading">ïƒ</a></h3> +<p>To build the documentation manually, run</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">generate_docs</span><span class="o">.</span><span class="n">sh</span> +</pre></div> </div> -<div class="section" id="faq-issues"> -<h2>FAQ/Issues:<a class="headerlink" href="#faq-issues" title="Permalink to this headline">¶</a></h2> +<p>from within the <code class="docutils literal notranslate"><span class="pre">commands/</span></code> directory</p> +</section> +<section id="generating-docstring-and-test-coverage-report"> +<h3>Generating docstring and test coverage report<a class="headerlink" href="#generating-docstring-and-test-coverage-report" title="Permalink to this heading">ïƒ</a></h3> +<p>To generate the unit test and docstring coverage report, run</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">generate_reports</span><span class="o">.</span><span class="n">sh</span> +</pre></div> +</div> +<p>from within the <code class="docutils literal notranslate"><span class="pre">commands/</span></code> directory</p> +</section> +<section id="running-unit-tests"> +<h3>Running unit tests<a class="headerlink" href="#running-unit-tests" title="Permalink to this heading">ïƒ</a></h3> +<p>There are two versions of the general unit tests. The first includes only the actual code of the project, and is located at <code class="docutils literal notranslate"><span class="pre">binarycpython/test/main.py</span></code>. The second includes the tutorial notebooks, and is located at <code class="docutils literal notranslate"><span class="pre">binarycpython/test/main_with_notebooks.py</span></code>. To run just the notebook tests run <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">binarycpython/tests/test_notebooks.py</span></code></p> +</section> +</section> +<section id="faq-issues"> +<h2>FAQ/Issues:<a class="headerlink" href="#faq-issues" title="Permalink to this heading">ïƒ</a></h2> +<p>Here we provide a non-exhaustive list of some issues we encountered and solutions for these:</p> <p>Building issues with binary_c itself:</p> <ul class="simple"> <li><p>see the documentation of binary_c (in doc/).</p></li> @@ -302,62 +255,44 @@ <li><p>When running jupyter notebooks, make sure you are running the jupyter installation from the same virtual environment.</p></li> <li><p>When the output of binary_c seems to be different than expected, you might need to rebuild this python package. Everytime binary_c is compiled, this package needs to be rebuilt too.</p></li> </ul> -</div> -</div> +</section> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="modules.html" class="btn btn-neutral float-right" title="Binarycpython code" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="index.html" class="btn btn-neutral float-left" title="Welcome to binary_c-python’s documentation!" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="index.html" class="btn btn-neutral float-left" title="Welcome to binary_c-python’s documentation!" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="modules.html" class="btn btn-neutral float-right" title="Binarycpython code" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/run_system_wrapper.html b/docs/build/html/run_system_wrapper.html index cd6cf5f4918f096e1bf90b24ec15becf50035857..99cc07eb06bb3b51c46185afb645d702aea5c99c 100644 --- a/docs/build/html/run_system_wrapper.html +++ b/docs/build/html/run_system_wrapper.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>run_system_wrapper module — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>run_system_wrapper module — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> - <link rel="next" title="spacing_functions module" href="spacing_functions.html" /> - <link rel="prev" title="plot_functions module" href="plot_functions.html" /> + <link rel="next" title="stellar_types module" href="stellar_types.html" /> + <link rel="prev" title="Population class extension: version_info module" href="population_extensions/version_info.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,30 +38,32 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> <li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="ensemble.html">ensemble module</a></li> <li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid.html">Population class module</a></li> <li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> <li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> <li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> </ul> @@ -107,70 +75,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li><a href="modules.html">Binarycpython code</a> »</li> - <li>run_system_wrapper module</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/run_system_wrapper.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -195,13 +124,13 @@ text-align: unset; } </style> -<div class="section" id="module-binarycpython.utils.run_system_wrapper"> -<span id="run-system-wrapper-module"></span><h1>run_system_wrapper module<a class="headerlink" href="#module-binarycpython.utils.run_system_wrapper" title="Permalink to this headline">¶</a></h1> +<section id="module-binarycpython.utils.run_system_wrapper"> +<span id="run-system-wrapper-module"></span><h1>run_system_wrapper module<a class="headerlink" href="#module-binarycpython.utils.run_system_wrapper" title="Permalink to this heading">ïƒ</a></h1> <p>Module containing the utility function run_system, which handles a lot of things by analysing the passed kwargs</p> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.run_system_wrapper.run_system"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.run_system_wrapper.</span></span><span class="sig-name descname"><span class="pre">run_system</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/run_system_wrapper.html#run_system"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.run_system_wrapper.run_system" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.run_system_wrapper.</span></span><span class="sig-name descname"><span class="pre">run_system</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/run_system_wrapper.html#run_system"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.run_system_wrapper.run_system" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function that runs a system. Mostly as a useful utility function that handles all the setup of argument lists etc.</p> <p class="rubric">Examples</p> @@ -216,8 +145,8 @@ Mostly as a useful utility function that handles all the setup of argument lists </ul> <dl class="simple"> <dt>Tasks:</dt><dd><ul class="simple"> -<li><p>TODO: Expand functionality.</p></li> <li><p>TODO: Notify user when an unknown keyword is passed.</p></li> +<li><p>TODO: Centralise the input checking routines here, abstract them and have the population object and this one use the same</p></li> </ul> </dd> </dl> @@ -244,61 +173,43 @@ and returns what the parse_function returns</p> </dl> </dd></dl> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="spacing_functions.html" class="btn btn-neutral float-right" title="spacing_functions module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="plot_functions.html" class="btn btn-neutral float-left" title="plot_functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="population_extensions/version_info.html" class="btn btn-neutral float-left" title="Population class extension: version_info module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="stellar_types.html" class="btn btn-neutral float-right" title="stellar_types module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/search.html b/docs/build/html/search.html index 68f29339ec5d1ffa259b2989091b34f30b331065..87f0f7726735eba99ffbc5fc98c74b53adafef32 100644 --- a/docs/build/html/search.html +++ b/docs/build/html/search.html @@ -1,69 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Search — binary_c-python documentation</title> - - - - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> + <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - <script src="_static/searchtools.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> + <script src="_static/searchtools.js"></script> + <script src="_static/language_data.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="#" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="#" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -71,17 +38,7 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> @@ -93,71 +50,33 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li>Search</li> - - <li class="wy-breadcrumbs-aside"> - - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <noscript> <div id="fallback" class="admonition warning"> <p class="last"> - Please activate JavaScript to enable the search - functionality. + Please activate JavaScript to enable the search functionality. </p> </div> </noscript> @@ -168,53 +87,41 @@ </div> </div> - </div> <footer> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> - - - - - - <script type="text/javascript"> + <script> jQuery(function() { Search.loadIndex("searchindex.js"); }); </script> - <script type="text/javascript" id="searchindexloader"></script> + <script id="searchindexloader"></script> diff --git a/docs/build/html/searchindex.js b/docs/build/html/searchindex.js index 80433e4bdbcf571c00a8a22e426d6e12ce58453d..f534d8b7adcbe6422bc3e7bdb5ac93dff2fd0cc0 100644 --- a/docs/build/html/searchindex.js +++ b/docs/build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["binary_c_parameters","custom_logging_functions","distribution_functions","example_notebooks","examples/notebook_BHBH","examples/notebook_HRD","examples/notebook_api_functionality","examples/notebook_common_envelope_evolution","examples/notebook_custom_logging","examples/notebook_extra_features","examples/notebook_individual_systems","examples/notebook_luminosity_function_binaries","examples/notebook_luminosity_function_single","examples/notebook_massive_remnants","examples/notebook_population","examples/notebook_solar_system","examples/old/basic_example","examples/old/workshop_example_notebook","functions","grid","grid_options_defaults","grid_options_descriptions","hpc_functions","index","modules","plot_functions","readme_link","run_system_wrapper","spacing_functions","stellar_types","useful_funcs"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.todo":2,"sphinx.ext.viewcode":1,nbsphinx:3,sphinx:56},filenames:["binary_c_parameters.rst","custom_logging_functions.rst","distribution_functions.rst","example_notebooks.rst","examples/notebook_BHBH.ipynb","examples/notebook_HRD.ipynb","examples/notebook_api_functionality.ipynb","examples/notebook_common_envelope_evolution.ipynb","examples/notebook_custom_logging.ipynb","examples/notebook_extra_features.ipynb","examples/notebook_individual_systems.ipynb","examples/notebook_luminosity_function_binaries.ipynb","examples/notebook_luminosity_function_single.ipynb","examples/notebook_massive_remnants.ipynb","examples/notebook_population.ipynb","examples/notebook_solar_system.ipynb","examples/old/basic_example.ipynb","examples/old/workshop_example_notebook.ipynb","functions.rst","grid.rst","grid_options_defaults.rst","grid_options_descriptions.rst","hpc_functions.rst","index.rst","modules.rst","plot_functions.rst","readme_link.rst","run_system_wrapper.rst","spacing_functions.rst","stellar_types.rst","useful_funcs.rst"],objects:{"binarycpython.utils":{custom_logging_functions:[1,0,0,"-"],distribution_functions:[2,0,0,"-"],functions:[18,0,0,"-"],grid:[19,0,0,"-"],grid_options_defaults:[20,0,0,"-"],hpc_functions:[22,0,0,"-"],plot_functions:[25,0,0,"-"],run_system_wrapper:[27,0,0,"-"],spacing_functions:[28,0,0,"-"],stellar_types:[29,0,0,"-"],useful_funcs:[30,0,0,"-"]},"binarycpython.utils.custom_logging_functions":{autogen_C_logging_code:[1,1,1,""],binary_c_log_code:[1,1,1,""],binary_c_write_log_code:[1,1,1,""],compile_shared_lib:[1,1,1,""],create_and_load_logging_function:[1,1,1,""],from_binary_c_config:[1,1,1,""],return_compilation_dict:[1,1,1,""]},"binarycpython.utils.distribution_functions":{"const":[2,1,1,""],Arenou2010_binary_fraction:[2,1,1,""],Izzard2012_period_distribution:[2,1,1,""],Kroupa2001:[2,1,1,""],Moe_di_Stefano_2017_multiplicity_fractions:[2,1,1,""],Moe_di_Stefano_2017_pdf:[2,1,1,""],build_q_table:[2,1,1,""],calc_P_integral:[2,1,1,""],calc_e_integral:[2,1,1,""],calc_total_probdens:[2,1,1,""],calculate_constants_three_part_powerlaw:[2,1,1,""],cosmic_SFH_madau_dickinson2014:[2,1,1,""],duquennoy1991:[2,1,1,""],fill_data:[2,1,1,""],flat:[2,1,1,""],flatsections:[2,1,1,""],gaussian:[2,1,1,""],gaussian_func:[2,1,1,""],gaussian_normalizing_const:[2,1,1,""],get_integration_constant_q:[2,1,1,""],get_max_multiplicity:[2,1,1,""],imf_chabrier2003:[2,1,1,""],imf_scalo1986:[2,1,1,""],imf_scalo1998:[2,1,1,""],imf_tinsley1980:[2,1,1,""],interpolate_in_mass_izzard2012:[2,1,1,""],ktg93:[2,1,1,""],linear_extrapolation_q:[2,1,1,""],merge_multiplicities:[2,1,1,""],normalize_dict:[2,1,1,""],number:[2,1,1,""],poisson:[2,1,1,""],powerlaw:[2,1,1,""],powerlaw_constant:[2,1,1,""],powerlaw_extrapolation_q:[2,1,1,""],prepare_dict:[2,1,1,""],raghavan2010_binary_fraction:[2,1,1,""],sana12:[2,1,1,""],set_opts:[2,1,1,""],three_part_powerlaw:[2,1,1,""]},"binarycpython.utils.functions":{Capturing:[18,2,1,""],bin_data:[18,1,1,""],call_binary_c_config:[18,1,1,""],catchtime:[18,2,1,""],check_if_in_shell:[18,1,1,""],conv_time_units:[18,1,1,""],convert_bytes:[18,1,1,""],convfloat:[18,1,1,""],create_arg_string:[18,1,1,""],create_hdf5:[18,1,1,""],datalinedict:[18,1,1,""],example_parse_output:[18,1,1,""],filter_arg_dict:[18,1,1,""],format_number:[18,1,1,""],get_ANSI_colours:[18,1,1,""],get_arg_keys:[18,1,1,""],get_defaults:[18,1,1,""],get_help:[18,1,1,""],get_help_all:[18,1,1,""],get_help_super:[18,1,1,""],get_moe_di_stefano_dataset:[18,1,1,""],get_size:[18,1,1,""],get_username:[18,1,1,""],imports:[18,1,1,""],is_capsule:[18,1,1,""],load_logfile:[18,1,1,""],make_build_text:[18,1,1,""],mem_use:[18,1,1,""],output_lines:[18,1,1,""],pad_output_distribution:[18,1,1,""],parse_binary_c_version_info:[18,1,1,""],remove_file:[18,1,1,""],return_binary_c_version_info:[18,1,1,""],temp_dir:[18,1,1,""],timedelta:[18,1,1,""],trem:[18,1,1,""],verbose_print:[18,1,1,""],write_binary_c_parameter_descriptions_to_rst_file:[18,1,1,""]},"binarycpython.utils.functions.Capturing":{__enter__:[18,3,1,""],__exit__:[18,3,1,""]},"binarycpython.utils.functions.catchtime":{__enter__:[18,3,1,""],__exit__:[18,3,1,""]},"binarycpython.utils.grid":{Population:[19,2,1,""]},"binarycpython.utils.grid.Population":{Moe_di_Stefano_2017:[19,3,1,""],add_grid_variable:[19,3,1,""],clean:[19,3,1,""],delete_grid_variable:[19,3,1,""],evolve:[19,3,1,""],evolve_single:[19,3,1,""],export_all_info:[19,3,1,""],parse_cmdline:[19,3,1,""],rename_grid_variable:[19,3,1,""],return_all_info:[19,3,1,""],return_binary_c_defaults:[19,3,1,""],return_binary_c_version_info:[19,3,1,""],return_population_settings:[19,3,1,""],set:[19,3,1,""],set_moe_di_stefano_settings:[19,3,1,""],update_grid_variable:[19,3,1,""],vb1print:[19,3,1,""],vb2print:[19,3,1,""],write_binary_c_calls_to_file:[19,3,1,""],write_ensemble:[19,3,1,""]},"binarycpython.utils.grid_options_defaults":{grid_options_description_checker:[20,1,1,""],grid_options_help:[20,1,1,""],print_option_descriptions:[20,1,1,""],write_grid_options_to_rst_file:[20,1,1,""]},"binarycpython.utils.plot_functions":{color_by_index:[25,1,1,""],dummy:[25,1,1,""],parse_function_hr_diagram:[25,1,1,""],parse_function_masses:[25,1,1,""],parse_function_orbit:[25,1,1,""],plot_HR_diagram:[25,1,1,""],plot_masses:[25,1,1,""],plot_orbit:[25,1,1,""],plot_system:[25,1,1,""]},"binarycpython.utils.run_system_wrapper":{run_system:[27,1,1,""]},"binarycpython.utils.spacing_functions":{"const":[28,1,1,""],const_dt:[28,1,1,""],const_ranges:[28,1,1,""],gaussian_zoom:[28,1,1,""],peak_normalized_gaussian_func:[28,1,1,""]},"binarycpython.utils.useful_funcs":{calc_period_from_sep:[30,1,1,""],calc_sep_from_period:[30,1,1,""],maximum_mass_ratio_for_RLOF:[30,1,1,""],minimum_period_for_RLOF:[30,1,1,""],minimum_separation_for_RLOF:[30,1,1,""],ragb:[30,1,1,""],roche_lobe:[30,1,1,""],rzams:[30,1,1,""],zams_collision:[30,1,1,""]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method"},terms:{"0":[0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,21,28,30],"00":[4,10,11,14,17],"000":[4,10,17],"0000":[4,10,17],"00000":17,"000000":17,"000000000000e":10,"000000e":17,"000001":10,"000002":10,"000003":10,"0001":[4,6,30],"000122339":14,"000161974":14,"000214449":14,"000220016":14,"000283924":14,"000287968":14,"000375908":14,"000497691":14,"000498487":14,"00065893":14,"0007":2,"000872405":14,"001":[0,4,6],"00115504":14,"0013":4,"00152924":14,"00182":4,"002":[4,16,17],"00202467":14,"0021272":4,"00215604":4,"00235329":4,"00237669":4,"00239838":4,"00242158":4,"00247821":4,"00247864":4,"00248439":4,"00254115":4,"00254512":4,"00256681":4,"00261516":4,"00268237":4,"00280816":4,"00283345":4,"00286793":4,"00288661":4,"00294":4,"00296406":4,"003":4,"00300971":4,"00303761":4,"00311757":4,"00317508":4,"00319483":4,"0034":4,"004":4,"004698855121516281":14,"005":4,"00518983":4,"0055":4,"00585495":4,"006":4,"0062211552141636295":14,"00632092":6,"00666382":4,"007":[4,15],"00707417":4,"00712":4,"00730797":4,"0074":4,"008":4,"0081514":4,"00823663875514986":14,"00832":4,"0087":4,"009":[4,15],"00984861":4,"00e":11,"01":[0,4,5,6,7,8,11,14,17],"010":4,"0102":4,"010905083645619543":14,"011":4,"0118":4,"012":4,"0122109":4,"012246630357e":14,"0128":4,"013":4,"0131145":4,"014":4,"0141":6,"0143651":4,"0143896":7,"014832":4,"015":4,"0152545":4,"0153961":4,"0155":4,"0156":4,"01561":4,"0156945":4,"0159":4,"016":4,"0162":4,"016309":7,"0163656":7,"0164":4,"0165":4,"0166":4,"0168":4,"0169":4,"017":[4,15],"0171":4,"0175264":7,"0176575":5,"01791":4,"018":4,"0182":4,"0184":4,"0187":4,"019":4,"0192009":4,"019715467199999996":7,"01e":11,"01t09":[5,7,11],"01t10":11,"02":[0,2,4,5,6,7,8,10,11,14,15,17,30],"020":4,"0208":4,"021":4,"0214":4,"0214824":4,"021960493499e":14,"022":4,"023":4,"0232618":4,"02379":4,"024":4,"0241634":4,"0245":4,"024684":4,"02473":4,"0248684":14,"025":4,"0250231":4,"0251003":4,"0259932":4,"026":4,"0261496":4,"027":4,"0276":4,"02786":4,"0278672":4,"028":4,"02823":4,"0283541":4,"029":4,"0290733":4,"0295":4,"0298011":4,"0298364":4,"02e":[7,11],"03":[0,1,4,6,7,11],"030":4,"0303129":4,"030499912298e":14,"031":4,"0316266":4,"0319":4,"032":4,"03221":4,"033":4,"0335":4,"0335017":4,"034":4,"03493":4,"03499999999999":13,"035":4,"03502960360000004":7,"03507":4,"036":4,"0367878":4,"037":4,"0385396":4,"039":4,"0393944":4,"0394":4,"0399":4,"03996e":4,"03e":11,"04":[0,4,6,11,17],"040":4,"041":4,"0411":4,"0414":4,"04198":4,"042":4,"0425":4,"043":4,"0434":14,"044":4,"0440989":4,"044142002936e":8,"04440288843805411":14,"0444029":14,"044572277695e":8,"044654032097e":8,"0448877":4,"0449442":4,"045":4,"045084306856e":8,"0459174":4,"046":4,"0461":4,"0469097":4,"047":[4,14,15],"0474164":4,"0474572":4,"048":[4,15,17],"049":4,"04924":4,"04e":11,"05":[0,4,6,7,8,11,14],"0501":4,"050651207308e":8,"051":[4,5],"0511173":4,"0512":4,"052":4,"0523":4,"0528412":4,"053":4,"0531294":4,"0533803":4,"0535":4,"0536749":4,"054":[2,4],"0547419":4,"055":4,"055188":4,"056":[4,15],"0563088":4,"057":4,"0570946":17,"0572914":4,"057949":4,"058":4,"0583837":4,"0585":4,"059":4,"05e":11,"05e51ba114934b37bab48f1db40b7333":14,"06":[0,4,7,8,10,11],"0608":4,"061":4,"061141":4,"0613":4,"062":4,"0621119":4,"0625403":4,"06257":4,"0626266":4,"063":4,"064":4,"0641":4,"06459059967730083":7,"0645906":7,"0649":4,"065":4,"06527":4,"066":4,"06696":4,"067":4,"0670735":4,"068":4,"0683196":4,"069":4,"06987":4,"06e":11,"07":[2,4,11,12,13,17,28],"070":[4,14],"0701913":4,"071":4,"07108":4,"0714679":4,"0717":4,"0719":4,"072":4,"0722":4,"0727126":4,"0727584":4,"074":4,"0744186":4,"0745":4,"07484":4,"075":4,"075416":4,"0755737":4,"076":4,"077":4,"0770302":4,"0772021":4,"0772781":4,"078":4,"0784":4,"0784722":4,"0787729":4,"0789786":4,"079":[4,5],"0791":4,"07e":11,"08":[0,4,7,11,17],"080763":10,"0808":4,"081":[4,5],"081024":5,"082":4,"0820":[0,6],"0823499":4,"0831":4,"0834973":17,"0837":4,"084":4,"0849409":4,"085":4,"086":4,"086004":4,"0868":4,"087":4,"0877":4,"0877243":4,"0878":4,"088":4,"089":4,"0890815":4,"0896":4,"08e":11,"08msun":[0,6],"09":[4,5,7,11],"090":4,"0900":17,"0902":[0,6],"0907":4,"0907537":4,"091":4,"0910814":4,"0913095":4,"09164":4,"092":4,"09295167374":11,"093":[5,15],"0931922":4,"094":[4,7],"094409257247e":14,"095":4,"0958704":4,"096":4,"09665":4,"0967":14,"097":4,"09706e":4,"09786":4,"098":[4,5],"0987206":4,"099":4,"0991059":4,"0993":4,"099417":7,"0995":4,"0m":11,"0mb":[7,11],"0msun":28,"0x146f912dbc60":6,"0x149c2e81ec10":10,"0x149c95c56c10":7,"0x14bf2250fdc0":5,"0x1528ac7290d0":14,"1":[0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,21,23,25,26,27,28,30],"10":[0,2,4,5,6,7,8,10,11,12,13,14,15,16,17,27,28],"100":[0,2,4,5,6,7,11,12,13,28],"1000":[0,6,7,21,28],"100000000000":[16,17],"1001":11,"1005":4,"101":4,"101038":4,"1012":4,"101323":4,"101955":4,"102":4,"1021":4,"1025":11,"102750e":17,"103":4,"1035":4,"103702":4,"103789":4,"104":[4,7],"1043":4,"104427":4,"104997":4,"105":[4,12,13],"105082":4,"10522":4,"105704":4,"106":4,"1062":4,"106368":4,"106545":4,"10689":4,"107":4,"107187":4,"1075":4,"10782":4,"108":[4,14],"1082":4,"1085":10,"108571":4,"10877":4,"1088":4,"109":[4,7],"10941":4,"109679":4,"1098":4,"1099":4,"10e":11,"11":[0,4,5,7,8,10,11,13,14,15,17],"110":4,"11003":10,"1104":4,"1108":4,"111":4,"111023":4,"111583":4,"11182":4,"112":4,"11239":4,"1124":4,"113":4,"1130":4,"11346":4,"113492":17,"1135":4,"11376":4,"114":4,"114678":4,"11491":4,"115":[2,4],"11506":4,"115297":4,"11558":4,"115722":4,"11582":10,"116":4,"11686":4,"11695":4,"117":4,"11707":4,"1173":4,"1178":4,"118":4,"11802":4,"118229":4,"11854":4,"119":4,"1193":4,"1199":4,"11e":11,"12":[0,2,4,5,8,10,11,13,14,15,17,18],"120":4,"120000":[0,6],"120066":4,"1204":[4,17],"121":4,"121263":4,"12136":4,"1219":4,"122":4,"1222":4,"123":4,"123048":4,"12325":10,"123635":4,"1237":4,"123794969278e":14,"1239555":7,"124":4,"1241251901":15,"124379":17,"124496":4,"12457":10,"12460":10,"12461":10,"124931":4,"12495":4,"125":[0,4,6],"12500":0,"12522":4,"1254":4,"12548":4,"125553":4,"125886":4,"125968":4,"126":4,"126532":4,"127":4,"12741":4,"127442":4,"127957":4,"128":4,"12806":4,"129":4,"12974":4,"129879":4,"12e":[1,5,8,10,11,12,13,14],"13":[0,4,5,6,7,8,10,11,13,14,15,17],"130":4,"1301":10,"1302":10,"1306":4,"130725":4,"131":4,"13108":17,"1314":4,"131680e":17,"132":4,"132057":4,"1326":4,"13267":4,"1327":4,"13298":4,"133":4,"1334":4,"134":[4,14],"13416":4,"1345":10,"1346":10,"13461":10,"1347":10,"1348":10,"1349":10,"135":4,"135101":4,"135164":4,"1354":11,"1355":11,"13567":8,"136":4,"1360":4,"13607":4,"13626":14,"137":4,"13700":[5,7],"137502":4,"1379":4,"13796e":4,"138":4,"1380":17,"139":4,"139044":4,"1392":4,"139293101586e":14,"139732":4,"1398":4,"13e3":[0,6],"14":[0,4,5,6,8,10,11,13,14,15,17],"140":4,"1403":2,"141":4,"14112":4,"141361":4,"1415":4,"142":4,"14212":4,"143":4,"144":4,"144141":4,"14439":4,"14461":10,"1449":[4,11],"145":4,"145296":4,"145632":4,"146":4,"1468":4,"146844":4,"147":4,"1471":4,"1473":4,"14764":4,"1478":4,"148":[4,17],"1485":4,"148721":4,"149":4,"1492":4,"1494":11,"1498":4,"14e":11,"15":[0,2,4,6,7,8,10,11,13,14,15,17,21],"150":[4,7,11,12,13,14],"15000":[0,4,6,8,10,14,15,17],"1502":4,"150217":4,"15042":4,"150681":4,"151":4,"1514":4,"151616":4,"1517":4,"15186":4,"152":4,"1521":4,"1527":4,"153":4,"153329":4,"153852":4,"1539":11,"154":4,"155":4,"1551":4,"1553":4,"155342":4,"155662":11,"155678":7,"15594":4,"156":[4,7,17],"1560":4,"1567":4,"1569":4,"157":4,"1571":4,"1575":4,"158":4,"1585":11,"1586":4,"158640":7,"15884":4,"159":[4,7],"15907":4,"1599":4,"15e":11,"15msun":2,"16":[0,2,4,7,11,13,14,15,17],"160":4,"1606":4,"160675":11,"161":4,"1610":4,"1612":4,"1618":4,"162":4,"162006":4,"162038":4,"1622":4,"1624":[4,11],"162454":11,"16265":4,"1627":10,"162734":10,"162941":4,"163":[4,7],"1631":4,"1633":4,"163481":7,"1635760192":5,"1635760194":5,"1635760256":7,"1635760377":7,"1635760613":11,"1635760806":13,"1635760813":13,"1635760967":14,"1635760970":14,"1635761189":11,"1637":4,"164":4,"164714":4,"165":4,"16539":4,"16564":4,"166":[4,7],"1663":4,"166559":4,"167":[4,11],"1670":4,"16729":4,"16733":4,"1674":[4,11],"1678":4,"168":[4,7],"16833":4,"16837":4,"168379":7,"168558":4,"168972":4,"169":4,"1691":4,"1695":4,"169775":11,"17":[4,5,7,11,13,14,15,17],"170":4,"1703":11,"1708":4,"171":4,"171096":4,"1713":4,"1715":4,"172":4,"172014":4,"1722":4,"1729":4,"173":4,"1736":4,"174":4,"174169":4,"1747":4,"1749":11,"175":4,"175004":4,"1753":4,"17588":4,"176":4,"176751":11,"177":[4,7],"177444":4,"1775":4,"177551":4,"177727":4,"178":4,"1780":11,"1781":4,"1783":4,"1784":4,"1786":4,"179":4,"179142":4,"1792":4,"17932":4,"1796":4,"18":[4,11,13,15,17],"180":4,"1804":4,"180453":4,"1806":4,"1807":4,"1808":4,"1809":4,"181":4,"1810":4,"18108":4,"1811":4,"1812":4,"181244":4,"1813":4,"18139":4,"1814":[4,11],"18148":4,"1815":4,"1816":4,"1817":4,"181795":4,"1818":4,"1819":4,"181971798545e":14,"182":4,"1821":4,"1822":4,"1823":4,"1824":4,"1825":4,"1826":4,"1827":4,"1828":4,"1829":4,"183":4,"1830":4,"183048":4,"1831":4,"1833":4,"1834":4,"1835":4,"1838":4,"1839":4,"183974":4,"184":4,"1841":4,"1843":4,"1844":4,"184464":4,"1845":4,"1846":4,"1847":4,"184829":4,"185":4,"1851":[4,11],"1854":4,"1858":4,"186":[4,11],"1865":8,"187":4,"1876":4,"187694":4,"1877":4,"1879":11,"187993":4,"188":4,"1882":4,"189":4,"189239":4,"19":[4,7,11,14,17],"190":[0,4,17],"19097":4,"191":4,"1910":11,"1915":4,"191543":4,"192":4,"1920":4,"1923":4,"193":4,"193528":4,"19366":4,"19393":4,"194":4,"1947":11,"195":4,"1951":[0,6],"19521":4,"196":4,"196046":4,"196177":4,"19622":4,"196311":4,"1967":4,"1968":11,"197":4,"1972":[0,6],"1973":4,"1975":[0,6],"1977":4,"197729":4,"197x":[0,6],"198":4,"1980":2,"1983":30,"1986":[0,2,6],"1987":4,"1989":[0,6,11],"199":4,"19907":4,"1991":2,"1992":[0,6],"1993":[0,6],"1996":30,"1998":[0,2,4,6],"1999":[0,6],"19e":11,"1aearth":15,"1ajupit":15,"1amar":15,"1amercuri":15,"1aneptun":15,"1apluto":15,"1asaturn":15,"1auranu":15,"1avenu":15,"1ckzg0p9":[23,26],"1dex":[11,12,13],"1e":[0,6,7,8,10,11,17],"1e2":[0,6],"1e9":[0,6],"1gyr":28,"1m":11,"1mb":[7,11],"1mearth":15,"1mjupit":15,"1mmar":15,"1mmercuri":15,"1mneptun":15,"1mpluto":15,"1msaturn":15,"1msun":28,"1muranu":15,"1mvenu":15,"1s":[7,11],"1y":[0,6],"2":[0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,17,18,21,22,23,25,26,28],"20":[0,4,5,7,8,11,12,13,14,15,17,28],"200":[0,4,6],"2000":[0,4,6],"2001":[2,12,13],"2002":[0,6],"2003":[0,2,6],"2004":[0,4,6],"2005":[0,4,6],"2008":4,"2009":[0,6],"201":4,"2010":[0,2,6,21],"2012":[0,2,6],"2013":[0,6],"2014":[0,2,4,6],"2015":[0,4,6],"2016":[0,6],"2017":[0,6,11,14,21],"2018":[0,1,4,6],"2019":[0,4,6,17],"202":4,"2020":[0,6],"2021":[0,4,5,7,11],"20211102":0,"202196":4,"202339":4,"202569":4,"20265":4,"202750e":17,"2029":4,"203":4,"2033":4,"204":4,"2044":4,"20447":4,"204663":4,"2048":11,"205":4,"2053":4,"205353":4,"205527":4,"205537":4,"2057":4,"206":[4,15],"2063":4,"20677":4,"207":4,"2071":11,"2075":4,"208":4,"2081":4,"208169":4,"208453":4,"20887":4,"208923":4,"209":4,"2091":11,"209274":4,"20938":4,"20980":4,"20e":[7,11],"21":[0,1,4,5,11,17],"210":[4,17],"21043":4,"211":[4,13],"2112":4,"2118":17,"212":4,"212034":4,"2122":11,"2127":4,"213":4,"2132":4,"21333":4,"213396":4,"2135":4,"213854":4,"214":4,"214274644851685":17,"2143":11,"2147":4,"215":4,"215504":4,"2156":4,"215638":4,"2157":4,"21587440567681537":14,"21587440567681548":14,"2158744056768156":14,"216":4,"21603":4,"216067":4,"2164":11,"216496":4,"216951":4,"217":4,"21764":4,"218":4,"2182":4,"218222":13,"21824":4,"2183":11,"21844":4,"219":4,"219029061236e":14,"219058":4,"2191":4,"21927":4,"21948":4,"21e":11,"22":[4,11,17],"220":4,"22036":4,"2206":11,"22098":4,"221":4,"2210":4,"2214":4,"2216":4,"221832":4,"222":4,"2221":4,"2224":4,"22281":4,"223":4,"2232":11,"2234":4,"224":4,"2245":11,"224923":4,"225":4,"225135":4,"22518":4,"22543":4,"2258":11,"226":4,"2261":4,"22611318083528548":7,"226424":4,"2266":4,"2268":4,"2269":11,"227":4,"227249":4,"2275":4,"22787":4,"227955577093495":14,"228":4,"2282":11,"228555":4,"229":4,"2291":4,"22936":4,"2295":4,"229591":4,"22e":7,"23":[0,4,11,14],"230":4,"2300":11,"230102":4,"2305":4,"230955":4,"231":4,"231680e":17,"231704":4,"232":4,"2329":11,"233":4,"2332":4,"2333":4,"2338":4,"234":[4,7],"2348":11,"235":[4,5],"23513":4,"2352":4,"235464":4,"235689312423":7,"236":[4,17],"2365":[11,17],"237":4,"2371":4,"237203":4,"237951":4,"238":4,"2383":11,"238584":4,"23894":4,"239":4,"239197":4,"239704":4,"24":[4,7,11],"240":4,"2400":11,"2403e":14,"2406":4,"24098":4,"241":4,"2413":4,"24165":4,"242":4,"2421":4,"242151":4,"2423":11,"242309":4,"2424":10,"243":[4,5],"243214":4,"243583":4,"2437":4,"2438":11,"2439":4,"244":[4,15],"2444":15,"244645":4,"245":4,"245209":4,"245223":4,"2454":11,"246":4,"2466":11,"246604":4,"246625":4,"246671":5,"247":4,"2472":4,"2477":[4,11],"248":[4,7],"248871":4,"249":4,"249106":4,"2492":11,"2493":4,"249848":4,"24e":11,"25":[0,4,7,11,17],"250":4,"25014bc73b334765a1c09a4e4a97ed66":11,"251":[4,7],"2514":4,"2516":11,"25164":4,"252":4,"2528":4,"252877":4,"2529":4,"253":4,"2537":11,"253705":4,"254":4,"2544031669784":14,"255":[0,4,6],"2551":4,"2552":4,"2554":11,"2556":4,"256":[4,5],"256488":4,"256783":4,"25694":4,"257":[4,30],"2570":11,"2572":14,"257278":4,"257437":4,"2576084265970895":14,"258":[4,7],"2583":4,"259":4,"2590":11,"25msun":[0,6],"26":[4,11],"260":4,"26051":4,"260676":4,"261":4,"2613":4,"261343":4,"26171201413c43f5b91552a374879940":5,"2618":4,"262":4,"2622":[4,11],"2626":4,"2629":4,"263":4,"263079":4,"2632":4,"263235":4,"2636":11,"264":4,"26416":4,"26441":4,"26456":4,"2646":17,"265":4,"2652":11,"266":4,"2663":4,"26637":4,"2664":4,"266485":4,"2666":11,"267":[4,7],"2670":4,"2671":4,"2672":4,"2673":4,"2674":4,"2676":4,"2677":4,"2678":4,"2679":4,"268":4,"2680":4,"2681":4,"2682":4,"2683":4,"2684":4,"2685":4,"2686":4,"2687":4,"2688":4,"2689":4,"269":4,"2690":4,"2691":[4,11],"2692":4,"2693":4,"2694":4,"2695":4,"2696":4,"2697":4,"2698":4,"2699":4,"27":[4,7,11,14],"270":4,"2700":4,"2701":4,"2702":4,"27025":4,"2703":4,"2704":4,"2705":4,"2706":4,"2707":4,"2708":4,"2709":4,"271":4,"2710":4,"2711":4,"2712":4,"2713":4,"2714":4,"27143e":14,"2715":4,"2716":4,"2717":4,"2718":4,"2719":4,"272":4,"2720":4,"2721":4,"2722":4,"2723":4,"2724":4,"2725":4,"2726":4,"2727":4,"2728":4,"2729":4,"272943":4,"273":4,"2730":4,"2731":4,"2732":4,"2733":[4,11],"2734":4,"274":4,"274206":4,"274445":4,"2746":11,"274854":4,"275":4,"2754":4,"27569e":4,"2757":11,"276":4,"2767":4,"277":4,"2773":4,"27734":4,"2775":11,"27767":4,"278":4,"27829":4,"279":4,"2791":4,"2795":11,"28":[4,6,7,8,10,11],"280":4,"2800":4,"2801":4,"2802":4,"280723":4,"280749":4,"281":[4,30],"281309":4,"28134439269236855":14,"2816":4,"2819":4,"282":4,"282234":4,"2823":4,"282623":4,"283":4,"2831":11,"2834":4,"2835":4,"2836":4,"28369":4,"283972":4,"284":4,"2845":11,"2846":4,"285":4,"286":4,"2861":11,"287":4,"2871":4,"2873":4,"2875":11,"2878":4,"288":4,"2881":4,"288353":4,"28867":4,"289":4,"2891":11,"2898":4,"28984":4,"28e":7,"29":[4,7,11,14],"290":4,"290684":4,"291":4,"29136":4,"2914":4,"292":4,"2921":4,"2924":4,"292641":4,"2927":4,"293":4,"2930":11,"2934e":17,"293512":4,"294":[4,5],"29427":14,"29448":14,"29457":14,"2947":[11,14],"295":4,"295543":4,"296":4,"2961":4,"2965":11,"296544":4,"2967":4,"2969346":2,"297":4,"297187":4,"297506":4,"298":4,"29816":4,"298194":4,"2982":11,"299":4,"2991":4,"2996":4,"29e":11,"2b66f805db424c48a1d29c45092b6e3c":7,"2d":[0,6],"2e":[8,11,17],"2f":17,"2m":[7,11],"2mb":[7,11],"2msun":[0,6],"2s":11,"3":[0,1,2,4,5,6,7,8,9,10,11,12,13,14,17,18,21,23,26,28],"30":[1,4,5,7,8,10,11,12,13,14,15,17],"300":[4,28],"3000":[0,6,15],"3002":4,"3008":4,"301":4,"3010":11,"301129":4,"301483":4,"3017":4,"302":[4,17],"3025":4,"302750e":17,"303":4,"3034":4,"3035":11,"303533":4,"3038":4,"30388e":4,"304":4,"3042":4,"30441":4,"3046":4,"3048":4,"305":4,"305334":4,"3059":11,"306":4,"30642":14,"3065":4,"306619":4,"3069":4,"307199":4,"3078":11,"308":4,"3081e":17,"3082":4,"308203":4,"3084":4,"309":4,"30902":14,"309361":4,"309461":4,"3096":4,"30975":4,"30e4":[0,6],"31":[0,4,6,7,11,17],"310":4,"3100":[4,11],"310029":4,"3101":4,"311":4,"312":[4,5],"3124":11,"312637":4,"3127":4,"313":4,"313623":11,"314":4,"31408":4,"314533":4,"3148":11,"315":4,"315124":4,"315223":4,"3154":4,"315404":4,"315903":4,"315973":4,"316":[4,7],"316118":4,"317":4,"3171":4,"3172":4,"3174":11,"3176":4,"317663":4,"317921":4,"318":4,"3185":4,"318753":4,"319":4,"3192":4,"3193":4,"31958":4,"3197":11,"31e":11,"32":[4,7,11,14,18,21],"320":4,"3205":14,"32076":4,"321":4,"321082":4,"3211":4,"32118":4,"3216":4,"321643":4,"322":4,"3223":4,"3228":[4,14],"32282":4,"323":4,"3231":[4,11],"323359":7,"3235":4,"324":4,"3243":4,"3244":4,"3245144":14,"3246":4,"3247":4,"3248":4,"325":4,"325197":4,"3256":11,"325743":4,"325965":4,"326":4,"326147":4,"32620":4,"32631":4,"3264":4,"326601":4,"32684":4,"327":4,"3273":[4,11],"328":4,"328066":4,"3282":4,"328512":4,"329":[4,7],"3294":11,"32e":11,"33":[4,11],"330":4,"331":4,"331680e":17,"332":4,"332091":4,"3321":11,"332251":4,"332777":4,"33295":4,"333":4,"333032":4,"3331":4,"334":4,"33451":4,"33469":8,"3348":11,"335":4,"335153":4,"3352":4,"335342":4,"335428":4,"33552":4,"335642":4,"335847":4,"336":4,"336295":4,"3368":4,"33699":14,"337":4,"33719":4,"337249":4,"3373":11,"338":[4,8],"33817":17,"33879":4,"339":4,"3394":11,"339587":4,"3396":4,"34":[4,5,6,7,8,10,11,12,14,15],"340":4,"34018":4,"340477":4,"34081":4,"341":4,"3412":4,"34126":4,"34175":4,"3419":4,"342":[4,11],"34213":8,"342134":4,"3422":11,"342474":4,"3429":4,"343":4,"3438":4,"344":4,"34421":17,"3445":11,"344772":4,"3448":4,"345":4,"34537":4,"345842":11,"346":4,"3461":4,"3462":4,"3464":11,"3469":4,"347":4,"3471":4,"347169":4,"347405":4,"347623":4,"348":[4,7],"3483":11,"34870":4,"349":4,"3495":4,"3497":4,"34e":7,"35":[0,2,4,7,11],"350":[4,11],"3502":4,"35051":4,"3507":4,"3509":11,"351":4,"351532":4,"3518":4,"352":4,"3529":4,"353":4,"3533":11,"353432":4,"3536":4,"354":4,"3540":17,"354576":4,"35487":4,"354981":4,"355":4,"3550":11,"35505":4,"355513":4,"3559":4,"356":4,"3563":4,"3568":11,"356812":4,"357":4,"358":4,"3583":4,"3588":11,"3589":4,"35895":4,"359":4,"3591":4,"359784":4,"359881":4,"3599":4,"36":[4,7,11,14],"360":4,"360093":4,"36016":4,"361":4,"3616":4,"362":4,"3622":11,"362601":4,"36298":4,"363":4,"3630":17,"3631":17,"36314":4,"3632":17,"36323":4,"3633":17,"3634":17,"3635":17,"364":4,"3640":11,"364017":4,"36403":4,"364747":4,"3649":4,"365":4,"3657":11,"365763":4,"365949":4,"366":4,"366259":4,"366392":4,"367":4,"367065497322e":14,"367268":4,"3674":4,"36747":4,"3676":11,"367793":4,"368":4,"368345":4,"3688":4,"369":4,"3695":4,"36957":4,"3698":4,"36e":11,"37":[4,7,11],"370":4,"3702e":17,"3706":11,"371":4,"371427":4,"371458":4,"371625":4,"3719":4,"372":4,"3726":[4,11],"3729":4,"373":4,"373282":4,"374":4,"37409":4,"3746":11,"374905":4,"375":4,"3752":4,"375537":4,"3757":4,"375712":4,"3758":4,"376":4,"376059":4,"3763":11,"376604":4,"3767":4,"377":4,"3771":4,"378":4,"3781":4,"3786":11,"37874":4,"379":4,"379292":4,"37e":11,"38":[0,4,7,11],"380":4,"38009":4,"380393":4,"380887":4,"381":4,"3811":11,"382":4,"382144":4,"382472":4,"383":4,"38316":4,"3832":11,"384":4,"3849":11,"385":4,"386":4,"387":4,"3875":11,"38788e":14,"388":4,"388321":4,"389":4,"38908":4,"389208":4,"38921":4,"389749":4,"38m":11,"39":[4,5,6,7,9,10,11,12,13,14,15,16],"390":4,"3905":11,"391":4,"3914":17,"39152e":4,"391798":4,"392":[4,17],"39205":14,"392194":4,"392487":4,"3927":17,"3928":[4,17],"3929":17,"393":4,"3930":[11,17],"3931":[11,17],"3932":17,"393886":4,"394":4,"394722435913e":14,"395":4,"39521":4,"3954":11,"3957":4,"3959":4,"396":4,"396133472739e":14,"396288708628e":14,"3963":4,"396675941641e":14,"3967":4,"397":4,"3971":4,"39754":14,"3977":11,"397754":4,"3978":4,"398":4,"39831":4,"39834":4,"398381":4,"398419":4,"398927":4,"399":4,"3995":4,"3999999999996":13,"3d":[0,6],"3e":17,"3m":11,"3mb":[7,11],"3msun":2,"3s":[7,11],"4":[0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,17,19,28],"40":[4,7,11,12,13],"400":4,"4000":[0,11],"40049":4,"401":4,"4011":4,"401263":4,"4013":4,"401728":4,"4018":4,"402":4,"40238":4,"402750e":17,"402961":4,"403":4,"40339":4,"404":4,"4046":4,"404641347602e":14,"4048":4,"404962":4,"404ce27a0":0,"405":4,"405068":4,"405577":4,"406":[4,11],"407":4,"40735":4,"4076":4,"408":4,"409":4,"4098":4,"40e":11,"41":[4,11],"410":[4,17],"4101":4,"4102":4,"4108":4,"410828":4,"411":4,"411151":4,"412":4,"41238":4,"413":[4,5],"413467":4,"414":4,"41457":4,"4146":4,"41485":4,"414875":4,"415":4,"416":4,"416141":5,"4162":4,"417":4,"41726":4,"4176":4,"418":4,"418029":4,"4182":4,"4183":4,"4184":4,"4186":4,"41862":4,"418757":4,"4188":4,"419":4,"4192":4,"4197":4,"41996":4,"41e":11,"42":[0,4,7,11],"420":4,"420182":4,"4202":4,"420316":4,"4205":4,"42052":4,"42097":4,"421":4,"421365":4,"421436":4,"421475":4,"4218":4,"4219":4,"422":4,"422436":4,"42266":4,"4229":4,"423":4,"42362":4,"424":[4,5],"4243":4,"424712":4,"424924":4,"425":4,"4251":4,"4256":4,"425788":4,"426":4,"427":4,"427601421985e":14,"42785":4,"428":4,"428699":4,"429":[4,11],"429122":4,"429398":4,"42e":11,"42msun":[0,6],"43":[4,11],"430":4,"4304":4,"430936289925951":14,"431":4,"4311":4,"431313":4,"431680e":17,"43173":4,"432":4,"4321":4,"432729":4,"433":[4,14],"4330":4,"433207":11,"4333":4,"433477":4,"434":4,"43422e":14,"435":4,"4357":4,"435809":4,"436":4,"43618":4,"4365":4,"4369":4,"437":[4,11,14],"43711":14,"4379":4,"438":4,"4380":4,"4385":4,"438686":4,"4387":4,"438861":4,"439":4,"4397":14,"44":[4,11],"440":4,"441":4,"441158":4,"44170":4,"442":4,"44211":4,"4422":4,"44223e":4,"443":4,"4433":4,"4438":4,"444":[4,17],"444217227690e":14,"445":4,"4454":4,"4455":4,"44558":4,"445821":4,"446":4,"447":4,"447918":4,"448":4,"448242":4,"448401":4,"44852":4,"449":[4,11],"4493":4,"44e":11,"44msun":[0,6],"45":[4,5,7,11,14],"450":4,"4500":6,"45000000080":14,"4501":4,"4504":14,"450629":4,"4507":4,"450818":4,"450828476487e":14,"4509":4,"451":[4,7],"45114":4,"451192744924e":14,"451732":4,"452":4,"453":4,"4530":[8,10,17],"453059":11,"453317880232e":14,"453348":4,"453412":4,"453932":4,"454":4,"4540":4,"454013":4,"45407":14,"454268":4,"454409":4,"455":4,"45534":4,"455552":4,"456":11,"456313":4,"456519":4,"457":4,"45757":4,"457987":4,"458":4,"458064":4,"458272":17,"4588":4,"45889":4,"459":4,"459382":4,"45msun":[0,6],"46":[4,7,11,14],"460":4,"460081":4,"46057":4,"46089":4,"462":[4,17],"4621":14,"4622":4,"46220":4,"4623":4,"462779538274e":14,"463":4,"463455":4,"464":4,"464494":4,"465":4,"465133":4,"46573":14,"465867":4,"46607":4,"4666":4,"4670":4,"4673":4,"467851":4,"468":4,"4680":7,"46822":4,"4683":4,"469":4,"46901":4,"469056":4,"469524":4,"47":[4,7,11],"470":4,"471":4,"4710":4,"471379":4,"4714":4,"472":[13,17],"472105":4,"472318":4,"4734":4,"473762":4,"474":4,"47419":4,"475":4,"4752":4,"475287":4,"47534":4,"4755":4,"4759":4,"476":4,"4764":4,"476589":4,"477":4,"477089":4,"4773":4,"47745":14,"477535":4,"477791":4,"478":4,"478253":4,"478315":4,"4788":4,"478807":4,"479":4,"47946":4,"4797":4,"479973":4,"48":[4,11],"480":4,"480045":4,"48046":4,"4807":4,"4809":4,"481":4,"482":4,"4822":4,"4825":4,"482668":4,"483":4,"48336":4,"4838":[6,8,10],"484":4,"4845":4,"485":4,"48586":4,"486":4,"4862":4,"4865":4,"4867":4,"4872":4,"48749":4,"4877":4,"488":4,"48809":4,"489":4,"489077":4,"48926":4,"48e":[7,11],"49":[4,5,11],"490":4,"491":4,"491811":4,"492":4,"492242":4,"492302":4,"492484":4,"492707":4,"492818":4,"493":4,"493648":4,"493975":4,"494":4,"4945":4,"4949":4,"495":4,"4957":4,"4959":4,"495924":4,"496":4,"4961":4,"496312":4,"4966016":13,"497":4,"497008":4,"497294":4,"498":4,"4981":4,"498232":4,"499":4,"49e":11,"4b8c7f4a86e445099d73f27dffaad94b":13,"4e":[0,6,17],"4e3":[0,6],"4m":11,"4mb":[7,11],"4s":[7,11],"5":[0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,17,19],"50":[0,4,6,7,11,13],"500":[0,4,6],"500000e":17,"501":4,"5017":4,"502":4,"502451":4,"502775":4,"502841":4,"503":4,"503726":4,"504":4,"5043":4,"5046":4,"505":4,"5051":4,"50537":4,"506":4,"5064":4,"50652":4,"5066257":13,"50682":4,"50687":4,"507":4,"507104":4,"507443":4,"508":[4,14],"5089":4,"509":4,"5094":4,"50973":4,"50e":11,"50fb66cc659c46c8bbc29fe0c8651c2f":14,"51":[4,7,11],"510":4,"511":4,"511114":4,"5112":4,"5114":4,"5117":4,"512":4,"512561":4,"512617":4,"513":4,"514":4,"514087":4,"51478":4,"514898":4,"514916":4,"515":11,"515062":4,"5164":4,"517":4,"51742":4,"517454":4,"5175":4,"518":4,"51803":8,"51809":4,"51819":4,"518397":4,"518757914":12,"518851":4,"519":4,"51e":11,"52":[4,5,7,11],"52058":4,"5208":4,"520903":4,"5217":4,"522":4,"5221":4,"523":4,"523485":4,"523561":4,"524":4,"52414":14,"52415":14,"5244":4,"524629":17,"524755":4,"525":4,"526":4,"527":4,"528":4,"528102":4,"5286":4,"529":4,"5294":14,"52e":11,"53":[4,5,7,11],"530":4,"5301":4,"5309":4,"531":4,"531293":4,"531411":4,"5317":4,"532":4,"5324":4,"533":4,"5333":4,"534":4,"534699":4,"535":4,"5358":4,"536":4,"5366":4,"53715":4,"5374":4,"537743":4,"538":4,"53854":4,"539":4,"539343":4,"539941":4,"53e":11,"54":[4,11],"54027":4,"5403":4,"541":4,"541792":4,"542":4,"5423":4,"542419":4,"543":4,"54307":4,"54371":4,"544":4,"54439":4,"544482":4,"545":4,"5456":4,"545743":4,"546":4,"5462":4,"547002":4,"547729":4,"548":4,"5483":14,"548589":4,"548740826516e":14,"548864":4,"549":4,"5493":4,"54949":4,"55":[2,4,5,7,11,13,14],"550575":4,"551":[4,5],"551072":4,"552":4,"552711":4,"5528":4,"553":4,"5532":4,"554":4,"55458":8,"55473":4,"555":[4,7],"5556":4,"5557":4,"557":4,"558":4,"559":4,"5593":4,"55982":4,"559889":4,"55e":11,"56":[4,7,11,14],"560118":4,"5603":4,"561":4,"5612":4,"5619":4,"562":4,"562029":17,"56228":4,"564":4,"565":4,"56518":4,"5652":4,"566":[4,17],"566263":4,"56631":4,"566495":4,"567":4,"567303":4,"567898":4,"568":4,"5681":4,"56865":4,"569":4,"569581":4,"5696":4,"56e":11,"57":[0,4,5,7,11],"570":4,"570222":4,"5703":4,"57062":4,"57093":4,"571":4,"5712":4,"57141":4,"5717":14,"572":4,"573":4,"5734":4,"5735":4,"573703":4,"5738":4,"573874":4,"574":4,"57443":8,"5747":0,"574826":4,"575":4,"57538":4,"57571":14,"576":4,"577":4,"57739":4,"5775":4,"577826":4,"578":4,"57878":4,"579":4,"579099761269e":14,"5791":4,"5794":4,"5795":4,"5796":4,"5798":4,"58":[4,11],"581":4,"5812":4,"581558":4,"58166":4,"582":4,"582318":4,"583":4,"58332":4,"583346":4,"583436":4,"584622":4,"585":4,"58504":4,"58518":14,"585985":4,"586":4,"587":[4,13],"588":4,"588396":4,"5885":4,"589":4,"58e":7,"59":[4,5,11],"590":4,"5904":4,"590877":4,"591":4,"5919":4,"592":4,"592309":4,"592733":4,"593":4,"594":4,"59429":4,"59452":8,"595":4,"596":[4,11],"59616":4,"596161":4,"597":4,"5977":4,"598":4,"5982":4,"59867":4,"59e":11,"5dex":[7,11,12,13],"5e":11,"5m":11,"5mb":[7,11],"5msun":[0,6],"5s":11,"6":[0,1,4,5,6,7,8,9,10,11,12,13,14,17,23,26],"60":[4,11,14],"600":4,"6000":[0,6],"600000":0,"60007":14,"600258":4,"600593":4,"6008":4,"601":4,"60101":4,"602":4,"603":[4,11],"6032":4,"604":4,"60468":4,"605":4,"60547":4,"6058":4,"606":[4,11],"606169":4,"60636":4,"607":11,"608":[4,11],"608269":4,"608402":17,"608485":4,"608655":4,"60876":4,"609":4,"6094":4,"61":[4,11],"610184":4,"610285":4,"611":[4,11],"61117":4,"611632":4,"611763":4,"611785":4,"612":[4,11],"612281":4,"613":[4,11],"613167":4,"614":[4,11],"6145":4,"615":4,"615165":4,"61521":4,"616":[4,11],"6161":4,"616737":4,"61679":4,"617":[4,11],"617224":4,"6179":4,"618":4,"6181":4,"6182":4,"618382":4,"618445":4,"6185":4,"618705":4,"619":[4,11],"619099":4,"61e":11,"62":[0,4,11],"620":11,"621":13,"6212":4,"62124":17,"621375":4,"6215":4,"62172":10,"622":4,"62200":4,"622081":4,"622494":4,"6225":4,"623":11,"623052":4,"623232":4,"623354":4,"62366":4,"624":[4,11],"624125":4,"6249793":14,"625":[0,4],"62549":4,"626":[4,11],"627748":17,"628":[4,11],"628169":4,"629":[4,11],"63":[4,7,11],"630":11,"631":[4,7],"63153":4,"632":[4,11],"6328":4,"633":4,"633148":4,"633684":4,"634":[4,11],"634261":4,"6344":4,"634667":17,"635":[0,6,11],"63566e":4,"635703":4,"636":11,"636985":4,"637":[4,11],"637666":4,"637754":4,"6379":4,"638":[4,11],"63818":4,"6384":4,"6388":4,"639":[4,11,17],"63923":4,"639951":4,"63e":11,"64":[4,11],"640":[4,11],"6409":4,"641":11,"6413":4,"64137":4,"642":11,"64207":4,"64265":4,"6429":4,"643":11,"64359":4,"6438124832773024":11,"644":[4,11],"644553":10,"64463":4,"645":[4,10,11,17],"645286":4,"645339":4,"645763":4,"646":4,"64611":4,"646273":4,"647":4,"647161":4,"64724":4,"6474":4,"6475":4,"648":4,"648549":4,"6485656144116352":11,"648566":11,"6489":4,"6492":4,"6493":4,"64932":4,"649327":4,"64e":11,"65":[4,11,28],"651":4,"6514":4,"6515":4,"65262":4,"652638":11,"652755":4,"653":[4,14],"6548":4,"6550":4,"6552":4,"655371":4,"6556":4,"6559":4,"656":4,"6562":4,"657":4,"6571":4,"6579":4,"658":4,"6588":4,"659":4,"659393":4,"659448":4,"659469":4,"659526":4,"659581":4,"659743":4,"65976":4,"65e":11,"66":[4,11],"66003":14,"66016":4,"66025":4,"6602514":11,"6604":4,"660415":4,"661":4,"661725":4,"662":4,"6626":4,"663":4,"663251":4,"663976":4,"664":4,"664546":4,"6649":4,"665406":4,"66554":4,"665969":4,"666661":4,"667":4,"6674":4,"668":4,"668328":4,"669":4,"66915":4,"669442":4,"66e":11,"67":[4,11],"670":4,"67023":4,"670337":4,"670413":4,"670422":4,"67059":4,"671":4,"671001":4,"671551":4,"67179":4,"672":4,"67245":4,"673":4,"674":4,"674063083432e":14,"6745":4,"674645":4,"6747":4,"6749":4,"675":4,"675689":4,"6758":4,"67586e":14,"676":4,"676181":4,"676215":4,"6764":4,"6765":4,"677":4,"6771":4,"677623":4,"678":4,"679":[4,7],"679223":4,"6797":4,"67e":11,"68":[4,7,11],"681":4,"681473":4,"681487":4,"6816":4,"682":[4,7],"6822":4,"683":4,"6831":4,"6832":4,"6834":4,"683467":4,"68376":4,"684":[4,7,14],"684890":11,"685":[7,11],"685255":4,"685872":4,"686":4,"686591":4,"687":[4,7],"68746":4,"68748":14,"688":[4,7],"6883":4,"6885":4,"689":4,"689781":4,"689835":4,"68e":11,"69":[4,11],"690":11,"690194":11,"690203":4,"6905":4,"690746":4,"6908":4,"6909":4,"691":[4,7],"691586":4,"692":4,"693":[4,7],"693128":4,"693321":4,"6934":4,"693944":4,"694":[4,7,11],"6944":0,"694517":11,"695":[4,14],"6952":4,"695505":4,"69569":4,"696":4,"696003":17,"696284":4,"697":4,"6975":4,"697827":4,"698":[4,11],"69808":4,"698517":4,"6989":4,"699":4,"6e":[7,11],"6e1":2,"6e5":[0,6],"6m":11,"6mb":[7,11],"6msun":[0,6],"6s":[7,11],"7":[0,1,2,4,5,6,7,8,10,11,12,13,14,16,17,23,26],"70":[2,4,7,11,14],"700":[4,17],"70005":4,"700359":4,"70043":4,"70052":4,"70054":4,"701":4,"702":4,"70235":4,"7028":4,"703":4,"703545":4,"70365":4,"704":4,"70429":4,"7046":4,"705":[4,17],"7052":4,"705715":4,"706":4,"7060":4,"706029":4,"706126":4,"706483":4,"706780":11,"7069":4,"706984":4,"707":[4,11],"708":4,"7085":4,"7087":17,"709":4,"7093":4,"709965":4,"70e":11,"71":[4,11],"710":4,"71025":14,"7106":17,"7107":4,"7108":4,"711":4,"7114":4,"71196":14,"712":4,"712414":4,"7128":14,"713946":4,"714712":4,"716":[4,10],"71617":10,"71662":8,"71746":4,"71818":4,"7184":4,"718549":4,"7188":4,"719058":4,"71e":11,"72":[4,11],"720749":4,"721":4,"7210":4,"7214":4,"7219":4,"722":4,"72386":4,"724":[4,8],"72498e":[8,14],"725":4,"725718":4,"726":17,"726002":4,"72611":4,"72617":4,"7267":4,"7269":4,"727":4,"727196":4,"72764":4,"728":[4,7],"7282":4,"728237":4,"72832e":4,"728797":4,"729":4,"729193":4,"7292":4,"7296":4,"72983":4,"72e":11,"73":[4,11,14],"730":4,"731":4,"7315":4,"7319":4,"732":4,"7322":4,"732244":7,"7324":4,"7326":4,"732818":4,"732953":4,"732983":4,"7335":4,"734":4,"7342":4,"734534":4,"735":4,"7354":4,"7359":4,"736":[4,7],"736112":4,"7365":4,"737":4,"7370":4,"737411":4,"738":4,"7380":4,"7381":4,"738399":4,"7384":4,"7385":4,"738524":4,"7386":4,"739":4,"7390":4,"739962":4,"73e":11,"74":[4,11],"740":4,"740494":4,"740929":4,"7413":4,"741346":4,"741448":4,"7418":4,"7419":4,"742":4,"7420":4,"7421":4,"7422":4,"7423":4,"7424":4,"7425":4,"7426":4,"7427":4,"7428":4,"7429":4,"743":4,"7430":4,"7431":4,"743118":4,"7432":4,"7433":4,"7434":4,"7435":4,"7436":4,"7437":4,"7438":4,"743837":4,"7439":4,"744":4,"7440":4,"7446":4,"7447":4,"7448":4,"7449":4,"745":4,"7450":4,"7451":4,"7452":4,"7453":4,"7454":4,"7455":4,"7456":4,"7457":4,"7458":4,"74583":4,"7459":4,"746":4,"7460":4,"7461":4,"7462":4,"747":4,"7472":4,"748":[4,17],"748832":4,"749":4,"75":[0,4,7,11],"750":[4,5],"7500":4,"75005":4,"750149":4,"750806":4,"7509":17,"751305":4,"752":4,"752134":4,"752438":4,"7527":4,"753":4,"7530":4,"7536":4,"7537":4,"754":4,"754141":4,"7544":4,"755":4,"75508":4,"755323":4,"7554":4,"7557":4,"756":4,"7561":14,"7564":4,"7566":4,"756795":4,"757":[4,7],"757025":4,"7572":4,"758":[4,17],"7582":4,"7589":4,"759":4,"75921":4,"75931":4,"7595":4,"7598":4,"75e":11,"76":[4,11],"760064":4,"760389":4,"7605":4,"7607":4,"761":4,"7612":4,"7613":4,"76134":4,"761478":4,"7617":4,"7619":0,"7620":4,"7622":4,"7626":4,"7629":4,"763":[2,4],"7631":4,"7633":4,"7635":4,"764":4,"76416e":4,"7644":4,"7645":4,"764629":4,"7647":4,"7647737053496777":14,"764989":4,"765":4,"7650":4,"7657":4,"7659":4,"766":4,"766094":4,"7666":4,"7669":4,"767":4,"7671":4,"7675":4,"7677":4,"7678":4,"7679":4,"768":4,"7683":4,"768339":4,"7684":4,"768655":4,"7689":4,"769":4,"7690":4,"7691":4,"769195":4,"7695":17,"76e":7,"77":[4,11,13],"7705":4,"770532":4,"7706":4,"7709":4,"7714":4,"7717":4,"7718":4,"772":4,"7720":4,"7721":4,"772169325355e":14,"7722":4,"7727":4,"7728":4,"77287":14,"773":4,"7730":4,"7731":4,"773166":4,"7734":4,"7735":4,"7736":4,"7737":4,"774":4,"7741":4,"77416":4,"7742":4,"7743":4,"7745":4,"77455":4,"7748":4,"774954":4,"774969":4,"775":[4,17],"7750":4,"77505":4,"7751":4,"7752":4,"77541":4,"7757":4,"7759":4,"776":[4,17],"7761":4,"77624":4,"776263":4,"77631":4,"7764":4,"7765":4,"776523":4,"7766":4,"7767":4,"776818":4,"7769":4,"777":4,"7772":4,"7773":[4,17],"7774":4,"77766":4,"7779":4,"778":4,"7781":4,"7782":4,"7785":4,"7789":4,"779":4,"7790":4,"779197348711e":14,"7792":4,"7795":4,"7797":4,"78":[4,11],"78012":4,"7803":4,"7806":4,"7809":14,"781":4,"781046":4,"78125":0,"7813":4,"7817":4,"7819":4,"782":4,"7823":4,"7825":4,"7826":4,"7827":4,"7828":4,"783":[4,10],"7831":4,"7836":4,"783746":4,"783792":4,"784":4,"7840":4,"7842":4,"7843":4,"7844":4,"7845":4,"7848":4,"78488":4,"784972":4,"785":4,"7852":4,"785539":4,"7856":4,"7858":4,"786":4,"786062":4,"7861":4,"7863":4,"7864":4,"7868":4,"786e":17,"787":4,"7871":4,"787102":4,"787368":4,"7874":4,"7875":4,"7877":4,"787705":4,"7879":4,"788":4,"78817":17,"7882":4,"7883":4,"7886":4,"7887":4,"789":4,"789064":4,"7891":4,"789188":4,"7893":4,"7898":4,"789859":4,"7899":4,"78e":11,"79":[4,11],"7901":4,"7902":4,"7903":4,"7905":4,"7907":4,"7909":4,"79092":14,"790941":4,"791":4,"7911":4,"7912":4,"791274":4,"7913":4,"791478":4,"7916":4,"7918":4,"7919":4,"791991":4,"792":4,"7920":4,"7925":4,"7926":4,"79264":4,"7927":4,"792721":4,"792744":4,"7928":4,"7933":4,"7934":4,"7936":4,"793832":4,"7941":4,"79412":4,"7942":4,"7943":4,"7944":4,"79487":14,"795":[2,4],"795024":4,"7958":4,"796":4,"7960":4,"7962":4,"7964":4,"796455":17,"7965":4,"7967":4,"7968":4,"7969":4,"797":4,"7973":4,"7974":4,"7975":4,"7979":4,"798":4,"7980":4,"7982":4,"7988":4,"799":4,"7990":4,"79911":4,"7996":4,"7997":4,"799889":4,"79e":11,"7a2e4301f5224b2cb8939d2297df0aad":13,"7e":11,"7m":11,"7mb":11,"7s":7,"8":[0,2,4,5,6,7,8,10,11,12,13,14,17],"80":[2,4,11,28],"800":5,"8000":4,"8001":4,"8003":4,"8004":4,"8008":4,"8009":4,"801":4,"8010":4,"8012":4,"8013":4,"802":4,"802706":5,"802986496151e":14,"803":4,"8031":4,"8034":4,"8039":4,"804":4,"80402":4,"8043":4,"8044":4,"8047":4,"8048":4,"804961":4,"805":4,"8050":4,"8053":4,"8055":4,"805733":4,"8058":4,"8059":4,"80592":14,"806":4,"8060":4,"80602":17,"8062":4,"806431":4,"8065":4,"8066":4,"8067":4,"806722":4,"807":4,"8071":4,"8073":4,"807331":4,"807361":4,"8074":4,"807403":4,"8076":4,"8079":4,"808":4,"808134":4,"809":[4,5],"8091":4,"8095":4,"80954":4,"809662":4,"80e":11,"80msol":2,"81":[4,7,11],"810":7,"8101":4,"8104":4,"8105":4,"81066":14,"8107":4,"8108":4,"8109":4,"811":4,"8111":4,"8115":4,"812":4,"8121":4,"8123":4,"8124797":5,"813":4,"81352":4,"8138":4,"81395":8,"814":4,"8140":4,"8141":4,"814387":4,"81495":14,"81499":14,"815":4,"8151":4,"81529":14,"81536":14,"8155":4,"81562":4,"81563":14,"8158":4,"816":4,"8163":4,"81636":14,"81689":14,"816958":4,"817":[4,10],"81705":4,"817432":4,"817620e":17,"81762e":17,"817843":4,"817888":4,"818":4,"8182":4,"818294":4,"819":4,"8194":4,"8195":4,"81957":14,"8196":4,"819715":4,"8199":4,"81e":11,"82":[4,11],"8200":4,"8202":4,"8205":4,"82061":14,"82064":4,"82074":14,"82088":14,"821":4,"82123":14,"821301":4,"821367":4,"8216":14,"822":4,"82224":4,"8224":4,"82245":4,"82255":14,"823":4,"823059079115e":14,"82325":4,"8234":4,"823767":4,"824494":4,"8245":4,"8247":4,"824848":4,"82486":4,"8249":4,"825":4,"8250":4,"825086":4,"8251":4,"8252":4,"8254":4,"82563":11,"825648":4,"826":4,"8261":4,"8263":4,"82642":4,"826771":4,"8268":4,"826831":4,"827":4,"8271":4,"8276":4,"82797":4,"828":4,"8280":4,"828241":4,"828858":4,"829":4,"829017":4,"8292":4,"8293":4,"8295":4,"829668":4,"829726":4,"829757":4,"8299":4,"82e":11,"83":[4,7,11],"830":[4,17],"8300":4,"8303":4,"830541":4,"831236":4,"832":4,"832981":4,"833":4,"8339":4,"834303":4,"834483":4,"835":4,"8354":4,"836":[4,5],"836621":4,"83672":4,"836783":4,"837":4,"8372":4,"83762":4,"8377":4,"837816":4,"8379":4,"838":[4,5],"838411":5,"838423":4,"83843":4,"839":4,"8399":4,"83e":11,"84":[4,7,11],"840":4,"84029":4,"84071":4,"840796":4,"840994":4,"841":4,"841284":4,"841718":4,"8427e":17,"8429":4,"843":4,"8435":4,"8435e":17,"844":[4,5],"8441":4,"84428":4,"8443":4,"845":4,"84502":4,"8452":4,"845387":4,"845641":4,"846":[4,5],"846045":5,"847":4,"847153":4,"84827":4,"848380621869e":8,"848866":4,"8493":4,"85":[4,7,11,28],"850":4,"850309":4,"851":4,"851646":4,"852":4,"852252":4,"8523":4,"852712":4,"853":4,"8533":4,"854":4,"85406e":4,"8544":4,"8545":4,"854649":4,"855":4,"856":[4,11],"85661":17,"8569":4,"857":4,"8573":4,"857699":4,"8577":4,"858":[4,5],"8585":4,"859":4,"8596":4,"859753":4,"8598":4,"859977":4,"86":[4,7,11],"860402":4,"8605":4,"861":4,"861368":4,"863":[4,7],"86323":4,"86334":4,"8635":4,"8638":4,"865":4,"8653":4,"8654":4,"865806":4,"866":4,"8664":4,"867":4,"86728":4,"8674":4,"8678":4,"86794":4,"868":4,"8683":4,"86878":4,"869":4,"86918":4,"8694":4,"869544":4,"87":[4,11,14],"870":4,"8704":4,"8706":4,"8708":4,"871":4,"872":[4,14],"872312":4,"872316":4,"873":4,"8731":4,"873639":4,"874":4,"874638":4,"875":4,"876":4,"876084":4,"876382":4,"877":4,"877963":4,"878":4,"87813":4,"878253":4,"879":4,"8791":4,"87e":11,"88":[4,11],"880":4,"8805":4,"880528":4,"881":4,"8813":4,"882017":4,"8828":4,"883":4,"883252":4,"88343":4,"8837":4,"884":4,"8840":4,"8843":4,"88441":4,"884461":4,"8846":4,"8848":4,"885":4,"8851":4,"8853":4,"8855":4,"885537":4,"8856":4,"8858":4,"88581":4,"886":4,"8860":4,"8862":[4,14],"8864":4,"8866":4,"8867":4,"8868":4,"8869":4,"887":4,"8870":4,"8871":4,"8872":4,"8873":4,"8874":4,"8875":4,"8876":4,"8877":4,"8878":4,"888":4,"8880":4,"8881":4,"888123":4,"8882":4,"8884":4,"8886":4,"888613":4,"8887":4,"8889":4,"889":4,"8891":4,"8892":4,"8893":4,"8894":4,"8896":4,"8897":4,"8898":4,"8899":4,"89":[4,5,11,13],"890":4,"8901":4,"8902":4,"8903":4,"8904":4,"8906":4,"8907":4,"8908":4,"8909":4,"891":4,"8910":4,"891056":4,"8911":4,"8912":4,"8917":4,"892":4,"89211":17,"8924":4,"8926":4,"893":4,"8934":4,"8935":4,"8939":4,"893941":4,"894":4,"894041":4,"8941":4,"8949":4,"895":4,"895821":4,"896":4,"8961":4,"896110e":17,"896196":4,"896286":4,"8972":4,"8975":4,"897612":4,"898":4,"8982":4,"898786":4,"899":4,"8992":4,"899464":4,"8a7d52edc59346ce991063d9e05e9ba7":5,"8bc1eafea1c34b05894c1618639d8c37":14,"8e":[0,6],"8m":[7,11],"8mb":11,"8s":[7,11],"9":[0,4,5,6,7,8,10,11,13,14,17,21],"90":[4,7,11],"900":4,"901":4,"901988":4,"902":4,"903":4,"9032":4,"9036":4,"9038":4,"904":4,"9043":4,"9046":4,"9047":4,"905":4,"905335716621e":14,"9057":4,"906":4,"906059":4,"906299":4,"90695":4,"907":4,"9071":4,"90716":4,"9073":4,"9074":4,"908":4,"9087":4,"909":4,"9093":4,"9098":4,"90e":11,"91":[4,7,11],"910419":4,"9105":4,"910817":4,"910981":4,"911":4,"9110":4,"911093":4,"9113":4,"912":4,"912238":4,"912283":4,"912289":4,"912327":4,"9127":4,"912919":4,"913":4,"9139":4,"914":4,"9147":4,"9148":4,"915":[4,7],"915148":4,"915221":4,"9153":4,"91548":4,"916":4,"916093":4,"916207":4,"917":4,"917439":4,"9179":4,"918":4,"918543":4,"9189":4,"919":4,"9196":4,"91e":11,"92":[4,11],"920":4,"9203":4,"9206":4,"920832":4,"921":4,"9214":4,"922":4,"922199":4,"923":4,"92382":4,"924":4,"924056":17,"925":4,"9253":4,"9255":4,"9256":4,"925761":4,"926":4,"9263":4,"9264":4,"927":4,"929":4,"929511":4,"92995":4,"92e":11,"93":[4,11,14],"930":[4,13],"930282":4,"9304":4,"93044":4,"9308":4,"9309":4,"930943":4,"931":4,"9310":4,"932":4,"9323":4,"932839":4,"933":4,"9339":4,"934":4,"9342":4,"935":4,"935069":4,"9351":4,"9357":4,"935816":4,"935920339886e":14,"936":4,"936532":4,"936762":4,"937":4,"9373e":17,"938":4,"938568":4,"938576":4,"93898":4,"939":4,"939376":4,"939378":4,"939757":4,"93e":11,"94":[4,5,7,11,18],"941":[4,7],"9411":4,"941478":4,"942":4,"942154":4,"9423":4,"9427":4,"942854":4,"943":4,"9436":14,"944":4,"9445":4,"94464":4,"945":4,"9452":4,"946":4,"946468":4,"946757":4,"947":4,"9471":4,"947719":4,"947774":4,"94797":4,"948":4,"949":4,"95":[4,11,13],"950":4,"9505":4,"950733":4,"951":4,"951344":4,"951597":4,"952":4,"9524":4,"952496":4,"953":4,"953182":4,"9537":4,"953738":4,"953798":4,"954":4,"954624":4,"9548":4,"954848":4,"955":4,"9557":4,"956":4,"9561":4,"956619":4,"957":4,"9573":4,"95783":4,"957894":4,"958":4,"959":4,"959422":4,"959492":4,"9595":4,"9598":4,"95e":7,"96":[4,5,7,11],"960":4,"9603":4,"9606":4,"960734":4,"961":4,"9610":4,"96112":4,"96161":4,"962":4,"962482":4,"962876":4,"963":[4,7],"963621764679e":14,"964":4,"9648":4,"965":4,"9650":4,"965167":4,"96557e":4,"966":4,"966681":4,"967":4,"968":4,"969":4,"96963":4,"96e":11,"97":[4,11],"970":4,"97008":14,"970206":4,"970505":4,"970783":4,"971":4,"971686":4,"971941":4,"972":4,"9725":4,"973":[4,11],"973135":4,"97316":4,"9739":4,"9739752":7,"974":4,"9743":4,"9749":4,"975":4,"9757":4,"9758":4,"975864":4,"976":4,"976041":4,"977":4,"9779":4,"97797":4,"978":4,"979":4,"97923e":14,"9794":4,"9797":4,"97e":[7,11],"98":[4,11,13],"98061":4,"98081":4,"98096":4,"981":4,"981292":4,"9814":4,"981555":4,"9816":4,"982":4,"9825":4,"983":4,"983229":4,"984":[4,13],"9841":4,"9842":4,"985":4,"9851":4,"985359":4,"9859":4,"986":[4,7],"9869":4,"987":4,"988":4,"988755":4,"989":4,"98e":11,"99":[4,11,13],"990":4,"9900":4,"9902":4,"991":4,"9912":4,"991224":4,"991657":7,"99191":8,"99192":8,"99194":8,"992":4,"99203":4,"9927":[4,10],"993":4,"994":4,"994118":4,"995":4,"995631":13,"995687":4,"995824":4,"996":[4,7],"996798":4,"997":4,"9977":4,"997751":4,"998":4,"998023":4,"99808":4,"9983":10,"998563":4,"999":4,"999122":4,"9999999999999998":13,"99e":11,"9e":7,"9m":11,"9mb":[7,11],"9s":[7,11],"boolean":[0,6,18,19,21,25,30],"break":[0,6],"case":[0,3,6,14,18,21,23,28],"catch":[5,7,10,11,12,13,14,17,18,21],"char":21,"class":[18,19],"const":[2,5,7,11,12,13,14,19,28],"default":[0,1,2,5,6,8,9,11,12,13,14,17,18,19,20,21,27,28],"do":[0,1,2,4,5,6,7,8,11,12,13,14,17,19,20,21,23,25,26],"export":[14,18,19],"final":[4,7,11,12,13,17],"float":[0,2,4,6,9,10,15,18,19,28,30],"function":[0,1,2,3,4,5,7,8,16,19,20,21,22,23,24,25,26,27,28,30],"import":[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],"int":[0,1,2,4,6,11,14,18,19,20,21,28,30],"krtickov\u00e1":[0,6],"kub\u00e1t":[0,6],"long":[0,5,6,7,14,18,19,21,29],"new":[0,2,5,6,7,10,11,12,13,14,19],"null":[0,5,6,7,14,18],"paczy\u0144ski":[0,6],"public":[11,12,13,14,20,23],"return":[1,2,4,5,6,7,9,10,11,12,13,14,17,18,19,20,21,25,27,28,30],"short":[0,5,6,7,11,12,13,29],"super":[0,6],"switch":[0,6],"throw":[23,26],"true":[0,4,5,6,7,9,11,12,13,14,16,17,18,19,20,21,25,28],"try":[0,4,6,7,10,11,12,13,14,23,26],"void":8,"while":[0,4,5,6,7,11],A:[0,3,6,14,30],And:[20,23,26,30],As:[0,5,6,7,10,11,12,13,14],At:[5,14],But:10,By:[0,5,6,11,12,13,14,17],For:[0,6,8,10,11,12,13,25],If:[0,2,5,6,7,11,12,13,14,19,21,23,25,26,27,30],In:[0,5,6,7,8,9,10,11,12,13,14,17,19,21,28],It:[0,5,6,7,10,11,12,13,14,15,17,21,23,26],Its:21,NO:21,NOT:[0,6,19,27],No:[4,6,21,23,26],Not:[5,7,21],OR:17,On:[0,6,14,18,19],One:[0,6],Or:[14,17],Such:7,That:[0,5,6],The:[0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,17,18,19,21,23,25,26,27,28],Then:[5,18,23,26],There:[2,5,6,7,8,9,10,11,12,13,14,15,17,19,20,21,25],These:[5,6,11,12,13,14,18,21,25],To:[0,6,10,11,12,13,14,21,23,26],Will:[0,6,18,27],With:20,_1:[11,12,13],_:[5,7,11,12,13,20,21],__:14,__arg_begin:6,__attribute__:8,__enter__:18,__exit__:18,_actually_evolve_system:21,_binary_c_bind:[6,8,10,15,18,30],_binary_c_config_execut:21,_binary_c_dir:21,_binary_c_execut:21,_binary_c_shared_librari:21,_commandline_input:21,_count:21,_custom_logging_shared_library_fil:21,_end_time_evolut:21,_errors_exceed:21,_errors_found:21,_evolution_type_opt:21,_failed_count:21,_failed_prob:21,_failed_systems_error_cod:21,_generate_grid_cod:21,_grid_vari:[12,13,19,21],_loaded_moe2017_data:21,_main_pid:21,_moe2017_json_data:21,_population_id:21,_pre_run_cleanup:19,_probtot:21,_process_run_population_grid:21,_repeat:21,_set:19,_set_moe2017_grid:21,_start_time_evolut:21,_store_memaddr:21,_system_gener:21,_total_mass_run:21,_total_probability_weighted_mass_run:21,_total_starcount:21,_zero_prob_stars_skip:21,a173:[0,6],a_in:4,a_out:4,abat:[0,6],abbrevi:29,abl:6,about:[3,5,7,11,12,13,14,18,19,20,30],abov:[0,2,5,6,8,10,12,13,14,18,19],abridg:[6,8],absolut:[0,6,18,28],abund:[0,6],ac:[5,14],acceler:[0,6],accept:[14,18],access:[2,8,10,11,12,13,14,21],accord:[0,2,5,6,28],accordingli:[10,12,13,14],account:[0,6,21],accret:[0,4,6],accretion_limit_dynamical_multipli:[0,6],accretion_limit_eddington_lmms_multipli:[0,6],accretion_limit_eddington_steady_multipli:[0,6],accretion_limit_eddington_wd_to_remnant_multipli:[0,6],accretion_limit_thermal_multipli:[0,6],accretor:[0,4,6,30],accur:[11,12,13],acquir:4,act:[0,6,12,13,14,21],activ:[0,6],actual:[0,5,6,7,8,10,11,12,13,14,19,21,23,25,26,28],ad:[3,5,7,10,19],adam:[0,6],adapt:[0,6,12,13],add:[0,2,5,6,7,8,10,11,12,13,14,18,19,21,25,28,30],add_grid_valu:28,add_grid_vari:[5,7,11,12,13,14,19],addit:0,address:[1,6,8,21,30],admittedli:25,adress:[6,8,30],advis:8,af:4,affect:[0,5,6],after:[0,5,6,7,8,11,12,13,14,19,21,28],ag89:[0,6],ag:[0,3,4,5,6,7,13,23,28],again:[5,9,10,18,21],against:25,agb:[0,5,6],agb_3dup_algorithm:[0,6],agb_core_algorithm:[0,6],agb_core_algorithm_default:0,agb_core_algorithm_hurlei:0,agb_core_algorithm_karaka:0,agb_luminosity_algorithm:[0,6],agb_luminosity_algorithm_default:0,agb_luminosity_algorithm_hurlei:0,agb_luminosity_algorithm_karaka:0,agb_radius_algorithm:[0,6],agb_radius_algorithm_default:0,agb_radius_algorithm_hurlei:0,agb_radius_algorithm_karaka:0,agb_third_dredge_up_algorithm_default:0,agb_third_dredge_up_algorithm_hurlei:0,agb_third_dredge_up_algorithm_karaka:0,agb_third_dredge_up_algorithm_stancliff:0,ago:5,al:[0,2,6,30],albedo:[0,6],algorithm:[6,23],algothim:[0,6],all:[0,1,2,5,6,7,9,10,11,12,13,14,16,17,18,19,20,21,23,24,25,26,27,28],all_info:19,alloc:[6,28],allow:[0,2,6,8,16,17,21],along:[0,20,21,23,26],alpha:[0,4,6],alpha_:7,alpha_c:[0,4,5,6,7],alpha_ej:4,alphacb:[0,6],alreadi:[5,14,15,19],also:[0,3,4,5,6,7,8,11,12,13,14,17,18,19,20,23,26,30],alter:[7,11,19],altern:[0,6,21],although:15,alwai:[0,2,6,21,28],amanda:[0,6],amax:2,amin:2,amount:[0,6],amp:[5,6,7],an:[0,2,5,6,7,9,10,11,12,13,14,17,18,19,23,27],analys:27,analyt:[5,7,11,12,13,14,19],analyz:10,andrew:[23,26],andronov:[0,6],angelou_lithium_cheb_decay_tim:[0,6],angelou_lithium_cheb_massfrac:[0,6],angelou_lithium_cheb_tim:[0,6],angelou_lithium_decay_funct:[0,6],angelou_lithium_decay_tim:[0,6],angelou_lithium_eagb_decay_tim:[0,6],angelou_lithium_eagb_massfrac:[0,6],angelou_lithium_eagb_tim:[0,6],angelou_lithium_gb_decay_tim:[0,6],angelou_lithium_gb_massfrac:[0,6],angelou_lithium_gb_tim:[0,6],angelou_lithium_hg_decay_tim:[0,6],angelou_lithium_hg_massfrac:[0,6],angelou_lithium_hg_tim:[0,6],angelou_lithium_lmms_decay_tim:[0,6],angelou_lithium_lmms_massfrac:[0,6],angelou_lithium_lmms_tim:[0,6],angelou_lithium_ms_decay_tim:[0,6],angelou_lithium_ms_massfrac:[0,6],angelou_lithium_ms_tim:[0,6],angelou_lithium_tpagb_decay_tim:[0,6],angelou_lithium_tpagb_massfrac:[0,6],angelou_lithium_tpagb_tim:[0,6],angelou_lithium_vrot_trigg:[0,6],angelou_lithium_vrotfrac_trigg:[0,6],angular:[0,6,15,25],ani:[0,2,6,10,14,18,19,23,26],anoth:[0,6],ansi:[0,6],ansi_colour:[0,6],anyth:[0,6,11,12,13,14,18,21,28],anywai:[10,14,19],api:[0,3,18,23],api_log_filename_prefix:[0,4,6,10,15],append:[1,5,10,11,12,13,15],appli:[0,6],apply_darwin_radau_correct:[0,6],appropri:[0,6,14,19,21],approxim:[0,5,6,7],ar:[0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,23,25,26,28,30],arang:17,aren:[2,21],arenou2010_binary_fract:2,arg:[2,4,6,14,18,25],arg_dict:18,argh:15,argopt:[0,6],argpair:[9,18],argstr:[6,8,10,15,17],argument:[0,2,6,10,12,14,15,16,17,18,19,21,27],argument_of_periastron:[0,6],argument_of_periastron_quadrupl:[0,6],argument_of_periastron_tripl:[0,6],aritif:7,around:[0,6,8,10,16,17],arrai:[2,10,14,17,18,19,21,28],arrow:[0,6],artefact:[12,13],artifici:[0,6],artificial_accretion_end_tim:[0,6],artificial_accretion_ignor:0,artificial_accretion_start_tim:[0,6],artificial_angular_momentum_accretion_r:[0,6],artificial_mass_accretion_r:[0,6],artificial_mass_accretion_rate_by_stellar_typ:[0,6],artificial_orbital_angular_momentum_accretion_r:[0,6],arxiv:[0,2,6],ask:[0,6,30],asplund:[0,6],assign:[11,12,13,14,19],associ:[5,7,11,12,13],assum:[0,5,6,7,11,15,25,28],ast871:[0,6],astronomi:[0,6],astrophys:[7,12,13],astropi:[23,25,26],asymptot:5,atom:18,attempt:19,au:15,auto:[1,24],autogen_c_logging_cod:[1,8,17],autogener:17,automat:[0,1,6,8,14,16,17,19,20,23,26],avaibl:[23,26],avail:[0,6,7,8,11,12,13,14,18,21,23,25,26],avoid:[5,6,7],awai:[0,6,11],ax:17,axessubplot:16,axi:[0,6,25],b6213f2eb7f94d3196cf966b7b76b9f9:13,b:21,b_1:[0,6],b_2:[0,6],b_3:[0,6],b_4:[0,6],b_inclination1:[0,6],b_inclination2:[0,6],b_inclination3:[0,6],b_inclination4:[0,6],back:[0,4,6],background:17,backward:[0,6],bagb:[0,6],bar:[12,13],barn:[0,6],base:[0,2,6,7,11,12,13,14,18,19,23,25,26,30],base_filenam:[14,19],basic:[14,19],batchmod:[0,6],bb:[0,6],bbox_inch:17,beasor:[0,6],becaus:[0,2,5,6,7,10,11,12,13,15,17,19,21,23,26],becom:[0,1,2,4,6,8,12,13,15,18],been:[0,6,9,19,21],befor:[0,4,5,6,7,11,12,13,14,19,21,23,26],beg_bss:4,beg_rch:4,beg_symb:4,begin:5,behaviour:[5,11,12,13,14,27],behind:17,belczynski:[0,6],below:[0,3,5,6,7,8,11,12,13,14,21],berro:[0,6],bertolami:[0,6],best:[4,19,21],beta:[0,6],beta_reverse_nova:[0,6],beta_reverse_novae_geometri:0,better:[0,3,6,14,19],between:[0,2,6,28],bewar:[14,19],beyond:15,bh:[0,4,7],bh_belczynski:[0,4,6],bh_bh:4,bh_fryer12_delai:[0,6],bh_fryer12_rapid:[0,4,6],bh_fryer12_startrack:[0,6],bh_hurley2002:[0,6],bh_prescript:[0,4,6],bh_spera2015:[0,6],bhbh:4,big:[0,6,21],biinari:14,bin:[0,6,7,11,12,13,18,23,26,28],bin_data:[7,11,12,13,18],binari:[2,3,6,7,10,12,13,14,19,21,23,25,26,30],binary_c2:[23,26],binary_c:[1,2,3,5,7,11,12,13,15,18,19,21,25,27],binary_c_api_funct:8,binary_c_cal:[14,19],binary_c_default:14,binary_c_grid:[5,7,11,14],binary_c_grid_25014bc73b334765a1c09a4e4a97ed66:11,binary_c_grid_26171201413c43f5b91552a374879940:5,binary_c_grid_2b66f805db424c48a1d29c45092b6e3c:7,binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f:14,binary_c_grid_8a7d52edc59346ce991063d9e05e9ba7:5,binary_c_grid_f4e5925effeb42e69b5be956f400ae41:5,binary_c_inline_config:1,binary_c_log_cod:[1,8,10,16,17],binary_c_macro:[0,6],binary_c_paramet:[0,5,11,12,13,14],binary_c_python:[5,6,7,10,11,12,13,14,18,19],binary_c_python_api:17,binary_c_task_:[0,6],binary_c_write_log_cod:1,binary_grid:[0,6],binary_star:30,binaryc:[1,18,27],binaryc_config:1,binarycpython:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,23,25,26,27,28,30],binarygrid:[11,12,13,14],bind:[0,6,8,10,15],binned_log_luminos:[11,12,13],binned_post_period:7,binned_pre_period:7,binwidth:[7,11,12,13,18],birth:[0,6],bit:[2,5,11],bivari:[0,6],black:[0,3,5,6,23],black_hol:0,block:[14,19],bloecker:[0,6],blog:1,boltzman:25,boltzmann:[0,6],bondi:[0,6],bondi_hoyle_accretion_factor:[0,6],bool:[14,18,19,20,25],born:[0,5,6,11,12,13],bosswissam:18,both:[0,6,11,12,13,14],bottom:[0,6,14,19],bottomcod:[5,7,14,19],bound:[2,4,28],boundari:2,brake:[0,6],branch:[0,5,6,18],branch_david:0,branchcod:[5,7,14,19],branchpoint:[5,7,14,19],breakup:[0,6],brighten:[12,13],broken:[0,6],bse:[0,2,6,8,14],bse_opt:[5,7,10,11,12,13,14,19],bsf:[0,6],buffer:[0,6],build:[0,1,3,6,18],build_q_tabl:2,built:[0,1,9,18,23,26],burn:[0,6],busso:[0,6],bye:[0,6],bz2:19,c13_eff:[0,6],c2:2,c:[0,1,4,6,8,10,14,27],c_auto_log:21,c_log:0,c_logging_cod:[5,7,8,10,11,12,13,14,21],calc_e_integr:2,calc_p_integr:2,calc_period_from_sep:30,calc_sep_from_period:[7,11,14,30],calc_total_probden:2,calcul:[0,2,5,6,7,11,12,13,14,18,19,21,30],calculate_constants_three_part_powerlaw:2,call:[0,1,6,10,12,13,14,15,18,19,21,25,27,28],call_binary_c_config:18,calls_filenam:14,can:[0,1,2,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,21,23,25,26,27],candid:7,cannot:[5,8,19],canon:21,cap:[0,6],capit:[11,12,13],capsul:[1,6,18],captur:[0,6,18],carbon:[0,4,5,6],carbon_oxygen_white_dwarf:0,care:[5,11,12,13],carlo:[0,6,21],carrasco:[0,6],carri:[0,6],cast:[17,18],catchtim:18,categor:6,categori:[6,14],categoris:18,caught:[10,18],caus:[4,11,30],cbdisc:[0,6],cbdisc_albedo:[0,6],cbdisc_alpha:[0,6],cbdisc_eccentricity_pumping_dermin:0,cbdisc_eccentricity_pumping_method:[0,6],cbdisc_eccentricity_pumping_non:0,cbdisc_end_evolution_after_disc:[0,6],cbdisc_fail_ring_inside_separ:[0,6],cbdisc_gamma:[0,6],cbdisc_init_djdm:[0,6],cbdisc_init_dm:[0,6],cbdisc_inner_edge_strip:[0,6],cbdisc_inner_edge_stripping_timescal:[0,6],cbdisc_kappa:[0,6],cbdisc_mass_loss_constant_r:[0,6],cbdisc_mass_loss_fuv_multipli:[0,6],cbdisc_mass_loss_inner_l2_cross_multipli:[0,6],cbdisc_mass_loss_inner_viscous_accretion_method:[0,6],cbdisc_mass_loss_inner_viscous_accretion_method_equ:0,cbdisc_mass_loss_inner_viscous_accretion_method_gerosa_2015:0,cbdisc_mass_loss_inner_viscous_accretion_method_non:0,cbdisc_mass_loss_inner_viscous_accretion_method_young_clarke_2015:0,cbdisc_mass_loss_inner_viscous_angular_momentum_multipli:[0,6],cbdisc_mass_loss_inner_viscous_multipli:[0,6],cbdisc_mass_loss_ism_pressur:[0,6],cbdisc_mass_loss_ism_ram_pressure_multipli:[0,6],cbdisc_mass_loss_xray_multipli:[0,6],cbdisc_max_lifetim:[0,6],cbdisc_minimum_evaporation_timescal:[0,6],cbdisc_minimum_fr:[0,6],cbdisc_minimum_luminos:[0,6],cbdisc_minimum_mass:[0,6],cbdisc_no_wind_if_cbdisc:[0,6],cbdisc_outer_edge_strip:[0,6],cbdisc_outer_edge_stripping_timescal:[0,6],cbdisc_resonance_damp:[0,6],cbdisc_resonance_multipli:[0,6],cbdisc_torquef:[0,6],cbdisc_viscous_l2_coupl:[0,6],cbdisc_viscous_photoevaporative_coupl:[0,6],cbdisc_viscous_photoevaporative_coupling_inst:[0,6],cbdisc_viscous_photoevaporative_coupling_non:[0,6],cbdisc_viscous_photoevaporative_coupling_visc:[0,6],ce:[0,6,7],cee:[0,6,7],cell:[6,11,12,13,14],cemp:[0,6],cemp_cfe_minimum:[0,6],centr:[7,14,19],central:15,central_object:[0,6],certain:[21,23,26],cf:[0,6],cf_amanda_log:[0,6],cflag:[23,26],chabrier:2,challeng:[12,13],chandrasekhar:[0,6],chandrasekhar_mass:[0,6],chang:[0,1,2,4,5,6,7,8,11,12,13,14,17,18,19,20,21,23,26],chapter:[0,21,24],charact:19,cheb:[0,6],check:[0,2,5,6,7,11,12,13,14,17,18,19,20,30],check_if_in_shel:18,chemic:[0,6,28],chen:[0,6],child:18,choic:[0,2,6,25],choos:[0,5,6,7,8,11,17,25],chose:10,chosen:[11,12,13,14,19],ci:15,circular:[0,4,6],circumbinari:[0,6],circumstanti:[0,6],claei:[0,6],clark:[0,6],clean:[1,5,10,12,13,19],clean_up_custom_logging_fil:19,clear:[12,13,18],clearli:[12,13],clock:18,close:[0,4,6,7,12,13,15],closer:4,cloud:[0,6],cluster:22,cmdline_str:19,co2:[12,13],co:[0,4,6],coalesc:4,code:[0,1,5,6,7,8,10,11,12,13,14,16,17,19,20,23,25,26,27],collaps:[0,6],collapsar:[0,6],collect:30,collid:30,color:25,color_by_index:25,colour:[0,6],colour_log:[0,6],column:[5,7,10,14,15,17,25],column_nam:10,com:[1,18],combin:[1,8,18,19,21],combine_ensemble_with_thread_join:21,come:[2,23,26,28],comenv:[4,7],comenv_bs:0,comenv_count:7,comenv_disc_angmom_fract:[0,6],comenv_disc_mass_fract:[0,6],comenv_ejection_spin_method:[0,6],comenv_ejection_spin_method_do_noth:[0,6],comenv_ejection_spin_method_sychron:[0,6],comenv_ejection_spin_method_synchron:0,comenv_merger_spin_method:[0,6],comenv_merger_spin_method_breakup:0,comenv_merger_spin_method_conserve_angmom:[0,6],comenv_merger_spin_method_conserve_omega:[0,6],comenv_merger_spin_method_specif:[0,6],comenv_ms_accret:[0,6],comenv_ms_accretion_fract:[0,6],comenv_ms_accretion_mass:[0,6],comenv_nandez2016:0,comenv_nelemans_tout:0,comenv_ns_accret:[0,6],comenv_ns_accretion_fract:[0,6],comenv_ns_accretion_mass:[0,6],comenv_post_eccentr:[0,6],comenv_prescript:[0,6],comenv_splitmass:[0,6],comenv_undef:0,comma:28,command:[0,1,6,14,19,21,23,26],commandlin:14,comment:14,commit:18,common:[0,3,4,5,6,8,10,11,12,13,14,23],compact:[7,14],companion:[0,4,6,17],compar:[0,6,7,11,14,21],compens:[12,13],compil:[1,8,14,17,23,26],compile_shared_lib:1,complet:[5,7,11,12,13,14],complex:[7,8,14,16,17,19,21,25],compon:[18,25],compress:19,comput:[0,5,6,11,12,13,22],conceptu:11,condit:[5,7,8,11,12,13,14,16,17,19],condor:[19,21,22],condor_grid:19,config:[1,18,21,23,26],config_fil:1,configur:[2,5,10,11,12,13,14,17,19],conjunct:9,conserv:[0,6],consid:[0,1,2,6,11,12,13,18,19,21,25,28],const_dt:28,const_rang:28,constant:[0,2,6,12,13,25,28],construct:[0,1,5,6,7,10,11,12,13,15,17],contact:4,contain:[0,1,2,6,9,10,11,12,13,14,18,19,20,21,22,23,24,25,26,27,28,29],content:[6,18,19],context:18,continu:[14,19],contribut:[23,26],control:[0,5,6,11,12,13,14],conv_time_unit:18,convect:[0,6],conveni:18,converg:[0,6],convert:[2,5,7,15,18,19],convert_byt:18,convfloat:18,convfrac:4,cool:[0,5,6],copi:[0,6,7,12,13,30],core:[0,5,6,7,11,12,13,14,19,21,25],core_co:8,core_h:8,core_helium_burn:0,core_mass:[0,6,8],correct:[0,2,6,10,19,25,30],correctli:[10,17,23,25,26],correspond:[14,19,25],corretor:[0,6],cosmic:2,cosmic_sfh_madau_dickinson2014:2,cost:[11,12,13],could:[0,6,12,13,14,17,18],count:[4,5,17,18,21],counter:21,coupl:[0,3,6],cours:[5,25],cover:[9,11,12,13],coverag:[23,26],cowd:[0,6],cpu:[0,5,6,7,11,12,13,14],cpu_count:21,cpython:6,crap_paramet:[0,6],creat:[2,5,7,8,10,11,12,13,14,18,19],create_and_load_logging_funct:[1,8,17],create_arg_str:18,create_hdf5:18,creation:6,critic:[0,6],cross:[0,6],crunch:[5,7,11,12,13],cs1:15,ctype:1,cube:11,cubic:11,cuntz:[0,6],current:[0,6,7,8,11,12,13,18,19,23,26],curv:[7,12,13],custom:[0,1,3,5,6,7,10,11,12,13,14,18,19,21,23,25,27],custom_gener:21,custom_log:[10,17,19,21],custom_logging_cod:[1,8,10,16,17,27],custom_logging_func_memaddr:[6,8,21],custom_logging_funct:[8,10,14,16,17,21,23,24],custom_logging_info:19,custom_logging_memaddr:8,custom_logging_print_stat:10,custom_logging_stat:[5,7,11,12,13,14],custom_opt:[5,10,11,12,13,14,19],custom_output_funct:8,custom_tmp_dir:1,customis:25,cut:17,cvode:[0,6],d48r:17,d:[0,1,4,5,6,7,8,10,11,14,15,28],dai:[0,2,4,6,7,8,10,11,14,17,30],damp:[0,6],darwin:[0,6],dat:[0,14,18],data:[0,4,5,6,7,10,11,12,13,14,15,17,18,19,21,27],data_dict:2,data_dir:[14,18,19,21],datadir:[14,19],datafram:[5,7,10,11,12,13,15,16,17,25],datalinedict:[5,7,11,12,13,18],dataset:[14,18,21],date:19,david:[0,17,23,26],david_logging_funct:0,dd7:[0,6],de:[0,4,6],deactiv:[0,6],deal:10,dear:4,death:[0,6],debug:[0,4,5,6,7,11,12,13,14,19,21],decai:[0,6],decid:[0,6,8,16,17,18,19],decreas:[0,6],deepcopi:7,deeper:[14,19],def:[4,5,7,10,11,12,13,14,17],default_to_metal:[0,6],defaultdict:18,defer:[0,6],defin:[0,1,2,6,14,15,19,25],definit:[1,11,12,13,30],degener:[0,6],degenerate_core_helium_merger_ignit:6,degenerate_core_merger_dredgeup_fract:6,degenerate_core_merger_nucsyn:6,degner:6,degre:[0,6],del:7,delai:[0,6],delete_grid_vari:19,delta:[18,28],delta_mcmin:[0,6],demonstr:7,den:[0,6],densiti:[2,11,12,13],depend:[0,2,5,6,18,23,25,26],deprec:[0,6,19],depth:28,dermin:[0,6],describ:[0,2,6,17,21],descript:[0,2,6,9,18,21,23,24],design:25,desir:[0,6],destruct:[14,19],detail:[0,5,6,10,18],detect:[0,4,6,7,15],detector:4,determin:[0,6,8,11,12,13,14,19,30],deton:[0,6],dev:[0,6],develop:1,development_requir:[23,26],deviat:[2,28],dewi:[0,6],dex:[0,6,7,28],df2:17,df:[15,16,17,25],di:[14,18,19,23],diagnost:21,diagram:[0,3,6,23,25],dickonson:2,dict:[1,2,4,5,10,11,12,13,14,15,18,19,20,29],dict_kei:[5,9,10],dictionari:[1,2,3,5,7,11,12,13,14,18,19,20,21,25,29],did:[18,23,26],differ:[0,5,6,7,11,12,13,14,17,18,19,23,25,26,28],differenti:18,dimmer:[0,6,11],dir:[23,26],direct:[0,6,19],directli:[10,21],director:21,directori:[0,3,6,14,18,19,21,23,26],disabl:[0,6,14],disable_debug:[0,6],disable_end_log:[0,6],disable_ev:[0,6],disc:[0,6,15],disc_legacy_log:[0,6],disc_log2d:[0,6],disc_log:[0,6],disc_log_directori:[0,6],disc_log_dt:[0,6],disc_log_level_non:0,disc_log_level_norm:0,disc_log_level_normal_first_disc_onli:0,disc_log_level_subtimestep:0,disc_log_level_subtimestep_first_disc_onli:0,disc_n_monte_carlo_guess:[0,6],disc_stripping_timescale_infinit:0,disc_stripping_timescale_inst:0,disc_stripping_timescale_orbit:0,disc_stripping_timescale_visc:0,disc_timestep_factor:[0,6],discret:14,discs_circumbinary_from_comenv:[0,6],discs_circumbinary_from_wind:[0,6],disk:[0,6,19],dispers:[0,6,28],displai:[0,5,6,7,15],disrupt:[4,6,17],dist:18,distanc:[5,15],distant:15,distefano2017:21,distefano:2,distribut:[0,2,3,6,7,11,14,18,19,22,28],distribution_funct:[5,7,11,12,13,14,23,24],divid:22,dj:[0,6],dlnm1:[7,11,14,19],dlnm:[12,13],dlnm_1:[12,13],dlog10per:[7,11,14],dlogp:2,dlogt:28,dm1:[5,12,13],dm:[0,2,4,6,12,13,28],dm_1:[5,12,13],dn:[2,18,19],do_dry_run:21,doc:[5,11,12,13,14,18,20,23,26],doc_fetch:2,docstr:[10,23,25,26],document:[11,12,13,14,18,20,21,24],doe:[0,2,5,6,8,9,10,11,12,13,14,19,21,30],doesn:[5,19,21],doesnt:[17,20],don:[2,5,18,21],done:[0,4,5,6,11,12,13,14,17,19,23,26],donor:[0,4,6,30],donor_limit_dynamical_multipli:[0,6],donor_limit_envelope_multipli:[0,6],donor_limit_thermal_multipli:[0,6],donor_rate_algorithm_bs:0,donor_rate_algorithm_claeys2014:0,dont:[6,17],doubl:[5,8,14],down:14,dp:2,dphasevol:[5,7,11,12,13,14,19],dprob:[5,7,12,13],dq:[7,11,14],dr2:[0,6],dr3:[0,6],drai:[0,6],dredg:[0,6],drop:10,dry:[5,7,11,13,14,21],dry_run:[5,7,11,14],dstep:2,dt:[0,1,6,18,19,28],dt_limit:9,dtfac:[0,6],dtlimit:18,dtm:[1,8,14],dtype:[15,16,17],due:[23,26],dummi:[2,25],dump:[0,6,10,19],dumpvers:[0,6],duquennoi:2,duquennoy1991:2,dure:[0,4,6,17],dust:[0,6],dwarf:[0,5,6,12,13],dx:[0,6],dynam:[0,6],e2:[0,6],e2_hurley_2002:0,e2_izzard:0,e2_mint:0,e2_prescript:[0,6],e:[0,2,4,5,6,7,8,10,11,12,13,14,18,19,21,23,26,28,30],each:[0,2,6,7,11,12,13,14,15,18,19,21,28],eagb:[0,4,6],eagb_wind_beasor_etal_2020:0,eagb_wind_bs:0,eagb_wind_goldman_etal_2017:0,eagbwind:[0,6],eagbwindfac:[0,6],earli:[0,6],early_asymptotic_giant_branch:0,earth:15,easi:10,easier:[14,17,18],ebindi:4,ecc2:2,ecc3:2,ecc:[2,4,10,14,17,19],eccentr:[0,2,6,8,10,11,12,13,14,15,17,25,30],eccentric_rlof_model:[0,6],eccentricity_quadrupl:[0,6],eccentricity_tripl:[0,6],echo:[0,6],eddington:[0,6],edg:[0,5,6,14,19],edit:8,edu:[0,6],eej:4,eff:5,effect:[0,2,4,6,8,11,21],effective_metal:[0,6,17],effici:[0,5,6,7],egg:[23,26],eggleton:[0,6,30],either:[0,6,11,12,13,14,17,18,19,21,23,26,27],eject:[0,6,7,15],el:[10,14],elabor:8,eld:[0,6],eldridg:[0,6],electon:[0,6],electron:[0,6],element:[0,1,6,9,15,18,21,25],els:[4,7],email:18,emp:[0,6],emp_feh_maximum:[0,6],emp_logg_maximum:[0,6],emp_minimum_ag:[0,6],empti:[10,18,20],enabl:[0,6],encount:21,end:[0,2,4,6,18,21],end_bss:4,end_index:2,end_rch:4,end_symb:4,end_timestamp:[5,7,11,13,14],energi:[0,6],enhanc:[0,6],enlarg:[0,6],enough:2,ensembl:[0,6,9,18,19,21],ensemble_def:[0,6],ensemble_dt:[0,6],ensemble_factor_in_probability_weighted_mass:21,ensemble_filt:9,ensemble_filter_:[0,6],ensemble_filters_off:[0,6],ensemble_legacy_ensembl:[0,6],ensemble_list:19,ensemble_logdt:[0,6],ensemble_logtim:[0,6],ensemble_macro:[0,6],ensemble_output_:21,ensemble_startlogtim:[0,6],enter:[0,6],enthalpi:[0,6],entir:[8,10,16,17],entri:[18,19],env:25,envelop:[0,3,4,5,6,23],eorbf:4,eorbi:4,ep:17,epoch:19,equal:[0,6,12,13,14,18],equat:[0,6],equation_of_state_algorithm:[0,6],equation_of_state_paczynski:0,equatori:[0,6],equival:[11,21],errno:[23,26],error:[0,5,6,7,11,12,13,14,18,21,23,26],errors_exceed:[5,7,11,13,14],errors_found:[5,7,11,13,14],esa:2,escap:[0,6],escape_fract:[0,6],escape_veloc:[0,6],estim:[5,15,18],et:[0,2,6,30],eta:[0,6,7,11],etal:[0,6],etc:[0,6,10,12,13,14,18,19,22,23,25,26,27],etf:[7,11],euler:[0,6],evalu:[2,14,19,28,30],evan:[0,6],evapor:[0,6],evaporate_escaped_orbiting_object:[0,6],even:[9,12,13],event:[0,4,5,6],everi:[0,6,7,18,23,26],everyth:[10,14,19,21],everytim:[23,26],evid:[0,6],evolut:[0,1,3,4,5,6,10,11,12,13,14,17,19,21,23,25,28],evolution_split:[0,6],evolution_splitting_maxdepth:[0,6],evolution_splitting_sn_eccentricity_threshold:[0,6],evolution_splitting_sn_n:[0,6],evolution_stop:7,evolution_typ:[5,7,11,13,14,21],evolutionari:[0,6,10],evolv:[0,3,6,8,19,21],evolve_popul:14,evolve_singl:[8,10,19],exact:[1,21],exactli:[0,6,12,13],exampl:[1,2,10,18,19,27,28],example_compact_object:14,example_dco:14,example_df:10,example_head:18,example_header_1:17,example_header_2:17,example_log:27,example_log_co:[1,8],example_logging_string_co:8,example_logging_string_post_m:8,example_massloss:[8,10],example_output:10,example_parse_output:[16,18],example_pop:[10,14],example_pop_set:14,example_post_m:8,example_python_population_result:14,example_sn:8,exce:[0,6,11,21],except:[4,5,6,11,12,13,14,20,21,25],excit:7,execut:[0,6,14,19,21],exist:[0,5,6,14,17,19,20],exist_ok:[14,18],exit:[0,6,18],exit_after_dry_run:21,exp:[7,11,12,13,14,19],expand:[14,27],expect:[5,6,7,11,12,13,23,26],experiment:[0,6,18],explain:[3,18],explicitli:[0,1,6],explod:[0,4,6],explor:15,explos:[0,4,5,6,17],expoenti:[0,6],expon:[0,6],export_all_info:[14,19],express:[0,6],extend:[0,6,7,23,26],extens:[6,19],extern:[0,6],extra:[0,3,6,14,19,21,23,27],extra_text:20,extract:14,extrapol:[2,21],ey:19,f4e5925effeb42e69b5be956f400ae41:5,f:[0,2,4,6,10,14,17],fa:2,fabian:[0,6],fabian_imf_log:[0,6],fabian_imf_log_tim:[0,6],fabian_imf_log_timestep:[0,6],factor:[0,2,6,21,28],fade:[0,6],fail:[0,5,6,7,11,18,21,23,26],fail_sil:18,failed_count:[5,7,11,13,14],failed_prob:[5,7,11,13,14],failed_system:21,failed_system_log:21,failed_systems_error_cod:[5,7,11,13,14],failed_systems_threshold:21,failsaf:10,failur:[0,6,18],fallback:[0,6],fals:[0,4,5,6,7,11,13,14,15,18,19,21,25,28],fancy_parsing_funct:27,far:[0,4,5,6,12,13,15],farmer:0,fase:14,fast:[0,6],faster:[11,12,13,14],favorit:10,fe:[0,6],featur:[3,14,23],feed:21,ferguson:[0,6],fetch:10,few:[0,6,7],fewer:10,field:[0,6],fig:[0,2,6,17],figsiz:[5,7,11,12,13,15,17],figur:[5,7,11,12,13,15,21,25],file:[0,1,4,6,10,14,18,19,20,21,22,23,25,26,27],file_log:[0,6],filehandl:20,filenam:[0,1,4,6,10,14,18,19,21,27],filenotfounderror:[23,26],filepath:1,fill:[10,18],fill_data:2,filter:[0,6,18],filter_arg_dict:18,filter_valu:18,fin:[0,6],final_mass:17,final_tim:17,find:[4,7,14,18,19,21],finish:[5,7,11,13,14,18,25],finit:[5,7,11,12,13],first:[0,2,5,6,7,10,11,12,13,14,15,18,19,23,26,30],first_giant_branch:0,fishlock:[0,6],fit:[0,2,6,10,19,30],fix:[0,2,4,6,10,14,18,19,25],flag:[0,1,18,21],flash:[0,6],flat:[2,21],flatsect:[2,7,11,14],flaw:19,float64:[16,17],float_overflow_check:[0,6],flto:[23,26],focu:7,fold:2,follow:[0,2,6,8,17,18,21,23,25,26,28],font_scal:[5,7,11,12,13,15],fontsiz:17,forc:[0,4,6],force_circularization_on_rlof:[0,6],force_corotation_of_primary_and_orbit:[0,6],foreach_star:[5,11],form:[0,5,6,7,11,12,13,14,18,19,20],formal:[0,6],format:[0,2,4,6,7,8,10,11,12,13,14,15,17,18,19,28],format_numb:18,former:4,formula:[0,6],forward:[0,6],found:[2,4,5,7,11,13,14,23,26],four:[0,6],fourth:15,fpic:1,fraction:[0,2,6,11,17,21],fractions_z0002:17,fractions_z001:17,fractions_z002:17,framework:6,free:[5,7,11],free_persistent_data_memaddr_and_return_json_output:6,free_store_memaddr:6,frequenc:[0,6,15],friction:[0,6],fring:[0,6],from:[0,2,4,5,7,9,10,11,12,13,14,15,16,17,18,19,21,25,30],from_binary_c_config:1,from_dict:[7,11,12,13,16,17],fryer:[0,6],fsampl:28,ftz:[23,26],full:[3,8,15,18,21],full_path:18,func_memaddr:17,further:[2,14],futur:15,fuv:[0,6],g:[0,1,2,4,5,6,7,8,10,11,12,13,14,16,17,18,19,21,23,26,28],ga:[0,6],gaia:[0,2,6],gaia_colour_transform_method:[0,6],gaia_conversion_ubvri_bivariate_jordi2010:[0,6],gaia_conversion_ubvri_riello2020:[0,6],gaia_conversion_ubvri_univariate_evans2018:[0,6],gaia_conversion_ubvri_univariate_jordi2010:[0,6],gaia_conversion_ugriz_bivariate_jordi2010:[0,6],gaia_conversion_ugriz_riello2020:[0,6],gaia_conversion_ugriz_univariate_evans2018:[0,6],gaia_conversion_ugriz_univariate_jordi2010:[0,6],gaia_l_binwidth:[0,6],gaia_teff_binwidth:[0,6],gain:21,galact:[0,6,28],gallino:[0,6],gamma:[0,6],gap:[0,6],garcia:[0,6],gauss:[0,6],gaussian:[2,28],gaussian_func:2,gaussian_normalizing_const:2,gaussian_zoom:28,gb:[0,6],gb_reimers_eta:[0,6],gb_wind_beasor_etal_2020:0,gb_wind_goldman_etal_2017:0,gb_wind_reim:0,gb_wind_schroeder_cuntz_2005:0,gbwind:[0,6],gbwindfac:[0,6],gcc:[1,23,26],gce:[0,6],gener:[0,1,2,5,6,7,8,10,11,13,14,16,17,18,19,20,21,25,28],generalis:2,geometr:[0,6],geq:5,gerosa:[0,6],get:[0,2,3,5,8,10,11,12,13,14,15,17,18,19,20,23,26,27,30],get_ansi_colour:18,get_arg_kei:18,get_default:[9,18],get_help:[9,18],get_help_al:[9,18,19],get_help_sup:[9,18],get_integration_constant_q:2,get_max_multipl:2,get_moe_di_stefano_dataset:18,get_siz:18,get_usernam:18,gettempdir:17,giant:[0,5,6,15],giant_branch:0,git:[0,11,12,13,14,18],git_branch:18,git_build:18,github:18,gitlab:23,give:[0,2,4,6,7,18,30],given:[0,1,2,6,11,12,13,16,17,18,19,21,27,28,30],global:[0,2,6,11,12,13,28],global_dict:2,gmax:2,gmin:2,gnu:6,go:[0,2,5,6,9,11,14,19,23,25,26],goe:[0,6,8,10,19,25],gogo:[0,6],goldman:[0,6],gonna:2,good:[0,6,10,11,12,13,14,21,30],got:[12,13],gov:[0,6],gravit:[0,5,6,7,14],gravitational_const:5,gravitational_radiation_bs:0,gravitational_radiation_bse_when_no_rlof:0,gravitational_radiation_landau_lifshitz:0,gravitational_radiation_landau_lifshitz_when_no_rlof:0,gravitational_radiation_model:[0,6],gravitational_radiation_modulator_:[0,6],gravitational_radiation_modulator_j:[0,6],gravitational_radiation_non:0,grb:[0,6],great:[0,6,12,13],greater:[0,6],grevess:[0,6],grid:[0,3,6,8,10,18,19,23,24,28],grid_class:[23,24],grid_cod:19,grid_ensemble_result:19,grid_opt:[5,7,10,11,12,13,14,19],grid_options_default:20,grid_options_defaults_dict:20,grid_options_descript:[5,14,20],grid_options_description_check:20,grid_options_help:20,grid_result:[5,7,11,12,13,21],grid_vari:[14,21],grid_variable_numb:[5,7,14,19],gridcod:21,gridcode_filenam:21,gridtyp:[5,7,14,19],group:[5,11,15,18],grvitation:4,gsl:[23,26],gsl_dir:[23,26],gt:[4,5,6,7,8,10,12,14,15,16,17],guess:[0,2,6],gyr:[4,5,7],gz:19,h5py:[23,26],h:[0,4,6,8],ha:[0,1,4,5,6,7,8,9,11,12,13,14,17,18,19,21],hachisu:[0,6],hachisu_disk_wind:[0,6],hachisu_ignore_qcrit:0,hachisu_qcrit:[0,6],hack:20,had:[5,7,11,12,13,19],half:[0,6],hall:[0,6],handi:[0,6],handl:[0,3,6,10,18,19,21,27,30],happen:[0,5,6,7],hardcod:[8,11,12,13,14],have:[0,2,3,4,5,6,7,8,10,11,12,13,14,17,18,19,20,21,23,25,26],haven:5,hbb:[0,6],hbbtfac:[0,6],hd:25,hdf5:18,hdf5file:18,he:[0,4,6],head:15,header:[1,5,7,8,10,11,12,13,14,17,18],headerlin:14,headlin:21,hegb:[0,4],hehg:0,height:[2,7,11,14],helium:[0,5,6],helium_flash_mass_loss:[0,6],helium_white_dwarf:0,help:[0,3,4,6,10,11,12,13,14,18,20],help_al:[0,6],hem:0,henc:[0,6,7,12,13,15],hendrik:[0,17,23,26],here:[1,5,6,8,10,11,12,13,15,17,18,19,21,25],hertzsprung:[0,3,6,23],hertzsprung_gap:0,hertzstrpung:[0,6],heuvel:[0,6],hewd:[0,6],hewd_hewd_ignition_mass:[0,6],hex:21,hg:[0,6],hi:2,high:[0,2,6,12,13],higher:[0,2,5,6,7,11,12,13,14,18,21,23,26],histogram:7,histori:2,hole:[0,3,5,6,23],home:6,homogen:[0,6],hood:10,hopefulli:[0,6],hot:[0,6],hour:18,how:[0,4,5,6,7,8,10,11,12,13,14,17,19,21],howev:[0,6,8,11,12,13,14],hoyl:[0,6],hpc:[19,22],hpc_function:[23,24],hr:25,hr_diagram:25,hrd:[0,5,6,7],hrdiag:[0,6],hrdiag_output:[0,6],html:[5,14,23,26],http:[0,1,2,5,6,14,18],human:18,hurlei:[0,6],hut:[0,6],hybrid:[0,6],hydro:[0,6],hydrogen:[0,5,6],i:[1,2,4,5,6,7,8,10,11,12,13,14,15,18,19,21,23,26],ia:[0,6,7],ib:[0,4,6],ibc:[0,6],id:[2,19,21],id_cor:8,idea:[14,25],idum:[0,6],ignit:[0,5,6],ignor:[0,6,8,10,14,17,19,21],ii:[0,6,17],iia:[0,6],iloc:[10,17],imf:[0,2,6,12,13],imf_chabrier2003:2,imf_scalo1986:2,imf_scalo1998:2,imf_tinsley1980:2,immedi:[0,5,6],implement:[0,6,19,21],impli:[0,6],implic:[12,13],impos:[5,7,11,12,13,14],imposs:7,improv:[2,28],inclin:[0,6],inclination1:[0,6],inclination2:[0,6],inclination3:[0,6],inclination4:[0,6],inclini:[0,6],incliniation_quadrupl:[0,6],incliniation_tripl:[0,6],includ:[0,1,2,5,6,8,10,12,13,14,15,18,19,23,25,26],include_binary_c_default:[14,19],include_binary_c_help_al:[14,19],include_binary_c_version_info:[14,19],include_default:[14,19],include_popul:14,include_population_set:19,incom:[0,6],increas:[0,4,6,7,11,12,13],inde:[0,6,12,13],indent:[10,19],index:[0,2,6,9,10,15,23],indic:[0,2,6],individu:[3,11,23],individual_nova:[0,6],induc:[0,6],inertia:[0,6],info:[6,9,14,18,19,23,25,26],inform:[0,1,3,5,8,10,11,12,13,14,18,19,20,25],init:19,init_abund:[0,6],init_abund_dex:[0,6],init_abund_mult:[0,6],init_abunds_onli:[0,6],initi:[0,2,3,4,6,9,10,17,19],initial_abundance_hash:19,initial_abundance_mix:[0,6],initial_abunds_onli:[0,6],initial_grid:17,initial_mass:[10,17],initial_tim:17,inlin:17,inner:[0,6,15],input:[1,2,6,9,10,18,19,21,23,25,30],insert:[14,19],insid:[0,6],inspect:[10,25],inspir:[1,25,30],instabl:[0,6],install_without_depend:[23,26],instanc:[10,11,12,13,14],instant:[0,6],instantli:[0,6],instead:[0,4,6,12,13,18,21],integ:[0,5,6,19,21,30],integr:[2,11,12,13,28],integrals_str:2,intens:[12,13],interact:[0,4,5,6,7,15,17,20],interfac:[6,15,18,23,26],interfer:[23,26],intermedi:7,intern:[0,6,9,21],internal_buff:[0,6],internal_buffering_off:0,internal_buffering_print:0,internal_buffering_stor:0,interpol:[2,19,28],interpolate_in_mass_izzard2012:2,interpolator_nam:2,intershel:[0,6],interstellar:[0,6],intger:[0,6],intro:[0,6],introduc:4,introduct:5,inv:[4,17],invers:30,invert_xaxi:5,involv:[0,6],inward:[0,6],ipykernel_216542:15,ipykernel_519112:12,ipynb:[11,12,13,14],is_capsul:18,isfil:14,isn:[12,13,18],isnt:14,isotop:[0,6,9,18],isotope_hash:19,isotope_list:19,item:[1,5,7,11,12,13],iter:18,its:[0,6,11,12,13,14,15,18,19,20,23,25,26,27,28],itself:[5,8,10,21,23,26],iwamoto:[0,6],izzard2012_period_distribut:2,izzard:[0,5,6,7,10,11,12,13,14,23,26],jager:[0,6],jaschek:2,jeff:[23,26],jej:4,jerki:5,jf:4,jia:[0,6],john:[0,6],join:[6,8,10,14,17],jorb_in:4,jorb_out:4,jordi:[0,6],json:[6,10,14,18,19,21],jtot_in:4,jupit:15,jupyt:[23,26],just:[0,2,5,6,7,14,17,18,19,21,23,26,30],k1:[4,10,17],k2:[4,10,17],k:[0,2,5,6,15],kap:[0,6],kappa:[0,6],kaps_rentrop:[0,6],karaka:[0,6],keep:[7,14,19],kei:[1,2,5,9,10,14,15,17,18,19,20,21,25],kelvin:[0,6],keplerian:[0,6],keyword:[12,25,27],kick:[0,4,6,17,21],kick_backward:0,kick_forward:0,kick_inward:0,kick_outward:0,kick_random:0,kick_straight_up:0,kick_velocity_custom:0,kick_velocity_fix:0,kick_velocity_maxwellian:0,kill:[1,8,14],kilonova:5,kim:[0,6],kind:[0,6],kippenhahn:[0,6],klencki:6,km:[0,6],know:[0,1,6,9,10,12,13,20],known:[0,2,5,6,10,11,12,13,14,19,27],kroupa2001:[2,14,19],kroupa:[2,12,13],krticka:[0,6],ktg93:2,kwarg:[17,19,25,27],l1:4,l2:[0,6],l:[0,5,6,11,12,13],l_:[11,12,13],label:[5,17],lambda:[0,4,6,7],lambda_:7,lambda_c:[0,4,6,7],lambda_ce_dewi_tauri:[0,6],lambda_ce_klencki_2020:[0,6],lambda_ce_polytrop:[0,6],lambda_ce_wang_2016:[0,6],lambda_enthalpi:[0,6],lambda_ion:4,lambda_ionis:[0,6],lambda_min:[0,6],lambda_mult:[0,6],lambda_multipli:[0,6],lambda_v:2,lamer:[0,6],landau:[0,6],langer:[0,6],languag:5,larger:[0,5,6],last:[2,3,12,15,17,18],last_st:17,last_stellar_type_change_time_1:17,lastli:[6,10],late:17,later:[11,12,13],latest0:[5,7,11],latest1:[5,7,11],latest2:[5,14],latest3:5,latest4:5,latest5:5,latest:[21,23,26],latter:[0,6],law:[2,12,13],law_const:2,lbv:[0,6],ld_library_path:[23,26],ldist:[12,13],lead:[0,5,6,11,12,13,14,30],learn:8,least:[23,26],leav:[0,6],left:[0,6],legaci:[0,6],legacy_yield:[0,6],legend:[15,17],len:[4,5,10,14,17],length:[4,18],lengthen:[0,6],leq:5,less:[0,1,2,3,4,6],let:[4,7,10,11,12,13,14,15,19],level:[1,5,18,19],li7:[0,6],li:[0,6],lib:[6,10,16,17,23,26],libbinary_c:21,libcustom_logging_0639ee205c7d4782b4a27378f5d890bd:10,libcustom_logging_dafa15d2b1e64e19972ac0e9eb5c9a55:10,libgsl:[23,26],libmemo:[23,26],librari:[0,1,5,6,8,17,19,21,27],library_path:[23,26],librinterpol:[23,26],life:7,lifetim:[0,6,7,11,12,13,14,28],lifshitz:[0,6],like:[0,1,5,6,7,11,12,13,14,17,18,19,21,23,25,26,28],limit:[0,5,6,7,11,12,13,14,25],line:[1,4,5,7,8,10,11,12,13,14,15,16,18,19,21,23,25,26,28],linear2:21,linear:[0,2,6,11,12,13,21,28],linear_extrapolation_q:2,linearli:[12,13,28],linedata:[5,7,11,12,13],lineplot:[5,7,11,12,13,15],linewidth:[5,7,11,12,13,15],linker:1,linspac:28,linux:6,list:[0,1,2,5,6,7,10,11,12,13,14,15,18,19,21,27,28],list_arg:[0,6],list_of_sub_kei:2,lit:[0,6],lithium:[0,6],lithium_gb_post_1dup:[0,6],lithium_gb_post_heflash:[0,6],lithium_hbb_multipli:[0,6],lithium_t:[0,6],littl:[4,5,7,11,15],littleton:[0,6],liu:[0,6],ll:[8,9,12,13,15,19],llnl:[0,6],ln:2,lnm1:[7,11,12,13,14,19],lnm_1:[12,13],load:[0,1,5,6,7,8,10,11,12,13,14,17,19,21,25],load_logfil:18,lobe:[0,4,6,7,30],loc:15,local:[2,6],locat:[0,2,6,21,23,26,28],lock:4,lodder:[0,6],log10:[0,2,5,6,7,11,12,13,14,28],log10m1:21,log10mass:28,log10p:2,log10per:[7,11,14],log10pmin:2,log:[0,1,2,3,4,6,10,15,16,18,19,21,23,25,26,27,28,30],log_:[5,7,11,12,13],log_arg:21,log_args_dir:21,log_arrow:[0,6],log_dt:[7,21],log_every_timestep:[8,10],log_fil:[4,21],log_filenam:[0,4,6,10,17,27],log_runtime_system:21,logarithm:[2,12,13,28],logensembletim:[0,6],logfil:[10,18,23,26],logg:[0,5,6],logger:14,logging_dict:1,logging_lin:[8,16,17],loggrav:5,logi:16,logic:[1,8,19,21],logl:5,logmass:[2,28],logp:2,logper:[2,7],logperiod:2,logperrang:[7,11],logspac:28,logteff:5,long_spectral_typ:2,longer:[0,5,6,7],longnam:[5,7,11,12,13,14,19],look:[1,5,7,11,12,13,14,17,23,26],lookback:[0,6],loon:[0,6],loop:[5,7,10,11,12,13,14,19],loos:25,lose:[0,6,17],loss:[0,4,6,10,11,15],lost:[0,6,7,17],lot:[5,11,12,13,14,15,18,21,27],lovegrov:0,low:[0,2,5,6,7,12,13],low_mass_m:0,low_mass_main_sequ:0,lower:[0,2,6,11,14,19,28],lsoda:[0,6],lsun:[0,6,25],lt:[5,6,7,10,12,14,15,16],lugaro:[0,6],luminos:[0,3,5,6,23,25],luminosity_1:25,luminosity_2:25,luminosu:5,lw:[0,6],lynnett:[0,6],m01:4,m0:2,m1:[0,2,4,6,7,8,10,11,12,13,14,17,19,30],m2:[2,4,7,8,10,11,14,17,19,30],m3:2,m4:2,m:[0,2,4,5,6,7,11,12,13,15,17,30],m_1:[0,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,27],m_2:[0,4,5,6,7,8,10,11,14,16,17],m_3:[0,6],m_4:[0,6],m_:17,m_max:[2,14,19],m_min:[14,19],m_sun:5,maccretor:[0,4,6],machin:[7,21,23,26],macro:[0,6,9,18],madau:2,made:[5,23,26],maeder:[0,6],magellan:[0,6],magnet:[0,6],magnetic_braking_algorithm:[0,6],magnetic_braking_algorithm_andronov_2003:0,magnetic_braking_algorithm_barnes_2010:0,magnetic_braking_algorithm_hurley_2002:0,magnetic_braking_algorithm_rappaport_1983:0,magnetic_braking_factor:[0,6],magnetic_braking_gamma:[0,6],magnitud:18,mai:[0,6,7,11],main:[0,1,5,6,8,11,12,13,14,17,21,23,26],main_sequ:[0,6,11,12,13,17],mainli:22,mainprocess:[5,7,11],major:[0,6],make:[0,1,2,4,5,6,7,10,11,12,13,14,15,17,18,19,21,23,25,26,27],make_build_text:18,makedir:[14,18],manag:[18,23,26],mani:[0,5,6,7,9,11,12,13,14,19,21],manual:8,manufactur:[0,6],map:21,mar:15,maria:[0,6],mass:[0,1,2,3,4,5,6,7,9,10,11,14,15,17,18,19,21,25,27,28,30],mass_1:[14,17,25],mass_2:[14,17,25],mass_accretion_for_eld:[0,6],mass_accretor:30,mass_donor:30,mass_evolut:25,mass_for_hestar_ia_low:[0,6],mass_for_hestar_ia_upp:[0,6],mass_loss_m:17,mass_lost:17,mass_of_pmz:[0,6],mass_rang:17,mass_str:2,massiv:[0,2,3,4,5,6,7,11,15,23],massless:[0,6],massless_remn:0,massloss:0,massrang:[5,7,11,12,13],master:[21,25],match:[0,5,6,10,11,14,15,25],materi:[0,5,6],math:[5,7,11,12,13,14,15,19,28],mathrm:[5,7,11,12,13],matplotlib:[5,7,12,13,15,17,23,25,26],matter:[0,6],mattsson:[0,6],mattsson_mass_loss:[0,6],mattsson_orich_tpagbwind:[0,6],max:[0,2,6,7,8,11,12,13,14],max_bound:[2,28],max_column:[5,7,15],max_evolution_tim:[0,1,5,6,7,8,10,11,12,13,14,15,17,28],max_hewd_mass:[0,6],max_logp:2,max_model_numb:[0,6],max_multipl:2,max_neutron_star_mass:[0,6],max_queue_s:21,max_row:[5,7,15],max_stellar_angmom_chang:[0,6],max_stellar_type_1:[0,6],max_stellar_type_2:[0,6],max_stellar_type_3:[0,6],max_stellar_type_4:[0,6],max_tim:[4,10,17],max_val:2,maxcount:4,maxdm:28,maximum:[0,2,5,6,7,8,11,12,13,14,21,28,30],maximum_mass_ratio_for_instant_rlof:[0,6],maximum_mass_ratio_for_rlof:30,maximum_mcbagb_for_degenerate_carbon_ignit:[0,6],maximum_nuclear_burning_timestep:[0,6],maximum_timestep:[0,6],maximum_timestep_factor:[0,6],maxmimum:[0,6],maxwellian:[0,6],mayb:25,mayor:2,mb:[5,7,11,13,14,18],mc13_pocket_multipli:[0,6],mc1:4,mc:[0,4,6,14,17,19],mch:[0,6],mcmin:[0,6],mdonor:[0,4,6],mean:[0,2,4,6,18,19,21,23,26,28],meant:21,measur:18,medium:[0,6],mega:2,mem:[7,11],mem_us:18,memaddr:[6,8],memori:[1,5,6,7,8,11,13,14,17,18,19,21,30],menv:[0,4,6],mer:4,mercuri:15,merg:[0,2,4,5,6,7,21],merge_dict:9,merge_multipl:2,merger:[0,4,6],merger_angular_momentum_factor:[0,6],merger_mass_loss_fract:[0,6],mesa:[23,26],mesasdk_init:[23,26],mesasdk_root:[23,26],mess:15,messag:18,messi:5,mestel:[0,6],met:[14,19],metal:[0,2,4,5,6,7,8,10,11,12,13,14,15,16,17,30],metallicity_0002:17,metallicity_001:17,metallicity_002:17,method:[0,6,8,10,11,12,13,14,17,19,21],meynet:[0,6],mf1:4,mf2:4,might:[7,11,14,15,19,23,26],milki:[0,6],miller:[0,6],min:[2,7,8,11,12,13,14],min_bound:[2,28],min_logp:2,min_per:2,min_val:2,mind:17,mindm:28,minimal_verbos:18,minimum:[0,2,6,18,21,28,30],minimum_co_core_mass_for_carbon_ignit:[0,6],minimum_co_core_mass_for_neon_ignit:[0,6],minimum_donor_menv_for_comenv:[0,6],minimum_envelope_mass_for_third_dredgeup:[0,6],minimum_helium_ignition_core_mass:[0,6],minimum_mcbagb_for_nondegenerate_carbon_ignit:[0,6],minimum_orbital_period_for_instant_rlof:[0,6],minimum_period_for_rlof:30,minimum_separation_for_instant_rlof:[0,6],minimum_separation_for_rlof:30,minimum_time_between_pn:[0,6],minimum_timestep:[0,6],mint:[0,6],mint_data_cleanup:[0,6],mint_dir:[0,6],mint_disable_grid_load_warn:[0,6],mint_fallback_to_test_data:[0,6],mint_hard_max_nshel:[0,6],mint_hard_min_nshel:[0,6],mint_kippenhahn:[0,6],mint_kippenhahn_companion_stellar_typ:[0,6],mint_kippenhahn_stellar_typ:[0,6],mint_maximum_nshel:[0,6],mint_maximum_shell_mass:[0,6],mint_metal:[0,6],mint_minimum_nshel:[0,6],mint_minimum_shell_mass:[0,6],mint_ms_rejuven:[0,6],mint_nshel:[0,6],mint_nuclear_burn:[0,6],mint_remesh:[0,6],mint_use_zams_profil:[0,6],minut:[7,18],mira:[0,6],misc:[6,23],miscellan:[9,18],miss:[0,6,11,12,13,18,20],mix:[0,6,21],mixtur:[0,6,11],mmax:[2,12,13,28],mmin:[2,12,13,21,28],mnra:30,model:[0,1,5,6,7,8,10,11,12,13,14,15,16,17,21],model_numb:[11,12,13],modif:3,modifi:[0,6,8,23,26],modul:[0,6,7,9,11,12,13,14,15,20,21,24],modulo:21,moe2017_opt:21,moe:[2,14,18,19,23],moe_di_stefano_2017:19,moe_di_stefano_2017_multiplicity_fract:2,moe_di_stefano_2017_pdf:2,moment:[0,5,6,8,14,17,28],momenta:[0,6,25],momentum:[0,6,15],monoton:[12,13],mont:[0,6,21],monte_carlo_kick:[0,6],more:[0,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,21,23,25,26,28],most:[5,6,7,12,13,15,18],mostli:[5,7,11,12,13,14,17,18,20,21,25,27],move:[0,5,6],ms:[0,4,6,8,11],msgpack:19,mstart:4,msun:[0,2,5,6,8,10,11,12,13,15,17,28],mu:[0,6],much:[0,5,6,7,11,14,17,18],multi:21,multipl:[0,2,5,6,21],multiplc:[0,6],multipli:[0,6,12,13,21,28],multiplicity_arrai:2,multiplicity_fraction_funct:21,multiplicity_model:21,multiplicity_modul:21,multiply_values_dict:9,multiprocess:21,must:[0,2,5,6,7,10,11,12,13,14,15,19,28],mw:[0,6],my:10,my_stellar_data:[1,8,14,16,17],myr:[0,5,6,7,10,11,12,13,15,28],n100:[0,6],n100_z0:[0,6],n100h:[0,6],n100l:[0,6],n10:[0,6],n150:[0,6],n1600:[0,6],n1600c:[0,6],n1:[0,6],n200:[0,6],n20:[0,6],n300c:[0,6],n3:[0,6],n40:[0,6],n5:[0,6],n:[0,1,2,4,5,6,7,8,10,11,12,13,14,16,17,18],n_logging_stat:21,naked_helium_star_giant_branch:0,naked_helium_star_hertzsprung_gap:0,naked_main_sequence_helium_star:0,name:[1,4,5,6,7,11,12,13,14,15,17,18,19,20,27,29],nameerror:15,narrow:[12,13],natur:[0,6,12,13],nauenberg:[0,6],nazehdin:0,nb:[0,6],nbinary_c:17,ncol:17,nearer:[0,6],nearest:[7,11,12,13],nebula:[0,6],necessari:[7,14,15,17,18,19],need:[0,2,6,8,10,11,12,13,14,15,17,19,23,26],neg:[0,6,28],neither:[0,6,19],neleman:[0,6],nelemans_gamma:[0,6],nelemans_max_frac_j_chang:[0,6],nelemans_minq:[0,6],nelemans_n_comenv:[0,6],nelemans_recalc_eccentr:[0,6],nemp:[0,6],nemp_cfe_minimum:[0,6],nemp_nfe_minimum:[0,6],nenamg:[0,6],neon:[0,5,6],neptun:15,nest:[14,18,19],network:[0,6,9],neutrn:[0,6],neutron:[0,5,6,14],neutron_star:0,never:[0,5,6,12,13],newer:[0,2,6],newli:[0,6],newnam:19,newopt:2,newton:[0,6],next:[11,12,13,14,18],nice:[1,19,25],nieuwenhuijzen:[0,6],nieuwenhuijzen_windfac:[0,6],nine:5,nmax:2,no_thermohaline_mix:[0,6],noecho:[0,6],noechonow:[0,6],noel:[0,6],nolowq:21,nomin:[0,6],non:[0,6,12,13,21],nonconservative_angmom_gamma:[0,6],none:[0,1,2,4,5,6,7,11,13,14,15,17,18,19,20,21,28,30],nonzero:21,nor:[0,6],norm:21,normal:[0,6,28],normalis:[2,21],normalize_dict:2,normalize_multipl:21,notabl:14,note:[0,4,5,6,11,12,13,14,17,18,19,21,28],notebook:[4,5,6,7,8,9,10,11,12,13,14,15,23,26],notebook_api_funct:10,notebook_bhbh:4,notebook_comenv:7,notebook_custom_log:[10,11,12,13,14],notebook_hrd:5,notebook_individual_system:[8,10,11,12,13,14],notebook_luminos:[12,13],notebook_luminosity_funct:11,notebook_luminosity_function_binari:[12,13],notebook_popul:[10,14],notebook_solar_system:15,noteworthi:3,noth:[19,21],notic:[12,13],notifi:27,nov:[0,17],nova:[0,5,6,7],nova_faml_multipli:[0,6],nova_irradiation_multipli:[0,6],nova_retention_algorithm_claeys2014:0,nova_retention_algorithm_const:0,nova_retention_algorithm_hillman2015:0,nova_retention_fract:[0,6],nova_retention_method:[0,6],nova_timestep_accelerator_index:[0,6],nova_timestep_accelerator_max:[0,6],nova_timestep_accelerator_num:[0,6],now:[0,2,4,5,6,7,8,10,11,12,13,14,15,17,18,19],np:[10,16,17,28],nre:[11,28],nrow:17,ns:[0,1,6,7,8,14],nsep:7,nsep_max:7,nsep_min:7,nstar:[5,11],nuclear:[0,6],nuclear_mass_hash:19,nuclear_mass_list:19,nucleosynthesi:[0,6,18],nucleosynthesis_sourc:[9,18],nucreacmult:[0,6],nucsyn:[6,23],nucsyn_angelou_lithium:[0,6],nucsyn_gce_outflow_check:[0,6],nucsyn_hbb:[0,6],nucsyn_metal:[0,6],nucsyn_network:[0,6],nucsyn_network_error:[0,6],nucsyn_s_process:[0,6],nucsyn_solv:[0,6],nucsyn_third_dredge_up:[0,6],nugi:[0,6],num_ansi_colour:[0,6],num_cor:[5,7,11,12,13,14,21],number:[0,2,4,5,6,7,11,12,13,14,15,17,18,19,20,21,23,26,28],numpi:[10,14,16,17,18,19,23,26,28],o:[2,6,18,23],obj:18,object:[0,3,6,15,18,19,21,22,25],object_parse_funct:10,observ:[11,12,13],obtain:[0,5,7,11,12,13],obvious:8,occur:[0,6,30],odot:[5,7,17],off:[0,4,6,14,17],off_m:[4,10,17],offset:[0,6],oh:4,ohio:[0,6],old:[12,13,19,21],old_solut:[23,26],oldnam:19,omega:[0,4,6,17],onc:[0,6,28],one:[0,6,9,12,13,14,15,16,17,19,21,25,28],onewd:0,onli:[0,5,6,8,11,12,13,14,15,17,18,19,21,28,30],onset:[0,6],onto:[0,2,6],oop:4,opac:[0,6],opacity_algorithm:[0,6],opacity_algorithm_ferguson_op:0,opacity_algorithm_paczynski:0,opacity_algorithm_star:0,opal:[0,6],open:[4,10,14,17],opm:2,opt:[2,4,6],option:[0,1,2,5,6,7,11,12,13,14,15,16,17,18,19,23,24,26,28,30],orb:[7,14,19],orbit:[0,2,4,6,7,11,15,25,30],orbit_evolut:25,orbital_eccentr:15,orbital_inclin:[0,6],orbital_inclinationi:[0,6],orbital_period:[0,4,6,7,8,10,11,14,16,17,30],orbital_period_quadrupl:[0,6],orbital_period_tripl:[0,6],orbital_phas:[0,6],orbital_phase_quadrupl:[0,6],orbital_phase_tripl:[0,6],orbital_separ:15,orbiting_object:[0,6,15],orbiting_objects_close_pc_threshold:[0,6],orbiting_objects_log:[0,6,15],orbiting_objects_tides_multipli:[0,6],orbiting_objects_wind_accretion_multipli:[0,6],order:[3,14,18,19],org:[0,2,6],orient:7,origin:[15,23,26],os:[4,5,7,10,11,12,13,14,15,17,18],other:[0,1,2,5,6,9,10,11,12,13,14,18,20,21,23,25,26],otherwis:[0,6,18,19,20,21],our:[5,7,11,12,13],out:[5,7,8,11,12,13,15,18,20,21],outcom:[0,6],outer:[0,5,6],outermost_core_mass:5,outfil:[14,19],outfile_nam:1,outfilenam:14,output:[1,3,4,6,8,9,10,15,16,17,18,19,21,23,25,26,27,30],output_dict:[5,7,10,11],output_dir:[10,14,19],output_fil:[10,18,19,20],output_filenam:[14,19],output_lin:18,outsid:[0,2,6],outward:[0,6],over:[5,7,9,10,11,12,13,14,18,19],overflow:[0,4,6,7],overrid:[2,17,19,28],overriden:14,overshoot:[0,6],overspin_algorithm:[0,6],overspin_bs:[0,6],overspin_massloss:[0,6],overview:6,own:[8,10,14,16,17,19,21,23,26],oxygen:[0,5,6],oxygen_neon_white_dwarf:0,p0:2,p1:2,p2:2,p3:2,p:[2,5,7,11,12,13,15,20],p_:7,p_in:4,p_out:4,packag:[6,14,18,23,26,28],paczynski:[0,6],pad:[7,11,12,13],pad_output_distribut:[5,7,11,12,13,18],page:[0,5,6,14,23,26],pair:[0,4,18,19],panda:[5,7,10,11,12,13,15,16,17,18,23,25,26],pane:25,panel:[0,6],paper:[0,6],param:[18,19],param_nam:18,paramet:[1,2,3,5,6,7,8,10,11,12,13,14,18,19,20,21,23,25,27,28,30],parameter_nam:[5,6,7,9,11,12,13,14,18,19],parameter_value_input_typ:[9,18],pars:[3,5,7,10,11,12,13,14,17,18,19,25,27],parse_binary_c_version_info:18,parse_cmdlin:19,parse_data:7,parse_funct:[5,7,10,11,12,13,14,19,21,27],parse_function_hr_diagram:25,parse_function_mass:25,parse_function_orbit:25,parse_output:17,parsec:2,part:[2,5,6,10,11,12,13,14,17,19,30],partial:[0,6],particularli:[0,6],pasp:2,pass:[6,8,10,14,15,17,18,19,21,23,25,26,27,28],path:[10,14,17,18,21,23,26],patho:[23,26],pd:[5,7,10,11,12,13,15,16,17],pdf:[0,2,6,17,23,26],peak:[7,12,13,28],peak_normalized_gaussian_func:28,pend:[0,4,6],per:[0,4,6,7,10,11,14,18,19,21,30],percentag:[0,6],peret:[0,6],perfect:[12,13],perfectli:[11,12,13],perform:[0,6],perhap:[0,5,6,7],periastron:[0,6],pericent:30,period:[0,2,4,6,7,8,10,11,12,13,14,15,17,25,30],period_str:2,perl:[1,11,12,13,14],persist:6,persistent_data:6,pgo:[0,6],phase:[0,5,6,7,11,12,13],phasevol:[0,6,14],phdi:0,phi:[4,17],photoevapor:[0,6],php:2,physic:[5,11,12,13,14],pick:25,piec:[14,17,19],pinnsonneault:[0,6],pisn:0,pkg:[23,26],pl:19,place:[0,6,11,18],placehold:25,plai:[0,6,12,13],plan:21,planet:15,planetari:[0,6],plaw2:21,pleas:[0,5,6,11,12,13,14,18],plot:[0,5,6,7,10,11,12,13,15,16,17,25],plot_data:[7,11,12,13],plot_funct:[23,24],plot_hr_diagram:25,plot_hr_diagram_singl:25,plot_mass:25,plot_orbit:25,plot_system:25,plot_typ:25,plt:[5,7,12,13,15,17],plu:[0,6],pluto:15,pm:25,pms_mass_1:25,pms_mass_2:25,pn:[0,6],pn_comenv_transition_tim:[0,6],pn_fast_wind:[0,6],pn_fast_wind_dm_agb:[0,6],pn_fast_wind_dm_gb:[0,6],pn_fast_wind_mdot_agb:[0,6],pn_fast_wind_mdot_gb:[0,6],pn_hall_fading_time_algorithm:[0,6],pn_hall_fading_time_algorithm_maximum:[0,6],pn_hall_fading_time_algorithm_minimum:[0,6],pn_resolv:[0,6],pn_resolve_maximum_envelope_mass:[0,6],pn_resolve_minimum_effective_temperatur:[0,6],pn_resolve_minimum_luminos:[0,6],pne:[0,6],png:17,pogg:[0,6],point:[0,2,5,6,18,19,23,26,28],poisson:[2,21],pol:[0,6],polytrop:[0,6],poor:[12,13],pop:[4,8,15],pop_macro:8,popul:[0,2,3,6,19,20,22,23,26,28],population_id:21,population_nam:[5,7,11,13,14],population_set:19,posit:[0,2,6,7],possibl:[0,1,2,5,6,10,15,18,20,23,26],post:[0,4,5,6,7,8],post_ce_adaptive_menv:[0,6],post_ce_envelope_dm_eagb:[0,6],post_ce_envelope_dm_gb:[0,6],post_ce_envelope_dm_tpagb:[0,6],post_ce_objects_have_envelop:[0,6],post_comenv_period:7,post_sn_orbit_bs:0,post_sn_orbit_method:[0,6],post_sn_orbit_tt98:0,postagb_legacy_log:[0,6],postagb_wind_gi:0,postagb_wind_krticka2020:[0,6],postagb_wind_non:[0,6],postagb_wind_use_gi:[0,6],postagbwind:[0,6],postcod:[5,7,14,19],potenti:[0,6],pow2:5,power:[0,2,6,7,12,13],powerlaw:2,powerlaw_const:2,powerlaw_extrapolation_q:2,ppisn:0,ppisn_additional_massloss:0,ppisn_farmer19:0,ppisn_new_fit_21:0,ppisn_non:0,ppisn_prescript:0,ppn_envelope_mass:[0,6],pragma:8,pre:[0,4,6,7,17,25],pre_comenv_period:7,pre_events_stardata:[0,6],pre_main_sequ:[0,6],pre_main_sequence_fit_lob:[0,6],precod:[5,7,11,12,13,14,19],predefin:[2,11,12,13,14],predict:21,predictor:[0,6],prefer:[0,6,19],prefix:[0,6],prep:0,prepar:2,prepare_dict:2,presc:4,prescrib:[0,6],prescript:[0,4,6,14],prescrit:[0,6],present:[2,5,11,12,13,14,17,19],preserv:[0,6],preset:25,pressur:[0,6],prev_stellar_type_1:14,prev_stellar_type_2:14,prevent:[0,4,5,6,21],previou:[7,12,13,18],previous:[10,14],previous_stardata:[1,7,8,10,14],primari:[1,2,5,7,11,12,13,14,19,30],prime:7,pringl:[0,6],print:[4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21],print_help:[9,18],print_info:20,print_option_descript:20,printf:[1,5,7,8,10,11,12,13,14,16,17],prior:[0,5,6],privat:[19,20,23],prob_dict:2,probability_weighted_mass:21,probabl:[0,1,2,5,6,7,8,11,12,13,14,17,19,20,21,25],probdist:[5,7,11,12,13,14,19],problem:[0,6,11],probtot:[12,13],process:[0,5,6,7,11,12,13,14,16,17,18,19,21],processor:[5,7,11],produc:5,profil:[0,6],progenitor:[0,6,14],program:[5,23,26],progress:18,project:[0,6],proper:[5,8,20],properli:[0,6,19],properti:[0,18,19,21,25],proport:7,prot1:[0,6],prot2:[0,6],prot3:[0,6],prot4:[0,6],provid:[0,2,6,14,19,21,27],pseudorandom:[0,6],psutil:21,publicli:8,puls:[0,5,6,30],pulsat:0,pump:[0,6],purpos:[11,12,13,14,21,25],push:15,push_macro:8,put:[1,5,7,11,12,13,14,17,18,19,21,25],py:[5,7,11,12,13,14,15,23,26],py_rinterpol:[23,26],pyenv:[23,26],pyplot:[5,7,12,13,15,17],pysiz:18,pytest:[23,26],python3:[6,23,26],python:[3,5,7,11,12,13,18,19],q:[0,2,4,6,7,11,14,17,21,30],q_high_extrapolation_method:21,q_interpol:2,q_low_extrapolation_method:21,qc:4,qcrit_bh:[0,6],qcrit_bs:0,qcrit_cheb:[0,6],qcrit_chen_han_formula:0,qcrit_chen_han_t:0,qcrit_cowd:[0,6],qcrit_degenerate_bh:[0,6],qcrit_degenerate_cheb:[0,6],qcrit_degenerate_cowd:[0,6],qcrit_degenerate_eagb:[0,6],qcrit_degenerate_gb:[0,6],qcrit_degenerate_hegb:[0,6],qcrit_degenerate_hehg:[0,6],qcrit_degenerate_hem:[0,6],qcrit_degenerate_hewd:[0,6],qcrit_degenerate_hg:[0,6],qcrit_degenerate_lmm:[0,6],qcrit_degenerate_m:[0,6],qcrit_degenerate_n:[0,6],qcrit_degenerate_onewd:[0,6],qcrit_degenerate_tpagb:[0,6],qcrit_eagb:[0,6],qcrit_gb:[0,6],qcrit_gb_bs:0,qcrit_gb_chen_han_formula:0,qcrit_gb_chen_han_t:0,qcrit_gb_ge2015:0,qcrit_gb_hjellming_webbink:0,qcrit_gb_q_no_comenv:0,qcrit_gb_temmink2021:0,qcrit_gb_vos2018:0,qcrit_ge2015:0,qcrit_hegb:[0,6],qcrit_hehg:[0,6],qcrit_hem:[0,6],qcrit_hewd:[0,6],qcrit_hg:[0,6],qcrit_hjellming_webbink:0,qcrit_lmm:[0,6],qcrit_m:[0,6],qcrit_n:[0,6],qcrit_onewd:[0,6],qcrit_q_no_comenv:0,qcrit_temmink2021:0,qcrit_tpagb:[0,6],qcrit_vos2018:0,qcrits_:[0,6],qcrits_degenerate_:[0,6],qdata:2,qlimit:2,qs:2,quad:21,quadrat:[0,6],quadrulpl:[0,6],quadrupl:[0,2,6,21],quantiti:25,queri:10,queue:[5,7,11,21],quickli:10,quit:[0,5,6,18],r1:[4,10,17],r2:[4,10,17],r:[0,1,4,5,6,10,14,17,23,26],r_l:30,r_sun:5,radau:[0,6],radi:[0,6],radiat:[0,6],radii:[0,6,30],radiu:[0,1,5,6,8,14,16,25,30],radius_1:25,radius_2:25,ragb:30,raghavan2010_binary_fract:2,raghavan:2,rai:[0,6],railton:[0,6],rais:[0,6,14,18,21],ram:[0,6],ran:[5,7,11,21],randbuf:[4,17],random:[0,4,6,17,21],random_count:[4,10,17],random_se:[0,4,6,10,17],random_skip:[0,6],random_system:[0,6],random_systems_se:[0,6],rang:[0,2,5,6,7,10,11,12,13,14,19,21,28],rapid:[0,6],rapidli:[0,6],rappaport:[0,6],rate:[0,2,6,12,13],rather:[0,6,8,10,14,19,21,23,26],ratio:[0,2,5,6,7,11,12,13,14,30],raw:[6,17,18,19,21,25,27],rc:[4,5,7,11,12,13,15,25],re:[0,1,5,6,7,11,12,13,15,20],reach:[0,4,5,6,7],reaction:[0,6],read:[3,4,10,14,17,18],readabl:18,readlin:4,real:[5,11,14,19],realist:[12,13],realiti:[12,13],realli:[0,5,6,14,19,20,21],reason:[0,6,12,13],rebuild:[0,6,23,26],rebuilt:[23,26],recalcul:[0,6],receiv:18,recent:[12,15],recogn:14,recognis:19,recombin:[0,6],recommend:[1,3,23,26],recompil:[11,12,13,14,23,26],recurs:[18,19],red:[0,5,6,12,13,15],redhat:1,redshift:2,reduc:[0,4,6],reduct:21,regardless:25,region:[0,6,28],regist:14,reignit:[0,6],reimer:[0,6],reinstal:[23,26],reject:[0,6],rejects_in_log:[0,6],rejuven:[0,6,11],rel:[0,6],relat:[0,6],releas:[18,23,26],reliabl:6,remain:[0,6,18],rememb:[4,5,12,13],remesh:[0,6],remnant:[0,5,6],remov:[0,6,7,10,14,15,18,19],remove_fil:18,renam:[12,13,19],rename_grid_vari:[12,13,19],renormalis:2,rentrop:[0,6],repeat:[0,6,21],repo:23,report:[0,5,6,7,11,12,13,14],repositori:3,repres:21,represent:[14,19],reproduc:[0,6],requir:[0,2,6,7,10,11,12,13,14,15,17,18,25,27],rerun:5,reset:[0,6],reset_pref:[0,6],reset_star:[0,6],reset_stars_default:[0,6],resolut:[0,5,6,7,11,12,13,14,19,21,28],resolv:[0,6,11],reson:[0,6],resourc:[12,13],respect:[0,2,6],rest:[2,14,19],restructuredtext:18,result:[0,1,2,5,6,7,10,11,12,13,14,17,18,19,21,23,26],result_arrai:2,result_dict:2,result_example_head:17,result_example_header_1:17,result_example_header_2:17,results_dictionari:[5,7,11,12,13],retain:[0,6],rethink:18,return_all_info:19,return_arglin:6,return_binary_c_default:19,return_binary_c_version_info:[9,18,19],return_compilation_dict:1,return_help:6,return_help_al:[6,18],return_maximum_mass_ratio_for_rlof:[6,30],return_minimum_orbit_for_rlof:[6,30],return_persistent_data_memaddr:6,return_population_set:19,return_store_memaddr:6,return_version_info:[6,18],reus:19,revap_in:[0,6],revap_out:[0,6],revers:[0,6,25],reverse_tim:[0,6],revis:[0,18],rewrit:19,rgb:5,rhagavan:21,ri0005:[5,14],rich:[0,6],riello:[0,6],rin:[0,6],ring:[0,6],risk:[14,19],ritter:[0,6],rk2:[0,6],rk4:[0,6],rl1:4,rl2:4,rl:[0,4,6],rlof:[0,4,6,30],rlof_angular_momentum_transfer_model:[0,6],rlof_angular_momentum_transfer_model_bs:0,rlof_angular_momentum_transfer_model_conserv:0,rlof_eccentric_as_circular:[0,6],rlof_entry_threshold:[0,6],rlof_f:[0,6],rlof_interpolation_binary_c:0,rlof_interpolation_bs:0,rlof_interpolation_method:[0,6],rlof_mdot_factor:[0,6],rlof_mdot_modul:[0,6],rlof_method:[0,6],rlof_method_adapt:0,rlof_method_adaptive2:0,rlof_method_bs:0,rlof_method_claei:0,rlof_method_ritt:0,rlof_nonconservative_gamma_donor:0,rlof_nonconservative_gamma_isotrop:0,rlof_radiation_correct:[0,6],rlof_transition_objects_escap:[0,6],rob:[0,2,6,30],robert:[23,26],roch:[0,4,6,7,30],roche_lob:30,rochelob:30,rol1:[4,10,17],rol2:[4,10,17],room:[14,19],root:[23,26],rotat:[0,2,6],rotation:[0,6],rotationally_enhanced_expon:[0,6],rotationally_enhanced_mass_loss:[0,6],rotationally_enhanced_massloss:[0,6],rotationally_enhanced_massloss_angmom:0,rotationally_enhanced_massloss_langer_formula:[0,6],rotationally_enhanced_massloss_langer_formula_and_angmom:0,rotationally_enhanced_massloss_non:0,rough:5,rout:[0,6],routin:[0,3,6,19,23,25],row:[10,17,25],rring:[0,6],rssd:2,rst:[18,20],rsun:[5,25],rubric:19,run:[0,1,3,4,5,6,7,11,12,13,16,18,19,21,23,26,27],run_and_calc_mass:17,run_binary_custom_log:17,run_popul:6,run_system:[4,6,8,9,10,15,16,25,27],run_system_wrapp:[3,4,8,16,23,24],run_zero_probability_system:21,runawai:[4,17],runtim:[1,21],russel:[0,3,6,23],rzam:[4,30],s:[0,2,4,5,6,7,10,12,13,14,15,17,18,19,21,30],safe:14,sai:[0,5,6],said:[0,6],same:[0,6,10,14,19,21,23,26],sampl:[0,2,3,6,11,14,19,28],sample_valu:2,sampler:23,samplerfunc:[5,7,11,12,13,14,19,21,28],sana12:[2,7,11,14],sana:2,saturn:15,save:[0,1,2,5,6,7,8,11,12,13,14],save_ensemble_chunk:21,save_loop:17,save_pre_events_stardata:[0,6],scalar:18,scalo:2,scanf:0,scene:17,scheme:[0,6],schneider:[0,6],schroeder:[0,6],script:[3,8,18,23,26],sdb:[0,6],sdo:[0,6],seaborn:[5,7,11,12,13,15],search:[5,11,15,23],search_for_bhbh:4,second:[0,2,6,7,15,18,19,25],secondari:[2,4,5,11,30],section:[2,6,14,18,22,23,26],see:[0,4,5,6,7,8,9,10,11,12,13,14,17,19,23,25,26],seed:[0,6],seem:[23,25,26],seen:18,segment:28,seitenzahl2013_model:[0,6],seitenzahl:[0,6],select:[0,6,10,11,15,17,18],selected_head:[17,18],selector:[0,6],self:[5,7,10,11,12,13,14,19,21,28],semi:[0,6],sent:[0,6],sentenc:1,sep:[2,4,7,10,11,14,17,19,30],sep_max:[7,11,14],sep_min:[7,11,14],separ:[0,2,4,5,6,8,10,14,15,16,17,19,20,25,30],separation_quadrupl:[0,6],separation_tripl:[0,6],separta:[0,6],seper:14,sepf:4,sequenc:[0,5,6,8,11,12,13,17],sequnec:[11,12,13],seri:[0,6,28],serialis:19,serv:[17,18],server:[17,19],set:[0,1,2,3,4,8,9,10,15,17,18,19,20,21,23,25,26,28],set_context:[5,7,11,12,13,15],set_moe_di_stefano_set:19,set_opt:[2,5,7,15],set_titl:17,set_xlabel:[5,7,11,12,13,15,17],set_ylabel:[5,7,11,12,13,15,17],set_yscal:17,setup:[5,14,27],sever:[9,14,17,20,21,25,27],sfh:2,sh:[23,26],shannon:28,shara:[0,6],share:[1,10,16,17,21,27],shared_lib_filenam:8,shell:[0,6,18],shellular:[0,6],shorten:[0,4,6],shorter:4,shortli:5,should:[0,1,2,4,5,6,7,10,11,12,13,14,17,18,19,20,21,23,25,26,27,28],shouldn:[0,6,18],show:[0,3,4,5,6,7,10,11,12,13,14,17,19,21,25,28],show_plot:25,show_stellar_typ:25,showlist:28,shown:[0,6,25,28],showtabl:28,shrink:[4,7],shrinkagb:10,side:[11,12,13,14],siess:[0,6],sigma:[2,28],signal:[5,7,11],silent:18,sill:[0,6],sim10:7,sim:5,similar:28,simpl:[5,7,11,15],simplest:10,simpli:[0,6,12,13],simul:[0,1,5,6,7,8,11,12,13,14],simulation_:19,sinc:[18,25],singl:[0,2,3,4,5,6,11,12,13,14,17,19,21,25],single_star_lifetim:[6,8,10],sit:[0,6],site:6,situat:6,size:[18,21],skip:[0,5,6,7,11,21],slice:17,sliced_df:17,slightli:6,slope:2,slow:[0,5,6,7,11,12,13],slower:[0,6],slurm:[19,21,22],slurm_grid:19,small:[0,4,6,12,13],small_envelope_method:[0,6],small_envelope_method_bs:0,small_envelope_method_miller_bertolami:0,smaller:[0,6,28],smarter:[12,13],smooth:[5,12,13],smoother:[7,12,13],sn:[0,4,5,6,7,11,12,13,15,17],sn_impulse_liu2015:0,sn_impulse_non:0,sn_impulse_wheeler1975:0,sn_kick_companion_a:[0,6],sn_kick_companion_aic_bh:[0,6],sn_kick_companion_bh_bh:[0,6],sn_kick_companion_bh_n:[0,6],sn_kick_companion_ecap:[0,6],sn_kick_companion_grb_collapsar:[0,6],sn_kick_companion_hestaria:[0,6],sn_kick_companion_ia_chand:[0,6],sn_kick_companion_ia_chand_co:[0,6],sn_kick_companion_ia_eld:[0,6],sn_kick_companion_ia_h:[0,6],sn_kick_companion_ia_he_co:[0,6],sn_kick_companion_ia_hybrid_hecowd:[0,6],sn_kick_companion_ia_hybrid_hecowd_sublumin:[0,6],sn_kick_companion_ibc:[0,6],sn_kick_companion_ii:[0,6],sn_kick_companion_iia:[0,6],sn_kick_companion_ns_n:[0,6],sn_kick_companion_phdi:0,sn_kick_companion_pisn:0,sn_kick_companion_ppisn:0,sn_kick_companion_tz:[0,6],sn_kick_companion_wdkick:[0,6],sn_kick_dispersion_aic_bh:[0,6],sn_kick_dispersion_bh_bh:[0,6],sn_kick_dispersion_bh_n:[0,6],sn_kick_dispersion_ecap:[0,6],sn_kick_dispersion_grb_collapsar:[0,4,6],sn_kick_dispersion_ia_hybrid_hecowd:[0,6],sn_kick_dispersion_ia_hybrid_hecowd_sublumin:[0,6],sn_kick_dispersion_ibc:[0,4,6],sn_kick_dispersion_ii:[0,4,6],sn_kick_dispersion_ns_n:[0,6],sn_kick_dispersion_phdi:0,sn_kick_dispersion_pisn:0,sn_kick_dispersion_ppisn:0,sn_kick_dispersion_tz:[0,6],sn_kick_distribution_aic_bh:[0,6],sn_kick_distribution_bh_bh:[0,6],sn_kick_distribution_bh_n:[0,6],sn_kick_distribution_ecap:[0,6],sn_kick_distribution_grb_collapsar:[0,6],sn_kick_distribution_ia_hybrid_hecowd:[0,6],sn_kick_distribution_ia_hybrid_hecowd_sublumin:[0,6],sn_kick_distribution_ibc:[0,6],sn_kick_distribution_ii:[0,6],sn_kick_distribution_ns_n:[0,6],sn_kick_distribution_phdi:0,sn_kick_distribution_pisn:0,sn_kick_distribution_ppisn:0,sn_kick_distribution_tz:[0,6],sn_none:8,sn_type:8,sneia:[0,6],snia:[0,6],snippet:[6,10],so:[0,2,4,5,6,7,8,10,11,12,13,14,19,21,25],solar:[0,2,3,5,6,7,9,23,30],solver:[0,6],solver_forward_eul:0,solver_predictor_corrector:0,solver_rk2:0,solver_rk4:0,some:[0,1,2,5,6,7,8,9,10,11,12,13,14,17,19,21,23,25,26],someth:[0,5,6,7,10,11,12,13,19],sometim:9,somewhat:[11,12,13,14,15],soon:28,sort:[5,11,12,13,15,18,19],sort_kei:19,sourc:[1,2,7,18,19,20,21,24,25,27,28,30],source_file_filenam:21,source_list:19,sourcecod:[6,8,23,26],sourcefile_nam:1,sp:2,space:[0,5,6,11,12,13,14,19,28],spacing_funct:[23,24],special:[0,6,14],specif:[0,6,9,10,18,25],specifi:[0,6,21,28],spectral:2,speed:[0,6,21],speedtest:[0,6],spent:18,spera:[0,6],spheric:[0,6],spiki:[12,13],spin:[0,6,15],spinrat:[0,6],split:[0,4,6,10,14,15,17,21],split_lin:10,splitlin:[5,6,7,8,10,11,12,13,14,15],splitpoint:[0,6],spread:19,sqrt:[0,6],src:[0,6,8,23,26],st1:17,st2:17,st:4,stabil:[0,6],stabl:[0,6,23,26],stancliff:[0,6],standard:[0,2,6,11,12,13,28],star1:15,star:[1,2,3,4,6,7,8,9,10,11,12,14,15,16,17,21,23,25,28,30],star_with_no_mass:0,starcount:[5,7,11,13,14],stardata:[0,1,5,6,7,8,10,11,12,13,14,16,17],stardata_dump_filenam:[0,6],stardata_load_filenam:[0,6],stardata_t:8,starnum:[5,11],start:[0,1,4,5,6,7,10,11,12,13,14,17,18,19,20,21],start_at:21,start_tim:[0,6],start_timestamp:[5,7,11,13,14],startrack:[0,6],startswith:10,state:[0,6],statement:[1,8,10,11,12,13,14,15,16,17],statist:[0,6],statu:[0,1,5,6,7,11,12,13,14],stderr:[0,6],stdout:[18,28],steadi:[0,6],stefan:25,stefano:[14,18,19,23],stellar:[0,2,3,4,6,13,21,23,25,28,29],stellar_structure_algorithm:[0,6],stellar_structure_algorithm_external_funct:0,stellar_structure_algorithm_mint:0,stellar_structure_algorithm_modified_bs:0,stellar_structure_algorithm_non:0,stellar_typ:[1,5,8,10,11,12,13,14,23,24,25],stellar_type1:4,stellar_type2:4,stellar_type_1:[0,6,14,25],stellar_type_2:[0,6,14,25],stellar_type_3:[0,6],stellar_type_4:[0,6],stellar_type_dict:29,stellar_type_dict_short:29,step:[5,7,8,10,11,12,13,14,19,25,28],stepsiz:[14,19],stick:21,stiff:[0,6],still:[1,8,15,21],stop:[0,5,6,7,11,17,18],stopfil:[0,6],storag:[0,6],store:[0,2,3,5,7,10,11,12,13,14,18,19,21,23,26,30],store_capsul:6,store_memaddr:[6,30],str:[1,4,5,14,18,19,20,25],straight:19,straightforward:[5,11,12,13,14],straniero:[0,6],strength:[0,6],strictli:[11,12,13],string:[0,1,3,6,10,11,12,13,14,15,18,19,20,21,25,27],strip:[0,6,10,15],strong:5,stronger:[0,5,6],struct:[0,6,8],structur:[0,6,7,18,21,25],studi:5,stuff:[10,14,18,21,25],style:[0,6,19],sub:[0,6,18],subject:[0,6],sublumin:[0,6],submit:23,subplot:17,subroutin:22,subsequ:[0,6],succe:[0,6],suddenli:5,suffer:5,suffici:5,suggest:[0,6,23,26],suit:[23,26],suitabl:28,sum:[0,6],sun:15,sundial:[0,6],supercrit:[0,6],superflu:15,supernova:[0,4,6,7,21],superwind:[0,6],superwind_mira_switchon:[0,6],support:19,sure:[2,10,11,12,13,14,19,21,23,25,26,27],surfac:[0,6],surrei:[5,14],surviv:[0,6,15],survivor:[0,6],swallow:15,switcher:[0,6],symlink:[5,7,11,14,21],symmetr:[0,6],synchron:[0,6],synonym:[0,6],synthesi:[11,12,13,14,21,23,26],system:[0,3,5,6,7,8,11,12,13,14,16,17,18,19,21,23,25,26,27],system_dict:19,system_gener:[14,19],system_numb:19,system_queue_fil:[5,7,11],t:[0,1,2,4,5,6,10,12,13,14,18,19,21,28],t_:5,tabl:[0,2,6,28],take:[0,2,6,7,11,14,17,18,19,21,27],taken:[0,6,8],talk:5,target:[1,20],task:[0,2,6,14,17,18,19,20,22,25,27,28,30],tauri:[0,6],tbse:[0,6],technic:[5,7,8,11,12,13,14],teff:[0,2,4,6],teff_1:25,teff_2:25,teff_from_star_struct:5,teff_postagb_max:[0,6],teff_postagb_min:[0,6],tell:18,temp_dir:[4,5,7,10,12,13,14,15,18],temperatur:[0,2,6,15,25],tempfil:17,termin:[1,5,8,14,23,26],test:[0,6,10,14,18,19,21,23,26,30],test_data:[0,6],test_func:6,test_log:17,test_logfil:10,test_pop:14,text:[5,7,15,18,20],than:[0,2,5,6,7,11,12,13,14,18,21,23,26],thats:14,thei:[0,2,4,5,6,7,11,14,15,19,21,25],thelog:[0,6],them:[2,5,6,7,14,16,17,18,19],themselv:2,theoret:[11,12,13],thermal:[0,2,5,6,30],thermally_pulsing_asymptotic_giant_branch:0,thermohalin:[0,6],thermonuclear:5,thesi:[0,6],thi:[0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,23,24,25,26,27,28,30],thick:[0,6],thick_disc_end_ag:[0,6],thick_disc_logg_max:[0,6],thick_disc_logg_min:[0,6],thick_disc_start_ag:[0,6],thin:[0,6],thing:[0,2,5,6,7,11,12,13,14,17,18,19,20,27],think:[0,6,18,19],third:[0,2,6,15,28],third_dup:[0,6],third_dup_multipli:[0,6],thorn:[0,6],those:[5,7,11,12,13,14,17,18,19,23,26],thread:[5,7,11,12,13,18,19,21],thread_id:21,three:[0,2,6,12,13,14],three_part_powerlaw:[2,7,11,12,13,14],threshold:[0,6,18,21],through:[5,6,10,11,12,13,14,19,25,27],throughout:[11,12,13,14,19],thu:28,tidal:[0,4,6],tidal_strength_factor:[0,6],tide:[0,6,15],tides_convective_damp:[0,6],tides_diagnosis_log:6,tides_hurley2002:[0,6],tides_zahn1989:[0,6],tight:17,time:[0,1,2,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,21,23,25,26,28],timedelta:18,timescal:[0,6],timestamp:21,timestep:[0,6,7,8,10,11,12,13],timestep_limit:[0,6],timestep_log:[0,6],timestep_modul:[0,6],timestep_multipli:[0,6],timestep_solver_factor:[0,6],tini:5,tinslei:2,tip:5,titl:[11,20],tmax:28,tmin:28,tmp:[0,5,6,7,10,11,12,13,14,15,18,23,26],tmp_dir:[4,5,7,10,12,13,14,15,19,21],tmp_tabl:2,toasti:15,todo:[0,1,2,4,6,9,14,18,19,20,21,25,27,28,30],toler:[0,6],too:[0,5,6,12,13,15,19,21,23,26,27],took:[5,7,11,13,14,17],top:[0,14,19],topcod:[5,7,14,19],topic:[0,6],torqu:[0,6],total:[0,2,5,6,7,11,12,13,14,17,18,19,21,25],total_count:[5,7,11,13,14],total_mass_run:[5,7,11,13,14],total_prob:[5,7,11,12,13,14],total_probability_weighted_mass_run:[5,7,11,13,14],tout:[0,6,30],tout_pringle_1992_multipli:[0,6],tp:[0,6],tpagb:[0,5,6],tpagb_reimers_eta:[0,6],tpagb_wind_beasor_etal_2020:0,tpagb_wind_bloeck:0,tpagb_wind_goldman_etal_2017:0,tpagb_wind_mattsson:0,tpagb_wind_reim:0,tpagb_wind_rob_cwind:0,tpagb_wind_van_loon:0,tpagb_wind_vw93_karaka:0,tpagb_wind_vw93_karakas_carbon_star:0,tpagb_wind_vw93_orig:0,tpagb_wind_vw93_orig_carbon_star:0,tpagbwind:[0,6],tpagbwindfac:[0,6],tpr:[7,11,19],traceback:[12,15,18],track:[5,21,25],trade:[0,6],trail:28,transfer:[0,5,6],transform:[0,6],transit:[0,6],treat:[0,6,28],trem:18,trigger:[0,6],trio:[11,12,13,14],tripl:[0,2,6,21],truli:[0,6],tupl:[1,5,18,28],turn:[0,4,6,10,14],tutori:[3,23],two:[0,5,6,8,18,19,29,30],txt:[10,14,17,19,23,26,27],type:[0,1,2,4,6,7,10,11,12,13,14,17,18,19,20,21,25,28,29,30],type_chng:[4,10,17],type_ia_mch_supernova_algorithm:[0,6],type_ia_sub_mch_supernova_algorithm:[0,6],typeerror:12,typic:[0,6],ubvri:[0,6],ugriv:[0,6],uk:[5,14],unavail:[0,6],unbound:4,uncom:[10,11,12,13,14,15,19],unction:6,undef:8,under:[10,28],undergo:[0,7],undescrib:20,unexpect:12,uniform:2,union:[2,14,18,19,28,30],uniqu:[14,17,19,21],unit:[0,5,6,9,18,30],univari:[0,6],univers:[5,7],unix:19,unknown:27,unless:[1,19,21],unlik:[12,13],unload:19,unmerg:7,unpars:6,unphys:[4,7,11],unrecogn:[23,26],unresolv:11,unsign:0,unstabl:[0,4,6],until:[0,2,5,6],unus:[0,6,21],unweight:14,up:[0,1,2,3,8,10,15,18,19],updat:[2,12,13,14,19,23,26],update_dict:9,update_grid_vari:[12,13,19],upper:[0,2,6,28],uranu:15,us:[0,1,2,3,9,10,14,18,19,20,21,22,23,25,26,27,28,30],usag:[0,3],use_astropy_valu:25,use_datadir:[14,19],use_fixed_timestep_:[0,6],use_lwn_fallback:0,use_periastron_roche_radiu:[0,6],use_tabular_intershell_abundances_karakas_2012:[0,6],usecas:3,useful_func:[23,24],user:[1,2,8,18,19,20,21,27],usual:[0,2,4,5,6,11,12,13,14,18,19,21],util:[1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,25,27,28,30],v:[4,17,23,26],val:2,valid:[0,2,6,8,18],valu:[0,1,2,5,6,9,10,11,12,13,14,17,18,19,20,21,25,28],value_lin:10,valueerror:14,valuerang:[5,7,11,12,13,14,19],values_arrai:10,van:[0,6],vandenheuvel_log:[0,6],vari:[0,5,6,7,14],variabl:[0,3,5,6,7,18,19,21],variant:[0,6],variou:[0,6],vassiliadi:[0,6],vb1print:19,vb2print:19,vb:4,veloc:[0,2,6],venu:15,verbos:[1,2,5,7,10,11,12,13,14,16,18,19,21,23,26],verbose_print:18,veri:[0,4,5,6,7,8,10,12,13,14,19,28],versa:30,version:[0,6,9,14,18,19,23,26],version_info:18,version_info_dict:9,version_info_str:18,version_onli:[0,6],via:[3,5,6,8,11,12,13,14,19,21,25],vice:30,vink:[0,6],virtual:[23,26],virtualenviron:[23,26],viscos:[0,6],viscou:[0,6],visibl:8,visit:23,vk:[4,17],vn:[4,17],volum:[0,6],vr:[4,17],vrot1:[0,6],vrot2:[0,6],vrot3:[0,6],vrot4:[0,6],vrot_breakup:0,vrot_bs:0,vrot_non_rot:0,vrot_sync:0,vs:[15,25],vw93:[0,6],vw93_eagb_wind_spe:[0,6],vw93_mira_shift:[0,6],vw93_multipli:[0,6],vw93_tpagb_wind_spe:[0,6],vwind:[0,6],vwind_beta:[0,6],vwind_multipli:[0,6],w:[1,10,14,19],wa:[0,2,5,6,9,10,12,13,14,19,21,23,26],wai:[0,6,10,12,13,19,21,25],wang:[0,6],want:[0,2,4,6,7,8,9,11,12,13,14,17,18,19,20,21,23,25,26],warmup_cpu:[0,6],warn:[0,6,10,14],wast:[7,12,13],wave:[0,5,6,7,14],wd:[0,6],wd_accretion_rate_new_giant_envelope_lower_limit_helium_donor:[0,6],wd_accretion_rate_new_giant_envelope_lower_limit_hydrogen_donor:[0,6],wd_accretion_rate_new_giant_envelope_lower_limit_other_donor:[0,6],wd_accretion_rate_novae_upper_limit_helium_donor:[0,6],wd_accretion_rate_novae_upper_limit_hydrogen_donor:[0,6],wd_accretion_rate_novae_upper_limit_other_donor:[0,6],wd_kick:[0,6],wd_kick_at_every_puls:0,wd_kick_at_given_puls:0,wd_kick_direct:[0,6],wd_kick_end_agb:0,wd_kick_first_rlof:0,wd_kick_pulse_numb:[0,6],wd_kick_when:[0,6],wd_sigma:[0,6],wdwd_merger_algorithm:[0,6],wdwd_merger_algorithm_bs:0,wdwd_merger_algorithm_chen2016:0,wdwd_merger_algorithm_perets2019:0,we:[0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,23,26,28],weight:[0,6,12,13,21],weirdli:11,well:[0,6,8,10,11,12,13,21,23,26],went:[12,13],were:[5,7,11,13,14,18],what:[0,1,2,4,5,6,7,8,10,11,12,13,14,17,18,20,21,23,26,27,28],whatev:[0,6,8,17,19,23,26],wheeler:[0,6],when:[0,1,2,5,6,7,9,10,14,15,18,19,20,21,23,26,27,28],whenev:[23,26],where:[0,1,2,5,6,11,12,13,14,18,19,20,21,23,26],whether:[0,2,6,14,18,19,20,21,25,28,30],which:[0,1,2,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20,21,23,26,27,28,30],whichev:21,white:[0,5,6],white_dwarf_cooling_carrasco2014:[0,6],white_dwarf_cooling_mestel:[0,6],white_dwarf_cooling_mestel_modifi:[0,6],white_dwarf_cooling_model:[0,6],white_dwarf_radius_carrasco2014:[0,6],white_dwarf_radius_model:[0,6],white_dwarf_radius_mu:[0,6],white_dwarf_radius_nauenberg1972:[0,6],whole:[6,7,8,19,21],why:7,wide:[4,11,12,13],wider:4,width:[0,6,7],wiggl:[12,13],wind:[0,4,5,6,11],wind_algorithm_binary_c_2020:[0,4],wind_algorithm_hurley2002:0,wind_algorithm_non:[0,4],wind_algorithm_schneider2018:0,wind_angmom_loss_bs:0,wind_angmom_loss_lw:0,wind_angmom_loss_lw_hybrid:0,wind_angmom_loss_spherically_symmetr:0,wind_angular_momentum_loss:[0,6],wind_disc_angmom_fract:[0,6],wind_disc_mass_fract:[0,6],wind_djorb_fac:[0,6],wind_gas_to_dust_ratio:[0,6],wind_lbv_luminosity_lower_limit:[0,6],wind_mass_loss:[0,4,6],wind_multiplier_:[0,6],wind_nieuwenhuijzen_luminosity_lower_limit:[0,6],wind_type_multiplier_:[0,6],within:[0,6,8,9,14,18,19,23,26],without:[2,8,10,12,13,18,19,21],won:[0,6,10],wood:[0,6],wooslei:0,work:[0,6,8,10,11,12,13,17,18,19,23,25,26],would:[0,6,12,13,14,25],wouldn:[14,19],wr:[0,6],wr_wind:[0,6],wr_wind_bs:0,wr_wind_eldridg:0,wr_wind_fac:[0,6],wr_wind_maeder_meynet:0,wr_wind_nugis_lam:0,wrap:[1,8],wrapper:[6,8,10,30],write:[1,4,5,6,7,8,10,11,14,16,17,18,19,20,21,27],write_binary_c_calls_to_fil:[14,19],write_binary_c_parameter_descriptions_to_rst_fil:18,write_ensembl:19,write_grid_options_to_rst_fil:20,write_logfil:6,written:[6,10,14,19,20,21,27],written_data:10,wrlof_mass_transf:[0,6],wrlof_method:[0,6],wrlof_non:0,wrlof_q_depend:0,wrlof_quadrat:0,wrong:[12,13,23,26],wrt:17,wrwindfac:[0,6],wtts2:[0,6],wtts_log:[0,6],www:[0,2,6],x0:2,x1:2,x86_64:6,x:[0,2,5,6,8,10,15,17,18,19,25,28],xlabel:16,xlim:[7,15],xx:15,y:[4,5,15,19,25],year:[0,2,6],year_length_in_dai:7,yet:[0,6,17,18,19,21,25],yield:[0,6,28],ylim:15,you:[0,1,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20,21,23,25,26,28,30],young:[0,6],your:[8,10,16,17,23,26],yourself:[5,7,11,12,13,14,25],yscale:[11,12,13,15],yy:15,z:[0,2,5,6,7,17,19,30],zahn:[0,6],zam:[0,2,3,5,6,11,27,30],zams_collis:30,zams_mass:[5,11,12,13,14],zams_mass_1:14,zams_mass_2:14,zero:[0,1,3,4,5,6,7,13,18,21,23],zero_ag:[5,8,10,11,12,13,14],zero_age_main_sequence_star:[11,12,13],zero_age_main_sequence_starn:11,zero_prob_stars_skip:[5,7,11,13,14],zone:[0,6],zoom:[0,6,28],zoom_dispers:28,zoom_magnitud:28,zoom_magntiud:28,zoom_mean:28,zoomfac_multiplier_decreas:[0,6],zoomfac_multiplier_increas:[0,6],zsolar:2,zytkow:[0,6]},titles:["Binary_c parameters","custom_logging_functions module","distribution_functions module","Example notebooks","Example use case: Binary black hole systems","Example use case: Hertzsprung-Russell diagrams","Tutorial: Using the API functionality of binary_c-python","Example use case: Common-envelope evolution","Tutorial: Using custom logging routines with binary_c-python","Tutorial: Extra features and functionality of binary_c-python","Tutorial: Running individual systems with binary_c-python","Example use case: Zero-age stellar luminosity function in binaries","Example use case: Zero-age stellar luminosity function","Example use case: Massive star luminosity","Tutorial: Running populations with binary_c-python","Example use case: Solar system using the API functionality","<no title>","Binary_c and python example notebook","functions module","grid_class module","Grid options and descriptions","Population grid code options","hpc_functions module","Welcome to binary_c-python\u2019s documentation!","Binarycpython code","plot_functions module","Python module for binary_c","run_system_wrapper module","spacing_functions module","stellar_types module","useful_funcs module"],titleterms:{"case":[4,5,7,11,12,13,15],"function":[6,9,10,11,12,13,14,15,17,18],"public":21,A:[12,13],about:9,ad:[11,12,13,14],after:[23,26],ag:[11,12],algorithm:0,api:[6,8,10,15,17],better:[12,13],binari:[0,4,5,11,17],binary_c:[0,6,8,9,10,14,17,23,26],binarycpython:24,black:4,build:[9,23,26],code:[21,24],common:7,compact:8,content:[3,23],core:17,custom:[8,17],custom_logging_funct:1,descript:20,develop:[23,26],di:21,diagram:5,dictionari:9,directli:8,distribut:[12,13],distribution_funct:2,document:[23,26],envelop:7,environ:[23,26],evolut:[7,8],evolv:[5,7,11,12,13,14],exampl:[3,4,5,6,7,8,9,11,12,13,14,15,17,23,26],extra:9,faq:[23,26],featur:9,free:6,from:[6,8,23,26],full:14,get:[6,9],grid:[5,7,11,12,13,14,20,21],grid_class:19,handl:[5,7,11,12,13,14],help:9,hertzsprung:5,hole:4,hpc_function:22,i:0,indic:23,individu:10,inform:[6,9],initi:[12,13],input:0,instal:[23,26],instruct:[23,26],issu:[23,26],line:17,log:[5,7,8,11,12,13,14,17],luminos:[11,12,13],mass:[8,12,13],massiv:13,misc:0,modif:9,modul:[1,2,18,19,22,23,25,26,27,28,29,30],moe:21,note:[23,26],notebook:[3,17],noteworthi:14,nucsyn:0,o:0,object:[5,7,8,10,11,12,13,14],option:[20,21],other:17,output:[0,5,7,11,12,13,14],paramet:[0,9],pars:9,pip:[23,26],plot_funct:25,popul:[5,7,8,10,11,12,13,14,21],privat:21,python:[6,8,9,10,14,17,23,26],requir:[23,26],routin:8,run:[8,10,14,17],run_binari:17,run_binary_with_log:17,run_system:17,run_system_wrapp:[10,27],russel:5,s:23,sampl:[12,13],sampler:21,script:14,section:0,set:[5,6,7,11,12,13,14],singl:10,solar:15,sourc:[23,26],spacing_funct:28,star:[0,5,13],stefano:21,stellar:[5,7,11,12],stellar_typ:29,store:6,string:8,supernova:8,system:[4,10,15],tabl:23,tutori:[6,8,9,10,14],up:[5,6,7,11,12,13,14],us:[4,5,6,7,8,11,12,13,15,17],usag:[6,8,23,26],useful_func:30,util:17,variabl:[11,12,13,14,23,26],via:[10,23,26],welcom:23,when:8,wrapper:17,zam:[12,13],zero:[11,12]}}) \ No newline at end of file +Search.setIndex({"docnames": ["binary_c_parameters", "custom_logging_functions", "dicts", "ensemble", "example_notebooks", "examples/notebook_BHBH", "examples/notebook_HRD", "examples/notebook_api_functionality", "examples/notebook_common_envelope_evolution", "examples/notebook_custom_logging", "examples/notebook_ensembles", "examples/notebook_extra_features", "examples/notebook_individual_systems", "examples/notebook_luminosity_function_binaries", "examples/notebook_luminosity_function_single", "examples/notebook_massive_remnants", "examples/notebook_population", "examples/notebook_solar_system", "examples/old/basic_example", "examples/old/workshop_example_notebook", "functions", "grid", "grid_options_descriptions", "index", "modules", "plot_functions", "population_extensions/HPC", "population_extensions/Moe_di_Stefano_2017", "population_extensions/analytics", "population_extensions/cache", "population_extensions/condor", "population_extensions/dataIO", "population_extensions/distribution_functions", "population_extensions/grid_logging", "population_extensions/grid_options_defaults", "population_extensions/gridcode", "population_extensions/metadata", "population_extensions/slurm", "population_extensions/spacing_functions", "population_extensions/version_info", "readme_link", "run_system_wrapper", "stellar_types", "useful_funcs"], "filenames": ["binary_c_parameters.rst", "custom_logging_functions.rst", "dicts.rst", "ensemble.rst", "example_notebooks.rst", "examples/notebook_BHBH.ipynb", "examples/notebook_HRD.ipynb", "examples/notebook_api_functionality.ipynb", "examples/notebook_common_envelope_evolution.ipynb", "examples/notebook_custom_logging.ipynb", "examples/notebook_ensembles.ipynb", "examples/notebook_extra_features.ipynb", "examples/notebook_individual_systems.ipynb", "examples/notebook_luminosity_function_binaries.ipynb", "examples/notebook_luminosity_function_single.ipynb", "examples/notebook_massive_remnants.ipynb", "examples/notebook_population.ipynb", "examples/notebook_solar_system.ipynb", "examples/old/basic_example.ipynb", "examples/old/workshop_example_notebook.ipynb", "functions.rst", "grid.rst", "grid_options_descriptions.rst", "index.rst", "modules.rst", "plot_functions.rst", "population_extensions/HPC.rst", "population_extensions/Moe_di_Stefano_2017.rst", "population_extensions/analytics.rst", "population_extensions/cache.rst", "population_extensions/condor.rst", "population_extensions/dataIO.rst", "population_extensions/distribution_functions.rst", "population_extensions/grid_logging.rst", "population_extensions/grid_options_defaults.rst", "population_extensions/gridcode.rst", "population_extensions/metadata.rst", "population_extensions/slurm.rst", "population_extensions/spacing_functions.rst", "population_extensions/version_info.rst", "readme_link.rst", "run_system_wrapper.rst", "stellar_types.rst", "useful_funcs.rst"], "titles": ["Binary_c parameters", "custom_logging_functions module", "dicts module", "ensemble module", "Example notebooks", "Example use case: Binary black hole systems", "Example use case: Hertzsprung-Russell diagrams", "Tutorial: Using the API functionality of binary_c-python", "Example use case: Common-envelope evolution", "Tutorial: Using custom logging routines with binary_c-python", "Tutorial: Generating and handling ensemble data", "Tutorial: Extra features and functionality of binary_c-python", "Tutorial: Running individual systems with binary_c-python", "Example use case: Zero-age stellar luminosity function in binaries", "Example use case: Zero-age stellar luminosity function", "Example use case: Massive star luminosity", "Tutorial: Running populations with binary_c-python", "Example use case: Solar system using the API functionality", "Basic example", "Binary_c and python example notebook", "functions module", "Population class module", "Population grid code options", "Welcome to binary_c-python\u2019s documentation!", "Binarycpython code", "plot_functions module", "Population class extension: HPC module", "Population class extension: Moe_di_Stefano_2017 module", "Population class extension: analytics module", "Population class extension: cache module", "Population class extension: condor module", "Population class extension: dataIO module", "Population class extension: distribution_functions module", "Population class extension: grid_logging module", "Population class extension: grid_options_defaults module", "Population class extension: gridcode module", "Population class extension: metadata module", "Population class extension: slurm module", "Population class extension: spacing_functions module", "Population class extension: version_info module", "Python module for binary_c", "run_system_wrapper module", "stellar_types module", "useful_funcs module"], "terms": {"The": [0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 25, 26, 28, 29, 30, 31, 32, 33, 35, 37, 38, 40, 41], "follow": [0, 7, 9, 16, 19, 20, 22, 25, 32, 38], "chapter": [0, 22, 24], "contain": [0, 1, 2, 3, 7, 11, 12, 13, 14, 15, 16, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42], "all": [0, 1, 2, 3, 6, 7, 8, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 31, 32, 34, 38, 39, 40, 41], "current": [0, 2, 8, 9, 11, 13, 14, 15, 20, 21, 23, 26, 31, 40], "version": [0, 2, 7, 11, 14, 16, 20, 21, 23, 39, 40], "can": [0, 1, 2, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 25, 26, 31, 32, 35, 40, 41, 43], "handl": [0, 2, 3, 4, 7, 12, 20, 21, 22, 23, 26, 27, 35, 36, 39, 41, 43], "along": [0, 22, 23, 34, 40], "descript": [0, 7, 11, 20, 22, 27, 32, 34], "other": [0, 1, 2, 6, 11, 12, 13, 14, 15, 16, 20, 22, 23, 25, 26, 32, 34, 40], "properti": [0, 20, 22, 25, 35], "thi": [0, 1, 2, 3, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43], "inform": [0, 1, 3, 4, 6, 9, 12, 13, 14, 15, 16, 20, 21, 22, 25, 26, 32, 34, 36, 39], "wa": [0, 6, 11, 12, 14, 15, 16, 21, 22, 23, 31, 32, 40], "obtain": [0, 6, 8, 13, 14, 15, 31], "build": [0, 1, 4, 7, 20, 26, 32], "git": [0, 13, 15, 16, 20, 23, 40], "branch": [0, 6, 20, 23, 39, 40], "branch_david": 0, "revis": [0, 39], "6118": 0, "20220617": 0, "8463fa650": 0, "built": [0, 1, 20, 23, 40], "jun": 0, "17": [0, 5, 6, 8, 13, 15, 16, 17, 19], "2022": 0, "23": [0, 5, 13, 14, 16], "20": [0, 5, 6, 8, 9, 13, 14, 15, 16, 17, 19, 38], "34": [0, 5, 6, 7, 8, 9, 12, 13, 14, 16, 17], "metal": [0, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 32, 43], "set": [0, 1, 2, 3, 4, 5, 9, 11, 12, 17, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 37, 38, 39, 40], "e": [0, 2, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 20, 21, 22, 23, 26, 29, 30, 31, 32, 35, 37, 38, 40, 43], "amount": [0, 2, 7], "mass": [0, 1, 2, 4, 5, 6, 7, 8, 11, 12, 13, 16, 17, 19, 20, 22, 25, 32, 35, 38, 39, 41, 43], "matter": [0, 7], "which": [0, 1, 2, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 26, 30, 31, 32, 34, 35, 37, 38, 39, 40, 41, 43], "hydrogen": [0, 6, 7], "helium": [0, 6, 7], "If": [0, 2, 6, 7, 8, 13, 14, 15, 16, 20, 21, 22, 23, 25, 26, 27, 28, 30, 31, 32, 35, 37, 40, 41, 43], "you": [0, 1, 2, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 31, 32, 34, 35, 38, 40, 43], "ar": [0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 25, 29, 30, 31, 32, 34, 35, 37, 38, 39, 40, 43], "us": [0, 1, 2, 3, 4, 11, 12, 16, 20, 21, 22, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 37, 38, 39, 41, 43], "bse": [0, 7, 9, 16, 32], "must": [0, 2, 6, 7, 8, 12, 13, 14, 15, 16, 17, 31, 35, 38], "1e": [0, 7, 8, 9, 12, 13, 19], "4": [0, 1, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 21, 31, 32, 38], "0": [0, 1, 2, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 26, 27, 29, 32, 35, 38, 40, 43], "03": [0, 1, 5, 7, 8, 13], "see": [0, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 19, 21, 22, 23, 25, 29, 31, 32, 35, 39, 40], "also": [0, 4, 5, 6, 7, 8, 9, 13, 14, 15, 16, 19, 20, 21, 22, 23, 26, 28, 31, 34, 39, 40, 43], "nucsyn_metal": [0, 7], "effective_metal": [0, 7, 19], "type": [0, 1, 2, 3, 5, 8, 12, 13, 14, 15, 16, 19, 20, 21, 22, 25, 26, 31, 32, 34, 35, 38, 39, 42, 43], "float": [0, 2, 3, 5, 7, 11, 12, 17, 20, 32, 33, 38, 43], "default": [0, 1, 2, 3, 6, 7, 9, 11, 13, 14, 15, 16, 19, 20, 21, 22, 26, 27, 29, 30, 31, 32, 34, 37, 38, 39, 41], "valu": [0, 1, 2, 3, 6, 7, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 25, 28, 29, 32, 34, 35, 38], "02": [0, 5, 6, 7, 8, 9, 12, 13, 16, 17, 19, 32, 43], "effect": [0, 5, 7, 9, 13, 22, 32], "routin": [0, 2, 4, 7, 23, 25, 41], "like": [0, 1, 6, 7, 8, 13, 14, 15, 16, 19, 20, 22, 23, 25, 31, 38, 40], "schneider": [0, 7], "wind": [0, 5, 6, 7, 13], "loss": [0, 5, 7, 12, 13, 17], "default_to_metal": [0, 7], "1": [0, 1, 2, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 25, 26, 30, 31, 32, 33, 35, 37, 38, 40, 41, 43], "just": [0, 2, 6, 7, 8, 16, 19, 20, 21, 22, 23, 27, 31, 39, 40, 43], "same": [0, 2, 7, 12, 16, 22, 23, 32, 35, 40, 41], "main": [0, 1, 6, 7, 9, 13, 14, 15, 16, 19, 22, 23, 40], "differ": [0, 6, 7, 8, 13, 14, 15, 16, 19, 20, 22, 23, 25, 38, 40], "between": [0, 7, 22, 32, 38], "rang": [0, 6, 7, 8, 12, 13, 14, 15, 16, 22, 32, 35, 38], "valid": [0, 7, 9, 20, 32], "while": [0, 5, 6, 7, 8, 13], "s": [0, 2, 3, 5, 6, 7, 8, 12, 14, 15, 16, 17, 19, 20, 21, 22, 26, 28, 29, 31, 32, 36, 43], "limit": [0, 6, 7, 8, 13, 14, 15, 16, 22, 25], "stellar": [0, 4, 5, 7, 15, 22, 23, 25, 32, 38, 39, 40, 42], "evolut": [0, 1, 4, 5, 6, 7, 12, 13, 14, 15, 16, 19, 22, 23, 25, 38, 40], "so": [0, 2, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 21, 22, 25, 26, 31], "macro": [0, 11, 20, 39], "m_1": [0, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 35, 41], "initi": [0, 4, 5, 7, 11, 12, 19, 21, 32], "one": [0, 2, 7, 11, 14, 15, 16, 17, 18, 19, 22, 25, 29, 31, 34, 38, 41], "solar": [0, 4, 6, 7, 8, 11, 23, 32, 43], "unit": [0, 6, 7, 11, 20, 43], "intern": [0, 7, 11, 22], "index": [0, 7, 11, 12, 16, 17, 22, 23, 26, 32, 35], "m_2": [0, 5, 6, 7, 8, 9, 12, 13, 16, 18, 19], "two": [0, 2, 6, 7, 9, 20, 23, 31, 33, 40, 42, 43], "m_3": [0, 7], "three": [0, 7, 14, 15, 16, 32], "2": [0, 1, 2, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 22, 23, 25, 26, 30, 32, 37, 38, 40], "m_4": [0, 7], "four": [0, 7], "3": [0, 1, 2, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 19, 20, 22, 23, 30, 32, 37, 38, 40], "vrot1": 0, "equatori": 0, "rotat": [0, 32], "veloc": [0, 32], "km": 0, "hurlei": 0, "et": [0, 32, 43], "al": [0, 32, 43], "2000": [0, 5], "2002": 0, "prescript": [0, 5, 16], "sequenc": [0, 6, 9, 13, 14, 15, 19], "truli": 0, "non": [0, 2, 14, 15, 22, 23, 31, 40], "someth": [0, 6, 8, 12, 13, 14, 15, 22, 43], "small": [0, 5, 14, 15], "g": [0, 1, 2, 5, 6, 8, 9, 12, 13, 14, 15, 16, 18, 19, 20, 22, 23, 26, 29, 30, 31, 32, 37, 38, 40], "001": [0, 5], "vrot2": 0, "vrot_bs": 0, "vrot_breakup": 0, "vrot_sync": 0, "vrot_non_rot": 0, "vrot3": 0, "vrot4": 0, "prot1": 0, "prot2": 0, "prot3": 0, "period": [0, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 19, 25, 32, 43], "dai": [0, 5, 8, 9, 12, 13, 16, 19, 32, 43], "prot4": 0, "inclination1": 0, "inclin": 0, "degre": 0, "inclination2": 0, "inclination3": 0, "inclination4": 0, "b_1": 0, "magnet": 0, "field": [0, 23, 40], "gauss": 0, "b_2": 0, "b_3": 0, "b_4": 0, "b_inclination1": 0, "b_inclination2": 0, "b_inclination3": 0, "b_inclination4": 0, "stellar_type_1": [0, 16, 25], "usual": [0, 5, 6, 7, 13, 14, 15, 16, 20, 22, 31, 32], "main_sequ": [0, 13, 14, 15, 19], "note": [0, 5, 6, 13, 14, 15, 16, 19, 20, 22, 26, 31, 35, 38, 39], "onli": [0, 2, 6, 9, 13, 14, 15, 16, 17, 19, 20, 22, 23, 26, 27, 31, 38, 40, 43], "work": [0, 2, 3, 9, 12, 13, 14, 15, 16, 19, 20, 22, 23, 26, 31, 40], "both": [0, 2, 7, 13, 14, 15, 16], "ag": [0, 4, 5, 6, 8, 15, 23, 38], "core_mass": [0, 9], "white": [0, 6], "dwarf": [0, 6, 14, 15], "black": [0, 4, 6, 23], "hole": [0, 4, 6, 23], "neutrn": 0, "integ": [0, 6, 22, 38, 43], "low_mass_m": 0, "ms": [0, 5, 9, 13], "hg": 0, "giant_branch": 0, "cheb": 0, "eagb": [0, 5], "5": [0, 1, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 29, 31, 32, 35], "tpagb": [0, 6], "6": [0, 1, 5, 6, 7, 8, 9, 11, 12, 13, 15, 16, 19, 23, 40], "hem": 0, "7": [0, 1, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 18, 19, 23, 32, 40], "hehg": 0, "8": [0, 3, 5, 6, 8, 9, 12, 13, 14, 15, 16, 19, 31, 32], "hegb": [0, 5], "9": [0, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 19, 23, 40], "hewd": 0, "10": [0, 2, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 22, 32, 38, 41], "cowd": 0, "11": [0, 5, 6, 8, 9, 12, 13, 15, 16, 17, 19], "onewd": 0, "12": [0, 5, 6, 9, 12, 13, 15, 16, 17, 19, 20, 32], "ns": [0, 1, 8, 9, 16], "13": [0, 5, 6, 8, 9, 12, 13, 15, 16, 17, 19], "bh": [0, 5, 8], "14": [0, 5, 6, 9, 12, 13, 15, 16, 17, 19], "massless_remn": 0, "15": [0, 5, 8, 9, 12, 13, 14, 15, 16, 17, 19, 22, 32], "low_mass_main_sequ": 0, "hertzsprung_gap": 0, "first_giant_branch": 0, "core_helium_burn": 0, "early_asymptotic_giant_branch": 0, "thermally_pulsing_asymptotic_giant_branch": 0, "naked_main_sequence_helium_star": 0, "naked_helium_star_hertzsprung_gap": 0, "naked_helium_star_giant_branch": 0, "helium_white_dwarf": 0, "carbon_oxygen_white_dwarf": 0, "oxygen_neon_white_dwarf": 0, "neutron_star": 0, "black_hol": 0, "star_with_no_mass": 0, "stellar_type_2": [0, 16, 25], "stellar_type_3": 0, "stellar_type_4": 0, "max_stellar_type_1": 0, "maximum": [0, 6, 7, 8, 9, 13, 14, 15, 16, 22, 32, 38, 43], "stop": [0, 6, 8, 13, 19, 20, 22], "when": [0, 1, 2, 3, 6, 7, 8, 11, 12, 16, 17, 20, 22, 23, 26, 28, 29, 30, 31, 32, 34, 37, 38, 40, 41], "reach": [0, 5, 6, 8], "neg": [0, 2, 38], "massless": 0, "remnant": [0, 6], "allow": [0, 2, 9, 18, 19, 22, 23, 29, 32, 40], "absolut": [0, 20, 38], "16": [0, 5, 8, 13, 14, 15, 17, 19, 32], "max_stellar_type_2": 0, "max_stellar_type_3": 0, "max_stellar_type_4": 0, "probabl": [0, 1, 2, 6, 8, 9, 13, 14, 15, 16, 19, 21, 22, 25, 31, 32, 34, 35], "weight": [0, 14, 15, 22], "appli": 0, "base": [0, 2, 3, 8, 13, 14, 15, 16, 20, 21, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 43], "sai": [0, 6], "function": [0, 1, 2, 3, 4, 5, 6, 8, 9, 18, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43], "run": [0, 1, 4, 5, 6, 7, 8, 13, 14, 15, 18, 20, 21, 22, 26, 28, 30, 32, 35, 37, 41, 43], "grid": [0, 4, 12, 20, 21, 23, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 43], "simul": [0, 1, 6, 8, 9, 13, 14, 15, 16, 37], "sum": [0, 2], "should": [0, 1, 2, 5, 6, 8, 12, 13, 14, 15, 16, 19, 20, 22, 23, 25, 26, 30, 31, 32, 34, 37, 38, 40, 41], "phasevol": [0, 16], "system": [0, 4, 6, 7, 8, 9, 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 25, 32, 33, 36, 40, 41, 43], "phase": [0, 6, 8, 13, 14, 15], "volum": 0, "binary_grid": 0, "null": [0, 6, 7, 8, 20], "stellar_structure_algorithm": 0, "structur": [0, 2, 8, 20, 22, 25], "modifi": [0, 2, 9, 23, 40], "none": [0, 1, 2, 3, 5, 6, 7, 8, 13, 14, 15, 16, 17, 19, 20, 21, 22, 26, 27, 29, 30, 31, 32, 34, 35, 37, 38, 43], "extern": 0, "defin": [0, 1, 16, 17, 21, 25, 32, 35], "call": [0, 1, 2, 11, 12, 14, 15, 16, 17, 20, 21, 22, 25, 26, 30, 31, 33, 35, 37, 38, 39, 41], "code": [0, 1, 6, 8, 9, 12, 13, 14, 15, 16, 18, 19, 21, 25, 30, 31, 32, 34, 35, 37, 38, 41, 43], "yet": [0, 2, 19, 20, 22, 25], "implement": [0, 2, 22], "stellar_structure_algorithm_modified_bs": 0, "stellar_structure_algorithm_non": 0, "stellar_structure_algorithm_external_funct": 0, "stellar_structure_algorithm_mint": 0, "solver": 0, "forward": 0, "euler": 0, "could": [0, 3, 14, 15, 16, 19, 20, 39], "rk2": 0, "rk4": 0, "predictor": 0, "corretor": 0, "solver_forward_eul": 0, "solver_rk2": 0, "solver_rk4": 0, "solver_predictor_corrector": 0, "max_evolution_tim": [0, 1, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 19, 38], "myr": [0, 6, 8, 12, 13, 14, 15, 17, 38], "15000": [0, 5, 7, 9, 12, 16, 17, 19], "max_model_numb": 0, "number": [0, 2, 3, 5, 6, 8, 13, 14, 15, 16, 17, 19, 20, 21, 22, 26, 31, 32, 33, 34, 35, 38], "model": [0, 1, 6, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 22], "ignor": [0, 2, 9, 12, 16, 19, 22, 32, 35], "monte_carlo_kick": 0, "turn": [0, 2, 3, 5, 12, 16, 20], "mont": [0, 22], "carlo": [0, 22], "sn": [0, 5, 6, 8, 13, 14, 15, 17, 19], "kick": [0, 5, 19, 22], "On": [0, 16, 20, 31], "true": [0, 2, 3, 5, 6, 8, 11, 13, 14, 15, 16, 18, 19, 20, 21, 22, 25, 26, 28, 30, 31, 34, 35, 37, 38, 39], "inde": [0, 14, 15], "broken": 0, "fals": [0, 3, 5, 6, 8, 13, 14, 15, 16, 17, 20, 21, 22, 25, 26, 28, 29, 30, 31, 35, 37, 38, 39], "disable_debug": 0, "disabl": [0, 16], "debug": [0, 5, 6, 8, 13, 14, 15, 16, 22, 33], "ha": [0, 1, 2, 5, 6, 8, 9, 11, 13, 14, 15, 16, 19, 20, 22, 28, 31, 35], "an": [0, 2, 3, 6, 7, 8, 11, 12, 13, 14, 15, 16, 19, 20, 22, 23, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 41], "requir": [0, 3, 8, 12, 13, 14, 15, 16, 17, 19, 20, 22, 25, 26, 32, 41], "rebuild": [0, 22, 23, 26, 40], "timestep_log": 0, "timestep": [0, 8, 9, 12, 13, 14, 15], "log": [0, 1, 4, 5, 7, 12, 17, 18, 20, 22, 23, 25, 31, 32, 33, 35, 38, 40, 41, 43], "rejects_in_log": 0, "show": [0, 4, 5, 6, 7, 8, 12, 13, 14, 15, 16, 19, 22, 25, 38], "reject": 0, "vandenheuvel_log": 0, "van": 0, "den": 0, "heuvel": 0, "custom_timeout_tim": 0, "custom": [0, 1, 2, 3, 4, 6, 7, 8, 12, 13, 14, 15, 16, 20, 21, 22, 23, 25, 32, 41], "timeout": 0, "time": [0, 1, 2, 3, 5, 6, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 25, 28, 31, 32, 33, 38], "compil": [0, 1, 9, 16, 19, 23, 40], "david_custom_timeout": 0, "100": [0, 5, 6, 8, 13, 14, 15, 32, 38], "evolution_split": 0, "split": [0, 5, 12, 16, 17, 19, 22, 30, 37], "evolutionari": [0, 12], "splitpoint": 0, "supernova": [0, 5, 8, 22], "occur": [0, 43], "disable_ev": 0, "whether": [0, 7, 16, 20, 21, 22, 25, 30, 31, 32, 34, 37, 38, 39, 43], "new": [0, 2, 6, 8, 12, 13, 14, 15, 16, 20, 21, 26, 31, 32, 35], "event": [0, 5, 6], "we": [0, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 26, 27, 28, 29, 30, 31, 32, 34, 37, 38, 40, 43], "evolution_splitting_sn_eccentricity_threshold": 0, "threshold": [0, 20, 22], "eccentr": [0, 7, 9, 12, 13, 14, 15, 16, 17, 19, 25, 32, 43], "abov": [0, 6, 9, 12, 14, 15, 16, 20, 21, 32], "happen": [0, 6, 8], "01": [0, 5, 6, 8, 9, 13, 16, 19], "evolution_splitting_sn_n": 0, "evolution_splitting_maxdepth": 0, "max": [0, 8, 9, 13, 14, 15, 16, 22, 32], "equation_of_state_algorithm": 0, "equat": 0, "state": [0, 31], "paczynski": 0, "equation_of_state_paczynski": 0, "opacity_algorithm": 0, "opac": 0, "ferguson": 0, "opal": 0, "opacity_algorithm_paczynski": 0, "opacity_algorithm_ferguson_op": 0, "opacity_algorithm_star": 0, "wind_mass_loss": [0, 5], "2018": [0, 1, 5], "sander": 0, "wink": 0, "2020": 0, "lbv": 0, "unsign": 0, "wind_algorithm_non": [0, 5], "wind_algorithm_hurley2002": 0, "wind_algorithm_schneider2018": 0, "wind_algorithm_binary_c_2020": [0, 5], "wind_algorithm_hendriks_2022": 0, "extra": [0, 4, 16, 22, 23, 33, 35, 41], "gbwind": 0, "first": [0, 2, 6, 8, 12, 13, 14, 15, 16, 17, 20, 23, 26, 31, 32, 40, 43], "red": [0, 6, 14, 15, 17], "giant": [0, 6, 17], "reimer": 0, "choos": [0, 6, 8, 9, 13, 19, 25, 26, 31], "gb_reimers_eta": 0, "rate": [0, 14, 15, 32], "schroeder": 0, "cuntz": 0, "2005": [0, 5], "gb_wind_reim": 0, "gb_wind_schroeder_cuntz_2005": 0, "gb_wind_goldman_etal_2017": 0, "gb_wind_beasor_etal_2020": 0, "postagbwind": 0, "special": [0, 16], "post": [0, 5, 6, 8, 9, 21], "A": [0, 2, 4, 16, 29, 43], "gb": 0, "postagb_wind_use_gi": 0, "mean": [0, 5, 20, 22, 23, 30, 32, 37, 38, 40], "whatev": [0, 9, 19, 20, 21, 23, 26, 31, 40], "prescrib": 0, "option": [0, 1, 2, 6, 8, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 26, 27, 29, 31, 32, 34, 35, 38, 40, 43], "includ": [0, 1, 2, 6, 9, 12, 14, 15, 16, 17, 20, 21, 23, 25, 31, 32, 40], "postagb_wind_non": 0, "postagb_wind_krticka2020": 0, "krticka": 0, "kub\u00e1t": 0, "krtickov\u00e1": 0, "635": [0, 13], "a173": 0, "postagb_wind_gi": 0, "teff_postagb_min": 0, "minimum": [0, 7, 20, 22, 32, 38, 39, 43], "temperatur": [0, 17, 25, 32], "teff_postagb_max": 0, "6000": 0, "k": [0, 6, 17, 32], "120000": 0, "mattsson_orich_tpagbwind": 0, "experiment": [0, 20], "mattsson": 0, "oxygen": [0, 6], "rich": 0, "mattsson_mass_loss": 0, "magnetic_braking_factor": 0, "multipli": [0, 2, 14, 15, 22, 38], "brake": 0, "angular": [0, 17, 25], "momentum": [0, 17], "magnetic_braking_gamma": 0, "gamma": 0, "factor": [0, 2, 22, 38], "rappaport": 0, "style": [0, 20, 33], "express": [0, 20], "magnetic_braking_algorithm": 0, "andronov": 0, "pinnsonneault": 0, "sill": 0, "2003": [0, 32], "barn": 0, "kim": 0, "2010": [0, 22, 32], "magnetic_braking_algorithm_hurley_2002": 0, "magnetic_braking_algorithm_andronov_2003": 0, "magnetic_braking_algorithm_barnes_2010": 0, "magnetic_braking_algorithm_rappaport_1983": 0, "helium_flash_mass_loss": 0, "lost": [0, 8, 19], "flash": 0, "multipl": [0, 2, 6, 22, 32], "cf": 0, "eta": [0, 8, 13], "formula": [0, 20], "4e": [0, 19], "8e": 0, "gbwindfac": 0, "tpagbwindfac": 0, "eagbwindfac": 0, "nieuwenhuijzen_windfac": 0, "nieuwenhuijzen": 0, "de": [0, 5], "jager": 0, "tpagbwind": 0, "dure": [0, 5, 19], "karaka": 0, "vassiliadi": 0, "wood": 0, "1993": 0, "bloecker": 0, "loon": 0, "rob": [0, 32, 43], "c": [0, 1, 5, 7, 9, 12, 16, 23, 40, 41], "variant": 0, "respect": [0, 30, 32, 37], "goldman": 0, "2017": [0, 13, 16, 22, 32], "beasor": 0, "tpagb_wind_vw93_karaka": 0, "tpagb_wind_vw93_orig": 0, "tpagb_wind_reim": 0, "tpagb_wind_bloeck": 0, "tpagb_wind_van_loon": 0, "tpagb_wind_rob_cwind": 0, "tpagb_wind_vw93_karakas_carbon_star": 0, "tpagb_wind_vw93_orig_carbon_star": 0, "tpagb_wind_mattsson": 0, "tpagb_wind_goldman_etal_2017": 0, "tpagb_wind_beasor_etal_2020": 0, "eagbwind": 0, "vw93": 0, "eagb_wind_bs": 0, "eagb_wind_goldman_etal_2017": 0, "eagb_wind_beasor_etal_2020": 0, "wind_gas_to_dust_ratio": 0, "ga": 0, "dust": 0, "ratio": [0, 6, 7, 8, 13, 14, 15, 16, 32, 43], "calcul": [0, 2, 6, 8, 13, 14, 15, 16, 20, 22, 28, 32, 35, 43], "typic": 0, "200": [0, 5], "milki": 0, "wai": [0, 2, 12, 14, 15, 21, 22, 26], "500": [0, 5], "magellan": 0, "cloud": 0, "approxim": [0, 6, 8], "mw": 0, "vwind_multipli": 0, "vwind_beta": 0, "beta": 0, "speed": [0, 29], "where": [0, 1, 2, 6, 13, 14, 15, 16, 20, 22, 23, 26, 28, 31, 32, 34, 38, 40], "vwind": 0, "sqrt": 0, "escap": 0, "125": [0, 5, 16], "from": [0, 2, 3, 5, 6, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 25, 26, 30, 31, 32, 35, 37, 39, 43], "superwind_mira_switchon": 0, "In": [0, 2, 6, 8, 9, 11, 12, 13, 14, 15, 16, 19, 22, 31, 38], "agb": [0, 6], "superwind": 0, "given": [0, 1, 3, 7, 13, 14, 15, 18, 19, 20, 21, 22, 26, 29, 30, 31, 32, 35, 37, 38, 41, 43], "mira": 0, "vari": [0, 6, 8, 16], "switch": 0, "vw93_mira_shift": 0, "depend": [0, 6, 20, 22, 23, 25, 32, 40], "plu": 0, "offset": 0, "vw93_multipli": 0, "tpagb_reimers_eta": 0, "tout_pringle_1992_multipli": 0, "tout": [0, 43], "pringl": 0, "1992": 0, "artificial_mass_accretion_r": 0, "d": [0, 1, 5, 6, 8, 9, 12, 13, 16, 17, 20, 38], "constant": [0, 2, 14, 15, 25, 32, 38], "accret": [0, 5], "n": [0, 1, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 18, 19, 20, 22, 26, 32], "scanf": 0, "artificial_mass_accretion_rate_by_stellar_typ": 0, "artificial_angular_momentum_accretion_r": 0, "artificial_orbital_angular_momentum_accretion_r": 0, "orbit": [0, 5, 7, 8, 13, 17, 25, 32, 43], "artificial_accretion_start_tim": 0, "artifici": 0, "artificial_accretion_ignor": 0, "artificial_accretion_end_tim": 0, "end": [0, 5, 20, 22, 28, 32], "wr_wind": 0, "massiv": [0, 4, 5, 6, 8, 13, 17, 23, 32], "wr": 0, "maeder": 0, "meynet": 0, "nugi": 0, "lamer": 0, "john": 0, "eldridg": 0, "vink": 0, "earli": [0, 23, 40], "lynnett": 0, "drai": 0, "thesi": 0, "wr_wind_bs": 0, "wr_wind_maeder_meynet": 0, "wr_wind_nugis_lam": 0, "wr_wind_eldridg": 0, "wr_wind_fac": 0, "wrwindfac": 0, "synonym": 0, "instead": [0, 5, 14, 15, 20, 22], "bh_prescript": [0, 5], "prescrit": 0, "relat": 0, "newli": 0, "form": [0, 6, 7, 8, 13, 14, 15, 16, 21, 26, 31, 34, 39], "its": [0, 2, 3, 13, 14, 15, 16, 17, 20, 22, 23, 25, 26, 27, 31, 34, 38, 39, 40, 41], "progenitor": [0, 16], "co": [0, 5], "core": [0, 6, 8, 13, 14, 15, 16, 22, 25], "bh_hurley2002": 0, "bh_belczynski": [0, 5], "belczynski": 0, "bh_spera2015": 0, "spera": 0, "2015": [0, 5], "bh_fryer12_delai": 0, "fryer": 0, "2012": [0, 32], "delai": [0, 22], "bh_fryer12_rapid": [0, 5], "rapid": 0, "bh_fryer12_startrack": 0, "startrack": 0, "ppisn_prescript": 0, "pulsat": 0, "pair": [0, 2, 5, 20, 35, 39], "instabl": 0, "undergo": [0, 8], "ppisn": 0, "pisn": 0, "flag": [0, 1, 21, 22, 31, 38, 39], "binary_c_paramet": [0, 6, 13, 14, 15, 16], "h": [0, 5, 9, 20], "farmer": 0, "2019": [0, 5, 19], "hendrik": [0, 19, 23, 40], "21": [0, 1, 5, 6, 13, 16, 19], "prep": 0, "fit": [0, 2, 12, 32, 43], "data": [0, 3, 4, 5, 6, 7, 8, 12, 13, 14, 15, 16, 17, 19, 20, 22, 23, 26, 27, 31, 32, 35, 41, 43], "ppisn_non": 0, "ppisn_farmer19": 0, "ppisn_new_fit_21": 0, "ppisn_additional_massloss": 0, "addit": 0, "massloss": 0, "top": [0, 16, 35], "result": [0, 1, 2, 3, 6, 8, 12, 13, 14, 15, 16, 19, 20, 22, 23, 26, 31, 32, 38, 40], "posit": [0, 2, 8, 32], "ppisn_core_mass_range_shift": 0, "shift": 0, "taken": [0, 2, 9, 32], "account": [0, 22, 32], "remov": [0, 2, 8, 12, 16, 17, 20, 21], "lower": [0, 13, 16, 32, 35, 38], "higher": [0, 6, 8, 13, 14, 15, 16, 20, 22, 23, 32, 40], "ppisn_massloss_multipli": 0, "p": [0, 6, 8, 13, 14, 15, 17, 32, 34], "THe": [0, 21], "affect": [0, 6], "use_lwn_fallback": 0, "nazehdin": 0, "lovegrov": 0, "wooslei": 0, "envelop": [0, 4, 5, 6, 23], "eject": [0, 8, 17], "fail": [0, 6, 8, 13, 14, 16, 20, 22, 23, 31, 40], "sn_kick_distribution_ii": 0, "distribut": [0, 2, 4, 8, 13, 16, 20, 26, 27, 32, 38], "ii": [0, 19], "collaps": 0, "fix": [0, 5, 12, 20, 21, 25, 31, 32, 33], "maxwellian": 0, "kick_velocity_fix": 0, "kick_velocity_maxwellian": 0, "kick_velocity_custom": 0, "sn_kick_distribution_ecap": 0, "electron": 0, "captur": [0, 20], "sn_kick_distribution_ns_n": 0, "neutron": [0, 6, 16], "surviv": [0, 17], "merger": [0, 5], "sn_kick_distribution_ibc": 0, "born": [0, 6, 13, 14, 15], "after": [0, 6, 8, 9, 13, 14, 15, 16, 21, 22, 31, 35, 38], "ib": [0, 5], "sn_kick_distribution_grb_collapsar": 0, "collapsar": 0, "sn_kick_distribution_tz": 0, "death": 0, "thorn": 0, "zytkow": 0, "object": [0, 2, 3, 4, 7, 11, 17, 20, 21, 22, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41], "sn_kick_distribution_aic_bh": 0, "induc": 0, "sn_kick_distribution_bh_bh": 0, "sn_kick_distribution_bh_n": 0, "sn_kick_distribution_ia_hybrid_hecowd": 0, "ani": [0, 3, 12, 16, 20, 21, 23, 26, 32, 35, 39, 40], "survivor": 0, "hybrid": 0, "he": [0, 5], "snia": 0, "explos": [0, 5, 6, 19], "sn_kick_distribution_ia_hybrid_hecowd_sublumin": 0, "sublumin": 0, "sn_kick_distribution_ppisn": 0, "sn_kick_distribution_pisn": 0, "sn_kick_distribution_phdi": 0, "phdi": 0, "sn_kick_dispersion_ii": [0, 5], "dispers": [0, 38], "190": [0, 5, 19], "sn_kick_dispersion_ecap": 0, "sn_kick_dispersion_ns_n": 0, "sn_kick_dispersion_ibc": [0, 5], "sn_kick_dispersion_grb_collapsar": [0, 5], "sn_kick_dispersion_tz": 0, "sn_kick_dispersion_aic_bh": 0, "sn_kick_dispersion_bh_bh": 0, "sn_kick_dispersion_bh_n": 0, "sn_kick_dispersion_ia_hybrid_hecowd": 0, "sn_kick_dispersion_ia_hybrid_hecowd_sublumin": 0, "sn_kick_dispersion_ppisn": 0, "sn_kick_dispersion_pisn": 0, "sn_kick_dispersion_phdi": 0, "sn_kick_companion_ia_h": 0, "algothim": 0, "companion": [0, 5, 19, 31], "ia": [0, 8], "liu": 0, "wheeler": 0, "1975": 0, "sn_impulse_non": 0, "sn_impulse_liu2015": 0, "sn_impulse_wheeler1975": 0, "sn_kick_companion_ia_eld": 0, "eld": 0, "sub": [0, 2, 20], "mch": 0, "sn_kick_companion_ia_chand": 0, "sn_kick_companion_a": 0, "sn_kick_companion_ecap": 0, "sn_kick_companion_ia_he_co": 0, "sn_kick_companion_ia_chand_co": 0, "sn_kick_companion_ns_n": 0, "sn_kick_companion_grb_collapsar": 0, "grb": 0, "rapidli": [0, 23, 40], "ibc": 0, "sn_kick_companion_hestaria": 0, "sn_kick_companion_ibc": 0, "sn_kick_companion_ii": 0, "sn_kick_companion_iia": 0, "iia": 0, "sn_kick_companion_wdkick": 0, "wd": 0, "sn_kick_companion_tz": 0, "sn_kick_companion_aic_bh": 0, "sn_kick_companion_bh_bh": 0, "merg": [0, 2, 5, 6, 8, 22, 26, 31, 32, 33], "sn_kick_companion_bh_n": 0, "sn_kick_companion_ia_hybrid_hecowd": 0, "sn_kick_companion_ia_hybrid_hecowd_sublumin": 0, "sn_kick_companion_ppisn": 0, "sn_kick_companion_pisn": 0, "sn_kick_companion_phdi": 0, "wd_sigma": 0, "thei": [0, 2, 5, 6, 8, 13, 16, 17, 21, 22, 25, 26, 30, 37, 38], "zero": [0, 1, 4, 5, 6, 8, 15, 20, 22, 23, 31], "wd_kick": 0, "wd_kick_direct": 0, "direct": [0, 21], "random": [0, 5, 7, 19, 22], "up": [0, 1, 4, 9, 12, 17, 20, 21, 26, 27, 29, 30, 32, 37], "backward": 0, "inward": 0, "outward": 0, "kick_random": 0, "kick_straight_up": 0, "kick_forward": 0, "kick_backward": 0, "kick_inward": 0, "kick_outward": 0, "wd_kick_when": 0, "decid": [0, 2, 9, 18, 19, 20, 21, 22, 26], "birth": 0, "rlof": [0, 5, 7, 43], "puls": [0, 6, 43], "wd_kick_pulse_numb": 0, "everi": [0, 8, 20, 22, 23, 40], "wd_kick_end_agb": 0, "wd_kick_first_rlof": 0, "wd_kick_at_given_puls": 0, "wd_kick_at_every_puls": 0, "desir": 0, "pre": [0, 5, 8, 16, 19, 25], "minimum_helium_ignition_core_mass": 0, "ignit": [0, 6], "case": [0, 2, 4, 7, 16, 20, 22, 23, 26, 31, 38, 40], "strip": [0, 7, 12, 17], "make": [0, 1, 2, 3, 5, 6, 8, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 25, 26, 30, 31, 32, 40, 41, 43], "sdb": 0, "sdo": 0, "total": [0, 2, 6, 8, 13, 14, 15, 16, 19, 20, 22, 25, 32, 35], "minimum_co_core_mass_for_carbon_ignit": 0, "carbon": [0, 5, 6], "assum": [0, 6, 8, 13, 17, 25, 38], "mc": [0, 5, 16, 19, 31], "bagb": 0, "6msun": 0, "around": [0, 9, 12, 18, 19], "08msun": 0, "pol": 0, "1998": [0, 5, 32], "08": [0, 5, 8, 13, 19], "minimum_co_core_mass_for_neon_ignit": 0, "neon": [0, 6], "42msun": 0, "have": [0, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 25, 26, 30, 31, 34, 37, 40, 41], "explod": [0, 5], "electon": 0, "42": [0, 5, 8, 13, 16], "minimum_mcbagb_for_nondegenerate_carbon_ignit": 0, "degener": 0, "25msun": 0, "25": [0, 5, 8, 13, 19], "maximum_mcbagb_for_degenerate_carbon_ignit": 0, "max_neutron_star_mass": 0, "befor": [0, 2, 5, 6, 8, 13, 14, 15, 16, 21, 22, 23, 31, 32, 40], "2msun": 0, "chandrasekhar_mass": 0, "chandrasekhar": 0, "44msun": 0, "38": [0, 5, 8, 13, 16], "delta_mcmin": 0, "reduc": [0, 5], "third": [0, 17, 32, 38], "dredg": 0, "As": [0, 6, 8, 12, 13, 14, 15, 16], "izzard": [0, 6, 8, 13, 15, 23, 40], "2004": [0, 5], "increas": [0, 5, 8, 13, 14, 15], "henc": [0, 8, 14, 15, 17], "lambda_min": 0, "effici": [0, 6, 8], "lambda": [0, 5, 8], "lambda_mult": 0, "impli": 0, "onc": [0, 38], "mcmin": 0, "lambda_multipli": 0, "minimum_envelope_mass_for_third_dredgeup": 0, "straniero": 0, "suggest": [0, 23, 40], "5msun": 0, "howev": [0, 9, 13, 14, 15, 16], "circumstanti": 0, "evid": 0, "2009": 0, "well": [0, 3, 9, 12, 13, 14, 15, 22, 23, 40], "newer": [0, 2, 23, 40], "stancliff": 0, "low": [0, 6, 8, 14, 15, 32], "nearer": 0, "more": [0, 1, 3, 4, 5, 6, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 38, 40], "appropri": [0, 16, 22, 26, 29, 30, 31, 35, 37], "mass_of_pmz": 0, "partial": 0, "mix": [0, 2, 22], "zone": 0, "tabl": [0, 32, 38], "ask": [0, 7, 43], "abat": 0, "detail": [0, 6, 12, 20, 22], "seri": [0, 38], "paper": 0, "2013": 0, "2014": [0, 5, 32], "use_tabular_intershell_abundances_karakas_2012": 0, "c13_eff": 0, "intershel": 0, "region": [0, 38], "process": [0, 6, 8, 13, 14, 15, 16, 18, 19, 20, 21, 22, 26, 30], "gallino": 0, "busso": 0, "lugaro": 0, "provid": [0, 16, 21, 22, 23, 26, 32, 40, 41], "maria": 0, "nucsyn_s_process": 0, "mc13_pocket_multipli": 0, "tides_convective_damp": 0, "tidal": [0, 5], "convect": 0, "damp": 0, "tides_hurley2002": 0, "zahn": 0, "197x": 0, "timescal": 0, "hut": 0, "tides_zahn1989": 0, "1989": [0, 13], "e2_prescript": 0, "how": [0, 2, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 19, 22, 28, 32, 35], "e2": 0, "siess": 0, "e2_hurley_2002": 0, "e2_izzard": 0, "e2_mint": 0, "dtfac": 0, "decreas": 0, "hbbtfac": 0, "modul": [0, 7, 8, 11, 13, 14, 15, 16, 17, 22, 24], "hot": 0, "bottom": [0, 16, 35], "burn": 0, "wind_multiplier_": 0, "specifi": [0, 22, 26, 38], "intger": 0, "By": [0, 6, 13, 14, 15, 16, 19, 22], "wind_type_multiplier_": 0, "pre_main_sequ": 0, "rather": [0, 2, 9, 12, 16, 20, 22, 26, 39], "fraction": [0, 13, 19, 22, 32], "radii": [0, 43], "match": [0, 2, 6, 12, 13, 16, 17, 22, 25, 29], "railton": 0, "pre_main_sequence_fit_lob": 0, "forc": [0, 5, 22, 28], "roch": [0, 5, 8, 43], "lobe": [0, 5, 8, 43], "done": [0, 2, 5, 6, 13, 14, 15, 16, 19, 22, 23, 31, 40], "small_envelope_method": 0, "method": [0, 9, 11, 12, 13, 14, 15, 16, 19, 21, 22, 27, 31, 33, 34, 35, 39], "determin": [0, 7, 9, 13, 14, 15, 16, 21, 32, 35, 43], "radiu": [0, 1, 6, 9, 16, 18, 25, 43], "veri": [0, 5, 6, 7, 8, 9, 12, 14, 15, 16, 31, 35, 38], "thin": 0, "miller": 0, "bertolami": 0, "2016": 0, "small_envelope_method_bs": 0, "small_envelope_method_miller_bertolami": 0, "timestep_modul": 0, "global": [0, 2, 13, 14, 15, 20, 32, 38], "timestep_multipli": 0, "maximum_timestep": 0, "zoomfac_multiplier_decreas": 0, "zoomfac_multiplier_increas": 0, "zoom": [0, 38], "succe": 0, "maximum_timestep_factor": 0, "subsequ": 0, "maximum_nuclear_burning_timestep": 0, "nuclear": 0, "nova_retention_method": 0, "retain": 0, "nova": [0, 6, 8], "nova_retention_fract": 0, "pend": [0, 5], "nova_retention_algorithm_const": 0, "nova_retention_algorithm_claeys2014": 0, "nova_retention_algorithm_hillman2015": 0, "mint_metal": 0, "mint": 0, "It": [0, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 19, 22, 23, 31, 34, 40], "normal": [0, 2, 21, 26, 38, 39], "gaia_teff_binwidth": 0, "log10": [0, 6, 8, 13, 14, 15, 16, 32, 38], "bin": [0, 8, 13, 14, 15, 20, 22, 23, 38, 40], "width": [0, 8, 20], "gaia": [0, 32], "hrd": [0, 6, 8], "gaia_l_binwidth": 0, "luminos": [0, 4, 6, 23, 25], "gaia_colour_transform_method": 0, "select": [0, 3, 12, 13, 17, 19, 20], "transform": [0, 3], "colour": 0, "scheme": 0, "gaia_conversion_ubvri_univariate_jordi2010": 0, "jordi": 0, "univari": 0, "ubvri": 0, "gaia_conversion_ubvri_bivariate_jordi2010": 0, "bivari": 0, "gaia_conversion_ugriz_univariate_jordi2010": 0, "gaia_conversion_ugriz_bivariate_jordi2010": 0, "ugriv": 0, "gaia_conversion_ubvri_univariate_evans2018": 0, "evan": 0, "dr2": 0, "gaia_conversion_ugriz_univariate_evans2018": 0, "gaia_conversion_ubvri_riello2020": 0, "riello": 0, "dr3": 0, "gaia_conversion_ugriz_riello2020": 0, "rotationally_enhanced_mass_loss": 0, "enabl": [0, 7], "rotation": 0, "enhanc": 0, "langer": 0, "rotationally_enhanced_massloss_langer_formula": 0, "rotationally_enhanced_expon": 0, "rotationally_enhanced_massloss_non": 0, "rotationally_enhanced_massloss_angmom": 0, "rotationally_enhanced_massloss_langer_formula_and_angmom": 0, "agb_core_algorithm": 0, "overshoot": 0, "agb_core_algorithm_default": 0, "agb_core_algorithm_hurlei": 0, "agb_core_algorithm_karaka": 0, "agb_radius_algorithm": 0, "agb_radius_algorithm_default": 0, "agb_radius_algorithm_hurlei": 0, "agb_radius_algorithm_karaka": 0, "agb_luminosity_algorithm": 0, "agb_luminosity_algorithm_default": 0, "agb_luminosity_algorithm_hurlei": 0, "agb_luminosity_algorithm_karaka": 0, "agb_3dup_algorithm": 0, "agb_third_dredge_up_algorithm_default": 0, "agb_third_dredge_up_algorithm_hurlei": 0, "agb_third_dredge_up_algorithm_karaka": 0, "agb_third_dredge_up_algorithm_stancliff": 0, "overspin_algorithm": 0, "what": [0, 1, 2, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 19, 22, 23, 26, 32, 34, 38, 39, 40, 41], "do": [0, 1, 2, 5, 6, 7, 8, 9, 11, 13, 14, 15, 16, 19, 21, 22, 23, 25, 26, 31, 32, 34, 38, 40, 43], "breakup": 0, "overspin_bs": 0, "conserv": 0, "transfer": [0, 6, 22], "back": [0, 2, 5], "overspin_massloss": 0, "rotationally_enhanced_massloss": 0, "lose": [0, 19], "carri": 0, "awai": [0, 13], "expon": [0, 20], "power": [0, 8, 14, 15, 22, 23, 32, 40], "rais": [0, 2, 14, 16, 20, 22], "batchmod": 0, "control": [0, 6, 13, 14, 15, 16, 22], "variabl": [0, 4, 6, 7, 8, 20, 22, 30, 31, 35], "know": [0, 1, 2, 7, 12, 14, 15, 22, 31, 34], "speedtest": 0, "off": [0, 5, 16, 19, 22], "use_fixed_timestep_": 0, "boolean": [0, 2, 7, 20, 21, 22, 25, 39, 43], "task": [0, 19, 20, 21, 25, 26, 29, 32, 38, 41, 43], "perform": [0, 31], "For": [0, 2, 9, 12, 13, 14, 15, 25], "binary_c_macro": 0, "particularli": 0, "binary_c_task_": 0, "orbiting_object": [0, 17], "usag": [0, 4], "spinrat": 0, "central_object": 0, "orbiting_objects_log": [0, 17], "orbiting_objects_wind_accretion_multipli": 0, "orbiting_objects_close_pc_threshold": 0, "close": [0, 5, 8, 14, 15, 17, 31], "percentag": 0, "orbiting_objects_tides_multipli": 0, "torqu": 0, "evaporate_escaped_orbiting_object": 0, "evapor": 0, "rlof_transition_objects_escap": 0, "otherwis": [0, 2, 20, 21, 22, 26, 28, 30, 31, 34, 37], "place": [0, 2, 13, 20, 22], "outsid": [0, 32], "stabl": [0, 23, 40], "pn_resolv": 0, "shorten": [0, 5], "resolv": [0, 13, 31], "better": [0, 2, 4, 7, 16, 26, 30, 31, 37, 43], "pn": 0, "pn_resolve_minimum_luminos": 0, "resolut": [0, 6, 8, 13, 14, 15, 16, 22, 35, 38], "pne": 0, "31": [0, 5, 7, 8, 13, 19], "62": [0, 5, 13], "pn_resolve_maximum_envelope_mass": 0, "below": [0, 4, 6, 7, 8, 9, 13, 14, 15, 16, 22, 32], "pn_resolve_minimum_effective_temperatur": 0, "12500": 0, "pn_fast_wind": 0, "fast": 0, "pn_fast_wind_dm_gb": 0, "pn_fast_wind_mdot_gb": 0, "06": [0, 5, 8, 9, 12, 13], "pn_fast_wind_dm_agb": 0, "pn_fast_wind_mdot_agb": 0, "hewd_hewd_ignition_mass": 0, "reignit": 0, "wind_nieuwenhuijzen_luminosity_lower_limit": 0, "activ": [0, 22, 23, 40], "4e3": 0, "lsun": [0, 25], "4000": [0, 13], "wind_lbv_luminosity_lower_limit": 0, "6e5": 0, "600000": 0, "num_ansi_colour": 0, "extend": [0, 8, 23, 39, 40], "ansi": [0, 20], "255": [0, 5], "src": [0, 7, 9, 23, 40], "ansi_colour": 0, "int": [0, 1, 2, 5, 7, 13, 16, 20, 21, 22, 26, 32, 33, 34, 35, 38, 43], "apply_darwin_radau_correct": 0, "darwin": 0, "radau": 0, "correct": [0, 12, 21, 23, 25, 32, 33, 40, 43], "moment": [0, 6, 9, 16, 19, 38], "inertia": 0, "take": [0, 2, 8, 13, 16, 19, 20, 22, 27, 31, 32, 35, 41], "degenerate_core_merger_nucsyn": 0, "degner": 0, "energi": 0, "gener": [0, 1, 4, 6, 7, 8, 9, 12, 13, 15, 16, 18, 19, 20, 21, 22, 25, 26, 31, 32, 34, 35, 38], "nucleosynthesi": [0, 39], "whole": [0, 8, 9, 21, 22], "disrupt": [0, 5, 19], "degenerate_core_helium_merger_ignit": 0, "r": [0, 1, 5, 6, 12, 16, 19, 23, 31, 40], "degenerate_core_merger_dredgeup_fract": 0, "separ": [0, 3, 5, 6, 7, 9, 12, 16, 17, 18, 19, 25, 31, 32, 43], "actual": [0, 3, 6, 8, 9, 12, 13, 14, 15, 16, 21, 22, 23, 25, 30, 32, 38, 40], "semi": 0, "major": 0, "axi": [0, 25], "indic": [0, 32], "want": [0, 2, 3, 5, 8, 9, 13, 14, 15, 16, 19, 20, 22, 23, 25, 26, 31, 32, 34, 35, 40], "either": [0, 2, 3, 13, 14, 15, 16, 19, 21, 22, 35, 39, 41], "separation_tripl": 0, "tripl": [0, 22, 32], "separation_quadrupl": 0, "quadrupl": [0, 22, 32], "orbital_period": [0, 5, 7, 8, 9, 12, 13, 16, 18, 19, 43], "orbital_period_tripl": 0, "orbital_period_quadrupl": 0, "outer": [0, 6], "quadrulpl": 0, "eccentricity_tripl": 0, "eccentricity_quadrupl": 0, "inclini": 0, "orbital_inclin": 0, "rel": 0, "incliniation_tripl": 0, "incliniation_quadrupl": 0, "orbital_inclinationi": 0, "orbital_phas": 0, "orbital_phase_tripl": 0, "orbital_phase_quadrupl": 0, "argument_of_periastron": 0, "argument": [0, 2, 7, 12, 16, 17, 18, 19, 20, 21, 22, 26, 27, 32, 39, 41], "periastron": 0, "argument_of_periastron_tripl": 0, "argument_of_periastron_quadrupl": 0, "disc_timestep_factor": 0, "natur": [0, 14, 15], "disc": [0, 17], "white_dwarf_cooling_model": 0, "cool": [0, 6], "white_dwarf_cooling_mestel": 0, "mestel": 0, "white_dwarf_cooling_mestel_modifi": 0, "white_dwarf_cooling_carrasco2014": 0, "carrasco": 0, "white_dwarf_radius_model": 0, "perhap": [0, 6, 8, 21], "white_dwarf_radius_nauenberg1972": 0, "nauenberg": 0, "1972": 0, "white_dwarf_radius_mu": 0, "mu": 0, "white_dwarf_radius_carrasco2014": 0, "cbdisc_mass_loss_inner_viscous_accretion_method": 0, "inner": [0, 17], "edg": [0, 6, 16, 35], "circumbinari": 0, "goe": [0, 2, 9, 12, 25], "young": 0, "clark": 0, "gerosa": 0, "50": [0, 5, 8, 13, 14, 15, 16], "cbdisc_mass_loss_inner_viscous_accretion_method_young_clarke_2015": 0, "cbdisc_mass_loss_inner_viscous_accretion_method_gerosa_2015": 0, "cbdisc_mass_loss_inner_viscous_accretion_method_equ": 0, "cbdisc_mass_loss_inner_viscous_accretion_method_non": 0, "cbdisc_inner_edge_strip": 0, "cbdisc_end_evolution_after_disc": 0, "cbdisc_no_wind_if_cbdisc": 0, "cbdisc_outer_edge_strip": 0, "disc_n_monte_carlo_guess": 0, "guess": [0, 32], "try": [0, 2, 5, 8, 12, 13, 14, 15, 16, 23, 26, 31, 35, 40], "list": [0, 1, 2, 3, 6, 8, 12, 13, 14, 15, 16, 17, 20, 22, 23, 26, 29, 32, 35, 38, 40, 41], "disc_log": 0, "disc_log_level_non": 0, "disc_log_level_norm": 0, "disc_log_level_subtimestep": 0, "disc_log_level_normal_first_disc_onli": 0, "disc_log_level_subtimestep_first_disc_onli": 0, "disc_log2d": 0, "2d": 0, "disc_log_dt": 0, "disc_log_directori": 0, "directori": [0, 4, 16, 20, 21, 22, 23, 26, 29, 30, 31, 34, 37, 40], "sent": 0, "exist": [0, 2, 6, 16, 19, 22, 26, 31, 34, 35], "string": [0, 1, 2, 3, 4, 7, 12, 13, 14, 15, 16, 17, 20, 21, 22, 25, 26, 30, 31, 34, 35, 37, 39, 41], "tmp": [0, 6, 8, 12, 13, 14, 15, 16, 17, 20, 23, 40], "post_ce_adaptive_menv": 0, "post_ce_objects_have_envelop": 0, "ce": [0, 8], "sit": 0, "insid": 0, "post_ce_envelope_dm_gb": 0, "post_ce_envelope_dm_eagb": 0, "post_ce_envelope_dm_tpagb": 0, "common": [0, 4, 5, 6, 9, 12, 13, 14, 15, 16, 23], "need": [0, 2, 7, 9, 12, 13, 14, 15, 16, 17, 19, 22, 23, 26, 32, 40, 43], "mai": [0, 8, 13, 31], "unstabl": [0, 5], "mani": [0, 6, 7, 8, 11, 13, 14, 15, 16, 22, 30], "cee": [0, 8], "pn_comenv_transition_tim": 0, "transit": 0, "year": [0, 32], "1e2": 0, "move": [0, 6], "teff": [0, 5, 32], "30e4": 0, "hall": 0, "minimum_time_between_pn": 0, "planetari": 0, "nebula": 0, "detect": [0, 5, 8, 17], "prevent": [0, 5, 6, 22], "trigger": 0, "pn_hall_fading_time_algorithm": 0, "45msun": 0, "fade": 0, "pn_hall_fading_time_algorithm_minimum": 0, "pn_hall_fading_time_algorithm_maximum": 0, "shown": [0, 25, 38], "fig": [0, 19, 32], "ppn_envelope_mass": 0, "cbdisc_eccentricity_pumping_method": 0, "variou": 0, "pump": 0, "cbdisc_eccentricity_pumping_non": 0, "cbdisc_eccentricity_pumping_dermin": 0, "cbdisc_viscous_photoevaporative_coupl": 0, "viscou": 0, "photoevapor": 0, "coupl": [0, 4], "cbdisc_viscous_photoevaporative_coupling_non": 0, "cbdisc_viscous_photoevaporative_coupling_inst": 0, "instant": 0, "cbdisc_viscous_photoevaporative_coupling_visc": 0, "slow": [0, 6, 8, 13, 14, 15], "cbdisc_inner_edge_stripping_timescal": 0, "long": [0, 6, 8, 16, 22, 28, 31, 35, 39, 42], "revap_in": 0, "disc_stripping_timescale_inst": 0, "disc_stripping_timescale_infinit": 0, "disc_stripping_timescale_visc": 0, "disc_stripping_timescale_orbit": 0, "cbdisc_outer_edge_stripping_timescal": 0, "revap_out": 0, "cbdisc_viscous_l2_coupl": 0, "l2": 0, "gravitational_radiation_model": 0, "gravit": [0, 6, 8, 16], "radiat": 0, "landau": 0, "lifshitz": 0, "1951": [0, 14], "gravitational_radiation_bs": 0, "gravitational_radiation_bse_when_no_rlof": 0, "gravitational_radiation_non": 0, "gravitational_radiation_landau_lifshitz": 0, "gravitational_radiation_landau_lifshitz_when_no_rlof": 0, "nova_irradiation_multipli": 0, "radi": 0, "shara": 0, "1986": [0, 32], "gravitational_radiation_modulator_j": 0, "wave": [0, 6, 8, 16], "gravitational_radiation_modulator_": 0, "nova_faml_multipli": 0, "friction": 0, "rlof_angular_momentum_transfer_model": 0, "rlof_angular_momentum_transfer_model_bs": 0, "rlof_angular_momentum_transfer_model_conserv": 0, "post_sn_orbit_method": 0, "tauri": 0, "post_sn_orbit_bs": 0, "post_sn_orbit_tt98": 0, "singl": [0, 4, 5, 6, 7, 13, 14, 15, 18, 19, 21, 22, 23, 25, 26, 32, 40], "accretion_limit_eddington_steady_multipli": 0, "steadi": 0, "eddington": 0, "spheric": 0, "symmetr": 0, "known": [0, 6, 12, 13, 14, 15, 16, 21, 32, 41], "trade": 0, "anyth": [0, 13, 14, 15, 16, 20, 22, 38], "greater": 0, "than": [0, 2, 6, 8, 13, 14, 15, 16, 20, 22, 23, 26, 31, 32, 39, 40], "potenti": 0, "give": [0, 5, 8, 20, 21, 32, 43], "super": 0, "accretion_limit_eddington_lmms_multipli": 0, "accretion_limit_eddington_wd_to_remnant_multipli": 0, "onto": [0, 32], "anoth": [0, 26], "accretion_limit_thermal_multipli": 0, "accretor": [0, 5, 43], "thermal": [0, 6, 32, 43], "accretion_limit_dynamical_multipli": 0, "dynam": 0, "donor_limit_envelope_multipli": 0, "donor": [0, 5, 43], "per": [0, 5, 8, 12, 13, 16, 20, 22, 31, 43], "donor_limit_thermal_multipli": 0, "donor_limit_dynamical_multipli": 0, "bondi_hoyle_accretion_factor": 0, "bondi": 0, "hoyl": 0, "littleton": 0, "multiplc": 0, "tidal_strength_factor": 0, "strength": 0, "tide": [0, 17], "stronger": [0, 6], "hachisu_qcrit": 0, "critic": 0, "q": [0, 5, 8, 13, 16, 19, 22, 32, 43], "maccretor": [0, 5], "mdonor": [0, 5], "hachisu": 0, "disk": [0, 21], "hachisu_ignore_qcrit": 0, "hachisu_disk_wind": 0, "materi": [0, 6], "too": [0, 2, 6, 7, 14, 15, 17, 22, 23, 40, 41], "help": [0, 5, 7, 11, 12, 13, 14, 15, 16, 20, 34], "sneia": 0, "mass_accretion_for_eld": 0, "lit": 0, "deton": 0, "wdwd_merger_algorithm": 0, "peret": 0, "chen": 0, "todo": [0, 1, 2, 5, 10, 11, 16, 20, 21, 22, 25, 26, 30, 31, 32, 33, 34, 37, 38, 39, 41, 43], "wdwd_merger_algorithm_bs": 0, "wdwd_merger_algorithm_perets2019": 0, "wdwd_merger_algorithm_chen2016": 0, "type_ia_mch_supernova_algorithm": 0, "yield": [0, 38], "dd7": 0, "iwamoto": 0, "1999": 0, "seitenzahl": 0, "3d": 0, "hydro": 0, "seitenzahl2013_model": 0, "One": [0, 22], "n1": 0, "n3": 0, "n5": 0, "n10": 0, "n20": 0, "n40": 0, "n100l": 0, "n100": 0, "n100h": 0, "n150": 0, "n200": 0, "n300c": 0, "n1600": 0, "n1600c": 0, "n100_z0": 0, "type_ia_sub_mch_supernova_algorithm": 0, "unus": [0, 22], "max_hewd_mass": 0, "merger_mass_loss_fract": 0, "merger_angular_momentum_factor": 0, "spin": [0, 17], "smaller": [0, 38], "wind_angular_momentum_loss": 0, "lw": 0, "specif": [0, 11, 12, 25, 30, 37], "wind_djorb_fac": 0, "wind_angmom_loss_bs": 0, "wind_angmom_loss_lw": 0, "wind_angmom_loss_lw_hybrid": 0, "wind_angmom_loss_spherically_symmetr": 0, "vw93_eagb_wind_spe": 0, "vw93_tpagb_wind_spe": 0, "use_periastron_roche_radiu": 0, "circular": [0, 5], "treat": [0, 38], "properli": 0, "hopefulli": 0, "qcrit_lmm": 0, "stabil": 0, "overflow": [0, 5, 8], "qcrits_": 0, "qcrits_degenerate_": 0, "6944": 0, "qcrit_bs": 0, "qcrit_hjellming_webbink": 0, "qcrit_q_no_comenv": 0, "qcrit_chen_han_t": 0, "qcrit_chen_han_formula": 0, "qcrit_ge2015": 0, "qcrit_vos2018": 0, "qcrit_temmink2021": 0, "qcrit_gb_bs": 0, "qcrit_gb_hjellming_webbink": 0, "qcrit_gb_q_no_comenv": 0, "qcrit_gb_chen_han_t": 0, "qcrit_gb_chen_han_formula": 0, "qcrit_gb_ge2015": 0, "qcrit_gb_vos2018": 0, "qcrit_gb_temmink2021": 0, "qcrit_m": 0, "qcrit_hg": 0, "hertzsprung": [0, 4, 23], "gap": 0, "qcrit_gb": 0, "qcrit_cheb": 0, "qcrit_eagb": 0, "qcrit_tpagb": 0, "tp": 0, "qcrit_hem": 0, "qcrit_hehg": 0, "qcrit_hegb": 0, "78125": 0, "qcrit_hewd": 0, "qcrit_cowd": 0, "qcrit_onewd": 0, "qcrit_n": 0, "qcrit_bh": 0, "qcrit_degenerate_lmm": 0, "qcrit_degenerate_m": 0, "qcrit_degenerate_hg": 0, "7619": 0, "qcrit_degenerate_gb": 0, "qcrit_degenerate_cheb": 0, "qcrit_degenerate_eagb": 0, "qcrit_degenerate_tpagb": 0, "qcrit_degenerate_hem": 0, "qcrit_degenerate_hehg": 0, "qcrit_degenerate_hegb": 0, "qcrit_degenerate_hewd": 0, "625": [0, 5], "qcrit_degenerate_cowd": 0, "qcrit_degenerate_onewd": 0, "qcrit_degenerate_n": 0, "qcrit_degenerate_bh": 0, "mass_for_hestar_ia_upp": 0, "never": [0, 6, 14, 15, 22, 29], "mass_for_hestar_ia_low": 0, "alphacb": 0, "viscos": 0, "alpha": [0, 5], "minimum_donor_menv_for_comenv": 0, "msun": [0, 6, 9, 12, 13, 14, 15, 17, 19, 32, 38, 39], "comenv_prescript": 0, "paczy\u0144ski": 0, "neleman": 0, "alpha_c": [0, 5, 6, 8], "comenv_ms_accretion_mass": 0, "comenv_ms_accretion_fract": 0, "comenv_ns_accretion_fract": 0, "comenv_ns_accretion_mass": 0, "nelemans_gamma": 0, "nelemans_minq": 0, "nelemans_max_frac_j_chang": 0, "nelemans_n_comenv": 0, "lambda_c": [0, 5, 8], "lambda_ionis": 0, "comenv_undef": 0, "comenv_bs": 0, "comenv_nelemans_tout": 0, "comenv_nandez2016": 0, "comenv_ejection_spin_method": 0, "left": 0, "comenv_ejection_spin_method_do_noth": 0, "leav": [0, 22], "omega": [0, 5, 19], "enter": [0, 22], "comenv_ejection_spin_method_sychron": 0, "synchron": 0, "comenv_ejection_spin_method_synchron": 0, "comenv_merger_spin_method": 0, "comenv_merger_spin_method_specif": 0, "preserv": 0, "onset": 0, "comenv_merger_spin_method_conserve_angmom": 0, "supercrit": 0, "comenv_merger_spin_method_conserve_omega": 0, "frequenc": [0, 17], "comenv_merger_spin_method_breakup": 0, "some": [0, 1, 6, 8, 9, 11, 12, 13, 14, 15, 16, 19, 21, 22, 23, 25, 30, 32, 35, 36, 37, 40], "comenv_ms_accret": 0, "comenv_ns_accret": 0, "formal": 0, "bind": [0, 7, 9, 12, 17], "m": [0, 5, 6, 8, 13, 14, 15, 17, 19, 20, 32, 43], "menv": [0, 5], "lambda_ce_dewi_tauri": 0, "dewi": 0, "lambda_ce_wang_2016": 0, "wang": 0, "jia": 0, "li": 0, "lambda_ce_polytrop": 0, "polytrop": 0, "comenv_splitmass": 0, "lambda_ce_klencki_2020": 0, "klencki": 0, "point": [0, 3, 6, 20, 21, 22, 23, 31, 32, 38, 40], "nelemans_recalc_eccentr": 0, "recalcul": 0, "comenv_post_eccentr": 0, "remain": [0, 7, 20, 22], "05": [0, 5, 8, 9, 13, 16], "accord": [0, 6, 31, 32, 38], "75": [0, 5, 8, 13], "chang": [0, 1, 2, 5, 6, 8, 9, 13, 14, 15, 16, 19, 20, 21, 22, 23, 34, 35, 40], "standard": [0, 13, 14, 15, 30, 32, 37, 38], "recombin": 0, "big": [0, 22], "outcom": 0, "lambda_enthalpi": 0, "enthalpi": 0, "far": [0, 5, 6, 14, 15, 17], "cbdisc_albedo": 0, "albedo": 0, "cbdisc_gamma": 0, "cbdisc_alpha": 0, "cbdisc_kappa": 0, "kappa": 0, "cbdisc_minimum_evaporation_timescal": 0, "would": [0, 2, 14, 15, 16, 22, 25], "less": [0, 1, 4, 5, 31, 32], "simpli": [0, 14, 15], "immedi": [0, 6, 22], "1y": 0, "cbdisc_torquef": 0, "cbdisc_max_lifetim": 0, "lifetim": [0, 8, 13, 14, 15, 16, 38], "cbdisc_init_dm": 0, "cbdisc": 0, "start": [0, 1, 5, 6, 8, 12, 13, 14, 15, 16, 19, 20, 22, 28, 34, 35], "dm": [0, 5, 14, 15, 32, 38], "won": [0, 12, 23, 40], "t": [0, 1, 2, 5, 6, 12, 14, 15, 16, 20, 22, 23, 26, 31, 38, 40], "converg": 0, "cbdisc_init_djdm": 0, "dj": 0, "cbdisc_mass_loss_constant_r": 0, "cbdisc_mass_loss_fuv_multipli": 0, "fuv": 0, "cbdisc_mass_loss_xray_multipli": 0, "x": [0, 6, 9, 12, 17, 19, 20, 21, 25, 26, 32, 38], "rai": 0, "cbdisc_mass_loss_ism_ram_pressure_multipli": 0, "interstellar": 0, "medium": 0, "ram": [0, 22], "pressur": 0, "cbdisc_mass_loss_ism_pressur": 0, "boltzmann": 0, "kelvin": 0, "think": [0, 20, 21], "3000": [0, 17], "http": [0, 1, 2, 6, 16, 20, 21, 23, 31, 32, 40], "www": [0, 32], "astronomi": 0, "ohio": 0, "edu": 0, "pogg": 0, "ast871": 0, "intro": 0, "pdf": [0, 19, 23, 32, 40], "page": [0, 6, 16, 23, 40], "arxiv": [0, 32], "org": [0, 2, 32], "0902": 0, "0820": 0, "panel": 0, "cbdisc_mass_loss_inner_viscous_multipli": 0, "cbdisc_mass_loss_inner_viscous_angular_momentum_multipli": 0, "cbdisc_resonance_multipli": 0, "reson": 0, "interact": [0, 3, 5, 6, 8, 17, 19, 34], "cbdisc_resonance_damp": 0, "l": [0, 6, 13, 14, 15], "locat": [0, 22, 23, 32, 38, 40], "cbdisc_fail_ring_inside_separ": 0, "rring": 0, "cbdisc_mass_loss_inner_l2_cross_multipli": 0, "cross": 0, "cbdisc_minimum_luminos": 0, "becom": [0, 1, 2, 5, 9, 14, 15, 17, 20, 22], "dimmer": [0, 13], "instantli": 0, "cbdisc_minimum_mass": 0, "cbdisc_minimum_fr": 0, "fring": 0, "ring": 0, "ab": [0, 20], "rout": 0, "rin": 0, "comenv_disc_angmom_fract": 0, "deprec": [0, 21], "discs_circumbinary_from_comenv": 0, "comenv_disc_mass_fract": 0, "wind_disc_angmom_fract": 0, "discs_circumbinary_from_wind": 0, "wind_disc_mass_fract": 0, "wrlof_method": 0, "quadrat": 0, "wrlof_mass_transf": 0, "wrlof_non": 0, "wrlof_q_depend": 0, "wrlof_quadrat": 0, "minimum_timestep": 0, "timestep_solver_factor": 0, "timestep_limit": 0, "compar": [0, 8, 13, 16, 22], "dx": 0, "dt": [0, 1, 20, 29, 38], "lengthen": 0, "altern": [0, 22], "rlof_mdot_factor": 0, "rlof_mdot_modul": 0, "rlof_f": 0, "enlarg": 0, "nomin": 0, "becaus": [0, 2, 6, 7, 8, 12, 13, 14, 15, 17, 19, 21, 22, 23, 29, 31, 32, 40], "dermin": 0, "rlof_radiation_correct": 0, "minimum_separation_for_instant_rlof": 0, "evolv": [0, 4, 7, 9, 21, 22, 23, 40], "report": [0, 6, 8, 13, 14, 15, 16], "lead": [0, 6, 13, 14, 15, 16, 31, 32, 43], "minimum_orbital_period_for_instant_rlof": 0, "maximum_mass_ratio_for_instant_rlof": 0, "m1": [0, 5, 8, 9, 12, 13, 14, 15, 16, 19, 31, 32, 43], "rlof_method": 0, "adapt": [0, 14, 15], "rl": [0, 5], "ritter": 0, "claei": 0, "etal": 0, "rlof_method_bs": 0, "rlof_method_adapt": 0, "rlof_method_ritt": 0, "rlof_method_claei": 0, "rlof_method_adaptive2": 0, "rlof_interpolation_method": 0, "alwai": [0, 21, 22, 32, 38], "get": [0, 2, 3, 4, 6, 9, 12, 13, 14, 15, 16, 17, 19, 20, 21, 23, 26, 27, 30, 32, 34, 35, 37, 40, 41, 43], "within": [0, 2, 9, 11, 16, 20, 23, 32, 35, 40], "toler": 0, "rlof_entry_threshold": 0, "revers": [0, 25], "newton": 0, "doe": [0, 2, 6, 7, 9, 11, 12, 13, 14, 15, 16, 21, 22, 29, 31, 32, 35, 43], "repeat": [0, 22], "half": [0, 32], "until": [0, 2, 6, 31, 32], "latter": 0, "now": [0, 2, 5, 6, 8, 9, 12, 13, 14, 15, 16, 17, 19, 20, 26, 32, 33], "break": 0, "rlof_interpolation_binary_c": 0, "rlof_interpolation_bs": 0, "beta_reverse_nova": 0, "automat": [0, 1, 9, 16, 18, 19, 22, 23, 29, 31, 34, 35, 40], "geometr": 0, "beta_reverse_novae_geometri": 0, "wd_accretion_rate_novae_upper_limit_hydrogen_donor": 0, "upper": [0, 32, 38], "donor_rate_algorithm_claeys2014": 0, "donor_rate_algorithm_bs": 0, "wd_accretion_rate_novae_upper_limit_helium_donor": 0, "wd_accretion_rate_novae_upper_limit_other_donor": 0, "neither": [0, 21], "nor": 0, "wd_accretion_rate_new_giant_envelope_lower_limit_hydrogen_donor": 0, "format": [0, 2, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 19, 20, 22, 30, 31, 32, 35, 38], "wd_accretion_rate_new_giant_envelope_lower_limit_helium_donor": 0, "wd_accretion_rate_new_giant_envelope_lower_limit_other_donor": 0, "crap_paramet": 0, "eggleton": [0, 43], "subject": 0, "bb": 0, "individual_nova": 0, "each": [0, 2, 8, 13, 14, 15, 16, 17, 20, 22, 26, 35, 38], "separta": 0, "nova_timestep_accelerator_num": 0, "acceler": 0, "exce": [0, 13], "nova_timestep_accelerator_index": 0, "nova_timestep_accelerator_max": 0, "larger": [0, 6], "longer": [0, 6, 8], "cap": 0, "nonconservative_angmom_gamma": 0, "NOT": [0, 35, 38, 41], "momenta": [0, 25], "rlof_nonconservative_gamma_donor": 0, "rlof_nonconservative_gamma_isotrop": 0, "max_stellar_angmom_chang": 0, "maxmimum": 0, "third_dup": 0, "nucsyn_third_dredge_up": 0, "third_dup_multipli": 0, "f": [0, 5, 12, 16, 19, 32], "abund": 0, "element": [0, 1, 11, 17, 22, 25, 39], "nenamg": 0, "reaction": 0, "network": [0, 11], "nucsyn_hbb": 0, "nucsyn_network": 0, "nucsyn_network_error": 0, "error": [0, 2, 6, 8, 13, 14, 15, 20, 22, 23, 26, 31, 40], "nucreacmult": 0, "z": [0, 6, 8, 19, 21, 32, 43], "04": [0, 5, 13, 19], "That": [0, 6], "said": 0, "been": [0, 2, 11, 21, 22, 26, 28, 30, 37], "warn": [0, 12, 16, 22, 26], "nucsyn_solv": 0, "kaps_rentrop": 0, "kap": 0, "rentrop": 0, "great": [0, 14, 15, 22], "stiff": 0, "problem": [0, 13], "lsoda": 0, "adam": 0, "bsf": 0, "switcher": 0, "cvode": 0, "librari": [0, 1, 6, 9, 19, 21, 22, 41], "comput": [0, 6, 13, 14, 15], "llnl": 0, "gov": 0, "project": [0, 23, 40], "sundial": 0, "initial_abundance_mix": 0, "mixtur": [0, 13], "ag89": 0, "lodder": 0, "asplund": 0, "avail": [0, 7, 8, 9, 13, 15, 16, 20, 22, 23, 28, 40], "garcia": 0, "berro": 0, "grevess": 0, "noel": 0, "init_abund": 0, "isotop": [0, 11, 39], "init_abund_mult": 0, "init_abund_dex": 0, "dex": [0, 8, 38], "init_abunds_onli": 0, "exit": [0, 20, 21, 22, 26, 30, 31, 37], "initial_abunds_onli": 0, "no_thermohaline_mix": 0, "thermohalin": 0, "lithium_gb_post_heflash": 0, "lithium": 0, "lithium_t": 0, "lithium_gb_post_1dup": 0, "lithium_hbb_multipli": 0, "hbb": 0, "fishlock": 0, "angelou_lithium_decay_funct": 0, "describ": [0, 19, 22, 32], "li7": 0, "decai": 0, "nucsyn_angelou_lithium": 0, "choic": [0, 25, 32], "expoenti": 0, "angelou_lithium_decay_tim": 0, "angelou_lithium_lmms_tim": 0, "manufactur": 0, "angelou_lithium_ms_tim": 0, "angelou_lithium_hg_tim": 0, "angelou_lithium_gb_tim": 0, "angelou_lithium_cheb_tim": 0, "angelou_lithium_eagb_tim": 0, "angelou_lithium_tpagb_tim": 0, "angelou_lithium_lmms_decay_tim": 0, "surfac": 0, "angelou_lithium_ms_decay_tim": 0, "angelou_lithium_hg_decay_tim": 0, "angelou_lithium_gb_decay_tim": 0, "angelou_lithium_cheb_decay_tim": 0, "angelou_lithium_eagb_decay_tim": 0, "angelou_lithium_tpagb_decay_tim": 0, "angelou_lithium_lmms_massfrac": 0, "angelou_lithium_ms_massfrac": 0, "angelou_lithium_hg_massfrac": 0, "angelou_lithium_gb_massfrac": 0, "angelou_lithium_cheb_massfrac": 0, "angelou_lithium_eagb_massfrac": 0, "angelou_lithium_tpagb_massfrac": 0, "angelou_lithium_vrot_trigg": 0, "angelou_lithium_vrotfrac_trigg": 0, "keplerian": 0, "david_logging_funct": 0, "kind": [0, 7], "david": [0, 2, 7, 12, 14, 16, 19, 23, 40], "david_tzo_log": 0, "tzo": 0, "david_ppisn_log": 0, "david_ppisn_single_log": 0, "underw": 0, "david_rlof_episode_log": 0, "episod": 0, "david_rlof_ensemble_log": 0, "ensembl": [0, 4, 7, 11, 22, 23, 24, 31, 35, 36, 39], "cf_amanda_log": 0, "amanda": 0, "float_overflow_check": 0, "check": [0, 6, 8, 13, 14, 15, 16, 19, 20, 21, 22, 26, 30, 31, 32, 34, 37, 41, 43], "stderr": [0, 22], "failur": [0, 20, 26], "save_pre_events_stardata": 0, "save": [0, 1, 6, 8, 9, 13, 14, 15, 16, 22, 26, 31, 32, 38], "copi": [0, 8, 14, 15, 22, 43], "stardata": [0, 1, 6, 8, 9, 12, 13, 14, 15, 16, 18, 19], "pre_events_stardata": 0, "disable_end_log": 0, "ensemble_filters_off": 0, "filter": [0, 2, 20], "ensemble_filter_": 0, "ensemble_macro": 0, "ensemble_legacy_ensembl": 0, "legaci": 0, "popul": [0, 3, 4, 7, 11, 23, 24, 40, 41], "legacy_yield": 0, "ensemble_def": 0, "defer": 0, "ensemble_dt": 0, "store": [0, 2, 4, 6, 8, 12, 13, 14, 15, 16, 20, 21, 22, 23, 31, 38, 40, 43], "ensemble_logdt": 0, "ensemble_startlogtim": 0, "logensembletim": 0, "storag": 0, "ensemble_logtim": 0, "act": [0, 14, 15, 16, 22], "linear": [0, 13, 14, 15, 22, 32, 38], "postagb_legacy_log": 0, "disc_legacy_log": 0, "emp_logg_maximum": 0, "logg": [0, 6], "emp": 0, "cemp_cfe_minimum": 0, "nemp_nfe_minimum": 0, "emp_minimum_ag": 0, "emp_feh_maximum": 0, "fe": 0, "cemp": 0, "nemp_cfe_minimum": 0, "nemp": 0, "thick_disc_start_ag": 0, "lookback": 0, "thick": 0, "13e3": 0, "thick_disc_end_ag": 0, "thick_disc_logg_min": 0, "thick_disc_logg_max": 0, "escape_veloc": 0, "construct": [0, 1, 6, 8, 12, 13, 14, 15, 17, 19, 22], "galact": [0, 38], "chemic": [0, 38], "gce": 0, "nucsyn_gce_outflow_check": 0, "1e9": 0, "escape_fract": 0, "colour_log": 0, "thelog": 0, "file_log": 0, "log_filenam": [0, 5, 12, 19, 41], "filenam": [0, 1, 3, 5, 12, 16, 20, 21, 22, 26, 30, 31, 37, 41], "dev": 0, "c_log": 0, "dat": [0, 16, 20], "log_arrow": 0, "add": [0, 2, 6, 8, 9, 12, 13, 14, 15, 16, 21, 22, 23, 25, 32, 35, 36, 38, 40], "arrow": 0, "stopfil": 0, "file": [0, 1, 3, 5, 7, 12, 14, 16, 20, 21, 22, 23, 25, 26, 29, 30, 31, 34, 35, 37, 39, 40, 41], "stardata_dump_filenam": 0, "dump": [0, 3, 12, 21, 31], "stardata_load_filenam": 0, "load": [0, 1, 3, 6, 8, 9, 12, 13, 14, 15, 16, 19, 20, 21, 22, 25, 26, 27, 31, 35], "api_log_filename_prefix": [0, 5, 12, 17], "prefix": 0, "api": [0, 4, 20, 23, 26], "hrdiag_output": 0, "high": [0, 14, 15, 32], "hertzstrpung": 0, "russel": [0, 4, 23], "diagram": [0, 4, 23, 25], "hrdiag": 0, "internal_buff": 0, "buffer": [0, 31], "prior": [0, 6], "shouldn": [0, 20], "realli": [0, 6, 16, 21, 22, 34, 35], "plai": [0, 14, 15], "internal_buffering_off": 0, "internal_buffering_print": 0, "internal_buffering_stor": 0, "eccentric_rlof_model": 0, "rlof_eccentric_as_circular": 0, "force_corotation_of_primary_and_orbit": 0, "force_circularization_on_rlof": 0, "wtts_log": 0, "wtts2": 0, "fabian_imf_log_tim": 0, "fabian": 0, "imf": [0, 14, 15, 32], "fabian_imf_log": 0, "fabian_imf_log_timestep": 0, "displai": [0, 6, 8, 17], "test": [0, 12, 20, 22, 26, 29, 31], "dumpvers": 0, "short": [0, 6, 8, 13, 14, 15, 42], "version_onli": 0, "tides_diagnosis_log": 0, "mint_dir": 0, "mint_data_cleanup": 0, "incom": 0, "Will": [0, 20, 22, 41], "slower": 0, "few": [0, 8], "thing": [0, 3, 6, 7, 8, 13, 14, 15, 16, 19, 20, 21, 32, 41], "mint_ms_rejuven": 0, "rejuven": [0, 13], "mint_remesh": 0, "remesh": 0, "mint_use_zams_profil": 0, "profil": 0, "zam": [0, 4, 6, 7, 13, 32, 41, 43], "homogen": 0, "mint_fallback_to_test_data": 0, "test_data": 0, "fallback": 0, "unavail": 0, "mint_disable_grid_load_warn": 0, "explicitli": [0, 1], "miss": [0, 13, 14, 15, 20, 34], "much": [0, 6, 8, 13, 16, 19, 20, 28], "mint_kippenhahn": 0, "kippenhahn": 0, "mint_nshel": 0, "shell": [0, 20], "shellular": 0, "mint_maximum_nshel": 0, "mint_hard_max_nshel": 0, "1000": [0, 8, 22, 38], "mint_minimum_nshel": 0, "equal": [0, 2, 14, 15, 16, 20], "mint_hard_min_nshel": 0, "mint_kippenhahn_stellar_typ": 0, "selector": 0, "plot": [0, 6, 8, 12, 13, 14, 15, 17, 18, 19, 25], "mint_kippenhahn_companion_stellar_typ": 0, "mint_nuclear_burn": 0, "mint_minimum_shell_mass": 0, "mint_maximum_shell_mass": 0, "go": [0, 6, 11, 13, 16, 21, 23, 25, 40], "command": [0, 1, 16, 20, 21, 22, 23, 31, 40], "gogo": 0, "reset_star": 0, "reset": 0, "reset_stars_default": 0, "echo": 0, "execut": [0, 16, 22, 35], "noecho": 0, "deactiv": 0, "noechonow": 0, "bye": 0, "quit": [0, 6, 20, 32], "fin": 0, "reset_pref": 0, "prefer": [0, 21], "struct": [0, 9], "statu": [0, 1, 6, 8, 13, 14, 15, 16, 22, 26, 30, 31, 37], "handi": 0, "re": [0, 1, 6, 7, 8, 13, 14, 15, 17, 26, 34], "sampl": [0, 4, 13, 16, 32, 35, 38], "space": [0, 6, 13, 14, 15, 16, 31, 35, 38], "good": [0, 12, 13, 14, 15, 16, 22, 43], "statist": [0, 22, 30], "reason": [0, 14, 15], "tbse": 0, "pgo": 0, "random_system": 0, "etc": [0, 7, 12, 14, 15, 16, 20, 21, 22, 23, 25, 31, 32, 40, 41], "random_se": [0, 5, 12, 19], "seed": 0, "possibl": [0, 1, 2, 6, 12, 17, 20, 22, 23, 29, 32, 34, 40], "exactli": [0, 14, 15], "reproduc": 0, "involv": 0, "pseudorandom": 0, "random_systems_se": 0, "random_skip": 0, "skip": [0, 2, 6, 8, 13, 22], "idum": 0, "nb": 0, "pleas": [0, 6, 7, 13, 14, 15, 16, 20, 22, 23, 29, 40], "reverse_tim": 0, "To": [0, 7, 12, 13, 14, 15, 16, 22, 23, 31, 32, 40], "consid": [0, 1, 2, 13, 14, 15, 21, 22, 25, 33, 34, 38], "start_tim": [0, 22], "warmup_cpu": 0, "cpu": [0, 6, 8, 13, 14, 15, 16, 22, 28], "second": [0, 2, 8, 17, 20, 23, 25, 31, 32, 33, 40], "topic": 0, "argopt": 0, "help_al": 0, "list_arg": 0, "here": [1, 6, 7, 9, 12, 13, 14, 15, 17, 19, 20, 21, 22, 23, 25, 32, 40, 41], "user": [1, 9, 20, 21, 22, 23, 27, 32, 34, 40, 41], "binaryc": [1, 20, 41], "output": [1, 2, 3, 4, 5, 7, 9, 11, 12, 17, 18, 19, 20, 21, 22, 23, 25, 31, 39, 40, 41, 43], "runtim": [1, 22], "binarycpython": [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43], "util": [1, 2, 3, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 43], "autogen_c_logging_cod": [1, 9, 19], "logging_dict": 1, "verbos": [1, 6, 8, 12, 13, 14, 15, 16, 18, 20, 22, 23, 27, 31, 32, 33, 38, 40], "sourc": [1, 2, 3, 8, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 43], "auto": [1, 24], "printf": [1, 6, 8, 9, 12, 13, 14, 15, 16, 18, 19], "statement": [1, 9, 12, 13, 14, 15, 16, 17, 18, 19, 22], "input": [1, 2, 3, 7, 11, 12, 14, 20, 21, 22, 23, 25, 27, 31, 32, 33, 34, 41, 43], "dictionari": [1, 2, 3, 4, 6, 8, 13, 14, 15, 16, 20, 21, 22, 25, 27, 28, 31, 32, 34, 35, 39, 42], "kei": [1, 2, 3, 6, 11, 12, 16, 17, 19, 20, 21, 22, 25, 29, 31, 32, 34, 35, 39], "header": [1, 6, 8, 9, 12, 13, 14, 15, 16, 19, 20], "line": [1, 5, 6, 8, 9, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 25, 31, 38, 40], "item": [1, 2, 6, 8, 13, 14, 15, 20], "paramet": [1, 2, 3, 4, 6, 7, 8, 9, 12, 13, 14, 15, 16, 20, 21, 22, 23, 25, 26, 29, 30, 31, 32, 34, 35, 37, 38, 39, 41, 43], "put": [1, 6, 8, 13, 14, 15, 16, 19, 20, 22, 25, 26, 34, 35, 36], "append": [1, 2, 6, 12, 13, 14, 15, 17], "exampl": [1, 2, 12, 20, 21, 32, 35, 38, 41], "look": [1, 3, 6, 8, 13, 14, 15, 16, 19, 23, 32, 40], "my_stellar_data": [1, 9, 16, 18, 19], "star": [1, 4, 5, 7, 8, 9, 11, 12, 13, 14, 17, 18, 19, 22, 23, 25, 30, 32, 37, 38, 40, 43], "dict": [1, 3, 5, 6, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 26, 27, 29, 31, 32, 34, 39, 42], "binary_c": [1, 2, 3, 4, 6, 8, 13, 14, 15, 17, 20, 21, 22, 25, 29, 31, 32, 35, 39, 41], "sentenc": 1, "level": [1, 6, 20, 33], "return": [1, 2, 3, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 37, 38, 39, 41, 43], "str": [1, 2, 3, 5, 6, 16, 20, 21, 25, 31, 34, 35, 39], "binary_c_log_cod": [1, 9, 12, 18, 19], "termin": [1, 6, 9, 16, 23, 40], "primari": [1, 6, 8, 13, 14, 15, 16, 32, 35, 43], "stellar_typ": [1, 6, 9, 12, 13, 14, 15, 16, 23, 24, 25], "example_log_co": [1, 9], "30": [1, 5, 6, 8, 9, 12, 13, 14, 15, 16, 17, 19], "12e": [1, 6, 9, 12, 13, 14, 15, 16], "previous_stardata": [1, 8, 9, 12, 16], "kill": [1, 9, 16, 21], "dtm": [1, 9, 16], "exact": [1, 2, 22], "wrap": [1, 9, 20, 29], "logic": [1, 2, 9, 21, 22], "definit": [1, 13, 14, 15, 43], "share": [1, 12, 18, 19, 22, 31, 41], "binary_c_write_log_cod": 1, "write": [1, 5, 6, 7, 8, 9, 12, 13, 16, 18, 19, 20, 21, 22, 31, 34, 41], "target": [1, 34], "compile_shared_lib": 1, "sourcefile_nam": 1, "outfile_nam": 1, "name": [1, 2, 5, 6, 7, 8, 13, 14, 15, 16, 17, 19, 20, 22, 30, 31, 34, 35, 41, 42], "create_and_load_logging_funct": [1, 9, 19], "custom_logging_cod": [1, 9, 12, 16, 18, 19, 41], "custom_tmp_dir": 1, "ctype": 1, "unless": [1, 21, 22], "i": [1, 2, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 26, 32, 35, 39, 40, 43], "recommend": [1, 4, 23, 40], "combin": [1, 2, 9, 20, 21, 22], "tupl": [1, 6, 20, 26, 31, 38], "memori": [1, 6, 7, 8, 9, 13, 14, 15, 16, 19, 20, 21, 22, 31, 43], "address": [1, 7, 9, 22, 43], "capsul": [1, 7, 20], "from_binary_c_config": 1, "config_fil": 1, "binaryc_config": 1, "config": [1, 20, 22, 23, 40], "filepath": 1, "return_compilation_dict": 1, "inspir": [1, 25, 43], "binary_c_inline_config": 1, "perl": [1, 2, 13, 14, 15, 16, 30], "still": [1, 9, 17, 22, 23, 40, 43], "clean": [1, 6, 12, 14, 15, 21], "w": [1, 12, 16, 21, 31], "develop": 1, "redhat": 1, "com": [1, 20, 21, 23, 32, 40], "blog": 1, "linker": 1, "gcc": [1, 23, 40], "python": [2, 3, 4, 6, 8, 13, 14, 15, 20, 22, 29, 31, 32, 35], "class": [2, 3, 20, 23, 24], "autovivificationdict": 2, "autovivif": 2, "featur": [2, 4, 16, 23], "overrid": [2, 19, 22, 32, 35, 38], "__iadd__": 2, "oper": [2, 31], "doc": [2, 6, 13, 14, 15, 16, 20, 23, 34, 40], "refer": [2, 22, 31], "datamodel": 2, "html": [2, 6, 16, 23, 31, 40], "highlight": 2, "iadd": 2, "subdict": 2, "might": [2, 3, 8, 13, 16, 17, 20, 22, 23, 31, 40], "newdict": 2, "print": [2, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 22, 26, 33, 34], "__getitem__": [2, 29], "getitem": 2, "autoviv": 2, "count_keys_recurs": 2, "input_dict": 2, "recurs": [2, 20], "count": [2, 5, 6, 19, 20, 22], "local_count": 2, "custom_sort_dict": 2, "order": [2, 4, 16, 20, 35], "ordereddict": 2, "find": [2, 5, 8, 16, 20, 22, 29, 34], "uniqu": [2, 19, 22], "sort": [2, 6, 13, 14, 15, 17, 20, 31], "Then": [2, 6, 20, 23, 40], "those": [2, 6, 8, 13, 14, 15, 16, 19, 21, 23, 32, 39, 40], "them": [2, 6, 7, 8, 16, 18, 19, 20, 21, 30, 31, 32, 34, 41], "directli": [2, 12, 22, 26, 31], "without": [2, 9, 12, 14, 15, 20, 22, 32], "filter_dict": 2, "arg_dict": [2, 20], "filter_list": 2, "out": [2, 3, 6, 8, 9, 13, 14, 15, 17, 20, 22, 23, 32, 34, 40], "filter_dict_through_valu": 2, "inspect_dict": 2, "indent": [2, 3, 12, 21, 31], "print_structur": 2, "inspect": [2, 12, 25], "nest": [2, 16, 35, 39], "content": [2, 3, 7, 20, 21, 26], "bool": [2, 16, 20, 21, 25, 31, 34, 35, 39], "except": [2, 5, 6, 7, 13, 14, 15, 16, 22, 25, 34], "keys_to_float": 2, "convert": [2, 3, 6, 8, 17, 20, 21, 31, 32, 38], "faster": [2, 13, 14, 15, 16], "recursive_change_key_to_float": 2, "convers": 2, "noth": [2, 22, 26, 27, 31], "els": [2, 5, 8, 14, 20, 22], "new_dict": 2, "merge_dict": [2, 11], "dict_1": 2, "dict_2": 2, "behaviour": [2, 6, 13, 14, 15, 16, 23, 40, 41], "present": [2, 3, 6, 13, 14, 15, 16, 19, 21, 23, 31, 32, 40], "again": [2, 3, 6, 11, 12, 20, 22], "ad": [2, 4, 6, 8, 12, 31, 35], "opt": [2, 5, 7, 32], "OR": [2, 19], "ident": 2, "concaten": 2, "nonetyp": 2, "instanc": [2, 11, 12, 13, 14, 15, 16, 21, 32], "multiply_float_valu": 2, "multiply_values_dict": [2, 11], "over": [2, 6, 8, 11, 12, 13, 14, 15, 16, 20, 21, 31], "general_info": 2, "origin": [2, 17, 31], "union": [2, 16, 20, 32, 35, 38, 39, 43], "complex": [2, 8, 9, 18, 19, 22], "pass": [2, 7, 9, 12, 16, 17, 19, 20, 21, 22, 23, 25, 26, 27, 30, 31, 37, 38, 40, 41], "multiplied_dict": 2, "normalize_dict": 2, "result_dict": 2, "normalis": [2, 22, 32], "divid": 2, "term": 2, "design": [2, 21, 23, 25, 40], "normalized_dict": 2, "prepare_dict": 2, "global_dict": 2, "list_of_sub_kei": 2, "sure": [2, 12, 13, 14, 15, 16, 23, 26, 31, 32, 40, 41], "prepar": 2, "don": [2, 6, 20, 22, 26], "access": [2, 9, 12, 13, 14, 15, 16, 22, 26, 31], "come": [2, 10, 23, 38, 40], "empti": [2, 12, 30, 34, 37], "recursive_change_key_to_str": 2, "custom_format": [2, 20], "ll": [2, 9, 11, 14, 15, 17, 31], "set_opt": [2, 6, 8, 17], "newopt": [2, 32], "updat": [2, 14, 15, 16, 21, 23, 35, 40], "subtract_dict": 2, "subtract": 2, "numer": 2, "overlap": 2, "update_dict": [2, 11], "dict2": 2, "packag": [3, 7, 14, 16, 20, 23, 35, 36, 37, 38, 40], "binarycdecod": 3, "object_hook": 3, "parse_float": 3, "parse_int": 3, "parse_const": 3, "strict": 3, "object_pairs_hook": 3, "jsondecod": 3, "decod": 3, "entri": [3, 20, 21], "binarycencod": 3, "skipkei": 3, "ensure_ascii": [3, 21, 31], "check_circular": 3, "allow_nan": 3, "sort_kei": [3, 31], "jsonencod": 3, "encod": [3, 16, 31], "attempt": [3, 20, 21], "o": [3, 20, 23, 32], "precis": 3, "json": [3, 7, 12, 16, 21, 22, 27, 31], "binaryc_json_seri": 3, "obj": [3, 20], "serialis": 3, "export": [3, 16, 20, 21, 23, 31, 40], "represent": [3, 16, 35], "themselv": [3, 32], "itself": [3, 6, 9, 12, 22, 23, 32, 40], "ensemble_compress": 3, "compress": [3, 31], "extens": [3, 7, 23, 24], "ensemble_file_typ": 3, "ensemble_set": 3, "parameter_nam": [3, 6, 7, 8, 11, 13, 14, 15, 16, 20, 35], "extract_ensemble_json_from_str": 3, "binary_c_output": 3, "extract": [3, 16], "ensemble_json": 3, "raw": [3, 7, 19, 20, 21, 22, 25, 39, 41], "pars": [3, 4, 6, 8, 12, 13, 14, 15, 16, 19, 20, 21, 25, 39, 41], "format_ensemble_result": 3, "ensemble_dictionari": 3, "step": [3, 6, 8, 9, 12, 13, 14, 15, 16, 25, 35, 38], "handle_ensemble_string_to_json": 3, "raw_output": 3, "deal": [3, 12], "creat": [3, 6, 8, 9, 12, 13, 14, 15, 16, 20, 21, 28, 31, 32, 35, 37], "wrapper": [3, 7, 9, 12, 21, 31, 33, 43], "easi": [3, 12, 23, 40], "cl": 3, "load_ensembl": 3, "convert_float_kei": 3, "select_kei": 3, "flush": [3, 21, 31], "ensemebl": 3, "even": [3, 11, 14, 15], "open_ensembl": 3, "utf": [3, 16, 31], "open": [3, 5, 12, 16, 19, 31], "read": [3, 4, 5, 12, 16, 19, 20, 22, 23, 31, 40], "decompress": 3, "explain": [4, 39], "repositori": 4, "last": [4, 14, 17, 19, 20, 32], "usecas": 4, "tutori": [4, 23, 40], "individu": [4, 13, 23, 40], "run_system_wrapp": [4, 5, 9, 18, 23, 24], "via": [4, 6, 7, 9, 13, 14, 15, 16, 21, 22, 25], "noteworthi": 4, "full": [4, 9, 17, 20, 22, 30, 37], "script": [4, 9, 20, 22, 23, 26, 30, 37, 40], "about": [4, 6, 8, 13, 14, 15, 16, 20, 21, 22, 26, 31, 34, 43], "modif": 4, "binari": [4, 7, 8, 12, 14, 15, 22, 23, 25, 32, 35, 40, 43], "introduc": 5, "notebook": [5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 23, 40], "import": [5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 35], "os": [5, 6, 8, 12, 13, 14, 15, 16, 17, 19, 20], "temp_dir": [5, 6, 8, 12, 14, 15, 16, 17, 20], "run_system": [5, 7, 9, 11, 12, 17, 18, 25, 41], "tmp_dir": [5, 6, 8, 12, 14, 15, 16, 17, 22, 35], "notebook_bhbh": 5, "log_fil": [5, 22], "60": [5, 13, 31], "m2": [5, 8, 9, 12, 13, 16, 19, 31, 32, 43], "k1": [5, 12, 19], "k2": [5, 12, 19], "sep": [5, 8, 12, 13, 16, 19, 31, 32, 43], "ecc": [5, 12, 16, 19, 31, 32], "r1": [5, 12, 19], "rol1": [5, 12, 19], "r2": [5, 12, 19], "rol2": [5, 12, 19], "30441": 5, "random_count": [5, 12, 19], "0000": [5, 12, 19], "000": [5, 12, 19], "00": [5, 12, 13, 16, 19], "1193": 5, "28": [5, 7, 8, 9, 12, 13], "792": 5, "6492": 5, "26": [5, 13], "756": 5, "off_m": [5, 12, 19], "type_chng": [5, 12, 19], "6588": 5, "687": [5, 8], "2135": 5, "972": 5, "3695": 5, "813": 5, "3967": 5, "827": 5, "randbuf": [5, 19], "14439": 5, "mer": 5, "354981": 5, "764989": 5, "550575": 5, "162006": 5, "78488": 5, "23513": 5, "gt": [5, 6, 7, 8, 9, 12, 14, 16, 17, 18, 19], "vk": [5, 19], "218": 5, "134": 5, "vr": [5, 19], "01791": 5, "phi": [5, 19], "101323": 5, "vn": [5, 19], "final": [5, 8, 13, 14, 15, 19], "runawai": [5, 19], "v": [5, 19, 23, 40], "114": 5, "552": 5, "184": 5, "683": 5, "18": [5, 13, 14, 15, 17, 19], "7769": 5, "957894": 5, "max_tim": [5, 12, 19], "wide": [5, 13, 14, 15], "littl": [5, 6, 8, 13, 16, 17, 29], "40": [5, 8, 13, 14, 15], "35895": 5, "3101": 5, "48": [5, 13], "y": [5, 6, 17, 20, 21, 25, 26], "009": [5, 17], "beg_symb": 5, "3583": 5, "081": [5, 6], "35": [5, 8, 13, 32], "930": [5, 15], "3971": 5, "98": [5, 13, 14, 15], "023": 5, "014": 5, "lock": [5, 31], "3928": [5, 19], "41": [5, 13], "632": [5, 13], "894": 5, "3995": 5, "1199": 5, "776": [5, 19], "5374": 5, "4219": 5, "27": [5, 8, 13, 14, 16], "615": 5, "603": [5, 13], "5603": 5, "013": 5, "5403": 5, "157": 5, "151": 5, "5696": 5, "012": 5, "6475": 5, "763": [5, 32], "731": 5, "5791": 5, "19": [5, 8, 13, 14, 16, 19], "010": 5, "011": 5, "6548": 5, "730": 5, "729": 5, "5794": 5, "203": 5, "6550": 5, "728": [5, 8], "225": 5, "inv": [5, 19], "6552": 5, "725": 5, "5795": 5, "246": 5, "6556": 5, "721": 5, "5796": 5, "282": 5, "6559": 5, "716": 5, "727": 5, "321": 5, "6571": 5, "691": [5, 8], "724": [5, 9], "5798": 5, "546": 5, "021": 5, "6649": 5, "502": 5, "5812": 5, "548": 5, "543": 5, "1021": 5, "167": [5, 13], "598": 5, "7342": 5, "36": [5, 8, 13], "588": 5, "574": 5, "2663": 5, "178": 5, "480": 5, "8828": 5, "57": [5, 6, 8, 13], "460": 5, "end_symb": 5, "2670": 5, "171": 5, "458": 5, "8837": 5, "58": [5, 13], "455": 5, "2671": 5, "454": 5, "8840": 5, "2672": 5, "170": 5, "450": 5, "453": 5, "2673": 5, "446": 5, "8843": 5, "452": 5, "2674": 5, "169": 5, "442": 5, "451": [5, 8], "2676": 5, "438": 5, "8846": 5, "2677": 5, "168": [5, 8], "435": 5, "448": 5, "2678": 5, "431": 5, "8848": 5, "447": 5, "2679": 5, "427": 5, "2680": 5, "424": [5, 6], "8851": 5, "445": 5, "2681": 5, "166": [5, 8], "420": 5, "444": [5, 19], "2682": 5, "417": 5, "8853": 5, "2683": 5, "165": 5, "413": [5, 6], "441": 5, "2684": 5, "410": [5, 19], "8856": 5, "440": 5, "2685": 5, "164": 5, "407": 5, "8855": 5, "439": 5, "2686": 5, "404": 5, "8858": 5, "437": [5, 13], "2687": 5, "163": [5, 8], "400": 5, "436": 5, "2688": 5, "397": 5, "8860": 5, "434": 5, "2689": 5, "162": 5, "394": 5, "433": 5, "2690": 5, "391": 5, "8862": 5, "432": 5, "2691": [5, 13], "161": 5, "388": 5, "430": 5, "2692": 5, "385": 5, "8864": 5, "429": [5, 13], "2693": 5, "382": 5, "2694": 5, "379": 5, "8867": 5, "425": 5, "2695": 5, "160": 5, "376": 5, "8866": 5, "2696": 5, "373": 5, "8869": 5, "422": 5, "2697": 5, "159": [5, 8], "370": 5, "8868": 5, "2698": 5, "368": 5, "8871": 5, "419": 5, "2699": 5, "158": 5, "365": [5, 14], "8870": 5, "2700": 5, "362": 5, "8873": 5, "415": 5, "359": 5, "8872": 5, "2701": 5, "357": 5, "8875": 5, "411": 5, "2702": 5, "156": [5, 8, 19], "354": 5, "8874": 5, "409": 5, "2703": 5, "352": 5, "8877": 5, "2704": 5, "349": 5, "8876": 5, "405": 5, "2705": 5, "346": 5, "8878": 5, "403": 5, "2706": 5, "155": 5, "344": 5, "342": [5, 13], "8880": 5, "398": 5, "2707": 5, "154": 5, "339": 5, "396": 5, "2708": 5, "337": 5, "8882": 5, "393": 5, "2709": 5, "153": 5, "334": 5, "2710": 5, "332": 5, "8884": 5, "152": 5, "330": 5, "386": 5, "2711": 5, "327": 5, "8886": 5, "383": 5, "2712": 5, "325": 5, "380": 5, "2713": 5, "323": 5, "8887": 5, "377": 5, "2714": 5, "320": 5, "374": 5, "318": 5, "8889": 5, "371": 5, "2715": 5, "150": [5, 8, 13, 14, 15, 16], "316": [5, 8], "2716": 5, "314": 5, "8891": 5, "2717": 5, "149": 5, "312": [5, 6], "361": 5, "2718": 5, "310": 5, "8893": 5, "358": 5, "148": [5, 19], "308": 5, "8892": 5, "355": 5, "2719": 5, "306": 5, "8894": 5, "351": 5, "2720": 5, "147": 5, "304": 5, "347": 5, "2721": 5, "302": [5, 19], "8896": 5, "343": [5, 14], "300": [5, 16, 38], "340": 5, "2722": 5, "298": 5, "8898": 5, "335": 5, "2723": 5, "146": 5, "296": 5, "8897": 5, "331": 5, "2724": 5, "294": [5, 6], "8899": 5, "145": 5, "292": 5, "2725": 5, "290": 5, "8901": 5, "2726": 5, "144": 5, "288": 5, "2727": 5, "286": 5, "8903": 5, "309": 5, "143": 5, "284": 5, "8902": 5, "2728": 5, "8904": 5, "59": [5, 6, 13], "299": [5, 16], "2729": 5, "142": 5, "281": [5, 43], "2730": 5, "279": 5, "8906": 5, "141": 5, "277": 5, "283": 5, "2731": 5, "275": 5, "8908": 5, "2732": 5, "140": 5, "274": 5, "8907": 5, "272": 5, "2733": [5, 13], "8909": 5, "266": 5, "2734": 5, "139": 5, "270": 5, "260": 5, "268": 5, "8911": 5, "253": 5, "2773": 5, "136": 5, "217": 5, "8934": 5, "020": 5, "2800": 5, "8949": 5, "3729": 5, "039": 5, "072": 5, "9043": 5, "3781": 5, "034": 5, "067": 5, "9047": 5, "501": 5, "045": 5, "102": 5, "91": [5, 8, 13], "69569": 5, "911093": 5, "184829": 5, "636985": 5, "611763": 5, "837816": 5, "0118": 5, "4101": 5, "183": 5, "098": [5, 6], "5462": 5, "26416": 5, "22543": 5, "192": 5, "531": [5, 16], "908": 5, "105": [5, 14, 15], "89": [5, 6, 13, 15, 16], "7432": 5, "187": 5, "589": 5, "90695": 5, "03221": 5, "104427": 5, "96112": 5, "511114": 5, "4046": 5, "586": 5, "776523": 5, "809662": 5, "448242": 5, "54439": 5, "0399": 5, "43173": 5, "384": 5, "535": 5, "4205": 5, "103702": 5, "582": 5, "106": [5, 16], "329": [5, 8], "8544": 5, "13796e": 5, "51": [5, 8, 13], "27569e": 5, "103": 5, "85406e": 5, "454268": 5, "let": [5, 8, 12, 13, 14, 15, 16, 17, 21], "bhbh": 5, "detector": 5, "found": [5, 6, 8, 13, 14, 15, 16, 30, 32, 37], "def": [5, 6, 8, 12, 13, 14, 15, 16, 19], "vb": [5, 26, 29, 31, 38], "readlin": 5, "length": [5, 20], "len": [5, 6, 12, 16, 19], "stellar_type1": 5, "stellar_type2": 5, "rememb": [5, 6, 14, 15], "pop": [5, 9, 17, 29], "oop": 5, "unbound": 5, "bound": [5, 32, 38], "search_for_bhbh": 5, "maxcount": 5, "arg": [5, 7, 16, 20, 29, 32, 33], "39": [5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18], "851": 5, "873": 5, "510": 5, "265": 5, "301": 5, "45": [5, 6, 8, 13], "261": 5, "898": 5, "553": 5, "276": 5, "54": [5, 13], "122": 5, "69": [5, 13], "09": [5, 6, 8, 13], "239": 5, "231": 5, "49": [5, 6, 13], "44": [5, 13], "341": 5, "55": [5, 6, 8, 13, 15, 16, 32], "2421": 5, "28369": 5, "402": 5, "88": [5, 13], "213": 5, "128": 5, "399": 5, "22": [5, 13, 14, 19], "921": 5, "24": [5, 8, 13, 14], "1876": 5, "118": 5, "20447": 5, "29": [5, 8, 13, 22], "421": 5, "115": [5, 32], "52": [5, 6, 8, 13], "004": 5, "32": [5, 8, 13, 20, 22], "113": 5, "33": [5, 13], "196": 5, "73": [5, 13, 16], "97": [5, 13], "711": 5, "78": [5, 13], "37": [5, 8, 13], "857": 5, "207": 5, "96": [5, 6, 8, 13], "881": 5, "85": [5, 8, 13, 38], "875": 5, "43": [5, 13], "79": [5, 13], "640": [5, 13], "46": [5, 8, 13, 16], "47": [5, 8, 13], "95": [5, 13, 15], "19622": 5, "87": [5, 13], "117": 5, "81": [5, 8, 13], "53": [5, 6, 8, 13, 16], "706": 5, "241": 5, "67": [5, 13, 16], "56": [5, 8, 13], "803": 5, "2439": 5, "235": [5, 6], "82": [5, 13], "61": [5, 13, 16], "210": [5, 19], "12522": 5, "63": [5, 8, 13], "64": [5, 13], "65": [5, 13, 38], "285": 5, "66": [5, 13], "1360": 5, "68": [5, 8, 13, 16], "1398": 5, "70": [5, 8, 13, 32], "77": [5, 13, 15], "71": [5, 13], "72": [5, 13], "208": 5, "84": [5, 8, 13, 16], "254": 5, "74": [5, 13], "1882": 5, "76": [5, 13], "123": 5, "132": 5, "86": [5, 8, 13], "80": [5, 13, 14, 32, 38], "83": [5, 8, 13], "240": 5, "129": 5, "127": 5, "93": [5, 13], "199": 5, "267": [5, 8], "18139": 5, "90": [5, 8, 13, 14], "180": 5, "92": [5, 13], "94": [5, 6, 8, 13, 20], "1254": [5, 12], "172": 5, "557": 5, "99": [5, 13, 14, 15], "3082": 5, "9548": 5, "32620": 5, "9310": 5, "60101": 5, "246604": 5, "283972": 5, "469524": 5, "55473": 5, "379292": 5, "38316": 5, "109679": 5, "0261496": 5, "4011": 5, "043": 5, "9308": 5, "107187": 5, "679223": 5, "238584": 5, "860402": 5, "891056": 5, "4186": 5, "59867": 5, "804961": 5, "0474572": 5, "4146": 5, "caus": [5, 13, 43], "former": 5, "unphys": [5, 8, 13], "5064": 5, "536": 5, "468": 5, "6493": 5, "53854": 5, "006": 5, "8674": 5, "840": 5, "505": 5, "3185": 5, "017": [5, 17], "8704": 5, "600": 5, "509": 5, "3192": 5, "592": 5, "418": 5, "8706": 5, "568": 5, "3193": 5, "496": 5, "8910": 5, "758": [5, 19], "3246": 5, "beg_rch": 5, "9650": 5, "495": 5, "571": 5, "3223": 5, "913": 5, "0585": 5, "961": 5, "3211": 5, "999": 5, "007": [5, 17], "end_rch": 5, "0649": 5, "747": 5, "479": 5, "3216": 5, "002": [5, 18, 19], "2967": 5, "576": 5, "392": [5, 19], "3429": 5, "beg_bss": 5, "2996": 5, "512": 5, "390": 5, "3462": 5, "59616": 5, "665406": 5, "861368": 5, "162038": 5, "282234": 5, "0511173": 5, "5117": 5, "7326": 5, "0717": 5, "32118": 5, "450629": 5, "3096": 5, "9074": 5, "493": 5, "3507": 5, "end_bss": 5, "9113": 5, "242": 5, "3529": 5, "223": 5, "9196": 5, "513": 5, "997": 5, "3591": 5, "221": 5, "9206": 5, "843": 5, "3599": 5, "9797": 5, "519": [5, 14], "984": [5, 15], "4098": 5, "0512": 5, "528": 5, "256": [5, 6, 22], "4673": 5, "137": 5, "1012": 5, "742": 5, "5017": 5, "1130": 5, "245": 5, "5043": 5, "1471": 5, "485": 5, "5114": 5, "4877": 5, "885": 5, "6409": 5, "845641": 5, "27734": 5, "925761": 5, "145632": 5, "67179": 5, "4683": 5, "83672": 5, "1844": 5, "22098": 5, "787705": 5, "5164": 5, "oh": 5, "dear": 5, "secondari": [5, 6, 13, 32, 43], "wider": 5, "shorter": 5, "shrink": [5, 8], "best": [5, 21, 22], "acquir": 5, "closer": 5, "grvitation": 5, "0001": [5, 7, 43], "0102": 5, "622": 5, "3069": 5, "1851": [5, 13], "215": 5, "508": 5, "2266": 5, "879": 5, "945": 5, "60876": 5, "7617": 5, "018": 5, "7647": 5, "572": 5, "583": 5, "7721": 5, "633": 5, "7785": 5, "3100": [5, 13], "1326": 5, "305": 5, "695": 5, "2791": 5, "09665": 5, "qc": 5, "714712": 5, "st": 5, "3048": 5, "0276": 5, "2332": 5, "rc": [5, 6, 8, 13, 14, 15, 17, 25], "71818": 5, "6952": 5, "9757": 5, "comenv": [5, 8], "presc": 5, "m01": 5, "mc1": 5, "l1": 5, "44223e": 5, "rzam": [5, 43], "33552": 5, "convfrac": 5, "467851": 5, "lambda_ion": 5, "a_in": 5, "p_in": 5, "1708": 5, "jtot_in": 5, "09706e": 5, "jorb_in": 5, "96557e": 5, "eorbi": 5, "76416e": 5, "ebindi": 5, "30388e": 5, "sepf": 5, "7114": 5, "4385": 5, "9758": 5, "8926": 5, "mf1": 5, "5423": 5, "mf2": 5, "af": 5, "jf": 5, "72832e": 5, "jej": 5, "63566e": 5, "eorbf": 5, "39152e": 5, "eej": 5, "03996e": 5, "alpha_ej": 5, "0241634": 5, "1327": 5, "028": 5, "367": 5, "232": 5, "459": 5, "mstart": 5, "397754": 5, "3084": 5, "9071": 5, "46089": 5, "a_out": 5, "p_out": 5, "0152545": 5, "57093": 5, "jorb_out": 5, "6771": 5, "rl1": 5, "236": [5, 19], "rl2": 5, "459382": 5, "No": [5, 7, 14, 16, 22, 23, 40], "9411": 5, "gyr": [5, 6, 8], "9452": 5, "934": 5, "70365": 5, "455552": 5, "66554": 5, "0303129": 5, "454409": 5, "106368": 5, "2147": 5, "612": [5, 13], "401": 5, "668328": 5, "0913095": 5, "387": 5, "9342": 5, "851646": 5, "360": 5, "844": [5, 6], "2823": 5, "1622": 5, "45534": 5, "9256": 5, "1973": 5, "126": 5, "1987": 5, "846": [5, 6], "4184": 5, "900": 5, "7052": 5, "131": 5, "7060": 5, "7527": 5, "852": 5, "046": 5, "356": 5, "7554": 5, "465": 5, "888": 5, "7557": 5, "328": 5, "051": [5, 6], "416": 5, "7572": 5, "618": 5, "234": [5, 8], "7669": 5, "375": 5, "7675": 5, "333": 5, "579": 5, "222": 5, "7779": 5, "541": 5, "991": 5, "7941": 5, "539": 5, "070": 5, "2191": 5, "2234": 5, "069": 5, "405577": 5, "425788": 5, "375537": 5, "574826": 5, "898786": 5, "6975": 5, "878": 5, "64724": 5, "150217": 5, "9445": 5, "368345": 5, "7093": 5, "1502": 5, "233": 5, "8377": 5, "3046": 5, "77416": 5, "7107": 5, "204": 5, "1822": 5, "949": 5, "1814": [5, 13], "784": 5, "1818": 5, "224": 5, "979": 5, "19097": 5, "112": 5, "84502": 5, "824494": 5, "0987206": 5, "883252": 5, "726002": 5, "995824": 5, "317": 5, "667": 5, "25694": 5, "46901": 5, "022": 5, "477791": 5, "781": 5, "206": [5, 17], "67059": 5, "826": 5, "6816": 5, "6008": 5, "592733": 5, "836": [5, 6], "121": 5, "4862": 5, "7418": 5, "7434": 5, "101": 5, "7455": 5, "870": 5, "7458": 5, "995": 5, "7459": 5, "055": 5, "577": 5, "7836": 5, "7852": 5, "252": 5, "8004": 5, "992": 5, "8194": 5, "024": 5, "9725": 5, "025": 5, "1124": 5, "825086": 5, "878253": 5, "783746": 5, "582318": 5, "354576": 5, "9794": 5, "994": 5, "969": 5, "22787": 5, "16539": 5, "9739": 5, "3518": 5, "953182": 5, "120": 5, "657": 5, "449": [5, 13], "20677": 5, "078": 5, "932": 5, "173": 5, "4710": 5, "11686": 5, "0165": 5, "contact": [5, 23, 40], "00288661": 5, "00242158": 5, "393886": 5, "981555": 5, "bh_bh": 5, "2033": 5, "16729": 5, "213854": 5, "coalesc": 5, "369": 5, "624": [5, 13], "133": [5, 16], "037": 5, "1824": 5, "935": 5, "608": [5, 13], "951": 5, "179": 5, "408": 5, "1828": 5, "909": 5, "3171": 5, "1823": 5, "943": 5, "619": [5, 13], "1826": 5, "925": 5, "587": [5, 15], "1829": 5, "903": 5, "348": [5, 8], "111": 5, "707": [5, 13], "34870": 5, "549": 5, "376059": 5, "365763": 5, "371625": 5, "728797": 5, "817432": 5, "220": 5, "905": 5, "13607": 5, "475287": 5, "5493": 5, "478315": 5, "672": 5, "4493": 5, "6989": 5, "923": 5, "786": 5, "7335": 5, "07": [5, 13, 14, 15, 19, 32, 38], "702": 5, "489": 5, "7424": 5, "901": 5, "7426": 5, "507": 5, "104": [5, 8], "591": 5, "7447": 5, "492": 5, "7451": 5, "869": 5, "971": 5, "895": 5, "7714": 5, "219": 5, "7727": 5, "108": 5, "7874": 5, "996": [5, 8], "990": 5, "8062": 5, "032": 5, "1830": 5, "48809": 5, "946468": 5, "0278672": 5, "850309": 5, "663251": 5, "8982": 5, "2583": 5, "498": 5, "16733": 5, "776263": 5, "212": 5, "7069": 5, "577826": 5, "107": 5, "238": 5, "189": 5, "7767": 5, "8073": 5, "887": 5, "066": 5, "982": 5, "81705": 5, "372": 5, "47534": 5, "705715": 5, "41996": 5, "33295": 5, "061141": 5, "825648": 5, "694": [5, 8, 13], "1877": 5, "07108": 5, "406": [5, 13, 16], "212034": 5, "7428": 5, "816": 5, "7430": 5, "922": 5, "7431": 5, "048": [5, 17, 19], "7437": 5, "7450": 5, "109": [5, 8], "491": 5, "7840": 5, "7856": 5, "250": 5, "8008": 5, "998": 5, "993": 5, "8205": 5, "9648": 5, "1135": 5, "364017": 5, "086004": 5, "422436": 5, "514898": 5, "872312": 5, "9816": 5, "3228": 5, "4809": 5, "0298011": 5, "274206": 5, "201": 5, "5885": 5, "82224": 5, "5175": 5, "3752": 5, "719058": 5, "7752": 5, "135": 5, "503": 5, "936": 5, "124": 5, "27025": 5, "22936": 5, "0572914": 5, "50682": 5, "836621": 5, "272943": 5, "792721": 5, "229": 5, "98081": 5, "471379": 5, "412": 5, "48046": 5, "658": 5, "457": 5, "637": [5, 13], "7453": 5, "768": 5, "077": 5, "7456": 5, "099": 5, "195": 5, "891": 5, "896": 5, "7764": 5, "593": 5, "604": 5, "7933": 5, "7934": 5, "8123": 5, "114678": 5, "647161": 5, "438686": 5, "118229": 5, "734534": 5, "9357": 5, "2873": 5, "243": [5, 6], "973": [5, 13], "61521": 5, "86878": 5, "7731": 5, "1237": 5, "956619": 5, "1468": 5, "7748": 5, "764": 5, "5528": 5, "8577": 5, "6765": 5, "194": 5, "5556": 5, "11376": 5, "0159": 5, "00303761": 5, "00254512": 5, "332091": 5, "703545": 5, "1586": 5, "342474": 5, "754": 5, "828": 5, "1812": 5, "036": 5, "66016": 5, "65976": 5, "420182": 5, "0755737": 5, "70235": 5, "0772781": 5, "362601": 5, "27829": 5, "0074": 5, "221832": 5, "7433": 5, "057": 5, "338": [5, 9], "899": 5, "293": [5, 16], "7927": 5, "174": 5, "7942": 5, "177": [5, 8], "478": 5, "8079": 5, "205": 5, "8268": 5, "1674": [5, 13], "0701913": 5, "836783": 5, "398419": 5, "681487": 5, "392487": 5, "0245": 5, "3559": 5, "653": 5, "957": 5, "46607": 5, "371458": 5, "8708": 5, "930943": 5, "7267": 5, "679": [5, 8], "703": 5, "601": 5, "3231": [5, 13], "1473": 5, "7324": 5, "12495": 5, "0182": 5, "00256681": 5, "00215604": 5, "249": 5, "738524": 5, "014832": 5, "2493": 5, "0931922": 5, "497294": 5, "542": 5, "259": 5, "475": 5, "595": 5, "1813": 5, "749": 5, "976": 5, "906": 5, "1838": 5, "664": 5, "033": 5, "941": [5, 8], "1099": 5, "989": 5, "1834": 5, "868": 5, "13267": 5, "19393": 5, "965167": 5, "024684": 5, "612281": 5, "280749": 5, "106545": 5, "669442": 5, "453932": 5, "952": 5, "6834": 5, "405068": 5, "739": 5, "4256": 5, "907": 5, "5366": 5, "959": 5, "737": 5, "673": 5, "7423": 5, "042": 5, "950": 5, "7427": 5, "202": 5, "7448": 5, "291": 5, "688": [5, 8], "570": [5, 14], "005": 5, "7679": 5, "7691": 5, "944": 5, "7828": 5, "8013": 5, "035": [5, 14], "1786": 5, "12741": 5, "970206": 5, "0192009": 5, "748832": 5, "618445": 5, "8683": 5, "2352": 5, "554": 5, "88581": 5, "520903": 5, "6764": 5, "2029": 5, "936762": 5, "182": 5, "366": 5, "774": [5, 12], "876": 5, "606": [5, 13], "414": 5, "757": [5, 8], "8805": 5, "11707": 5, "0166": 5, "00286793": 5, "00239838": 5, "090": 5, "985359": 5, "790941": 5, "0896": 5, "96963": 5, "3282": 5, "1923": 5, "181": 5, "797": 5, "57739": 5, "8140": 5, "645763": 5, "309361": 5, "0877243": 5, "351532": 5, "959422": 5, "659": 5, "02823": 5, "301483": 5, "280": 5, "674": [5, 16], "6181": 5, "698517": 5, "942": 5, "9927": [5, 12], "4807": 5, "58504": 5, "914": 5, "6905": 5, "4243": 5, "533": 5, "692": 5, "9264": 5, "798": 5, "854": 5, "271": 5, "761": 5, "097": 5, "7460": 5, "7472": 5, "806": 5, "7589": 5, "778": 5, "7595": 5, "856": [5, 13], "874": 5, "7689": 5, "981": 5, "7690": 5, "988": 5, "7863": 5, "059": 5, "9110": 5, "061": 5, "1514": 5, "1915": 5, "058": 5, "1920": 5, "784972": 5, "231704": 5, "950733": 5, "127442": 5, "999122": 5, "3758": 5, "8545": 5, "27767": 5, "84071": 5, "7969": 5, "952496": 5, "4957": 5, "26441": 5, "269": 5, "9351": 5, "243583": 5, "4666": 5, "11346": 5, "00300971": 5, "00247821": 5, "651": 5, "882017": 5, "700359": 5, "6514": 5, "40049": 5, "869544": 5, "1839": 5, "837": 5, "46220": 5, "787": 5, "82245": 5, "0531294": 5, "367268": 5, "912283": 5, "67023": 5, "0670735": 5, "315": 5, "815": 5, "421436": 5, "347405": 5, "7875": 5, "70005": 5, "6185": 5, "14212": 5, "481": 5, "84428": 5, "1847": 5, "4455": 5, "116": 5, "237": 5, "4540": 5, "765": 5, "777": 5, "6822": 5, "482": 5, "6831": 5, "7214": 5, "483": 5, "7219": 5, "7422": 5, "7449": 5, "893": 5, "534": 5, "216": 5, "053": 5, "7657": 5, "965": [5, 14], "7781": 5, "7782": 5, "7962": 5, "040": 5, "8182": 5, "1695": 5, "3038": 5, "0714679": 5, "144141": 5, "608655": 5, "0385396": 5, "8372": 5, "2112": 5, "263": 5, "242151": 5, "219058": 5, "364": 5, "681": 5, "929": 5, "706483": 5, "2053": 5, "0641": 5, "353": 5, "4018": 5, "50537": 5, "7633": 5, "70054": 5, "524": 5, "60636": 5, "493975": 5, "450818": 5, "456519": 5, "938568": 5, "859977": 5, "671": 5, "40339": 5, "06987": 5, "5244": 5, "281309": 5, "4176": 5, "2834": 5, "2268": 5, "9537": 5, "7046": 5, "4755": 5, "228": 5, "295": 5, "7429": 5, "047": [5, 17], "661": 5, "529": 5, "084": 5, "986": [5, 8], "886": 5, "678": [5, 12], "7774": 5, "7789": 5, "7944": 5, "8141": 5, "027": 5, "498232": 5, "463455": 5, "752134": 5, "246625": 5, "139044": 5, "9423": 5, "2924": 5, "091": 5, "873639": 5, "531411": 5, "258": [5, 8], "872316": 5, "2224": 5, "2632": 5, "602": 5, "99203": 5, "1612": 5, "6094": 5, "8091": 5, "1825": 5, "67245": 5, "42052": 5, "938576": 5, "0316266": 5, "659526": 5, "104997": 5, "0823499": 5, "4867": 5, "51742": 5, "910817": 5, "3563": 5, "205353": 5, "4670": 5, "522": 5, "884": 5, "016": 5, "7438": 5, "7446": 5, "7452": 5, "805": 5, "7759": 5, "646": 5, "7928": 5, "8121": 5, "852712": 5, "248871": 5, "398927": 5, "135164": 5, "756795": 5, "9323": 5, "2846": 5, "809": [5, 6], "497": 5, "75508": 5, "817843": 5, "872": 5, "454013": 5, "1807": 5, "226": 5, "064": 5, "581": 5, "1816": 5, "648": 5, "1713": 5, "2081": 5, "2182": 5, "52058": 5, "1062": 5, "447918": 5, "0727584": 5, "93044": 5, "693944": 5, "896286": 5, "63153": 5, "39834": 5, "2216": 5, "743837": 5, "8917": 5, "0831": 5, "56865": 5, "4365": 5, "1314": 5, "5735": 5, "1753": 5, "3767": 5, "564": 5, "4192": 5, "865": 5, "7988": 5, "7997": 5, "7500": 5, "319": 5, "927": 5, "110": 5, "7530": 5, "7544": 5, "7644": 5, "611": [5, 13], "7650": 5, "7750": 5, "7907": 5, "8276": 5, "2156": 5, "068": 5, "608269": 5, "309461": 5, "901988": 5, "741346": 5, "691586": 5, "2063": 5, "9505": 5, "198": 5, "609": 5, "34537": 5, "503726": 5, "484": 5, "871": 5, "648549": 5, "37409": 5, "4013": 5, "828858": 5, "404962": 5, "512561": 5, "876382": 5, "718549": 5, "51478": 5, "852252": 5, "324": 5, "478807": 5, "130": 5, "311": 5, "821": 5, "890": 5, "7461": 5, "7960": 5, "186": [5, 13], "7975": 5, "736": [5, 8], "8104": 5, "8292": 5, "1784": 5, "1810": 5, "335642": 5, "191543": 5, "332777": 5, "97316": 5, "569581": 5, "0394": 5, "3674": 5, "076": 5, "57878": 5, "24165": 5, "624125": 5, "15907": 5, "802": 5, "9153": 5, "5619": 5, "675": 5, "504": 5, "850": 5, "1821": 5, "48336": 5, "16833": 5, "0910814": 5, "677623": 5, "874638": 5, "910419": 5, "847153": 5, "785": 5, "32282": 5, "962876": 5, "6179": 5, "18148": 5, "085": 5, "2816": 5, "596": [5, 13], "8523": 5, "8654": 5, "4797": 5, "954": 5, "464": 5, "855": 5, "962": 5, "214": 5, "644": [5, 13], "841": 5, "7803": 5, "7819": 5, "7973": 5, "7974": 5, "8163": 5, "1637": 5, "567303": 5, "507104": 5, "0563088": 5, "15884": 5, "9606": 5, "3065": 5, "248": [5, 8], "998023": 5, "09164": 5, "264": 5, "835": 5, "741448": 5, "1005": 5, "712": 5, "514": 5, "1035": 5, "8379": 5, "6797": 5, "1747": 5, "744": 5, "904": 5, "16837": 5, "471": 5, "20980": 5, "962482": 5, "401263": 5, "689781": 5, "991224": 5, "841718": 5, "28867": 5, "597": 5, "4714": 5, "43618": 5, "7823": 5, "1736": 5, "6604": 5, "6032": 5, "1715": 5, "4380": 5, "7425": 5, "662": 5, "381": 5, "931": 5, "7735": 5, "193": 5, "7883": 5, "8071": 5, "031": 5, "832981": 5, "367793": 5, "0528412": 5, "325965": 5, "929511": 5, "9038": 5, "2626": 5, "395": 5, "84029": 5, "355513": 5, "544": 5, "518851": 5, "0335": 5, "1485": 5, "273": 5, "2551": 5, "3959": 5, "01561": 5, "6745": 5, "926": 5, "64463": 5, "41238": 5, "0789786": 5, "697827": 5, "336295": 5, "0232618": 5, "981292": 5, "16564": 5, "26456": 5, "0013": 5, "476589": 5, "6379": 5, "2221": 5, "2802": 5, "70043": 5, "5904": 5, "567": 5, "4734": 5, "801": 5, "861": 5, "119": 5, "026": 5, "853": 5, "7751": 5, "138": 5, "740": 5, "7766": 5, "735": 5, "7919": 5, "8111": 5, "029": 5, "659743": 5, "318753": 5, "774969": 5, "492302": 5, "125968": 5, "9263": 5, "2801": 5, "227": 5, "791478": 5, "0153961": 5, "884461": 5, "2132": 5, "9779": 5, "7631": 5, "727196": 5, "3273": [5, 13], "019": 5, "2437": 5, "257": [5, 43], "54371": 5, "36403": 5, "82064": 5, "137502": 5, "935816": 5, "181795": 5, "297187": 5, "86728": 5, "689835": 5, "266485": 5, "960": 5, "7435": 5, "336": 5, "7457": 5, "759": 5, "494": 5, "7911": 5, "185": 5, "389": 5, "8067": 5, "8261": 5, "8435": 5, "1624": [5, 13], "209274": 5, "548864": 5, "783792": 5, "0770302": 5, "187694": 5, "0171": 5, "3502": 5, "17932": 5, "00832": 5, "230": 5, "915": [5, 8], "829668": 5, "38921": 5, "474": 5, "4369": 5, "251": [5, 8], "937": 5, "569": 5, "1819": 5, "1841": 5, "825": 5, "81562": 5, "32076": 5, "512617": 5, "817888": 5, "592309": 5, "885537": 5, "150681": 5, "946757": 5, "880528": 5, "795": [5, 32], "978": 5, "807361": 5, "289": 5, "13298": 5, "3771": 5, "3127": 5, "4218": 5, "4764": 5, "175": 5, "4387": 5, "811": 5, "807": 5, "6384": 5, "6388": 5, "631": [5, 8], "7292": 5, "7296": 5, "052": 5, "7635": 5, "511": 5, "7645": 5, "7765": 5, "7943": 5, "8339": 5, "1678": 5, "551072": 5, "608485": 5, "94464": 5, "243214": 5, "899464": 5, "8251": 5, "6515": 5, "539343": 5, "701": 5, "428699": 5, "8354": 5, "6212": 5, "0523": 5, "0208": 5, "8441": 5, "975": 5, "1811": 5, "562": 5, "1815": 5, "003": 5, "68746": 5, "19907": 5, "768655": 5, "0583837": 5, "429398": 5, "789859": 5, "720749": 5, "0295": 5, "5286": 5, "618382": 5, "205537": 5, "818": 5, "049": 5, "506": 5, "7882": 5, "7898": 5, "8044": 5, "8234": 5, "123048": 5, "307199": 5, "581558": 5, "0991059": 5, "0907537": 5, "0034": 5, "3396": 5, "570222": 5, "930282": 5, "209": 5, "670422": 5, "5221": 5, "57062": 5, "9036": 5, "9427": 5, "866": 5, "26051": 5, "82797": 5, "670413": 5, "0772021": 5, "151616": 5, "253705": 5, "893941": 5, "61679": 5, "515062": 5, "247": [5, 16], "5456": 5, "411151": 5, "616": [5, 13], "4304": 5, "5301": 5, "738": 5, "955": 5, "545": 5, "559": 5, "7677": 5, "566": [5, 19], "7825": 5, "7826": 5, "8010": 5, "1783": 5, "0283541": 5, "410828": 5, "567898": 5, "0335017": 5, "139732": 5, "8664": 5, "2338": 5, "197": 5, "677": 5, "877963": 5, "20265": 5, "4202": 5, "896196": 5, "3957": 5, "859": 5, "3025": 5, "5919": 5, "8605": 5, "8924": 5, "1088": 5, "5977": 5, "11506": 5, "0162": 5, "00296406": 5, "00247864": 5, "088": 5, "760064": 5, "126532": 5, "0877": 5, "795024": 5, "547002": 5, "490": 5, "947": 5, "832": 5, "974": 5, "75931": 5, "054": [5, 32], "19521": 5, "859753": 5, "23894": 5, "62549": 5, "77541": 5, "227249": 5, "42785": 5, "583346": 5, "0535": 5, "301129": 5, "262": 5, "892": 5, "629": [5, 13], "7440": 5, "7454": 5, "709": 5, "7827": 5, "7843": 5, "7996": 5, "8196": 5, "9902": 5, "0995": 5, "123635": 5, "335153": 5, "0259932": 5, "335847": 5, "105082": 5, "9743": 5, "3172": 5, "66025": 5, "33451": 5, "089": 5, "818294": 5, "689": 5, "6909": 5, "443": 5, "918543": 5, "4048": 5, "819": 5, "57538": 5, "46057": 5, "517454": 5, "325743": 5, "975864": 5, "00707417": 5, "739962": 5, "699": 5, "64932": 5, "40238": 5, "743": 5, "196177": 5, "963": [5, 8, 14], "752": 5, "7920": 5, "7936": 5, "8074": 5, "8263": 5, "1670": 5, "973135": 5, "35487": 5, "431313": 5, "180453": 5, "831236": 5, "0214": 5, "3536": 5, "22281": 5, "693321": 5, "293512": 5, "605": 5, "2214": 5, "4507": 5, "6328": 5, "2618": 5, "1831": 5, "80402": 5, "565": 5, "79911": 5, "897612": 5, "696284": 5, "954848": 5, "0469097": 5, "915148": 5, "297": 5, "676": 5, "75005": 5, "13416": 5, "5652": 5, "448401": 5, "2057": 5, "9912": 5, "8493": 5, "2991": 5, "3757": 5, "5734": 5, "4321": 5, "6626": 5, "966": 5, "773": 5, "7384": 5, "902": 5, "558": 5, "530": 5, "7705": 5, "7718": 5, "7864": 5, "8050": 5, "263235": 5, "959492": 5, "915221": 5, "263079": 5, "72611": 5, "8912": 5, "2529": 5, "647": 5, "56228": 5, "493648": 5, "906299": 5, "8975": 5, "958": 5, "211": [5, 14, 15], "746": 5, "0745": 5, "3243": 5, "686": 5, "2295": 5, "772": 5, "1781": 5, "64611": 5, "101955": 5, "189239": 5, "951597": 5, "398381": 5, "970505": 5, "917": 5, "09786": 5, "204663": 5, "9073": 5, "773166": 5, "6344": 5, "7315": 5, "62366": 5, "9105": 5, "2472": 5, "1575": 5, "079": [5, 6], "2914": 5, "4183": 5, "911": 5, "6749": 5, "6758": 5, "7536": 5, "638": [5, 13], "791": 5, "363": 5, "7564": 5, "7566": 5, "783": [5, 12], "7582": 5, "7678": 5, "7684": 5, "7790": 5, "065": 5, "985": 5, "071": 5, "2210": 5, "063": 5, "2261": 5, "12806": 5, "912327": 5, "690746": 5, "544482": 5, "155342": 5, "7717": 5, "6145": 5, "964": [5, 14], "087": 5, "976041": 5, "0890815": 5, "951344": 5, "345": 5, "0907": 5, "463": 5, "3471": 5, "8972": 5, "12136": 5, "4981": 5, "812": 5, "5051": 5, "10782": 5, "015": 5, "00317508": 5, "00248439": 5, "600593": 5, "164714": 5, "1098": 5, "03493": 5, "202569": 5, "9339": 5, "938": 5, "1843": 5, "808": 5, "176": 5, "804": 5, "34175": 5, "953": 5, "78012": 5, "970783": 5, "761478": 5, "514087": 5, "706029": 5, "819715": 5, "15042": 5, "424712": 5, "656": 5, "528102": 5, "3719": 5, "2291": 5, "7184": 5, "0784": 5, "499": 5, "4357": 5, "378": 5, "1334": 5, "5324": 5, "5703": 5, "5712": 5, "775": [5, 19], "7354": 5, "7359": 5, "7419": 5, "7421": 5, "525": 5, "7620": 5, "883": 5, "7629": 5, "7741": 5, "7742": 5, "7918": 5, "8533": 5, "1610": 5, "179142": 5, "296544": 5, "237203": 5, "0156945": 5, "617224": 5, "8039": 5, "1854": 5, "87813": 5, "31958": 5, "585": 5, "464494": 5, "041": 5, "1633": 5, "68376": 5, "35051": 5, "566263": 5, "0474164": 5, "750149": 5, "0787729": 5, "537743": 5, "4162": 5, "37874": 5, "00182": 5, "306619": 5, "833": 5, "7462": 5, "814": 5, "7965": 5, "188": 5, "7980": 5, "191": 5, "782": 5, "8107": 5, "8108": 5, "8295": 5, "473762": 5, "894041": 5, "457987": 5, "738399": 5, "315223": 5, "0414": 5, "98061": 5, "497008": 5, "942854": 5, "7879": 5, "3589": 5, "8452": 5, "9595": 5, "1631": 5, "2305": 5, "39521": 5, "3419": 5, "32684": 5, "0533803": 5, "740494": 5, "317663": 5, "857699": 5, "38908": 5, "373282": 5, "1977": 5, "359784": 5, "326": 5, "4311": 5, "6474": 5, "750": [5, 6], "7380": 5, "056": [5, 17], "710": 5, "7709": 5, "7722": 5, "7868": 5, "8055": 5, "709965": 5, "260676": 5, "438861": 5, "0625403": 5, "328066": 5, "8941": 5, "2552": 5, "0613": 5, "06527": 5, "613167": 5, "36957": 5, "86334": 5, "215638": 5, "175004": 5, "932839": 5, "339587": 5, "829017": 5, "20887": 5, "326601": 5, "1104": 5, "38009": 5, "4438": 5, "6934": 5, "7322": 5, "700": [5, 19], "705": [5, 19], "830": [5, 19], "968": 5, "7720": 5, "7734": 5, "8076": 5, "124496": 5, "659469": 5, "0744186": 5, "706126": 5, "225135": 5, "9032": 5, "2622": [5, 13], "698": [5, 13], "41457": 5, "424924": 5, "9093": 5, "939378": 5, "3649": 5, "0868": 5, "634": [5, 13], "1108": 5, "5094": 5, "1392": 5, "7028": 5, "8881": 5, "12548": 5, "0184": 5, "00254115": 5, "0021272": 5, "826831": 5, "573703": 5, "60468": 5, "712414": 5, "517": 5, "817": [5, 12], "2157": 5, "1817": 5, "3008": 5, "1835": 5, "33719": 5, "81352": 5, "202196": 5, "453412": 5, "935069": 5, "374905": 5, "177551": 5, "987": 5, "11558": 5, "252877": 5, "1043": 5, "548589": 5, "4333": 5, "939": 5, "693": [5, 8], "970": 5, "526": 5, "7671": 5, "858": [5, 6], "7683": 5, "7817": 5, "8001": 5, "1775": 5, "912238": 5, "432729": 5, "998563": 5, "996798": 5, "823767": 5, "17588": 5, "45757": 5, "737411": 5, "573": 5, "5557": 5, "4102": 5, "3495": 5, "4945": 5, "2528": 5, "1808": 5, "2629": 5, "668": 5, "14764": 5, "77631": 5, "524755": 5, "166559": 5, "560118": 5, "228555": 5, "671001": 5, "21603": 5, "573874": 5, "469": 5, "418029": 5, "7967": 5, "7982": 5, "8109": 5, "8300": 5, "492707": 5, "583436": 5, "489077": 5, "445821": 5, "760389": 5, "0425": 5, "3698": 5, "77766": 5, "108571": 5, "426": 5, "615165": 5, "4788": 5, "8791": 5, "8271": 5, "88343": 5, "3264": 5, "1551": 5, "3154": 5, "062": 5, "1809": 5, "476": 5, "80954": 5, "62200": 5, "492484": 5, "298194": 5, "807403": 5, "382144": 5, "303533": 5, "90716": 5, "237951": 5, "847": 5, "539941": 5, "7439": 5, "822": 5, "7964": 5, "7979": 5, "8299": 5, "1792": 5, "623354": 5, "732953": 5, "639951": 5, "492818": 5, "729193": 5, "0411": 5, "3688": 5, "58166": 5, "0143651": 5, "828241": 5, "0791": 5, "755": 5, "7188": 5, "9851": 5, "5681": 5, "50652": 5, "4845": 5, "2371": 5, "4623": 5, "1827": 5, "61117": 5, "46822": 5, "585985": 5, "665969": 5, "751305": 5, "588396": 5, "216951": 5, "36314": 5, "177727": 5, "645286": 5, "095": 5, "094": [5, 8], "244": [5, 17], "799": 5, "7899": 5, "8095": 5, "030": 5, "888123": 5, "610285": 5, "315404": 5, "683467": 5, "789064": 5, "9139": 5, "075": 5, "682": [5, 8], "95783": 5, "375712": 5, "441158": 5, "532": 5, "1075": 5, "1449": [5, 13], "4509": 5, "6058": 5, "2878": 5, "33879": 5, "282623": 5, "472318": 5, "115722": 5, "685872": 5, "936532": 5, "278": 5, "88441": 5, "380887": 5, "36016": 5, "8992": 5, "3042": 5, "54027": 5, "7886": 5, "7958": 5, "8280": 5, "1729": 5, "433477": 5, "791274": 5, "413467": 5, "495924": 5, "706984": 5, "0319": 5, "3616": 5, "44211": 5, "0081514": 5, "916093": 5, "2021": [5, 6, 8, 13], "2927": 5, "766": 5, "0837": 5, "315903": 5, "8939": 5, "1858": 5, "5112": 5, "82486": 5, "619099": 5, "101038": 5, "840994": 5, "542419": 5, "00585495": 5, "0367878": 5, "0849409": 5, "0128": 5, "676215": 5, "518": 5, "477089": 5, "287": 5, "796": 5, "807331": 5, "6832": 5, "168972": 5, "6883": 5, "845": 5, "4961": 5, "594": 5, "8443": 5, "3034": 5, "4188": 5, "4197": 5, "086": 5, "7420": 5, "880": 5, "722": 5, "7598": 5, "7605": 5, "7706": 5, "7877": 5, "8935": 5, "1492": 5, "478253": 5, "42097": 5, "939376": 5, "196311": 5, "22518": 5, "7108": 5, "41485": 5, "652755": 5, "6161": 5, "469056": 5, "1833": 5, "25164": 5, "391798": 5, "388321": 5, "507443": 5, "208169": 5, "830541": 5, "21844": 5, "623232": 5, "402961": 5, "4501": 5, "428": 5, "779": 5, "7891": 5, "917439": 5, "479973": 5, "922199": 5, "806722": 5, "769195": 5, "9087": 5, "2664": 5, "092": 5, "660415": 5, "322": 5, "096": 5, "728237": 5, "313": 5, "867": 5, "977": 5, "36298": 5, "829": 5, "9189": 5, "308203": 5, "0621119": 5, "366259": 5, "740929": 5, "96161": 5, "04198": 5, "502775": 5, "8293": 5, "366392": 5, "8635": 5, "5612": 5, "3244": 5, "0719": 5, "51819": 5, "9214": 5, "946": 5, "7831": 5, "7848": 5, "8000": 5, "8195": 5, "9814": 5, "1082": 5, "171096": 5, "480045": 5, "808134": 5, "257278": 5, "205527": 5, "29136": 5, "50687": 5, "988755": 5, "8399": 5, "4108": 5, "4822": 5, "1796": 5, "2127": 5, "8961": 5, "8252": 5, "11239": 5, "0156": 5, "00311757": 5, "00261516": 5, "6429": 5, "208453": 5, "2008": 5, "30975": 5, "28984": 5, "2836": 5, "734": 5, "54307": 5, "77455": 5, "359881": 5, "325197": 5, "29816": 5, "208923": 5, "805733": 5, "06257": 5, "621375": 5, "0501": 5, "344772": 5, "4825": 5, "477": 5, "663": 5, "523": 5, "918": 5, "732": 5, "7773": [5, 19], "527": 5, "8138": 5, "953798": 5, "649327": 5, "456313": 5, "316118": 5, "249106": 5, "2921": 5, "56518": 5, "376604": 5, "8003": 5, "834303": 5, "2275": 5, "5593": 5, "2871": 5, "3978": 5, "8031": 5, "6562": 5, "11854": 5, "0169": 5, "00280816": 5, "00235329": 5, "559889": 5, "750806": 5, "71746": 5, "120066": 5, "8569": 5, "76134": 5, "0393944": 5, "347623": 5, "960734": 5, "465867": 5, "145296": 5, "555": [5, 8], "912919": 5, "0683196": 5, "623052": 5, "4379": 5, "0608": 5, "4622": 5, "5208": 5, "5217": 5, "7386": 5, "7390": 5, "912": 5, "578": 5, "983": 5, "7612": 5, "708": 5, "7728": 5, "7902": 5, "8694": 5, "1553": 5, "197729": 5, "670337": 5, "663976": 5, "124931": 5, "888613": 5, "1691": 5, "58332": 5, "84827": 5, "292641": 5, "7666": 5, "5738": 5, "9304": 5, "7626": 5, "39831": 5, "953738": 5, "256488": 5, "181244": 5, "00666382": 5, "226424": 5, "42266": 5, "40735": 5, "423": 5, "127957": 5, "590": 5, "7893": 5, "7909": 5, "8053": 5, "8250": 5, "8731": 5, "1527": 5, "00518983": 5, "196046": 5, "634261": 5, "332251": 5, "153852": 5, "0087": 5, "3438": 5, "628": [5, 13], "966681": 5, "342134": 5, "997751": 5, "3331": 5, "14112": 5, "7269": 5, "967": 5, "2075": 5, "11182": 5, "0155": 5, "00319483": 5, "00268237": 5, "202339": 5, "130725": 5, "2333": 5, "821367": 5, "637666": 5, "47419": 5, "56631": 5, "460081": 5, "633684": 5, "547729": 5, "321082": 5, "954624": 5, "99808": 5, "365949": 5, "4422": 5, "335428": 5, "6413": 5, "7413": 5, "8638": 5, "75921": 5, "9147": 5, "074": 5, "7844": 5, "7861": 5, "8012": 5, "8202": 5, "9557": 5, "1219": 5, "224923": 5, "249848": 5, "781046": 5, "0784722": 5, "326147": 5, "9842": 5, "3248": 5, "04924": 5, "00294": 5, "787368": 5, "83762": 5, "64359": 5, "776818": 5, "472105": 5, "63923": 5, "939757": 5, "21764": 5, "36747": 5, "07484": 5, "328512": 5, "7925": 5, "8065": 5, "8066": 5, "8254": 5, "8429": 5, "1618": 5, "942154": 5, "0122109": 5, "00984861": 5, "664546": 5, "183974": 5, "0164": 5, "3497": 5, "15594": 5, "335342": 5, "523561": 5, "1722": 5, "1571": 5, "44170": 5, "7319": 5, "174169": 5, "242309": 5, "841284": 5, "736112": 5, "693128": 5, "35505": 5, "491811": 5, "486": 5, "541792": 5, "704": 5, "684": [5, 8], "7990": 5, "8115": 5, "8303": 5, "675689": 5, "111583": 5, "429122": 5, "183048": 5, "0536749": 5, "0461": 5, "3726": [5, 13], "769": 5, "337249": 5, "686591": 5, "753": 5, "64265": 5, "9255": 5, "8585": 5, "924": 5, "92382": 5, "5775": 5, "20938": 5, "4872": 5, "697": 5, "64137": 5, "63818": 5, "295543": 5, "0290733": 5, "983229": 5, "514916": 5, "177444": 5, "11491": 5, "0298364": 5, "9046": 5, "315124": 5, "303": 5, "4454": 5, "538": 5, "933": 5, "823": 5, "838": [5, 6], "669": 5, "7745": 5, "7912": 5, "8101": 5, "752438": 5, "590877": 5, "920832": 5, "48926": 5, "135101": 5, "2767": 5, "767": 5, "848866": 5, "0214824": 5, "97797": 5, "10877": 5, "44558": 5, "1967": 5, "16265": 5, "5333": 5, "1663": 5, "1845": 5, "21824": 5, "15186": 5, "618705": 5, "0958704": 5, "380393": 5, "596161": 5, "941478": 5, "91548": 5, "193528": 5, "2961": 5, "584622": 5, "1204": [5, 19], "0187": 5, "617": [5, 13], "2044": 5, "51809": 5, "3017": 5, "4330": 5, "1178": 5, "5089": 5, "956": 5, "5532": 5, "7365": 5, "7370": 5, "561": 5, "7736": 5, "7737": 5, "7913": 5, "8573": 5, "1606": 5, "86323": 5, "0440989": 5, "389749": 5, "19366": 5, "310029": 5, "1804": 5, "2413": 5, "94797": 5, "659448": 5, "245223": 5, "1806": 5, "4076": 5, "36323": 5, "347169": 5, "666661": 5, "916207": 5, "695505": 5, "213396": 5, "34081": 5, "401728": 5, "611785": 5, "7757": 5, "7772": 5, "670": 5, "7926": 5, "725718": 5, "420316": 5, "312637": 5, "321643": 5, "755323": 5, "9309": 5, "2835": 5, "74583": 5, "364747": 5, "766094": 5, "919": 5, "916": 5, "2898": 5, "42362": 5, "18108": 5, "785539": 5, "0547419": 5, "829757": 5, "994118": 5, "162941": 5, "02379": 5, "41726": 5, "4865": 5, "824848": 5, "622494": 5, "9859": 5, "7282": 5, "8155": 5, "1379": 5, "1517": 5, "1521": 5, "4182": 5, "7761": 5, "745": 5, "7792": 5, "7795": 5, "7813": 5, "7901": 5, "8048": 5, "8200": 5, "9253": 5, "2514": 5, "2819": 5, "770532": 5, "458064": 5, "288353": 5, "635703": 5, "971941": 5, "9179": 5, "10689": 5, "274854": 5, "470": 5, "4959": 5, "465133": 5, "7085": 5, "6885": 5, "1498": 5, "6674": 5, "31408": 5, "6908": 5, "645": [5, 13, 19], "6747": 5, "65262": 5, "633148": 5, "26637": 5, "057949": 5, "676181": 5, "732983": 5, "614": [5, 13], "60547": 5, "360093": 5, "382472": 5, "7903": 5, "8047": 5, "8245": 5, "8813": 5, "1478": 5, "912289": 5, "389208": 5, "840796": 5, "834483": 5, "0055": 5, "3412": 5, "732818": 5, "791991": 5, "72764": 5, "44852": 5, "646273": 5, "2556": 5, "70429": 5, "245209": 5, "792744": 5, "98096": 5, "534699": 5, "9471": 5, "317921": 5, "7806": 5, "8151": 5, "502451": 5, "121263": 5, "690203": 5, "229591": 5, "829726": 5, "9524": 5, "3002": 5, "21333": 5, "57141": 5, "421365": 5, "789": 5, "1306": 5, "21043": 5, "79412": 5, "055188": 5, "239704": 5, "41862": 5, "0131145": 5, "261343": 5, "64207": 5, "34126": 5, "153329": 5, "7436": 5, "7916": 5, "8058": 5, "8247": 5, "8596": 5, "1567": 5, "392194": 5, "816958": 5, "606169": 5, "906059": 5, "754141": 5, "3461": 5, "350": [5, 13], "947774": 5, "865806": 5, "863": [5, 8], "3963": 5, "4752": 5, "6579": 5, "6215": 5, "2477": [5, 13], "72983": 5, "105704": 5, "115297": 5, "826771": 5, "681473": 5, "713946": 5, "48586": 5, "371427": 5, "305334": 5, "748": [5, 19], "8059": 5, "8060": 5, "8249": 5, "8598": 5, "1569": 5, "168558": 5, "82325": 5, "838423": 5, "947719": 5, "637754": 5, "3469": 5, "00712": 5, "10941": 5, "111023": 5, "5358": 5, "3448": 5, "877": 5, "79264": 5, "70052": 5, "421475": 5, "12974": 5, "216067": 5, "0727126": 5, "806431": 5, "06696": 5, "02473": 5, "129879": 5, "6489": 5, "551": [5, 6], "7210": 5, "575": 5, "044": 5, "9900": 5, "0993": 5, "645339": 5, "239197": 5, "451732": 5, "787102": 5, "172014": 5, "9749": 5, "3176": 5, "0808": 5, "611632": 5, "971686": 5, "9869": 5, "4773": 5, "6225": 5, "3368": 5, "9610": 5, "11802": 5, "0168": 5, "00283345": 5, "00237669": 5, "48749": 5, "764629": 5, "8043": 5, "0250231": 5, "55982": 5, "34018": 5, "216496": 5, "518397": 5, "821301": 5, "789188": 5, "814387": 5, "889": 5, "11695": 5, "616737": 5, "6182": 5, "492242": 5, "4588": 5, "7743": 5, "920": 5, "8105": 5, "453348": 5, "9148": 5, "661725": 5, "141361": 5, "743118": 5, "9203": 5, "2754": 5, "66915": 5, "799889": 5, "757025": 5, "2881": 5, "9057": 5, "7537": 5, "10522": 5, "659581": 5, "610184": 5, "685255": 5, "768339": 5, "230955": 5, "45114": 5, "566495": 5, "54949": 5, "7845": 5, "9561": 5, "1222": 5, "132057": 5, "274445": 5, "86794": 5, "353432": 5, "774954": 5, "9841": 5, "3247": 5, "696": 5, "86918": 5, "297506": 5, "622081": 5, "24098": 5, "22036": 5, "995687": 5, "502841": 5, "600258": 5, "531293": 5, "00730797": 5, "0459174": 5, "0626266": 5, "523485": 5, "659393": 5, "8678": 5, "146844": 5, "7659": 5, "488": 5, "7842": 5, "7858": 5, "8009": 5, "8199": 5, "9598": 5, "1173": 5, "184464": 5, "215504": 5, "314533": 5, "333032": 5, "235464": 5, "9825": 5, "3235": 5, "47946": 5, "340477": 5, "545743": 5, "72617": 5, "83843": 5, "482668": 5, "103789": 5, "125553": 5, "477535": 5, "786062": 5, "93898": 5, "0449442": 5, "256783": 5, "626": [5, 13], "7797": 5, "7968": 5, "8158": 5, "854649": 5, "895821": 5, "257437": 5, "92995": 5, "671551": 5, "9573": 5, "21948": 5, "03507": 5, "613": [5, 13], "230102": 5, "9127": 5, "4229": 5, "4251": 5, "4949": 5, "639": [5, 13, 19], "839": 5, "462": [5, 19], "1560": 5, "21927": 5, "69808": 5, "280723": 5, "418757": 5, "552711": 5, "793832": 5, "244645": 5, "53715": 5, "628169": 5, "414875": 5, "7871": 5, "7887": 5, "8034": 5, "8224": 5, "9098": 5, "1415": 5, "496312": 5, "075416": 5, "7607": 5, "125886": 5, "290684": 5, "9977": 5, "3352": 5, "2613": 5, "82642": 5, "845387": 5, "32631": 5, "1846": 5, "788": 5, "77624": 5, "77505": 5, "50973": 5, "0448877": 5, "0251003": 5, "655371": 5, "876084": 5, "5046": 5, "315973": 5, "59429": 5, "4433": 5, "0722": 5, "082": 5, "4759": 5, "948": 5, "5309": 5, "5317": 5, "7381": 5, "7385": 5, "008": 5, "7613": 5, "7622": 5, "7730": 5, "7905": 5, "8653": 5, "1599": 5, "435809": 5, "148721": 5, "45889": 5, "674645": 5, "910981": 5, "72386": 5, "356812": 5, "0878": 5, "187993": 5, "9603": 5, "5982": 5, "2406": 5, "02786": 5, "math": [6, 8, 13, 14, 15, 16, 17, 35, 38], "matplotlib": [6, 8, 14, 15, 17, 19, 25], "pyplot": [6, 8, 14, 15, 17, 19], "plt": [6, 8, 14, 15, 17, 19], "notebook_hrd": 6, "our": [6, 8, 13, 14, 15, 22, 23, 32, 40], "mathrm": [6, 8, 13, 14, 15], "univers": [6, 8, 22], "These": [6, 7, 13, 14, 15, 16, 20, 22, 25, 26], "rough": 6, "real": [6, 13, 16, 35], "finit": [6, 8, 13, 14, 15], "ago": 6, "cannot": [6, 9, 16, 29, 31, 34], "geq": 6, "_": [6, 8, 13, 14, 15, 22, 34], "odot": [6, 8, 19], "through": [6, 7, 11, 12, 13, 14, 15, 16, 25, 26, 35, 41], "studi": [6, 23, 40], "leq": 6, "bse_opt": [6, 8, 13, 14, 15, 16, 21, 38], "grid_opt": [6, 8, 12, 13, 14, 15, 16, 21, 26, 29, 30, 31, 35, 36, 37, 38], "custom_opt": [6, 12, 13, 14, 15, 16, 21, 31], "physic": [6, 13, 14, 15, 16, 22], "13700": [6, 8], "nine": 6, "distribution_funct": [6, 8, 13, 15, 16, 21, 23, 24], "massrang": [6, 8, 13, 14, 15], "add_grid_vari": [6, 8, 13, 14, 15, 16, 35], "longnam": [6, 8, 13, 14, 15, 16, 35], "valuerang": [6, 8, 13, 14, 15, 16, 35], "samplerfunc": [6, 8, 13, 14, 15, 16, 22, 35, 38], "const": [6, 8, 13, 15], "probdist": [6, 8, 13, 14, 15, 16, 35], "dprob": [6, 8, 14, 15], "dm1": [6, 14, 15], "care": [6, 13, 14, 15, 22], "dphasevol": [6, 8, 13, 14, 15, 16, 35], "dm_1": [6, 14, 15], "condit": [6, 8, 9, 13, 14, 15, 16, 18, 19, 35], "impos": [6, 8, 13, 14, 15, 16], "mostli": [6, 8, 13, 14, 15, 16, 19, 20, 22, 25, 34, 41], "yourself": [6, 8, 13, 14, 15, 16, 25], "gridtyp": [6, 8, 16, 35], "precod": [6, 8, 13, 14, 15, 16, 35], "postcod": [6, 8, 16, 35], "branchpoint": [6, 8, 16, 35], "branchcod": [6, 8, 16, 35], "topcod": [6, 8, 16, 35], "bottomcod": [6, 8, 16, 35], "grid_variable_numb": [6, 8, 35], "asymptot": 6, "made": [6, 26], "bit": [6, 13], "messi": 6, "avoid": [6, 7, 8], "track": [6, 22, 25], "custom_logging_stat": [6, 8, 13, 14, 15], "foreach_star": [6, 13], "outermost_core_mass": 6, "doubl": [6, 9, 16, 20], "logteff": 6, "teff_from_star_struct": 6, "logl": 6, "loggrav": 6, "tini": 6, "gravitational_const": 6, "m_sun": 6, "pow2": 6, "r_sun": 6, "starnum": [6, 13], "zero_ag": [6, 9, 12, 13, 14, 15, 16], "c_logging_cod": [6, 8, 9, 12, 13, 14, 15, 16, 22], "lt": [6, 7, 8, 12, 14, 16, 17, 18], "amp": [6, 8], "catch": [6, 8, 12, 13, 14, 15, 16, 19, 20, 22], "doesn": [6, 22], "associ": [6, 8, 13, 14, 15, 30, 37], "datalinedict": [6, 8, 13, 14, 15, 20], "parse_funct": [6, 8, 12, 13, 14, 15, 16, 21, 22, 41], "self": [6, 8, 12, 13, 14, 15, 16, 21, 22, 26, 29, 30, 31, 32, 35, 37, 38, 39], "zams_mass": [6, 13, 14, 15, 16], "loop": [6, 8, 12, 13, 14, 15, 16, 31, 35], "splitlin": [6, 7, 8, 9, 12, 13, 14, 15, 16, 17], "search": [6, 13, 17, 23], "nstar": [6, 13], "group": [6, 13, 17, 39], "linedata": [6, 8, 13, 14, 15], "setup": [6, 16, 23, 40, 41], "grid_result": [6, 8, 13, 14, 15, 22], "results_dictionari": [6, 8, 13, 14, 15], "0x14bf2250fdc0": 6, "configur": [6, 11, 12, 13, 14, 15, 16, 19, 22, 27, 32], "part": [6, 7, 12, 13, 14, 15, 16, 19, 21, 30, 32, 35, 37, 43], "straightforward": [6, 13, 14, 15, 16], "num_cor": [6, 8, 13, 14, 15, 16, 22], "lot": [6, 13, 14, 15, 16, 17, 22, 39, 41], "There": [6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 19, 21, 22, 23, 25, 32, 34, 40], "ri0005": [6, 16, 23, 40], "surrei": [6, 16, 23, 40], "ac": [6, 16, 23, 40], "uk": [6, 16, 23, 40], "grid_options_descript": [6, 16, 34], "thread": [6, 8, 13, 14, 15, 20, 22, 33], "suffici": 6, "crunch": [6, 8, 13, 14, 15], "analyt": [6, 8, 13, 14, 15, 16, 21, 23, 24], "dry": [6, 8, 13, 14, 15, 16, 22, 35], "starcount": [6, 8, 13, 14, 15, 16], "binary_c_python": [6, 7, 8, 12, 13, 14, 15, 16, 20], "binary_c_grid_8a7d52edc59346ce991063d9e05e9ba7": 6, "py": [6, 8, 13, 14, 15, 16, 17, 22, 23, 29, 40], "dry_run": [6, 8, 13, 16], "symlink": [6, 8, 13, 16], "binary_c_grid": [6, 8, 13, 16], "latest0": [6, 8, 13], "mainprocess": [6, 8, 13], "system_queue_fil": [6, 8, 13], "processor": [6, 8, 13], "latest1": [6, 8, 13], "signal": [6, 8, 13, 22], "800": 6, "finish": [6, 8, 13, 14, 15, 16, 20, 25, 31], "free": [6, 8, 13], "01t09": [6, 8, 13], "838411": 6, "802706": 6, "ran": [6, 8, 13, 22], "had": [6, 8, 13, 14, 15, 21], "queue": [6, 8, 13, 22, 26, 30], "output_dict": [6, 8, 12, 13], "8a7d52edc59346ce991063d9e05e9ba7": 6, "took": [6, 8, 13, 14, 15, 16, 19], "mb": [6, 8, 13, 14, 15, 16, 20, 22], "were": [6, 8, 13, 14, 15, 16, 20, 39], "dict_kei": [6, 11, 12], "complet": [6, 8, 13, 14, 15, 16], "technic": [6, 8, 9, 13, 14, 15, 16], "population_nam": [6, 8, 13, 15], "evolution_typ": [6, 8, 13, 14, 15, 16, 22], "failed_count": [6, 8, 13, 14, 15, 16], "failed_prob": [6, 8, 13, 14, 15, 16], "failed_systems_error_cod": [6, 8, 13, 14, 15, 16], "errors_exceed": [6, 8, 13, 14, 15, 16], "errors_found": [6, 8, 13, 14, 15, 16], "total_prob": [6, 8, 13, 14, 15, 16], "total_count": [6, 8, 13, 14, 15, 16], "start_timestamp": [6, 8, 13, 14, 15, 16], "1635760192": 6, "8124797": 6, "end_timestamp": [6, 8, 13, 14, 15, 16], "1635760194": 6, "0176575": 6, "total_mass_run": [6, 8, 13, 14, 15, 16], "total_probability_weighted_mass_run": [6, 8, 13, 14, 15, 16], "zero_prob_stars_skip": [6, 8, 13, 14, 15, 16], "seaborn": [6, 8, 13, 14, 15, 17], "panda": [6, 8, 12, 13, 14, 15, 17, 18, 19, 20, 25], "pd": [6, 8, 12, 13, 14, 15, 17, 18, 19], "max_row": [6, 8, 17], "max_column": [6, 8, 17], "pad_output_distribut": [6, 8, 13, 14, 15, 20], "figur": [6, 8, 13, 14, 15, 17, 25], "figsiz": [6, 8, 13, 14, 15, 17, 19], "set_context": [6, 8, 13, 14, 15, 17], "font_scal": [6, 8, 13, 14, 15, 17], "linewidth": [6, 8, 13, 14, 15, 17], "datafram": [6, 8, 12, 13, 14, 15, 17, 18, 19, 25], "column": [6, 8, 12, 16, 17, 19, 25], "lineplot": [6, 8, 13, 14, 15, 17], "estim": [6, 17, 20, 22], "label": [6, 19, 32], "text": [6, 8, 17, 20, 34], "invert_xaxi": 6, "set_xlabel": [6, 8, 13, 14, 15, 17, 19], "log_": [6, 8, 13, 14, 15], "t_": 6, "eff": 6, "set_ylabel": [6, 8, 13, 14, 15, 17, 19], "distanc": [6, 17], "rerun": [6, 22], "At": [6, 16], "expect": [6, 7, 8, 13, 14, 15, 22, 23, 40], "begin": 6, "shortli": 6, "rsun": [6, 25], "alreadi": [6, 16, 17, 26, 31, 35], "Not": [6, 8], "binary_c_grid_f4e5925effeb42e69b5be956f400ae41": 6, "latest2": [6, 16], "latest3": 6, "093": [6, 17], "081024": 6, "246671": 6, "f4e5925effeb42e69b5be956f400ae41": 6, "suddenli": 6, "smooth": [6, 14, 15], "binary_c_grid_26171201413c43f5b91552a374879940": 6, "latest4": 6, "latest5": 6, "846045": 6, "416141": 6, "26171201413c43f5b91552a374879940": 6, "jerki": 6, "most": [6, 7, 8, 14, 15, 17, 20, 23, 40], "strong": 6, "rgb": 6, "tip": [6, 32], "proper": [6, 9, 34], "program": [6, 23, 40], "languag": 6, "sim": 6, "cours": [6, 25], "simpl": [6, 8, 13, 17], "introduct": 6, "haven": 6, "talk": 6, "produc": 6, "suffer": 6, "thermonuclear": 6, "luminosu": 6, "kilonova": 6, "interfac": [7, 17, 20, 23, 26, 40], "framework": [7, 23, 40], "sourcecod": [7, 9, 23, 40], "_binary_c_bind": [7, 9, 12, 17, 39, 43], "cell": [7, 13, 14, 15, 16], "free_persistent_data_memaddr_and_return_json_output": 7, "persistent_data": 7, "adress": [7, 9, 43], "persist": 7, "free_store_memaddr": 7, "memaddr": [7, 9], "return_arglin": 7, "return_help": 7, "info": [7, 11, 16, 20, 21, 23, 25, 39, 40], "return_help_al": [7, 20], "overview": 7, "categor": 7, "section": [7, 16, 20, 23, 32, 40], "return_maximum_mass_ratio_for_rlof": [7, 43], "argstr": [7, 9, 12, 17, 19], "store_capsul": 7, "unction": 7, "return_minimum_orbit_for_rlof": [7, 43], "return_persistent_data_memaddr": 7, "run_popul": 7, "return_store_memaddr": 7, "return_version_info": [7, 39], "abl": 7, "situat": 7, "slightli": 7, "custom_logging_func_memaddr": [7, 9, 22], "store_memaddr": [7, 43], "write_logfil": 7, "test_func": 7, "snippet": [7, 12], "reliabl": 7, "dont": [7, 19], "home": 7, "pyenv": [7, 14, 23, 40], "binarycpython3": 7, "lib": [7, 12, 14, 18, 19, 23, 40], "python3": [7, 14, 23, 40], "site": [7, 14], "cpython": 7, "x86_64": 7, "linux": 7, "gnu": 7, "categori": [7, 16], "creation": 7, "alloc": [7, 38], "written": [7, 12, 16, 22, 31, 34, 35, 41], "4500": 7, "0x7fc1f0c3ff00": 7, "single_star_lifetim": [7, 9, 12], "4838": [7, 9, 12], "unpars": 7, "join": [7, 9, 12, 14, 16, 19, 22, 26], "abridg": [7, 9, 16], "algorithm": [7, 23], "__arg_begin": 7, "lastli": [7, 12], "00632092": 7, "0141": 7, "alter": [8, 13, 35], "intermedi": 8, "notebook_comenv": 8, "alpha_": 8, "demonstr": 8, "keep": [8, 16, 31, 33], "log_dt": [8, 22], "focu": 8, "imposs": 8, "logperrang": [8, 13], "lnm1": [8, 13, 14, 15, 16], "min": [8, 9, 13, 14, 15, 16, 32], "exp": [8, 13, 14, 15, 16, 35], "three_part_powerlaw": [8, 13, 14, 15, 16, 32], "dlnm1": [8, 13, 16], "flatsect": [8, 13, 16, 32], "height": [8, 13, 16, 32], "dq": [8, 13, 16], "log10per": [8, 13, 16], "calc_sep_from_period": [8, 13, 16, 43], "sep_min": [8, 13, 16], "sep_max": [8, 13, 16], "sana12": [8, 13, 16, 32], "dlog10per": [8, 13, 16], "centr": [8, 16, 35], "nsep": 8, "nsep_min": 8, "nsep_max": 8, "comenv_count": 8, "proport": 8, "previou": [8, 14, 15, 20, 22, 39], "year_length_in_dai": 8, "wast": [8, 14, 15], "evolution_stop": 8, "parse_data": 8, "bin_data": [8, 13, 14, 15, 20], "binwidth": [8, 13, 14, 15, 20], "pre_comenv_period": 8, "post_comenv_period": 8, "nearest": [8, 13, 14, 15], "5dex": [8, 13, 14, 15], "binned_pre_period": 8, "aritif": 8, "binned_post_period": 8, "histogram": 8, "0x149c95c56c10": 8, "machin": [8, 22, 23, 40], "binary_c_grid_2b66f805db424c48a1d29c45092b6e3c": 8, "0645906": 8, "9s": [8, 13], "tpr": [8, 13], "28e": 8, "etf": [8, 13], "mem": [8, 13], "1mb": [8, 13], "1s": [8, 13], "34e": 8, "5mb": [8, 13], "6e": [8, 13], "6mb": [8, 13], "8s": [8, 13], "95e": 8, "4mb": [8, 13], "9e": 8, "7s": 8, "22e": 8, "685": [8, 13], "3mb": [8, 13], "4s": [8, 13], "58e": 8, "02e": [8, 13], "9mb": [8, 13], "810": 8, "20e": [8, 13], "0mb": [8, 13], "3s": [8, 13], "48e": [8, 13], "76e": 8, "2mb": [8, 13], "6s": [8, 13], "97e": [8, 13], "168379": 8, "323359": 8, "2m": [8, 13], "0163656": 8, "155678": 8, "991657": 8, "0175264": 8, "158640": 8, "099417": 8, "0143896": 8, "163481": 8, "732244": 8, "016309": 8, "2b66f805db424c48a1d29c45092b6e3c": 8, "8m": [8, 13], "06459059967730083": 8, "1635760256": 8, "1239555": 8, "1635760377": 8, "9739752": 8, "4680": 8, "235689312423": 8, "22611318083528548": 8, "unmerg": 8, "deepcopi": 8, "logper": [8, 32], "del": 8, "pad": [8, 13, 14, 15], "plot_data": [8, 13, 14, 15], "from_dict": [8, 13, 14, 15, 18, 19], "orient": 8, "p_": 8, "orb": [8, 16, 31], "xlim": [8, 17], "necessari": [8, 16, 17, 19, 20, 21, 37], "03502960360000004": 8, "019715467199999996": 8, "peak": [8, 14, 15, 38], "sim10": 8, "minut": [8, 20], "Such": 8, "prime": 8, "candid": 8, "excit": 8, "astrophys": [8, 14, 15, 23, 40], "life": 8, "compact": [8, 16], "lambda_": 8, "smoother": [8, 14, 15], "curv": [8, 14, 15], "why": 8, "learn": [9, 22], "custom_logging_funct": [9, 12, 16, 18, 19, 22, 23, 24], "edit": 9, "log_every_timestep": [9, 12], "evolve_singl": [9, 12, 21], "publicli": 9, "elabor": 9, "advis": 9, "hardcod": [9, 13, 14, 15, 16], "your": [9, 12, 18, 19, 22, 23, 40], "obvious": 9, "logging_lin": [9, 18, 19], "own": [9, 12, 16, 18, 19, 22, 23, 35, 40], "entir": [9, 12, 18, 19], "pragma": 9, "push_macro": 9, "undef": 9, "visibl": 9, "__attribute__": 9, "void": 9, "binary_c_api_funct": 9, "custom_output_funct": 9, "stardata_t": 9, "pop_macro": 9, "notebook_individual_system": [9, 12, 13, 14, 15, 16], "2e": [9, 13, 19], "example_logging_string_post_m": 9, "example_post_m": 9, "044142002936e": 9, "99194": 9, "13567": 9, "044572277695e": 9, "99192": 9, "51803": 9, "044654032097e": 9, "81395": 9, "045084306856e": 9, "99191": 9, "57443": 9, "manual": [9, 22, 23, 40], "custom_logging_memaddr": 9, "shared_lib_filenam": 9, "4530": [9, 12, 19], "example_logging_string_co": 9, "848380621869e": 9, "33469": 9, "1865": 9, "72498e": [9, 16], "example_massloss": [9, 12], "sn_type": 9, "sn_none": 9, "example_sn": 9, "id_cor": 9, "core_co": 9, "core_h": 9, "050651207308e": 9, "59452": 9, "34213": 9, "55458": 9, "71662": 9, "soon": [10, 38], "cover": [11, 13, 14, 15], "get_help": [11, 20], "get_help_al": [11, 20, 21], "get_help_sup": [11, 20], "get_default": [11, 20], "sever": [11, 16, 19, 22, 25, 34, 41], "print_help": [11, 20], "parameter_value_input_typ": [11, 20], "fetch": [11, 12], "return_binary_c_version_info": [11, 21, 39], "version_info": [11, 21, 23, 24], "argpair": [11, 39], "ensemble_filt": 11, "dt_limit": 11, "nucleosynthesis_sourc": [11, 39], "miscellan": [11, 39], "conjunct": 11, "analyz": 12, "quickli": 12, "simplest": 12, "notebook_custom_log": [12, 13, 14, 15, 16], "path": [12, 16, 19, 20, 22, 23, 26, 29, 30, 31, 34, 37, 40], "logfil": [12, 20, 23, 40], "uncom": [12, 13, 14, 15, 16, 17], "docstr": [12, 25], "12461": 12, "test_logfil": 12, "txt": [12, 16, 19, 23, 31, 40, 41], "22065": 12, "11003": 12, "1302": 12, "11582": 12, "2424": 12, "12325": 12, "1085": 12, "12457": 12, "1301": 12, "12460": 12, "8955": 12, "shrinkagb": 12, "1490": 12, "custom_log": [12, 19, 21, 22], "custom_logging_print_stat": 12, "000000000000e": 12, "column_nam": 12, "initial_mass": [12, 19], "value_lin": 12, "chose": 12, "startswith": 12, "split_lin": 12, "el": [12, 16], "numpi": [12, 16, 18, 19, 20, 35, 38], "arrai": [12, 16, 19, 20, 22, 32, 35, 38], "my": 12, "favorit": 12, "queri": [12, 26], "example_df": 12, "iloc": [12, 19], "drop": 12, "000001": 12, "000002": 12, "000003": 12, "1250": 12, "061259": 12, "718593": 12, "1251": 12, "149038": 12, "678026": 12, "1252": 12, "13461": 12, "1253": 12, "14461": 12, "row": [12, 19, 25], "notebook_popul": [12, 16], "everyth": [12, 16, 21, 22], "accordingli": [12, 14, 15, 16], "example_pop": [12, 16], "stuff": [12, 16, 22], "libcustom_logging_34a350b8f15c4d149deab88632948c99": 12, "np": [12, 18, 19, 38], "object_parse_funct": 12, "output_fil": [12, 20, 31, 34], "output_dir": [12, 16, 31], "example_output": 12, "values_arrai": 12, "fill": [12, 20], "anywai": [12, 16, 32, 35], "written_data": 12, "0x7f35b603e9d0": 12, "previous": [12, 16, 26], "libcustom_logging_446fe4cddfa94946bcafd55591ef3730": 12, "under": [12, 38], "hood": 12, "fewer": 12, "failsaf": 12, "notebook_api_funct": 12, "But": 12, "caught": [12, 20, 39], "correctli": [12, 19, 23, 40], "notebook_luminosity_funct": 13, "ipynb": [13, 14, 15, 16], "conceptu": 13, "public": [13, 14, 15, 16, 23], "purpos": [13, 14, 15, 16, 22, 25], "synthesi": [13, 14, 15, 16, 22, 23, 40], "side": [13, 14, 15, 16], "binarygrid": [13, 14, 15, 16], "predefin": [13, 14, 15, 16, 32], "assign": [13, 14, 15, 16, 35], "chosen": [13, 14, 15, 16, 35], "trio": [13, 14, 15, 16], "throughout": [13, 14, 15, 16, 35], "theoret": [13, 14, 15], "integr": [13, 14, 15, 32, 38], "densiti": [13, 14, 15, 32], "later": [13, 14, 15, 22], "accur": [13, 14, 15], "next": [13, 14, 15, 16, 20], "_1": [13, 14, 15], "cubic": 13, "cube": 13, "nre": [13, 38], "document": [13, 14, 15, 16, 22, 24, 31, 34], "recompil": [13, 14, 15, 16, 23, 40], "somewhat": [13, 14, 15, 16, 17], "perfectli": [13, 14, 15], "strictli": [13, 14, 15], "zero_age_main_sequence_starn": 13, "unresolv": 13, "model_numb": [13, 14, 15], "equival": [13, 22, 26], "capit": [13, 14, 15], "zero_age_main_sequence_star": [13, 14, 15], "1dex": [13, 14, 15], "binned_log_luminos": [13, 14, 15], "binary_c_grid_25014bc73b334765a1c09a4e4a97ed66": 13, "648566": 13, "690": 13, "1354": 13, "1355": 13, "11e": 13, "7e": 13, "1494": 13, "3m": 13, "7mb": 13, "1539": 13, "0m": 13, "1585": 13, "4m": 13, "36e": 13, "607": 13, "5m": 13, "56e": 13, "7m": 13, "79e": 13, "1703": 13, "83e": 13, "1749": 13, "9m": 13, "1780": 13, "14e": 13, "32e": 13, "44e": 13, "1879": 13, "52e": 13, "8mb": 13, "1910": 13, "1m": 13, "67e": 13, "1947": 13, "78e": 13, "5e": 13, "1968": 13, "82e": 13, "98e": 13, "15e": 13, "2048": 13, "24e": 13, "2071": 13, "31e": 13, "2091": 13, "42e": 13, "620": 13, "2122": 13, "55e": 13, "2143": 13, "59e": [13, 16], "623": 13, "2164": 13, "70e": 13, "2183": 13, "80e": 13, "2206": 13, "91e": 13, "2232": 13, "99e": 13, "2245": 13, "06e": 13, "2258": 13, "21e": 13, "2269": 13, "6m": 13, "2282": 13, "51e": 13, "2300": 13, "63e": 13, "2329": 13, "72e": 13, "2348": 13, "73e": 13, "2365": [13, 19], "81e": 13, "2383": 13, "90e": 13, "2400": 13, "2423": 13, "07e": 13, "2438": 13, "10e": 13, "2454": 13, "2466": 13, "29e": 13, "40e": 13, "2492": 13, "630": 13, "2516": 13, "2537": 13, "61e": 13, "2554": 13, "65e": 13, "2570": 13, "71e": 13, "2590": 13, "2636": 13, "2652": 13, "87e": 13, "2666": 13, "37e": 13, "75e": 13, "2746": 13, "2757": 13, "04e": 13, "2775": 13, "2795": 13, "2831": 13, "636": 13, "2845": 13, "2861": 13, "92e": 13, "2875": 13, "01e": 13, "2891": 13, "03e": 13, "2930": 13, "05e": 13, "2947": 13, "2965": 13, "2982": 13, "515": 13, "3010": 13, "3035": 13, "3059": 13, "3078": 13, "08e": 13, "3124": 13, "3148": 13, "3174": 13, "3197": 13, "3256": 13, "3294": 13, "641": 13, "3321": 13, "3348": 13, "3373": 13, "3394": 13, "642": 13, "3422": 13, "00e": 13, "3445": 13, "93e": 13, "3464": 13, "3483": 13, "96e": 13, "3509": 13, "3533": 13, "3550": 13, "3568": 13, "3588": 13, "64e": 13, "643": 13, "3622": 13, "68e": 13, "313623": 13, "3640": 13, "3657": 13, "50e": 13, "3676": 13, "53e": 13, "3706": 13, "66e": 13, "3746": 13, "3763": 13, "3786": 13, "49e": 13, "3811": 13, "5s": 13, "3832": 13, "3849": 13, "3875": 13, "3905": 13, "2s": 13, "3930": [13, 19], "41e": 13, "3931": [13, 19], "3954": 13, "19e": 13, "3977": 13, "690194": 13, "01t10": 13, "176751": 13, "1001": 13, "160675": 13, "706780": 13, "345842": 13, "155662": 13, "684890": 13, "433207": 13, "1025": 13, "162454": 13, "694517": 13, "453059": 13, "169775": 13, "456": 13, "25014bc73b334765a1c09a4e4a97ed66": 13, "38m": 13, "6485656144116352": 13, "1635760613": 13, "6602514": 13, "1635761189": 13, "652638": 13, "82563": 13, "09295167374": 13, "6438124832773024": 13, "titl": [13, 34], "l_": [13, 14, 15], "yscale": [13, 14, 15, 17], "weirdli": 13, "cost": [13, 14, 15], "observ": [13, 14, 15], "sequnec": [13, 14, 15], "notebook_luminos": [14, 15], "const_linear": [14, 16, 35, 38], "probtot": [14, 15], "mmax": [14, 15, 32, 38], "mmin": [14, 15, 22, 32, 38], "0x7f6920fd2430": 14, "subprocess": [14, 16], "f9b28e4ed6ec4a67b17cd86c5a43c41c": 14, "metadata": [14, 16, 21, 23, 24, 35], "population_id": [14, 16, 22], "9999999999999999": 14, "1655508316": 14, "7679594": 14, "1655508320": 14, "7581806": 14, "time_elaps": [14, 16, 28], "9902212619781494": 14, "ldist": [14, 15], "implic": [14, 15], "clearli": [14, 15], "realist": [14, 15], "went": [14, 15], "wrong": [14, 15, 23, 40], "unlik": [14, 15], "realiti": [14, 15], "law": [14, 15, 32], "kroupa": [14, 15, 32], "2001": [14, 15, 32], "update_grid_vari": [14, 15, 35], "211729": 14, "1d1d556abeae4549aa28f9740807dc84": 14, "spiki": [14, 15], "notic": [14, 15], "poor": [14, 15], "compens": [14, 15], "intens": [14, 15], "resourc": [14, 15, 26], "smarter": [14, 15], "linearli": [14, 15, 38], "renam": [14, 15, 35], "clear": [14, 15, 39], "logarithm": [14, 15, 32, 38], "old": [14, 15, 22, 35], "lnm_1": [14, 15, 16, 35], "rename_grid_vari": [14, 15, 35], "valueerror": [14, 16], "traceback": [14, 17], "recent": [14, 17, 23, 40], "env": [14, 22, 25], "dev_binarycpython3": 14, "population_extens": [14, 16, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], "gridcod": [14, 16, 21, 23, 24], "oldnam": [14, 35], "newnam": [14, 35], "msg": 14, "dlnm": [14, 15], "dlnm_1": [14, 15, 16, 35], "_grid_vari": [14, 15, 22, 35], "perfect": [14, 15], "got": [14, 15], "wiggl": [14, 15], "artefact": [14, 15], "monoton": [14, 15], "brighten": [14, 15], "narrow": [14, 15], "co2": [14, 15], "bar": [14, 15], "isn": [14, 15, 20], "challeng": [14, 15], "notebook_luminosity_function_binari": [14, 15], "b6213f2eb7f94d3196cf966b7b76b9f9": 15, "472": [15, 19], "9999999999999998": 15, "1635760806": 15, "5066257": 15, "1635760813": 15, "4966016": 15, "3999999999996": 15, "03499999999999": 15, "218222": 15, "4b8c7f4a86e445099d73f27dffaad94b": 15, "995631": 15, "7a2e4301f5224b2cb8939d2297df0aad": 15, "621": 15, "recogn": 16, "__": 16, "45000000080": 16, "data_dir": [16, 20, 21, 22, 31], "example_python_population_result": 16, "base_filenam": [16, 21], "idea": [16, 25], "export_all_info": [16, 21], "include_popul": 16, "binary_c_default": 16, "commandlin": 16, "accept": [16, 20, 27], "include_binary_c_default": [16, 21], "include_binary_c_version_info": [16, 21], "include_binary_c_help_al": [16, 21], "fase": 16, "overriden": 16, "use_datadir": [16, 21], "outfil": [16, 21], "ok": [16, 26, 31], "example_pop_set": 16, "gz": [16, 31], "ret": 16, "easier": [16, 19, 20, 21], "discret": 16, "unweight": 16, "notabl": 16, "moe": [16, 23, 26, 27, 32], "di": [16, 23, 27, 32], "stefano": [16, 23, 27, 32], "dataset": [16, 22, 26, 27], "further": 16, "down": 16, "dry_parallel": [16, 35], "deeper": [16, 35], "evalu": [16, 32, 35, 38, 43], "bewar": [16, 31, 35], "insert": [16, 35], "destruct": [16, 35], "piec": [16, 19, 35], "risk": [16, 35], "rest": [16, 32, 35], "correspond": [16, 25, 30, 35, 37], "m_min": [16, 35], "m_max": [16, 32, 35], "room": [16, 35], "kroupa2001": [16, 32, 35], "met": [16, 21, 26, 35], "continu": [16, 30, 35, 37], "stepsiz": [16, 35], "parallel": [16, 35], "block": [16, 35], "comment": [16, 26, 30, 37], "test_pop": 16, "Or": [16, 19], "example_compact_object": 16, "makedir": [16, 20], "exist_ok": [16, 20], "seper": 16, "outfilenam": 16, "headerlin": 16, "isnt": 16, "0x7f2b6ca163a0": 16, "grid_vari": [16, 22], "0443872": 16, "598268106227e": 16, "30592": 16, "75988": 16, "00193614": 16, "436983545111e": 16, "35842": 16, "9948": 16, "00144093": 16, "690157944401e": 16, "43124": 16, "7998": 16, "00107238": 16, "242397939068e": 16, "52416": 16, "3205": 16, "000798096": 16, "756794139032e": 16, "66914": 16, "7394": 16, "000593966": 16, "401414766976e": 16, "73729": 16, "2857": 16, "000442046": 16, "536373523810e": 16, "80677": 16, "000328983": 16, "393982410080e": 16, "82164": 16, "9844": 16, "000244839": 16, "396470605248e": 16, "82129": 16, "9508": 16, "000182216": 16, "399005684057e": 16, "82041": 16, "7151": 16, "00013561": 16, "443375325717e": 16, "81645": 16, "9909": 16, "000100925": 16, "451195752942e": 16, "81559": 16, "51114e": 16, "452661646076e": 16, "81543": 16, "ce756bb317f64099a459bf8b55a746ac": 16, "044387171445641534": 16, "1646563001": 16, "7193637": 16, "1646563002": 16, "4480088": 16, "7286450862884521": 16, "649": 16, "905447944397": 16, "28133908148630704": 16, "write_binary_c_calls_to_fil": [16, 31], "dataio": [16, 21, 23, 24], "output_filenam": [16, 31], "include_default": [16, 31], "system_gener": [16, 31], "wouldn": [16, 31], "basic": [16, 31], "datadir": [16, 31], "binary_c_cal": [16, 31], "calls_filenam": 16, "binary_c_grid_ce756bb317f64099a459bf8b55a746ac": 16, "2406484012210224": 16, "22723621650191106": 16, "011394572976608001": 16, "812296769855663": 16, "22723621650191117": 16, "008480166685456411": 16, "5297876799548944": 16, "006311182276049824": 16, "430329401616038": 16, "004696962123378559": 16, "thats": 16, "evolve_popul": 16, "isfil": 16, "0fa4c2b8707741a5ab41d209ef95a3a4": 16, "regist": 16, "expand": 16, "intend": 16, "mass_1": [16, 19, 25], "zams_mass_1": 16, "mass_2": [16, 19, 25], "zams_mass_2": 16, "prev_stellar_type_1": 16, "prev_stellar_type_2": 16, "example_dco": 16, "logger": 16, "safe": [16, 31], "0211592": 16, "0eb5c0c9abd34607a6ee060b26a7e32f": 16, "378266748188e": 16, "66293": 16, "9713": 16, "78767": 16, "8178": 16, "000339963": 16, "817608462595e": 16, "82104": 16, "41436": 16, "000193036": 16, "422997711686e": 16, "82479": 16, "82171": 16, "2535": 16, "205711924468e": 16, "73765": 16, "notebook_solar_system": 17, "mercuri": 17, "1mmercuri": 17, "orbital_separ": 17, "1amercuri": 17, "star1": 17, "orbital_eccentr": 17, "venu": 17, "1mvenu": 17, "1avenu": 17, "earth": 17, "1mearth": 17, "1aearth": 17, "mar": 17, "1mmar": 17, "1amar": 17, "jupit": 17, "1mjupit": 17, "1ajupit": 17, "saturn": 17, "1msaturn": 17, "1asaturn": 17, "uranu": 17, "1muranu": 17, "1auranu": 17, "neptun": 17, "1mneptun": 17, "1aneptun": 17, "pluto": 17, "1mpluto": 17, "1apluto": 17, "2444": 17, "planet": 17, "central": 17, "cs1": 17, "superflu": 17, "fourth": 17, "nameerror": 17, "ipykernel_216542": 17, "1241251901": 17, "dtype": [17, 18, 19], "argh": 17, "sun": 17, "df": [17, 18, 19, 25], "ci": 17, "legend": [17, 19], "xx": 17, "head": 17, "loc": 17, "yy": 17, "au": 17, "swallow": 17, "although": 17, "mess": 17, "push": 17, "beyond": 17, "explor": 17, "vs": [17, 25], "ylim": 17, "toasti": 17, "distant": 17, "futur": 17, "example_parse_output": [18, 20], "100000000000": [18, 19], "float64": [18, 19], "logi": 18, "axessubplot": 18, "xlabel": 18, "server": 19, "nov": 19, "binary_c_python_api": 19, "nbinary_c": 19, "example_header_1": 19, "st1": 19, "st2": 19, "3540": 19, "example_header_2": 19, "initial_grid": 19, "tempfil": 19, "gettempdir": 19, "test_log": 19, "7106": 19, "786e": 19, "7509": 19, "8427e": 19, "8435e": 19, "1380": 19, "9373e": 19, "0900": 19, "2934e": 19, "726": 19, "3081e": 19, "2118": 19, "3702e": 19, "2646": 19, "34421": 19, "d48r": 19, "0570946": 19, "458272": 19, "13108": 19, "562029": 19, "924056": 19, "89211": 19, "78817": 19, "113492": 19, "80602": 19, "124379": 19, "7087": 19, "7695": 19, "608402": 19, "696003": 19, "796455": 19, "0834973": 19, "85661": 19, "3914": 19, "524629": 19, "634667": 19, "func_memaddr": 19, "run_binary_custom_log": 19, "3e": 19, "serv": [19, 20], "parse_output": 19, "behind": 19, "scene": 19, "background": 19, "inlin": 19, "mind": 19, "result_example_header_1": 19, "selected_head": [19, 20], "result_example_header_2": 19, "cast": [19, 20], "df2": 19, "81762e": 19, "000000e": 19, "00000": 19, "817620e": 19, "3927": 19, "102750e": 19, "33817": 19, "62124": 19, "896110e": 19, "202750e": 19, "3929": 19, "302750e": 19, "402750e": 19, "500000e": 19, "3932": 19, "doesnt": [19, 34], "autogener": 19, "result_example_head": 19, "000000": 19, "3630": 19, "131680e": 19, "627748": 19, "3631": 19, "231680e": 19, "3632": 19, "331680e": 19, "3633": 19, "431680e": 19, "3634": 19, "3635": 19, "run_and_calc_mass": 19, "kwarg": [19, 21, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41], "2f": 19, "last_st": 19, "last_stellar_type_change_time_1": 19, "slice": 19, "sliced_df": 19, "cut": 19, "late": 19, "final_mass": 19, "initial_tim": 19, "final_tim": 19, "mass_lost": 19, "wrt": 19, "metallicity_002": 19, "metallicity_001": 19, "metallicity_0002": 19, "mass_rang": 19, "arang": 19, "fractions_z002": 19, "fractions_z001": 19, "fractions_z0002": 19, "214274644851685": 19, "ax": 19, "subplot": 19, "nrow": 19, "ncol": 19, "m_": 19, "fontsiz": 19, "set_titl": 19, "set_yscal": 19, "save_loop": 19, "mass_loss_m": 19, "png": 19, "ep": 19, "bbox_inch": 19, "tight": 19, "verbose_print": [20, 33], "iter": 20, "context": 20, "manag": [20, 23, 40], "__enter__": 20, "stdout": [20, 22, 38], "__exit__": 20, "releas": [20, 23, 40], "call_binary_c_config": 20, "catchtim": 20, "spent": 20, "clock": 20, "exc_typ": 20, "exc_val": 20, "exc_tb": 20, "measur": 20, "check_if_in_shel": 20, "command_string_from_list": 20, "quot": 20, "conv_time_unit": 20, "hour": 20, "magnitud": 20, "convert_byt": 20, "size": [20, 22, 29], "convfloat": 20, "scalar": 20, "create_arg_str": 20, "filter_valu": 20, "create_hdf5": 20, "hdf5": 20, "hdf5file": 20, "conveni": [20, 23, 40], "example_head": 20, "defaultdict": 20, "rethink": 20, "filter_arg_dict": 20, "format_numb": 20, "scientif": 20, "notat": 20, "trail": [20, 38], "get_ansi_colour": 20, "color": [20, 25], "get_arg_kei": 20, "sinc": [20, 25, 32], "param_nam": 20, "fail_sil": 20, "did": [20, 23, 40], "compon": [20, 25], "categoris": 20, "silent": 20, "get_siz": 20, "seen": 20, "github": [20, 31], "bosswissam": 20, "pysiz": 20, "get_usernam": 20, "usernam": 20, "spawn": 20, "is_capsul": 20, "tell": [20, 26], "isfloat": 20, "isint": 20, "load_logfil": 20, "make_build_text": 20, "mem_us": 20, "now_object": 20, "nospac": 20, "date": [20, 21, 22], "d_": 20, "output_lin": 20, "receiv": 20, "dist": 20, "quotewrap": 20, "remove_fil": 20, "child_dir": 20, "child": 20, "full_path": 20, "timedelta": 20, "delta": [20, 38], "human": 20, "readabl": 20, "trem": 20, "dn": [20, 32], "differenti": 20, "progress": 20, "messag": [20, 21], "minimal_verbos": 20, "newlin": [20, 22, 31, 33], "charact": [20, 22, 31], "x0d": [20, 22], "carriag": [20, 22], "write_binary_c_parameter_descriptions_to_rst_fil": 20, "rst": [20, 34], "restructuredtext": 20, "save_snapshot": [21, 22, 31], "distinct": 21, "init": 21, "initial_abundance_hash": 21, "isotope_hash": 21, "isotope_list": 21, "nuclear_mass_hash": 21, "nuclear_mass_list": 21, "source_list": 21, "ensemble_list": 21, "spread": 21, "privat": [21, 23], "nice": [21, 25], "unload": 21, "custom_logging_info": 21, "grid_cod": 21, "mixin": 21, "portal": 21, "decor": 21, "staticmethod": 21, "classmethod": 21, "realpython": 21, "static": 21, "demystifi": 21, "cach": [21, 22, 23, 24, 28, 34, 38], "grid_log": [21, 23, 24], "grid_options_default": [21, 23, 24, 29], "hpc": [21, 22, 23, 24, 30, 37], "moe_di_stefano_2017": [21, 23, 24], "spacing_funct": [21, 23, 24], "reus": 21, "_pre_run_setup": 21, "relev": 21, "clean_up_custom_logging_fil": 21, "stacktrac": 21, "sy": 21, "include_population_set": 21, "all_info": 21, "flaw": 21, "rewrit": 21, "pl": 21, "population_set": 21, "return_population_set": 21, "_set": 21, "simulation_": 21, "jobid": [21, 22, 37], "job": [21, 22, 26, 30, 37], "id": [21, 22, 26, 30, 31, 32, 33, 37], "pid": 21, "hpc_jobid": [21, 26], "parse_cmdlin": 21, "return_all_info": 21, "return_binary_c_default": 21, "was_kil": 21, "meant": 22, "c_auto_log": 22, "headlin": 22, "hpc_force_join": 22, "slurm": [22, 23, 24, 26], "condor": [22, 23, 24, 26], "hpc_rebuild_joinlist": [22, 26], "joinlist": [22, 26], "moe2017_opt": 22, "cache_dir": [22, 38], "combine_ensemble_with_thread_join": 22, "ensemble_output_": 22, "thread_id": 22, "command_lin": 22, "htcondor": 22, "launch": [22, 30, 37], "condor_clusterid": [22, 30], "clusterid": [22, 30], "condor_process": [22, 30], "jobarrayindex": [22, 37], "condor_bash": 22, "bash": 22, "submit": [22, 23], "node": 22, "condor_batchnam": 22, "batchnam": 22, "appear": 22, "condor_q": 22, "condor_d": 22, "usr": 22, "condor_dir": [22, 26, 30, 37], "nf": [22, 31], "condor_env": 22, "condor_extra_set": 22, "te": 22, "batch": 22, "overwrit": [22, 26], "condor_getenv": 22, "environ": 22, "submiss": 22, "almost": 22, "certainli": 22, "condor_initial_dir": 22, "condor_kill_sig": 22, "sigint": 22, "condor_memori": 22, "images": 22, "condor_njob": 22, "condor_postpone_join": 22, "condor_postpone_submit": 22, "tool": 22, "condor_pwd": 22, "pwd": 22, "instal": [22, 43], "condor_requir": 22, "condor_should_transfer_fil": 22, "ye": 22, "condor_snapshot_on_kil": 22, "snapshot": [22, 26, 31], "sigkil": 22, "condor_stream_error": 22, "stream": 22, "condor_stream_output": 22, "condor_submit": 22, "condor_univers": 22, "vanilla": 22, "condor_warn_max_memori": 22, "condor_when_to_transfer_output": 22, "on_exit_or_evict": 22, "custom_gener": 22, "do_analyt": 22, "do_dry_run": 22, "dry_run_hook": 22, "hook": 22, "dry_run_num_cor": 22, "ensemble_factor_in_probability_weighted_mass": 22, "probability_weighted_mass": 22, "multiprocess": 22, "exit_after_dry_run": 22, "exit_cod": 22, "failed_systems_threshold": 22, "failed_system": 22, "function_cach": 22, "certain": [22, 23, 40], "function_cache_ttl": 22, "function_cache_default_maxs": 22, "maxsiz": 22, "function_cache_default_typ": 22, "lrucach": 22, "lfucach": 22, "fifocach": 22, "mrucach": 22, "rrcach": 22, "ttlcach": 22, "nullcach": [22, 29], "nocach": 22, "cachetool": [22, 29], "fo": 22, "dummi": [22, 25, 32], "overhead": 22, "function_cache_funct": [22, 29], "gridcode_filenam": 22, "log_arg": 22, "log_args_dir": 22, "log_newlin": 22, "log_runtime_system": 22, "plan": 22, "max_queue_s": 22, "feed": 22, "modulo": 22, "multiplicity_fraction_funct": 22, "aren": [22, 32], "rhagavan": 22, "n_logging_stat": 22, "num_cores_avail": 22, "original_command_lin": 22, "original_submission_tim": 22, "original_working_diretori": 22, "Its": 22, "print_stack_on_exit": 22, "stack": 22, "trace": 22, "restore_from_snapshot_dir": 22, "restore_from_snapshot_fil": [22, 26], "return_after_dry_run": 22, "run_zero_probability_system": 22, "rungrid": 22, "save_ensemble_chunk": 22, "save_population_object": [22, 31], "skip_befor": 22, "slurm_arrai": 22, "slurm_array_max_job": 22, "concurr": 22, "slurm_bash": 22, "slurm_dat": 22, "slurm_dir": [22, 26, 30, 37], "slurm_env": 22, "slurm_extra_set": 22, "slurm_jobarrayindex": [22, 37], "slurm_jobid": [22, 37], "slurm_jobnam": 22, "slurm_memori": 22, "megabyt": 22, "understand": 22, "512mb": 22, "slurm_njob": 22, "slurm_ntask": 22, "slurm_partit": 22, "partit": 22, "local": [22, 32], "sview": 22, "slurm_postpone_join": 22, "slurm_postpone_sbatch": 22, "sbatch": 22, "slurm_pwd": 22, "slurm_sbatch": 22, "slurm_tim": 22, "slurm_warn_max_memori": 22, "excess": 22, "mistak": 22, "1024mb": 22, "source_file_filenam": 22, "start_at": 22, "status_dir": 22, "stop_queu": 22, "symlink_latest_gridcod": 22, "diagnost": 22, "_repeat": 22, "reduct": 22, "working_diretori": 22, "multiplicity_model": 22, "log10m1": 22, "poisson": [22, 32], "map": 22, "quad": 22, "NO": 22, "multiplicity_modul": 22, "normalize_multipl": 22, "norm": 22, "b": [22, 31], "whichev": 22, "stick": 22, "predict": 22, "repres": 22, "canon": 22, "nonzero": 22, "q_high_extrapolation_method": 22, "q_low_extrapolation_method": 22, "extrapol": [22, 32], "flat": [22, 32], "linear2": 22, "plaw2": 22, "nolowq": 22, "_moe2017_json_data": 22, "distefano2017": 22, "_actually_evolve_system": 22, "_process_run_population_grid": 22, "_binary_c_config_execut": 22, "_binary_c_dir": 22, "director": 22, "_binary_c_execut": 22, "_binary_c_shared_librari": 22, "libbinary_c": 22, "_commandline_input": 22, "_count": 22, "counter": 22, "_custom_logging_shared_library_fil": 22, "_end_time_evolut": 22, "timestamp": [22, 28], "_errors_exceed": 22, "failed_system_log": 22, "_errors_found": 22, "encount": [22, 23, 40], "_evolution_type_opt": 22, "_failed_count": 22, "_failed_prob": 22, "_failed_systems_error_cod": 22, "_generate_grid_cod": 22, "_kill": 22, "_loaded_moe2017_data": 22, "_main_pid": 22, "master": [22, 23, 25, 40], "_population_id": 22, "char": 22, "hex": 22, "_probtot": 22, "_queue_don": 22, "_set_moe2017_grid": 22, "_start_time_evolut": 22, "_store_memaddr": 22, "_system_gener": 22, "_total_mass_run": 22, "_total_probability_weighted_mass_run": 22, "_total_starcount": 22, "_zero_prob_stars_skip": 22, "aim": [23, 40], "jeff": [23, 40], "andrew": [23, 40], "robert": [23, 40], "student": [23, 40], "scientist": [23, 40], "who": [23, 40], "onlin": [23, 40], "older": [23, 40], "guarante": [23, 40], "meet": [23, 40], "least": [23, 40], "eol": [23, 40], "root": [23, 40], "ld_library_path": [23, 40], "libgsl": [23, 40], "libmemo": [23, 40], "librinterpol": [23, 40], "library_path": [23, 40], "gsl_dir": [23, 40], "gsl": [23, 40], "dir": [23, 30, 40], "binary_c2": [23, 40], "latest": [23, 40], "virtual": [23, 40], "sh": [23, 40], "suit": [23, 40], "pythonpath": [23, 40], "download": [23, 40], "clone": [23, 40], "gitlab": [23, 40], "repo": [23, 40], "whenev": [23, 40], "reinstal": [23, 40], "virtualenviron": [23, 40], "host": [23, 40], "person": [23, 40], "ph": [23, 40], "contribut": [23, 40], "development_requir": [23, 40], "hesit": [23, 40], "discuss": [23, 40], "generate_doc": [23, 40], "generate_report": [23, 40], "main_with_notebook": [23, 40], "test_notebook": [23, 40], "exhaust": [23, 40], "solut": [23, 40], "mesa": [23, 40], "mesasdk_root": [23, 40], "mesasdk_init": [23, 40], "interfer": [23, 40], "throw": [23, 40], "unrecogn": [23, 40], "ftz": [23, 40], "flto": [23, 40], "due": [23, 40], "cflag": [23, 40], "avaibl": [23, 40], "1ckzg0p9": [23, 40], "egg": [23, 40], "pkg": [23, 40], "filenotfounderror": [23, 40], "errno": [23, 40], "jupyt": [23, 40], "seem": [23, 25, 34, 40], "everytim": [23, 40], "rebuilt": [23, 40], "plot_funct": [23, 24], "useful_func": [23, 24], "nucsyn": 23, "misc": 23, "sampler": 23, "visit": 23, "plot_system": 25, "loos": 25, "admittedli": 25, "customis": 25, "regardless": 25, "color_by_index": 25, "placehold": [25, 29, 30, 31], "parse_function_hr_diagram": 25, "hr": 25, "parse_function_mass": 25, "parse_function_orbit": 25, "plot_hr_diagram": 25, "show_stellar_typ": 25, "show_plot": 25, "use_astropy_valu": 25, "plot_hr_diagram_singl": 25, "radius_1": 25, "radius_2": 25, "luminosity_1": 25, "luminosity_2": 25, "teff_1": 25, "teff_2": 25, "hd": 25, "astropi": 25, "stefan": 25, "boltzman": 25, "plot_mass": 25, "pms_mass_1": 25, "pms_mass_2": 25, "quantiti": 25, "pm": 25, "mayb": 25, "plot_orbit": 25, "plot_typ": 25, "preset": 25, "mass_evolut": 25, "orbit_evolut": 25, "hr_diagram": 25, "keyword": [25, 41], "against": 25, "pick": 25, "pane": 25, "distefano": [26, 27, 32], "hpc_can_join": 26, "joinfil": 26, "joiningfil": 26, "hpc_check_requir": 26, "hpc_dir": 26, "hpc_dump_statu": 26, "hpc_get_statu": 26, "job_id": 26, "job_index": 26, "hpc_grid": 26, "makejoiningfil": 26, "hpc_task": 26, "exclud": 26, "hpc_id_filenam": 26, "hpc_id_from_dir": 26, "hpc_job": 26, "hpc_jobid_tupl": 26, "hpc_job_id_rang": 26, "hpc_job_task": 26, "hpc_job_typ": 26, "hpc_join_from_fil": 26, "newobj": 26, "hpc_join_previ": 26, "hpc_joinlist": 26, "hpc_load_joinfiles_list": 26, "hpc_make_joiningfil": 26, "error_on_overwrit": 26, "hpc_njob": 26, "error_on_overwit": 26, "issu": 26, "hpc_path": 26, "hpc_queue_stat": 26, "stat": 26, "hpc_restor": 26, "restor": 26, "_restart_dir": 26, "stage": 26, "hpc_set_statu": 26, "hpc_snapshot_filenam": 26, "hpc_statu": 26, "hpc_touch": 26, "touch": [26, 31], "distrefano": 27, "interpol": [27, 32, 38], "get_moe_di_stefano_2017_default_opt": 27, "get_moe_di_stefano_2017_default_options_descript": 27, "get_moe_di_stefano_dataset": 27, "set_moe_di_stefano_set": 27, "cpu_tim": 28, "ve": 28, "make_analytics_dict": 28, "set_tim": 28, "elaps": 28, "lru": 29, "lru_": 29, "__delitem__": 29, "delet": [29, 35], "getter": 29, "__setitem__": 29, "setter": 29, "popitem": 29, "default_cache_dir": [29, 34], "setup_function_cach": 29, "cachetyp": 29, "function_cache_s": 29, "func": 29, "test_cach": 29, "replac": 30, "condorid": 30, "condor_check_requir": 30, "condor_grid": 30, "being": [30, 37], "condor_outfil": 30, "chunk": [30, 37], "condor_queue_stat": 30, "condor_status_fil": 30, "condorpath": 30, "get_condor_statu": 30, "correspon": [30, 37], "make_condor_dir": 30, "set_condor_statu": 30, "held": [30, 37], "io": 31, "nfs_flush_hack": 31, "opendir": 31, "closedir": 31, "complaint": 31, "unclos": 31, "scandir": 31, "nfspath": 31, "mount": 31, "compression_typ": 31, "dir_ok": 31, "load_population_object": 31, "load_snapshot": 31, "preloaded_popul": 31, "locked_clos": 31, "partner": 31, "locked_open_for_writ": 31, "unlock": 31, "lock_suffix": 31, "lock_timeout": 31, "lock_lifetim": 31, "exists_ok": 31, "fatal_open_error": 31, "mode": 31, "lockfil": 31, "flufl": 31, "file_object": 31, "lock_object": 31, "merge_popul": 31, "refpop": 31, "newpop": 31, "merge_populations_from_fil": 31, "closefd": 31, "compresslevel": 31, "population_object": 31, "confirm": 31, "gzip": 31, "pickl": 31, "compress_pickl": 31, "lucianopaz": 31, "shared_memori": 31, "set_statu": 31, "format_stat": 31, "process_": 31, "snapshot_filenam": 31, "wait_for_unlock": 31, "wait": 31, "write_ensembl": 31, "recognis": 31, "bz2": 31, "msgpack": 31, "support": 31, "grid_ensemble_result": [31, 36], "stackoverflow": 32, "28060251": 32, "hi": 32, "gonna": 32, "mathieu": 32, "sfh": 32, "redshift": 32, "enough": 32, "arenou2010_binary_fract": 32, "c2": 32, "sp": 32, "opm": 32, "fa": 32, "rssd": 32, "esa": 32, "doc_fetch": 32, "php": 32, "2969346": 32, "izzard2012_period_distribut": 32, "log10pmin": 32, "duquennoi": 32, "mayor": 32, "1991": 32, "spectral": 32, "15msun": 32, "sana": 32, "3msun": 32, "dlogp": 32, "raghavan": 32, "gaussian": [32, 38], "log10p": 32, "logp": 32, "m0": 32, "p1": 32, "p2": 32, "p3": 32, "moe_di_stefano_2017_multiplicity_fract": 32, "6e1": 32, "moe_di_stefano_2017_pdf": 32, "m3": 32, "m4": 32, "ecc2": 32, "ecc3": 32, "build_q_tabl": 32, "independ": 32, "q_min": 32, "renormalis": 32, "lowest": 32, "qmin": 32, "goal": 32, "boundari": 32, "calc_p_integr": 32, "min_logp": 32, "max_logp": 32, "integrals_str": 32, "interpolator_nam": 32, "mass_str": 32, "min_per": 32, "calc_e_integr": 32, "period_str": 32, "calc_total_probden": 32, "prob_dict": 32, "calculate_constants_three_part_powerlaw": 32, "law_const": 32, "slope": 32, "const_distribut": 32, "min_bound": [32, 38], "max_bound": [32, 38], "val": 32, "cosmic_sfh_madau_dickinson2014": 32, "cosmic": 32, "histori": 32, "madau": 32, "dickonson": 32, "1403": 32, "0007": 32, "mega": 32, "parsec": 32, "duquennoy1991": 32, "fill_data": 32, "sample_valu": 32, "data_dict": 32, "logmass": [32, 38], "logperiod": 32, "dstep": 32, "uniform": 32, "sigma": [32, 38], "gmin": 32, "gmax": 32, "deviat": [32, 38], "gaussian_func": 32, "gaussian_normalizing_const": 32, "get_integration_constant_q": 32, "q_interpol": 32, "tmp_tabl": 32, "qdata": 32, "get_max_multipl": 32, "multiplicity_arrai": 32, "imf_chabrier2003": 32, "chabrier": 32, "pasp": 32, "imf_scalo1986": 32, "scalo": 32, "80msol": 32, "imf_scalo1998": 32, "imf_tinsley1980": 32, "tinslei": 32, "1980": 32, "interpolate_in_mass_izzard2012": 32, "ktg93": 32, "linear_extrapolation_q": 32, "qs": 32, "qlimit": 32, "end_index": 32, "merge_multipl": 32, "result_arrai": 32, "max_multipl": 32, "fold": 32, "lambda_v": 32, "nmax": 32, "improv": [32, 38], "powerlaw": 32, "min_val": 32, "max_val": 32, "powerlaw_const": 32, "powerlaw_constant_nocach": 32, "powerlaw_extrapolation_q": 32, "raghavan2010_binary_fract": 32, "zsolar": 32, "long_spectral_typ": 32, "jaschek": 32, "amin": 32, "amax": 32, "x0": 32, "x1": 32, "ln": 32, "dp": 32, "p0": 32, "generalis": 32, "vb1print": 33, "system_numb": 33, "system_dict": 33, "ey": 33, "unix": 33, "epoch": 33, "vb2print": 33, "cmdline_str": 33, "grid_options_defaults_dict": 34, "grid_options_help": 34, "grid_options_description_check": 34, "write_grid_options_to_rst_fil": 34, "With": 34, "hack": 34, "reconsid": 34, "unnecessari": 34, "get_grid_options_defaults_dict": 34, "get_grid_options_descript": 34, "print_info": 34, "undescrib": 34, "And": [34, 43], "print_option_descript": 34, "filehandl": 34, "extra_text": 34, "delete_grid_vari": 35, "add_ensemble_metadata": 36, "combined_output_dict": 36, "add_system_metadata": 36, "get_slurm_statu": 37, "make_slurm_dir": 37, "set_slurm_statu": 37, "slurmid": 37, "slurm_check_requir": 37, "slurm_grid": 37, "slurm_outfil": 37, "slurm_queue_stat": 37, "xxx": 37, "slurm_status_fil": 37, "slurmpath": 37, "const_dt": 38, "cachedir": 38, "usecach": 38, "logspac": 38, "dlogt": 38, "tmin": 38, "tmax": 38, "mindm": 38, "1msun": 38, "0msun": 38, "comma": 38, "thu": 38, "maxdm": 38, "similar": 38, "fsampl": 38, "shannon": 38, "showtabl": 38, "showlist": 38, "log10mass": 38, "const_dt_cach": 38, "add_grid_valu": 38, "1gyr": 38, "suitabl": 38, "const_int": 38, "segment": 38, "linspac": 38, "const_rang": 38, "gaussian_zoom": 38, "zoom_mean": 38, "zoom_dispers": 38, "zoom_magnitud": 38, "depth": 38, "zoom_magntiud": 38, "peak_normalized_gaussian_func": 38, "hardli": 39, "minimum_stellar_mass": 39, "parse_binary_c_version_info": 39, "version_info_str": 39, "atom": 39, "dtlimit": 39, "git_branch": 39, "git_build": 39, "email": 39, "analys": 41, "example_log": 41, "fancy_parsing_funct": 41, "notifi": 41, "unknown": 41, "centralis": 41, "abstract": 41, "stellar_type_dict": 42, "stellar_type_dict_short": 42, "abbrevi": 42, "collect": 43, "binary_star": 43, "calc_period_from_sep": 43, "invers": 43, "zams_collis": 43, "collid": 43, "roche_lob": 43, "ragb": 43, "minimum_period_for_rlof": 43, "minimum_separation_for_rlof": 43, "maximum_mass_ratio_for_rlof": 43, "upon": 43, "r_l": 43, "1983": 43, "mass_accretor": 43, "mass_donor": 43, "rochelob": 43, "vice": 43, "versa": 43, "1996": 43, "mnra": 43, "pericent": 43}, "objects": {"binarycpython.utils": [[1, 0, 0, "-", "custom_logging_functions"], [2, 0, 0, "-", "dicts"], [3, 0, 0, "-", "ensemble"], [20, 0, 0, "-", "functions"], [21, 0, 0, "-", "grid"], [25, 0, 0, "-", "plot_functions"], [41, 0, 0, "-", "run_system_wrapper"], [42, 0, 0, "-", "stellar_types"], [43, 0, 0, "-", "useful_funcs"]], "binarycpython.utils.custom_logging_functions": [[1, 1, 1, "", "autogen_C_logging_code"], [1, 1, 1, "", "binary_c_log_code"], [1, 1, 1, "", "binary_c_write_log_code"], [1, 1, 1, "", "compile_shared_lib"], [1, 1, 1, "", "create_and_load_logging_function"], [1, 1, 1, "", "from_binary_c_config"], [1, 1, 1, "", "return_compilation_dict"]], "binarycpython.utils.dicts": [[2, 2, 1, "", "AutoVivificationDict"], [2, 1, 1, "", "count_keys_recursive"], [2, 1, 1, "", "custom_sort_dict"], [2, 1, 1, "", "filter_dict"], [2, 1, 1, "", "filter_dict_through_values"], [2, 1, 1, "", "inspect_dict"], [2, 1, 1, "", "keys_to_floats"], [2, 1, 1, "", "merge_dicts"], [2, 1, 1, "", "multiply_float_values"], [2, 1, 1, "", "multiply_values_dict"], [2, 1, 1, "", "normalize_dict"], [2, 1, 1, "", "prepare_dict"], [2, 1, 1, "", "recursive_change_key_to_float"], [2, 1, 1, "", "recursive_change_key_to_string"], [2, 1, 1, "", "set_opts"], [2, 1, 1, "", "subtract_dicts"], [2, 1, 1, "", "update_dicts"]], "binarycpython.utils.dicts.AutoVivificationDict": [[2, 3, 1, "", "__getitem__"], [2, 3, 1, "", "__iadd__"]], "binarycpython.utils.ensemble": [[3, 2, 1, "", "BinarycDecoder"], [3, 2, 1, "", "BinarycEncoder"], [3, 1, 1, "", "binaryc_json_serializer"], [3, 1, 1, "", "ensemble_compression"], [3, 1, 1, "", "ensemble_file_type"], [3, 1, 1, "", "ensemble_setting"], [3, 1, 1, "", "extract_ensemble_json_from_string"], [3, 1, 1, "", "format_ensemble_results"], [3, 1, 1, "", "handle_ensemble_string_to_json"], [3, 1, 1, "", "load_ensemble"], [3, 1, 1, "", "open_ensemble"]], "binarycpython.utils.ensemble.BinarycDecoder": [[3, 3, 1, "", "decode"]], "binarycpython.utils.ensemble.BinarycEncoder": [[3, 3, 1, "", "default"]], "binarycpython.utils.functions": [[20, 2, 1, "", "Capturing"], [20, 1, 1, "", "bin_data"], [20, 1, 1, "", "call_binary_c_config"], [20, 2, 1, "", "catchtime"], [20, 1, 1, "", "check_if_in_shell"], [20, 1, 1, "", "command_string_from_list"], [20, 1, 1, "", "conv_time_units"], [20, 1, 1, "", "convert_bytes"], [20, 1, 1, "", "convfloat"], [20, 1, 1, "", "create_arg_string"], [20, 1, 1, "", "create_hdf5"], [20, 1, 1, "", "datalinedict"], [20, 1, 1, "", "example_parse_output"], [20, 1, 1, "", "filter_arg_dict"], [20, 1, 1, "", "format_number"], [20, 1, 1, "", "get_ANSI_colours"], [20, 1, 1, "", "get_arg_keys"], [20, 1, 1, "", "get_defaults"], [20, 1, 1, "", "get_help"], [20, 1, 1, "", "get_help_all"], [20, 1, 1, "", "get_help_super"], [20, 1, 1, "", "get_size"], [20, 1, 1, "", "get_username"], [20, 1, 1, "", "imports"], [20, 1, 1, "", "is_capsule"], [20, 1, 1, "", "isfloat"], [20, 1, 1, "", "isint"], [20, 1, 1, "", "load_logfile"], [20, 1, 1, "", "make_build_text"], [20, 1, 1, "", "mem_use"], [20, 1, 1, "", "now"], [20, 1, 1, "", "output_lines"], [20, 1, 1, "", "pad_output_distribution"], [20, 1, 1, "", "quotewrap"], [20, 1, 1, "", "remove_file"], [20, 1, 1, "", "temp_dir"], [20, 1, 1, "", "timedelta"], [20, 1, 1, "", "trem"], [20, 1, 1, "", "verbose_print"], [20, 1, 1, "", "write_binary_c_parameter_descriptions_to_rst_file"]], "binarycpython.utils.functions.Capturing": [[20, 3, 1, "", "__enter__"], [20, 3, 1, "", "__exit__"]], "binarycpython.utils.functions.catchtime": [[20, 3, 1, "", "__enter__"], [20, 3, 1, "", "__exit__"]], "binarycpython.utils.grid": [[21, 2, 1, "", "Population"]], "binarycpython.utils.grid.Population": [[21, 3, 1, "", "clean"], [21, 3, 1, "", "evolve"], [21, 3, 1, "", "evolve_single"], [21, 3, 1, "", "exit"], [21, 3, 1, "", "export_all_info"], [21, 3, 1, "", "jobID"], [21, 3, 1, "", "parse_cmdline"], [21, 3, 1, "", "return_all_info"], [21, 3, 1, "", "return_binary_c_defaults"], [21, 3, 1, "", "return_population_settings"], [21, 3, 1, "", "set"], [21, 3, 1, "", "was_killed"]], "binarycpython.utils.plot_functions": [[25, 1, 1, "", "color_by_index"], [25, 1, 1, "", "dummy"], [25, 1, 1, "", "parse_function_hr_diagram"], [25, 1, 1, "", "parse_function_masses"], [25, 1, 1, "", "parse_function_orbit"], [25, 1, 1, "", "plot_HR_diagram"], [25, 1, 1, "", "plot_masses"], [25, 1, 1, "", "plot_orbit"], [25, 1, 1, "", "plot_system"]], "binarycpython.utils.population_extensions": [[26, 0, 0, "-", "HPC"], [27, 0, 0, "-", "Moe_di_Stefano_2017"], [28, 0, 0, "-", "analytics"], [29, 0, 0, "-", "cache"], [30, 0, 0, "-", "condor"], [31, 0, 0, "-", "dataIO"], [32, 0, 0, "-", "distribution_functions"], [33, 0, 0, "-", "grid_logging"], [34, 0, 0, "-", "grid_options_defaults"], [35, 0, 0, "-", "gridcode"], [36, 0, 0, "-", "metadata"], [37, 0, 0, "-", "slurm"], [38, 0, 0, "-", "spacing_functions"], [39, 0, 0, "-", "version_info"]], "binarycpython.utils.population_extensions.HPC": [[26, 2, 1, "", "HPC"]], "binarycpython.utils.population_extensions.HPC.HPC": [[26, 3, 1, "", "HPC_can_join"], [26, 3, 1, "", "HPC_check_requirements"], [26, 3, 1, "", "HPC_dir"], [26, 3, 1, "", "HPC_dirs"], [26, 3, 1, "", "HPC_dump_status"], [26, 3, 1, "", "HPC_get_status"], [26, 3, 1, "", "HPC_grid"], [26, 3, 1, "", "HPC_id_filename"], [26, 3, 1, "", "HPC_id_from_dir"], [26, 3, 1, "", "HPC_job"], [26, 3, 1, "", "HPC_jobID"], [26, 3, 1, "", "HPC_jobID_tuple"], [26, 3, 1, "", "HPC_job_id_range"], [26, 3, 1, "", "HPC_job_task"], [26, 3, 1, "", "HPC_job_type"], [26, 3, 1, "", "HPC_join_from_files"], [26, 3, 1, "", "HPC_join_previous"], [26, 3, 1, "", "HPC_joinlist"], [26, 3, 1, "", "HPC_load_joinfiles_list"], [26, 3, 1, "", "HPC_make_joiningfile"], [26, 3, 1, "", "HPC_njobs"], [26, 3, 1, "", "HPC_path"], [26, 3, 1, "", "HPC_queue_stats"], [26, 3, 1, "", "HPC_restore"], [26, 3, 1, "", "HPC_set_status"], [26, 3, 1, "", "HPC_snapshot_filename"], [26, 3, 1, "", "HPC_status"], [26, 3, 1, "", "HPC_touch"]], "binarycpython.utils.population_extensions.Moe_di_Stefano_2017": [[27, 2, 1, "", "Moe_di_Stefano_2017"]], "binarycpython.utils.population_extensions.Moe_di_Stefano_2017.Moe_di_Stefano_2017": [[27, 3, 1, "", "Moe_di_Stefano_2017"], [27, 3, 1, "", "get_Moe_di_Stefano_2017_default_options"], [27, 3, 1, "", "get_Moe_di_Stefano_2017_default_options_description"], [27, 3, 1, "", "get_moe_di_stefano_dataset"], [27, 3, 1, "", "set_moe_di_stefano_settings"]], "binarycpython.utils.population_extensions.analytics": [[28, 2, 1, "", "analytics"]], "binarycpython.utils.population_extensions.analytics.analytics": [[28, 3, 1, "", "CPU_time"], [28, 3, 1, "", "make_analytics_dict"], [28, 3, 1, "", "set_time"], [28, 3, 1, "", "time_elapsed"]], "binarycpython.utils.population_extensions.cache": [[29, 2, 1, "", "cache"]], "binarycpython.utils.population_extensions.cache.cache": [[29, 2, 1, "", "NullCache"], [29, 3, 1, "", "default_cache_dir"], [29, 3, 1, "", "setup_function_cache"], [29, 3, 1, "", "test_caches"]], "binarycpython.utils.population_extensions.cache.cache.NullCache": [[29, 3, 1, "", "__delitem__"], [29, 3, 1, "", "__getitem__"], [29, 3, 1, "", "__setitem__"], [29, 3, 1, "", "popitem"]], "binarycpython.utils.population_extensions.condor": [[30, 2, 1, "", "condor"]], "binarycpython.utils.population_extensions.condor.condor": [[30, 3, 1, "", "condorID"], [30, 3, 1, "", "condor_check_requirements"], [30, 3, 1, "", "condor_dirs"], [30, 3, 1, "", "condor_grid"], [30, 3, 1, "", "condor_outfile"], [30, 3, 1, "", "condor_queue_stats"], [30, 3, 1, "", "condor_status_file"], [30, 3, 1, "", "condorpath"], [30, 3, 1, "", "get_condor_status"], [30, 3, 1, "", "make_condor_dirs"], [30, 3, 1, "", "set_condor_status"]], "binarycpython.utils.population_extensions.dataIO": [[31, 2, 1, "", "dataIO"]], "binarycpython.utils.population_extensions.dataIO.dataIO": [[31, 3, 1, "", "NFS_flush_hack"], [31, 3, 1, "", "NFSpath"], [31, 3, 1, "", "compression_type"], [31, 3, 1, "", "dir_ok"], [31, 3, 1, "", "load_population_object"], [31, 3, 1, "", "load_snapshot"], [31, 3, 1, "", "locked_close"], [31, 3, 1, "", "locked_open_for_write"], [31, 3, 1, "", "merge_populations"], [31, 3, 1, "", "merge_populations_from_file"], [31, 3, 1, "", "open"], [31, 3, 1, "", "save_population_object"], [31, 3, 1, "", "save_snapshot"], [31, 3, 1, "", "set_status"], [31, 3, 1, "", "snapshot_filename"], [31, 3, 1, "", "wait_for_unlock"], [31, 3, 1, "", "write_binary_c_calls_to_file"], [31, 3, 1, "", "write_ensemble"]], "binarycpython.utils.population_extensions.distribution_functions": [[32, 2, 1, "", "distribution_functions"]], "binarycpython.utils.population_extensions.distribution_functions.distribution_functions": [[32, 3, 1, "", "Arenou2010_binary_fraction"], [32, 3, 1, "", "Izzard2012_period_distribution"], [32, 3, 1, "", "Kroupa2001"], [32, 3, 1, "", "Moe_di_Stefano_2017_multiplicity_fractions"], [32, 3, 1, "", "Moe_di_Stefano_2017_pdf"], [32, 3, 1, "", "build_q_table"], [32, 3, 1, "", "calc_P_integral"], [32, 3, 1, "", "calc_e_integral"], [32, 3, 1, "", "calc_total_probdens"], [32, 3, 1, "", "calculate_constants_three_part_powerlaw"], [32, 3, 1, "", "const_distribution"], [32, 3, 1, "", "cosmic_SFH_madau_dickinson2014"], [32, 3, 1, "", "duquennoy1991"], [32, 3, 1, "", "fill_data"], [32, 3, 1, "", "flat"], [32, 3, 1, "", "flatsections"], [32, 3, 1, "", "gaussian"], [32, 3, 1, "", "gaussian_func"], [32, 3, 1, "", "gaussian_normalizing_const"], [32, 3, 1, "", "get_integration_constant_q"], [32, 3, 1, "", "get_max_multiplicity"], [32, 3, 1, "", "imf_chabrier2003"], [32, 3, 1, "", "imf_scalo1986"], [32, 3, 1, "", "imf_scalo1998"], [32, 3, 1, "", "imf_tinsley1980"], [32, 3, 1, "", "interpolate_in_mass_izzard2012"], [32, 3, 1, "", "ktg93"], [32, 3, 1, "", "linear_extrapolation_q"], [32, 3, 1, "", "merge_multiplicities"], [32, 3, 1, "", "number"], [32, 3, 1, "", "poisson"], [32, 3, 1, "", "powerlaw"], [32, 3, 1, "", "powerlaw_constant"], [32, 3, 1, "", "powerlaw_constant_nocache"], [32, 3, 1, "", "powerlaw_extrapolation_q"], [32, 3, 1, "", "raghavan2010_binary_fraction"], [32, 3, 1, "", "sana12"], [32, 3, 1, "", "three_part_powerlaw"]], "binarycpython.utils.population_extensions.grid_logging": [[33, 2, 1, "", "grid_logging"]], "binarycpython.utils.population_extensions.grid_logging.grid_logging": [[33, 3, 1, "", "vb1print"], [33, 3, 1, "", "vb2print"], [33, 3, 1, "", "verbose_print"]], "binarycpython.utils.population_extensions.grid_options_defaults": [[34, 2, 1, "", "grid_options_defaults"]], "binarycpython.utils.population_extensions.grid_options_defaults.grid_options_defaults": [[34, 3, 1, "", "default_cache_dir"], [34, 3, 1, "", "get_grid_options_defaults_dict"], [34, 3, 1, "", "get_grid_options_descriptions"], [34, 3, 1, "", "grid_options_description_checker"], [34, 3, 1, "", "grid_options_help"], [34, 3, 1, "", "print_option_descriptions"], [34, 3, 1, "", "write_grid_options_to_rst_file"]], "binarycpython.utils.population_extensions.gridcode": [[35, 2, 1, "", "gridcode"]], "binarycpython.utils.population_extensions.gridcode.gridcode": [[35, 3, 1, "", "add_grid_variable"], [35, 3, 1, "", "delete_grid_variable"], [35, 3, 1, "", "rename_grid_variable"], [35, 3, 1, "", "update_grid_variable"]], "binarycpython.utils.population_extensions.metadata": [[36, 2, 1, "", "metadata"]], "binarycpython.utils.population_extensions.metadata.metadata": [[36, 3, 1, "", "add_ensemble_metadata"], [36, 3, 1, "", "add_system_metadata"]], "binarycpython.utils.population_extensions.slurm": [[37, 2, 1, "", "slurm"]], "binarycpython.utils.population_extensions.slurm.slurm": [[37, 3, 1, "", "get_slurm_status"], [37, 3, 1, "", "make_slurm_dirs"], [37, 3, 1, "", "set_slurm_status"], [37, 3, 1, "", "slurmID"], [37, 3, 1, "", "slurm_check_requirements"], [37, 3, 1, "", "slurm_dirs"], [37, 3, 1, "", "slurm_grid"], [37, 3, 1, "", "slurm_outfile"], [37, 3, 1, "", "slurm_queue_stats"], [37, 3, 1, "", "slurm_status_file"], [37, 3, 1, "", "slurmpath"]], "binarycpython.utils.population_extensions.spacing_functions": [[38, 2, 1, "", "spacing_functions"]], "binarycpython.utils.population_extensions.spacing_functions.spacing_functions": [[38, 3, 1, "", "const_dt"], [38, 3, 1, "", "const_int"], [38, 3, 1, "", "const_linear"], [38, 3, 1, "", "const_ranges"], [38, 3, 1, "", "gaussian_zoom"], [38, 3, 1, "", "peak_normalized_gaussian_func"]], "binarycpython.utils.population_extensions.version_info": [[39, 2, 1, "", "version_info"]], "binarycpython.utils.population_extensions.version_info.version_info": [[39, 3, 1, "", "minimum_stellar_mass"], [39, 3, 1, "", "parse_binary_c_version_info"], [39, 3, 1, "", "return_binary_c_version_info"]], "binarycpython.utils.run_system_wrapper": [[41, 1, 1, "", "run_system"]], "binarycpython.utils.useful_funcs": [[43, 1, 1, "", "calc_period_from_sep"], [43, 1, 1, "", "calc_sep_from_period"], [43, 1, 1, "", "maximum_mass_ratio_for_RLOF"], [43, 1, 1, "", "minimum_period_for_RLOF"], [43, 1, 1, "", "minimum_separation_for_RLOF"], [43, 1, 1, "", "ragb"], [43, 1, 1, "", "roche_lobe"], [43, 1, 1, "", "rzams"], [43, 1, 1, "", "zams_collision"]]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:class", "3": "py:method"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "class", "Python class"], "3": ["py", "method", "Python method"]}, "titleterms": {"binary_c": [0, 7, 9, 11, 12, 16, 19, 23, 40], "paramet": [0, 11], "section": 0, "star": [0, 6, 15, 16], "binari": [0, 5, 6, 13, 16, 19], "nucsyn": 0, "output": [0, 6, 8, 13, 14, 15, 16], "input": 0, "i": 0, "o": 0, "algorithm": 0, "misc": 0, "custom_logging_funct": 1, "modul": [1, 2, 3, 20, 21, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43], "dict": 2, "ensembl": [3, 10], "exampl": [4, 5, 6, 7, 8, 9, 11, 13, 14, 15, 16, 17, 18, 19, 23, 40], "notebook": [4, 19], "content": [4, 23], "us": [5, 6, 7, 8, 9, 13, 14, 15, 17, 19, 23, 40], "case": [5, 6, 8, 13, 14, 15, 17], "black": 5, "hole": 5, "system": [5, 12, 17], "hertzsprung": 6, "russel": 6, "diagram": 6, "set": [6, 7, 8, 13, 14, 15, 16], "up": [6, 7, 8, 13, 14, 15, 16], "popul": [6, 8, 9, 12, 13, 14, 15, 16, 21, 22, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], "object": [6, 8, 9, 12, 13, 14, 15, 16], "stellar": [6, 8, 13, 14], "grid": [6, 8, 13, 14, 15, 16, 22], "log": [6, 8, 9, 13, 14, 15, 16, 19], "handl": [6, 8, 10, 13, 14, 15, 16], "evolv": [6, 8, 13, 14, 15, 16], "tutori": [7, 9, 10, 11, 12, 16], "api": [7, 9, 12, 17, 19], "function": [7, 11, 12, 13, 14, 15, 16, 17, 19, 20], "python": [7, 9, 11, 12, 16, 19, 23, 40], "usag": [7, 9, 23, 40], "free": 7, "store": 7, "get": [7, 11], "inform": [7, 11], "from": [7, 9, 23, 40], "common": 8, "envelop": 8, "evolut": [8, 9], "custom": [9, 19], "routin": 9, "when": 9, "run": [9, 12, 16, 19, 23, 40], "directli": 9, "string": 9, "compact": 9, "mass": [9, 14, 15], "supernova": 9, "gener": [10, 23, 40], "data": 10, "extra": 11, "featur": 11, "about": 11, "build": [11, 23, 40], "pars": 11, "dictionari": 11, "modif": 11, "individu": 12, "singl": [12, 16], "run_system_wrapp": [12, 41], "via": [12, 23, 40], "zero": [13, 14], "ag": [13, 14], "luminos": [13, 14, 15], "ad": [13, 14, 15, 16], "variabl": [13, 14, 15, 16, 23, 40], "zam": [14, 15], "distribut": [14, 15], "initi": [14, 15], "A": [14, 15], "better": [14, 15], "sampl": [14, 15], "massiv": 15, "noteworthi": 16, "full": 16, "script": 16, "solar": 17, "basic": 18, "core": 19, "wrapper": 19, "run_binari": 19, "run_binary_with_log": 19, "line": 19, "util": 19, "run_system": 19, "other": 19, "class": [21, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], "code": [22, 23, 24, 40], "option": 22, "public": 22, "moe": 22, "di": 22, "stefano": 22, "sampler": 22, "privat": 22, "welcom": 23, "s": 23, "document": [23, 40], "instal": [23, 40], "requir": [23, 40], "environ": [23, 40], "instruct": [23, 40], "pip": [23, 40], "sourc": [23, 40], "after": [23, 40], "without": [23, 40], "note": [23, 40], "develop": [23, 40], "docstr": [23, 40], "test": [23, 40], "coverag": [23, 40], "report": [23, 40], "unit": [23, 40], "faq": [23, 40], "issu": [23, 40], "indic": 23, "tabl": 23, "binarycpython": 24, "plot_funct": 25, "extens": [26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], "hpc": 26, "moe_di_stefano_2017": 27, "analyt": 28, "cach": 29, "condor": 30, "dataio": 31, "distribution_funct": 32, "grid_log": 33, "grid_options_default": 34, "gridcod": 35, "metadata": 36, "slurm": 37, "spacing_funct": 38, "version_info": 39, "stellar_typ": 42, "useful_func": 43}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.todo": 2, "sphinx.ext.viewcode": 1, "nbsphinx": 4, "sphinx": 56}}) \ No newline at end of file diff --git a/docs/build/html/spacing_functions.html b/docs/build/html/spacing_functions.html deleted file mode 100644 index 04d54d1151870680b97bfb241fa7bf8cc56ba492..0000000000000000000000000000000000000000 --- a/docs/build/html/spacing_functions.html +++ /dev/null @@ -1,396 +0,0 @@ - - -<!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> -<head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>spacing_functions module — binary_c-python documentation</title> - - - - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> - <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> - <script src="_static/jquery.js"></script> - <script src="_static/underscore.js"></script> - <script src="_static/doctools.js"></script> - <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="index" title="Index" href="genindex.html" /> - <link rel="search" title="Search" href="search.html" /> - <link rel="next" title="stellar_types module" href="stellar_types.html" /> - <link rel="prev" title="run_system_wrapper module" href="run_system_wrapper.html" /> -</head> - -<body class="wy-body-for-nav"> - - - <div class="wy-grid-for-nav"> - - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> - <div class="wy-side-scroll"> - <div class="wy-side-nav-search" > - - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - - </a> - - - - - - - -<div role="search"> - <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> - <input type="text" name="q" placeholder="Search docs" /> - <input type="hidden" name="check_keywords" value="yes" /> - <input type="hidden" name="area" value="default" /> - </form> -</div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - - <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> -<ul class="current"> -<li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> -<li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> -<li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2 current"><a class="current reference internal" href="#">spacing_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> -<li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> -</ul> -</li> -<li class="toctree-l1"><a class="reference internal" href="example_notebooks.html">Example notebooks</a></li> -<li class="toctree-l1"><a class="reference internal" href="binary_c_parameters.html">Binary_c parameters</a></li> -<li class="toctree-l1"><a class="reference internal" href="grid_options_descriptions.html">Population grid code options</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li> -<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> -</ul> - - - - </div> - </div> - </nav> - - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - - <i data-toggle="wy-nav-top" class="fa fa-bars"></i> - <a href="index.html">binary_c-python</a> - - </nav> - - - <div class="wy-nav-content"> - - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - - <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - - <li><a href="modules.html">Binarycpython code</a> »</li> - - <li>spacing_functions module</li> - - - <li class="wy-breadcrumbs-aside"> - - - <a href="_sources/spacing_functions.rst.txt" rel="nofollow"> View page source</a> - - - </li> - - </ul> - - - <hr/> -</div> - <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> - <div itemprop="articleBody"> - - -<style> -/* CSS overrides for sphinx_rtd_theme */ - -/* 24px margin */ -.nbinput.nblast.container, -.nboutput.nblast.container { - margin-bottom: 19px; /* padding has already 5px */ -} - -/* ... except between code cells! */ -.nblast.container + .nbinput.container { - margin-top: -19px; -} - -.admonition > p:before { - margin-right: 4px; /* make room for the exclamation icon */ -} - -/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */ -.math { - text-align: unset; -} -</style> -<div class="section" id="module-binarycpython.utils.spacing_functions"> -<span id="spacing-functions-module"></span><h1>spacing_functions module<a class="headerlink" href="#module-binarycpython.utils.spacing_functions" title="Permalink to this headline">¶</a></h1> -<p>Module containing the spacing functions for the binarycpython package. Very under-populated at the moment, but more are likely to come soon</p> -<dl class="simple"> -<dt>Tasks:</dt><dd><p>TODO: add more spacing functions to this module.</p> -</dd> -</dl> -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.spacing_functions.const"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.spacing_functions.</span></span><span class="sig-name descname"><span class="pre">const</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/spacing_functions.html#const"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.spacing_functions.const" title="Permalink to this definition">¶</a></dt> -<dd><p>Samples a range linearly. Uses numpy linspace.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>min_bound</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – lower bound of range</p></li> -<li><p><strong>max_bound</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – upper bound of range</p></li> -<li><p><strong>steps</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – number of segments between min_bound and max_bound</p></li> -</ul> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p> -</dd> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>np.linspace(min_bound, max_bound, steps+1)</p> -</dd> -</dl> -</dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.spacing_functions.const_dt"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.spacing_functions.</span></span><span class="sig-name descname"><span class="pre">const_dt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dlogt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mmin</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.07</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mmax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nres</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">logspacing</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tmin</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tmax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mindm</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">maxdm</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">((0.07,</span> <span class="pre">1.0,</span> <span class="pre">0.1),</span> <span class="pre">(1.0,</span> <span class="pre">300.0,</span> <span class="pre">1.0))</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fsample</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">factor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">logmasses</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">log10masses</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">showlist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">showtable</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/spacing_functions.html#const_dt"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.spacing_functions.const_dt" title="Permalink to this definition">¶</a></dt> -<dd><p>const_dt returns a list of masses spaced at a constant age difference</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>dt</strong> – the time difference between the masses (1000.0 Myr, used when logspacing==False)</p></li> -<li><p><strong>dlogt</strong> – the delta log10(time) difference between masses (0.1 dex, used when logspacing==True)</p></li> -<li><p><strong>mmin</strong> – the minimum mass to be considered in the stellar lifetime interpolation table (0.07 Msun)</p></li> -<li><p><strong>mmax</strong> – the maximum mass to be considered in the stellar lifetime interpolation table (100.0 Msun)</p></li> -<li><p><strong>nres</strong> – the resolution of the stellar lifetime interpolation table (100)</p></li> -<li><p><strong>logspacing</strong> – whether to use log-spaced time, in which case dt is actually d(log10(t))</p></li> -<li><p><strong>tmin</strong> – the minimum time to consider (Myr, default 3.0 Myr)</p></li> -<li><p><strong>tmax</strong> – the maximum time to consider (Myr, default None which means we use the grid option ‘max_evolution_time’)</p></li> -<li><p><strong>mindm</strong> – a tuple of tuples containing a mass range and minimum mass spacing in that range. The default is ((0.07,1.0,0.1),(1.0,300.0,1.0)) allocated a minimum dm of 0.1Msun in the mass range 0.07 to 1.0 Msun and 1.0Msun in the range 1.0 to 300.0 Msun. Anything you set overrides this. Note, if you use only one tuple, you must set it with a trailing comma, thus, e.g. ((0.07,1.0,0.1),). (default None)</p></li> -<li><p><strong>maxdm</strong> – a list of tuples similar to mindm but specifying a maximum mass spacing. In the case of maxdm, if the third option in each tuple is negative it is treated as a log step (its absolute value is used as the step). (default None)</p></li> -<li><p><strong>fsample</strong> – a global sampling (Shannon-like) factor (<1) to improve resolution (default 1.0, set to smaller to improve resolution)</p></li> -<li><p><strong>factor</strong> – all masses generated are multiplied by this after generation</p></li> -<li><p><strong>showtable</strong> – if True, the mass list and times are shown to stdout after generation</p></li> -<li><p><strong>showlist</strong> – if True, show the mass list once generated</p></li> -<li><p><strong>logmasses</strong> – if True, the masses are logged with math.log()</p></li> -<li><p><strong>log10masses</strong> – if True, the masses are logged with math.log10()</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>Array of masses.</p> -</dd> -</dl> -<p>Example: -# these are lines set as options to Population.add_grid_value(…)</p> -<p># linear time bins of 1Gyr -samplerfunc=â€const_dt(self,dt=1000,nres=100,mmin=0.07,mmax=2.0,showtable=True)â€</p> -<p># logarithmic spacing in time, generally suitable for Galactic -# chemical evolution yield grids. -samplerfunc=â€const_dt(self,dlogt=0.1,nres=100,mmin=0.07,mmax=80.0,maxdm=((0.07,1.0,0.1),(1.0,10.0,1.0),(10.0,80.0,2.0)),showtable=True,logspacing=True,fsample=1.0/4.0)â€</p> -</dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.spacing_functions.const_ranges"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.spacing_functions.</span></span><span class="sig-name descname"><span class="pre">const_ranges</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ranges</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/spacing_functions.html#const_ranges"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.spacing_functions.const_ranges" title="Permalink to this definition">¶</a></dt> -<dd><p>Samples a series of ranges linearly.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>ranges</strong> – a tuple of tuples passed to the const() spacing function.</p> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p> -</dd> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>numpy array of masses</p> -</dd> -</dl> -<p class="rubric">Example</p> -<p>The following allocates 10 stars between 0.1 and 0.65, 20 stars between 0.65 -and 0.85, and 10 stars between 0.85 and 10.0 Msun.</p> -<dl class="simple"> -<dt>samplerfunc=â€const_ranges((({},{},{}),({},{},{}),({},{},{})))â€.format(</dt><dd><p>0.1,0.65,10, -0.65,0.85,20, -0.85,10.0,10</p> -</dd> -</dl> -<p>),</p> -</dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.spacing_functions.gaussian_zoom"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.spacing_functions.</span></span><span class="sig-name descname"><span class="pre">gaussian_zoom</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_bound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">zoom_mean</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">zoom_dispersion</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">zoom_magnitude</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/spacing_functions.html#gaussian_zoom"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.spacing_functions.gaussian_zoom" title="Permalink to this definition">¶</a></dt> -<dd><p>Samples such that a region is zoomed in according to a 1-Gaussian function</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>min_bound</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – lower bound of range</p></li> -<li><p><strong>max_bound</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – upper bound of range</p></li> -<li><p><strong>zoom_mean</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – mean of the Gaussian zoom location</p></li> -<li><p><strong>zoom_dispersion</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – dispersion of the Gaussian</p></li> -<li><p><strong>zoom_magnitude</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – depth of the Gaussian (should be 0<= zoom_magntiude <1)</p></li> -<li><p><strong>steps</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – number of segments between min_bound and max_bound assuming a linear step -this is what you’d normally call “resolutionâ€</p></li> -</ul> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p> -</dd> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>Numpy array of sample values</p> -</dd> -</dl> -</dd></dl> - -<dl class="py function"> -<dt class="sig sig-object py" id="binarycpython.utils.spacing_functions.peak_normalized_gaussian_func"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.spacing_functions.</span></span><span class="sig-name descname"><span class="pre">peak_normalized_gaussian_func</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mean</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sigma</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/spacing_functions.html#peak_normalized_gaussian_func"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.spacing_functions.peak_normalized_gaussian_func" title="Permalink to this definition">¶</a></dt> -<dd><p>Function to evaluate a Gaussian at a given point, note -that the normalization is such that the peak is always 1.0, -not that the integral is 1.0</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>x</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – location at which to evaluate the distribution</p></li> -<li><p><strong>mean</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – mean of the Gaussian</p></li> -<li><p><strong>sigma</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – standard deviation of the Gaussian</p></li> -</ul> -</dd> -<dt class="field-even">Return type</dt> -<dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]</p> -</dd> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>value of the Gaussian at x</p> -</dd> -</dl> -</dd></dl> - -</div> - - - </div> - - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="stellar_types.html" class="btn btn-neutral float-right" title="stellar_types module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="run_system_wrapper.html" class="btn btn-neutral float-left" title="run_system_wrapper module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - - </div> - - - <hr/> - - <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> - </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. -<br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. -<br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. - - - -</footer> - - </div> - </div> - - </section> - - </div> - - - - <script type="text/javascript"> - jQuery(function () { - SphinxRtdTheme.Navigation.enable(true); - }); - </script> - - - - - - -</body> -</html> \ No newline at end of file diff --git a/docs/build/html/stellar_types.html b/docs/build/html/stellar_types.html index 4d1a4f3dff920571ffa71b691c769b3346890d0c..bc2e10e34f6aeb0aa49453ac00bac708fe072082 100644 --- a/docs/build/html/stellar_types.html +++ b/docs/build/html/stellar_types.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>stellar_types module — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>stellar_types module — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="useful_funcs module" href="useful_funcs.html" /> - <link rel="prev" title="spacing_functions module" href="spacing_functions.html" /> + <link rel="prev" title="run_system_wrapper module" href="run_system_wrapper.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,30 +38,32 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> <li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="ensemble.html">ensemble module</a></li> <li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid.html">Population class module</a></li> <li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> <li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">stellar_types module</a></li> <li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li> </ul> @@ -107,70 +75,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li><a href="modules.html">Binarycpython code</a> »</li> - <li>stellar_types module</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/stellar_types.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -195,8 +124,8 @@ text-align: unset; } </style> -<div class="section" id="module-binarycpython.utils.stellar_types"> -<span id="stellar-types-module"></span><h1>stellar_types module<a class="headerlink" href="#module-binarycpython.utils.stellar_types" title="Permalink to this headline">¶</a></h1> +<section id="module-binarycpython.utils.stellar_types"> +<span id="stellar-types-module"></span><h1>stellar_types module<a class="headerlink" href="#module-binarycpython.utils.stellar_types" title="Permalink to this heading">ïƒ</a></h1> <dl class="simple"> <dt>Module containing two stellar type dicts:</dt><dd><ul class="simple"> <li><p>STELLAR_TYPE_DICT: dictionary with long names</p></li> @@ -204,61 +133,43 @@ </ul> </dd> </dl> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="useful_funcs.html" class="btn btn-neutral float-right" title="useful_funcs module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="spacing_functions.html" class="btn btn-neutral float-left" title="spacing_functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="run_system_wrapper.html" class="btn btn-neutral float-left" title="run_system_wrapper module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="useful_funcs.html" class="btn btn-neutral float-right" title="useful_funcs module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/build/html/useful_funcs.html b/docs/build/html/useful_funcs.html index 7c5b2294be6ff6852aa9a05e75e5732ceb797684..44bb5b1040009945a12c455d3bbcb1adc5ac0cd4 100644 --- a/docs/build/html/useful_funcs.html +++ b/docs/build/html/useful_funcs.html @@ -1,70 +1,36 @@ - - <!DOCTYPE html> -<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> -<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<html class="writer-html5" lang="en" > <head> - <meta charset="utf-8"> - - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>useful_funcs module — binary_c-python documentation</title> - + <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>useful_funcs module — binary_c-python documentation</title> + <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> + <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <!--[if lt IE 9]> + <script src="_static/js/html5shiv.min.js"></script> + <![endif]--> - - - - - - <script type="text/javascript" src="_static/js/modernizr.min.js"></script> - - - <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> + <script src="_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> - - <script type="text/javascript" src="_static/js/theme.js"></script> - - - - - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> - <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> + <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Example notebooks" href="example_notebooks.html" /> <link rel="prev" title="stellar_types module" href="stellar_types.html" /> </head> -<body class="wy-body-for-nav"> - - +<body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> - <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > - - - <a href="index.html" class="icon icon-home"> binary_c-python - - - </a> - - - - - - - <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> @@ -72,30 +38,32 @@ <input type="hidden" name="area" value="default" /> </form> </div> - - - </div> - - <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> - - - - - - + </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li> <li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="dicts.html">dicts module</a></li> +<li class="toctree-l2"><a class="reference internal" href="ensemble.html">ensemble module</a></li> <li class="toctree-l2"><a class="reference internal" href="functions.html">functions module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li> -<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li> -<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="grid.html">Population class module</a></li> <li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/analytics.html">Population class extension: analytics module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/cache.html">Population class extension: cache module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/condor.html">Population class extension: condor module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/dataIO.html">Population class extension: dataIO module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/distribution_functions.html">Population class extension: distribution_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/gridcode.html">Population class extension: gridcode module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_logging.html">Population class extension: grid_logging module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/grid_options_defaults.html">Population class extension: grid_options_defaults module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/HPC.html">Population class extension: HPC module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/metadata.html">Population class extension: metadata module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/Moe_di_Stefano_2017.html">Population class extension: Moe_di_Stefano_2017 module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/slurm.html">Population class extension: slurm module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/spacing_functions.html">Population class extension: spacing_functions module</a></li> +<li class="toctree-l2"><a class="reference internal" href="population_extensions/version_info.html">Population class extension: version_info module</a></li> <li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li> -<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li> <li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">useful_funcs module</a></li> </ul> @@ -107,70 +75,31 @@ <li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li> </ul> - - </div> </div> </nav> - <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> - - - <nav class="wy-nav-top" aria-label="top navigation"> - + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">binary_c-python</a> - </nav> - <div class="wy-nav-content"> - <div class="rst-content"> - - - - - - - - - - - - - - - - - -<div role="navigation" aria-label="breadcrumbs navigation"> - + <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> - - <li><a href="index.html">Docs</a> »</li> - + <li><a href="index.html" class="icon icon-home"></a> »</li> <li><a href="modules.html">Binarycpython code</a> »</li> - <li>useful_funcs module</li> - - <li class="wy-breadcrumbs-aside"> - - <a href="_sources/useful_funcs.rst.txt" rel="nofollow"> View page source</a> - - </li> - </ul> - - <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - + <style> /* CSS overrides for sphinx_rtd_theme */ @@ -195,8 +124,8 @@ text-align: unset; } </style> -<div class="section" id="module-binarycpython.utils.useful_funcs"> -<span id="useful-funcs-module"></span><h1>useful_funcs module<a class="headerlink" href="#module-binarycpython.utils.useful_funcs" title="Permalink to this headline">¶</a></h1> +<section id="module-binarycpython.utils.useful_funcs"> +<span id="useful-funcs-module"></span><h1>useful_funcs module<a class="headerlink" href="#module-binarycpython.utils.useful_funcs" title="Permalink to this heading">ïƒ</a></h1> <p>Collection of useful functions.</p> <p>Part of this is copied/inspired by Rob’s binary_stars module</p> <dl class="simple"> @@ -206,7 +135,7 @@ <li><p>rzams(m, z) gives you the ZAMS radius of a star</p></li> <li><p>ZAMS_collision(m1, m2, e, sep, z) returns 1 if stars collide on the ZAMS</p></li> <li><p>roche_lobe(q): returns roche lobe radius in units of separation</p></li> -<li><p>ragb(m, z): radius at first thermal pulse</p></li> +<li><p>ragb(m): radius at first thermal pulse</p></li> <li><p>minimum_period_for_RLOF(M1, M2, metallicity, store_memaddr=-1): function to calculate the minimum period that leads to RLOF on ZAMS</p></li> <li><p>minimum_separation_for_RLOF(M1, M2, metallicity, store_memaddr=-1): function to calculate the minimum period that leads to RLOF on ZAMS</p></li> <li><p>maximum_mass_ratio_for_RLOF(M1, orbital_period, store_memaddr=None): Function to calculate the maximum mass ratio that leads to RLOF on ZAMS</p></li> @@ -214,13 +143,12 @@ </dd> <dt>Tasks:</dt><dd><ul class="simple"> <li><p>TODO: check whether these functions are correct</p></li> -<li><p>TODO: add unit test for maximum_mass_ratio_for_RLOF</p></li> </ul> </dd> </dl> <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.useful_funcs.calc_period_from_sep"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">calc_period_from_sep</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sep</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#calc_period_from_sep"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.calc_period_from_sep" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">calc_period_from_sep</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sep</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#calc_period_from_sep"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.calc_period_from_sep" title="Permalink to this definition">ïƒ</a></dt> <dd><p>calculate period from separation</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -241,7 +169,7 @@ <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.useful_funcs.calc_sep_from_period"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">calc_sep_from_period</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">period</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#calc_sep_from_period"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.calc_sep_from_period" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">calc_sep_from_period</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">period</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#calc_sep_from_period"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.calc_sep_from_period" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Calculate separation from period.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -262,7 +190,7 @@ <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.useful_funcs.maximum_mass_ratio_for_RLOF"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">maximum_mass_ratio_for_RLOF</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">orbital_period</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">metallicity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.02</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">store_memaddr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#maximum_mass_ratio_for_RLOF"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.maximum_mass_ratio_for_RLOF" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">maximum_mass_ratio_for_RLOF</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">orbital_period</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">metallicity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.02</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">store_memaddr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#maximum_mass_ratio_for_RLOF"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.maximum_mass_ratio_for_RLOF" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Wrapper function for _binary_c_bindings.return_maximum_mass_ratio_for_RLOF</p> <p>Handles the output and returns the maximum mass ratio at which RLOF just does not occur at ZAMS</p> <dl class="field-list simple"> @@ -282,7 +210,7 @@ <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.useful_funcs.minimum_period_for_RLOF"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">minimum_period_for_RLOF</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">metallicity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">store_memaddr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#minimum_period_for_RLOF"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.minimum_period_for_RLOF" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">minimum_period_for_RLOF</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">metallicity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">store_memaddr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#minimum_period_for_RLOF"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.minimum_period_for_RLOF" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Wrapper function for _binary_c_bindings.return_minimum_orbit_for_RLOF</p> <p>Handles the output and returns the minimum orbital period at which RLOF just does not occur at ZAMS</p> <dl class="field-list simple"> @@ -302,7 +230,7 @@ <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.useful_funcs.minimum_separation_for_RLOF"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">minimum_separation_for_RLOF</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">metallicity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">store_memaddr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#minimum_separation_for_RLOF"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.minimum_separation_for_RLOF" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">minimum_separation_for_RLOF</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">metallicity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">store_memaddr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#minimum_separation_for_RLOF"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.minimum_separation_for_RLOF" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Wrapper function for _binary_c_bindings.return_minimum_orbit_for_RLOF</p> <p>Handles the output and returns the minimum separation at which RLOF just does not occur at ZAMS</p> <dl class="field-list simple"> @@ -322,14 +250,14 @@ <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.useful_funcs.ragb"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">ragb</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#ragb"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.ragb" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">ragb</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#ragb"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.ragb" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to calculate radius of a star in units of solar radii at first thermal pulse as a function of mass (Z=0.02 only, but also good for Z=0.0001)</p> -<p>TODO: ask rob about this function</p> +<p>TODO: ask rob about this function. Do we still need this? Can we make something better? (i.e. upon installation of the code run a grid of systems and get the data from there?)</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>m</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – mass of star in units of solar mass</p></li> -<li><p><strong>z</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – metallicity of star</p></li> +<li><p><strong>z</strong> – metallicity of star</p></li> </ul> </dd> <dt class="field-even">Return type</dt> @@ -343,7 +271,7 @@ <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.useful_funcs.roche_lobe"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">roche_lobe</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">q</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#roche_lobe"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.roche_lobe" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">roche_lobe</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">q</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#roche_lobe"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.roche_lobe" title="Permalink to this definition">ïƒ</a></dt> <dd><p>A function to evaluate R_L/a(q), Eggleton 1983.</p> <p># TODO: check the definition of the mass ratio # TODO: check whether the logs are correct</p> @@ -362,7 +290,7 @@ <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.useful_funcs.rzams"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">rzams</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#rzams"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.rzams" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">rzams</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#rzams"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.rzams" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Function to determine the radius of a ZAMS star as a function of m and z:</p> <p>Based on the fits of Tout et al., 1996, MNRAS, 281, 257</p> <dl class="field-list simple"> @@ -380,7 +308,7 @@ <dl class="py function"> <dt class="sig sig-object py" id="binarycpython.utils.useful_funcs.zams_collision"> -<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">zams_collision</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sep</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">e</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#zams_collision"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.zams_collision" title="Permalink to this definition">¶</a></dt> +<span class="sig-prename descclassname"><span class="pre">binarycpython.utils.useful_funcs.</span></span><span class="sig-name descname"><span class="pre">zams_collision</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sep</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">e</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/useful_funcs.html#zams_collision"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#binarycpython.utils.useful_funcs.zams_collision" title="Permalink to this definition">ïƒ</a></dt> <dd><p>given m1,m2, separation and eccentricity (and metallicity) determine if two stars collide on the ZAMS</p> <dl class="field-list simple"> @@ -402,61 +330,43 @@ determine if two stars collide on the ZAMS</p> </dl> </dd></dl> -</div> +</section> </div> - </div> - <footer> - - <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - - <a href="example_notebooks.html" class="btn btn-neutral float-right" title="Example notebooks" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> - - - <a href="stellar_types.html" class="btn btn-neutral float-left" title="stellar_types module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> - + <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> + <a href="stellar_types.html" class="btn btn-neutral float-left" title="stellar_types module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> + <a href="example_notebooks.html" class="btn btn-neutral float-right" title="Example notebooks" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> - <hr/> <div role="contentinfo"> - <p> - © Copyright 2021, David Hendriks, Robert Izzard - - </p> + <p>© Copyright 2021, David Hendriks, Robert Izzard.</p> </div> - Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + + Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a + <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> + provided by <a href="https://readthedocs.org">Read the Docs</a>. + <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. </footer> - </div> </div> - </section> - </div> - - - - <script type="text/javascript"> + <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); - </script> - - - - - + </script> </body> </html> \ No newline at end of file diff --git a/docs/source/_templates/footer.html b/docs/source/_templates/footer.html index 2029d613c4eea83cd5e8b1e0bfd60cf71d445567..6ffb34e3cbbe1c97e6aa0ea753b560e1ce079d54 100644 --- a/docs/source/_templates/footer.html +++ b/docs/source/_templates/footer.html @@ -2,8 +2,8 @@ {%- block extrafooter %} <br><br> -Generated on binarycpython git branch: development_0.9.2/2.2.1 git revision d1fde5c9bf26c24340a5de90244686794e870ba3 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.2/2.2.1">git url</a>. +Generated on binarycpython git branch: development_0.9.3/2.2.1 git revision 06a53f149689875d942ee00fddaaa90db4af76f9 url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_0.9.3/2.2.1">git url</a>. <br><br> -Using binary_c with bit branch branch_david: git revision: "5747:20211102:404ce27a0" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. +Using binary_c with bit branch branch_david: git revision: "6118:20220617:8463fa650" url: <a href="https://gitlab.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>. {% endblock %} \ No newline at end of file diff --git a/docs/source/badges/test_coverage.svg b/docs/source/badges/test_coverage.svg index dfb99a19bbb554f31bc566f509dce7df5d8bb40d..a4262d340358b7051e60330569727e5a2d1695f9 100644 --- a/docs/source/badges/test_coverage.svg +++ b/docs/source/badges/test_coverage.svg @@ -15,7 +15,7 @@ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text> <text x="31.5" y="14">coverage</text> - <text x="80" y="15" fill="#010101" fill-opacity=".3">67%</text> - <text x="80" y="14">67%</text> + <text x="80" y="15" fill="#010101" fill-opacity=".3">69%</text> + <text x="80" y="14">69%</text> </g> </svg> diff --git a/docs/source/binary_c_parameters.rst b/docs/source/binary_c_parameters.rst index b66bc0c57226dd2dcc729ece18ca996604c0dc16..9d00a7aca6f63646c1f16d38ad998fcbbe5c3874 100644 --- a/docs/source/binary_c_parameters.rst +++ b/docs/source/binary_c_parameters.rst @@ -4,7 +4,7 @@ The following chapter contains all the parameters that the current version of bi This information was obtained by the following binary_c build: - **binary_c git branch**: branch_david **binary_c git revision**: 5747:20211102:404ce27a0 **Built on**: Nov 2 2021 23:57:35 + **binary_c git branch**: branch_david **binary_c git revision**: 6118:20220617:8463fa650 **Built on**: Jun 17 2022 23:20:34 Section: stars @@ -250,6 +250,11 @@ Section: stars | **Parameter input type**: True|False | **Default value**: False +| **Parameter**: custom_timeout_time +| **Description**: Custom timeout time. Requires compilation with DAVID_CUSTOM_TIMEOUT +| **Parameter input type**: Float +| **Default value**: 100 + | **Parameter**: evolution_splitting | **Description**: If True, turn on splitting of an evolutionary run if splitpoint (e.g. supernova) occurs. | **Parameter input type**: True|False @@ -288,10 +293,10 @@ Section: stars | **Macros**: ['OPACITY_ALGORITHM_PACZYNSKI = 0', 'OPACITY_ALGORITHM_FERGUSON_OPAL = 1', 'OPACITY_ALGORITHM_STARS = 2'] | **Parameter**: wind_mass_loss -| **Description**: Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018). +| **Description**: Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018), 3 = Schneider + Sander and Wink (2020) for helium stars, 4 = Schneider + Hurley for LBV mass loss | **Parameter input type**: Unsigned integer | **Default value**: 3 -| **Macros**: ['WIND_ALGORITHM_NONE = 0', 'WIND_ALGORITHM_HURLEY2002 = 1', 'WIND_ALGORITHM_SCHNEIDER2018 = 2', 'WIND_ALGORITHM_BINARY_C_2020 = 3'] +| **Macros**: ['WIND_ALGORITHM_NONE = 0', 'WIND_ALGORITHM_HURLEY2002 = 1', 'WIND_ALGORITHM_SCHNEIDER2018 = 2', 'WIND_ALGORITHM_BINARY_C_2020 = 3', 'WIND_ALGORITHM_HENDRIKS_2022 = 4'] | **Extra**: 0 | **Parameter**: gbwind @@ -486,6 +491,18 @@ Section: stars | **Default value**: 0 | **Extra**: Ignore +| **Parameter**: PPISN_core_mass_range_shift +| **Description**: (Pulsational) Pair-Instability Supernova CO core mass range shift: Value by which we shift the range of CO core mass values that undergo PPISN. This is taken into account in the fit that calculates the mass removal. Negative number is shifting the range to lower masses, positive to higher masses. +| **Parameter input type**: Float +| **Default value**: 0 +| **Extra**: Ignore + +| **Parameter**: PPISN_massloss_multiplier +| **Description**: (Pulsational) Pair-Instability Supernova CO massloss multiplier: Value by which the (P)PISN massloss is multiplied. Currently only works with the new prescription. THe additional mass loss is not affected multiplied by this. +| **Parameter input type**: Float +| **Default value**: 1 +| **Extra**: Ignore + | **Parameter**: use_LWN_fallback | **Description**: Flag whether to use the Nazehdin-Lovegrove-Woosley hydrogen envelope ejection at failed supernova. | **Parameter input type**: Integer @@ -561,7 +578,7 @@ Section: stars | **Parameter**: sn_kick_distribution_PPISN | **Description**: Set the distribution of speeds applied to PPISN supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). | **Parameter input type**: Integer -| **Default value**: 1 +| **Default value**: 0 | **Macros**: ['KICK_VELOCITY_FIXED = 0', 'KICK_VELOCITY_MAXWELLIAN = 1', 'KICK_VELOCITY_CUSTOM = 2'] | **Parameter**: sn_kick_distribution_PISN @@ -634,7 +651,7 @@ Section: stars | **Parameter**: sn_kick_dispersion_PPISN | **Description**: Set the dispersion of speeds applied to the survivor of a PPISN supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). | **Parameter input type**: Float -| **Default value**: 190 +| **Default value**: 0 | **Parameter**: sn_kick_dispersion_PISN | **Description**: Set the dispersion of speeds applied to the survivor of a PISN supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). @@ -968,7 +985,7 @@ Section: stars | **Parameter**: MINT_metallicity | **Description**: This sets the metallicity for MINT. It is ignored if set to -1.0, the default, in which case the normal metallicity parameter is used. | **Parameter input type**: Float -| **Default value**: NULL +| **Default value**: -1 | **Parameter**: gaia_Teff_binwidth | **Description**: log10(Effective temperature) bin width used to make Gaia-like HRDs @@ -1153,6 +1170,21 @@ Section: stars | **Parameter input type**: True|False | **Default value**: False +| **Parameter**: degenerate_core_merger_nucsyn +| **Description**: If TRUE, assume that in a degnerate core merger, energy is generated from nucleosynthesis of the whole core, and that this can disrupt the core. The BSE algorithm (Hurley et al. 2002) assumes this to be TRUE, but binary_c assumes FALSE by default. (FALSE) +| **Parameter input type**: True|False +| **Default value**: False + +| **Parameter**: degenerate_core_helium_merger_ignition +| **Description**: If TRUE, assume that when there is a degenerate helium core merger, the star reignites helium. This is required to make R-type carbon stars. (TRUE) +| **Parameter input type**: True|False +| **Default value**: True + +| **Parameter**: degenerate_core_merger_dredgeup_fraction +| **Description**: If non-zero, mix this fraction of the degenerate core during a merger.(0.0). +| **Parameter input type**: Float +| **Default value**: NULL + Section: binary --------------- @@ -1325,7 +1357,7 @@ Section: binary | **Parameter**: post_ce_objects_have_envelopes | **Description**: If TRUE then post-common-envelope objects have thin envelopes. You need this if you are to have post-CE post-AGB stars. Note that this *may* be unstable, i.e. you may end up having many CEEs. The mass in the envelope is controlled by post_ce_adaptive_menv. TRUE by default. | **Parameter input type**: True|False -| **Default value**: True +| **Default value**: False | **Parameter**: PN_comenv_transition_time | **Description**: post-common envelope transition time in years (1e2). This is the time taken to move from CEE ejection to Teff > 30e4 K. Hall et al. (2013) suggest ~100 years. @@ -1794,7 +1826,7 @@ Section: binary | **Default value**: NULL | **Parameter**: lambda_ce -| **Description**: Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to -1 binary_c uses the Dewi and Tauris fits instead, -2 uses the formalism of Wang, Jia and Li (2016) and if -3 then a polytropic formalism is used (see also comenv_splitmass). +| **Description**: Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to LAMBDA_CE_DEWI_TAURIS == -1 binary_c uses the Dewi and Tauris fits instead, LAMBDA_CE_WANG_2016 == -2 uses the formalism of Wang, Jia and Li (2016), if LAMBDA_CE_POLYTROPE == -3 then a polytropic formalism is used (see also comenv_splitmass) and if LAMBDA_CE_KLENCKI_2020 == -4 use Klencki et al. (2020). | **Parameter input type**: Float | **Default value**: 0.5 | **Macros**: ['LAMBDA_CE_DEWI_TAURIS = -1', 'LAMBDA_CE_WANG_2016 = -2', 'LAMBDA_CE_POLYTROPE = -3', 'LAMBDA_CE_KLENCKI_2020 = -4'] @@ -1970,7 +2002,7 @@ Section: binary | **Default value**: 1e-06 | **Parameter**: cbdisc_minimum_fRing -| **Description**: Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = |Rout/Rin-1| < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS. +| **Description**: Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = abs(Rout/Rin-1) < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS. | **Parameter input type**: Float | **Default value**: 0.2 @@ -2357,6 +2389,36 @@ Section: output | **Parameter**: david_logging_function | **Description**: Function to choose which kind of information gets logged Requires DAVID. Choices are: 0= None, >0 for custom logging functions | **Parameter input type**: Integer +| **Default value**: -1 +| **Extra**: Ignore + +| **Parameter**: david_tzo_logging +| **Description**: Flag to enable logging for TZO project +| **Parameter input type**: Integer +| **Default value**: 0 +| **Extra**: Ignore + +| **Parameter**: david_ppisn_logging +| **Description**: Flag to enable logging for PPISN project +| **Parameter input type**: Integer +| **Default value**: 0 +| **Extra**: Ignore + +| **Parameter**: david_ppisn_single_logging +| **Description**: Flag to enable logging for PPISN project capturing single star systems that underwent SN +| **Parameter input type**: Integer +| **Default value**: 0 +| **Extra**: Ignore + +| **Parameter**: david_rlof_episode_logging +| **Description**: Flag to enable the RLOF episode logging +| **Parameter input type**: Integer +| **Default value**: 0 +| **Extra**: Ignore + +| **Parameter**: david_rlof_ensemble_logging +| **Description**: Flag to enable the RLOF ensemble logging +| **Parameter input type**: Integer | **Default value**: 0 | **Extra**: Ignore @@ -2593,105 +2655,111 @@ Section: output | **Default value**: NULL | **Extra**: Ignore +| **Parameter**: tides_diagnosis_log +| **Description**: Enable logging to test MINT tides. Requires MINT. Choices are: 0 disabled, 1 enable lambda test. +| **Parameter input type**: Integer +| **Default value**: 0 +| **Extra**: Ignore + Section: input -------------- | **Parameter**: MINT_dir | **Description**: Location of MINT algorithm data. | **Parameter input type**: String -| **Default value**: NULL +| **Default value**: | **Extra**: | **Parameter**: MINT_data_cleanup | **Description**: Activate checks on incoming data to try to account for problems. Will make data-loading slower, but may fix a few things. | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: False | **Extra**: | **Parameter**: MINT_MS_rejuvenation | **Description**: Turn on or off (hydrogen) main-sequence rejuvenation. | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: True | **Extra**: | **Parameter**: MINT_remesh | **Description**: Turn on or off MINT's remeshing. | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: True | **Extra**: | **Parameter**: MINT_use_ZAMS_profiles | **Description**: Use chemical profiles at the ZAMS if MINT_use_ZAMS_profiles is TRUE, otherwise set homogeneous abundances. (Default is TRUE, so we use the profiles if they are available.) | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: True | **Extra**: | **Parameter**: MINT_fallback_to_test_data | **Description**: If TRUE, use the MINT test_data directory as a fallback when data is unavailable. (FALSE) | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: False | **Extra**: | **Parameter**: MINT_disable_grid_load_warnings | **Description**: Use this to explicitly disable MINT's warnings when loading a grid with, e.g., missing or too much data. | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: False | **Extra**: | **Parameter**: MINT_Kippenhahn | **Description**: Turn on or off MINT's Kippenhahn diagrams. If 0, off, if 1, output star 1 (index 0), if 2 output star 2 (index 1). Default 0. | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: 0 | **Extra**: | **Parameter**: MINT_nshells | **Description**: Set the initial number of shells MINT uses in each star when doing nuclear burning. Note: remeshing can change this. If MINT_nshells is 0, shellular burning and other routines that require shells will not be available. (200) | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: 200 | **Extra**: | **Parameter**: MINT_maximum_nshells | **Description**: Set the maximum number of shells MINT uses in each star when doing nuclear burning. Note that this will be limited to MINT_HARD_MAX_NSHELLS. (1000) | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: 1000 | **Extra**: | **Parameter**: MINT_minimum_nshells | **Description**: Set the minimum number of shells MINT uses in each star when doing nuclear burning. Note that this will be greater than or equal to MINT_HARD_MIN_NSHELLS, which is 0 by default. (0) | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: 10 | **Extra**: | **Parameter**: MINT_Kippenhahn_stellar_type | **Description**: Stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for which Kippenhahn plot data should be output. | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: -1 | **Macros**: ['LOW_MASS_MS = 0', 'MS = 1', 'HG = 2', 'GIANT_BRANCH = 3', 'CHeB = 4', 'EAGB = 5', 'TPAGB = 6', 'HeMS = 7', 'HeHG = 8', 'HeGB = 9', 'HeWD = 10', 'COWD = 11', 'ONeWD = 12', 'NS = 13', 'BH = 14', 'MASSLESS_REMNANT = 15'] | **Extra**: | **Parameter**: MINT_Kippenhahn_companion_stellar_type | **Description**: Companion stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for the companion for which Kippenhahn plot data should be output. | **Parameter input type**: Integer -| **Default value**: NULL +| **Default value**: -1 | **Macros**: ['LOW_MASS_MS = 0', 'MS = 1', 'HG = 2', 'GIANT_BRANCH = 3', 'CHeB = 4', 'EAGB = 5', 'TPAGB = 6', 'HeMS = 7', 'HeHG = 8', 'HeGB = 9', 'HeWD = 10', 'COWD = 11', 'ONeWD = 12', 'NS = 13', 'BH = 14', 'MASSLESS_REMNANT = 15'] | **Extra**: | **Parameter**: MINT_nuclear_burning | **Description**: Turn on or off MINT's nuclear burning algorithm. | **Parameter input type**: True|False -| **Default value**: NULL +| **Default value**: False | **Extra**: | **Parameter**: MINT_minimum_shell_mass | **Description**: Minimum shell mass in MINT's nuclear burning routines. | **Parameter input type**: Float -| **Default value**: NULL +| **Default value**: 1e-06 | **Extra**: | **Parameter**: MINT_maximum_shell_mass | **Description**: Maximum shell mass in MINT's nuclear burning routines. : | **Parameter input type**: Float -| **Default value**: NULL +| **Default value**: 0.1 | **Extra**: Section: i/o diff --git a/docs/source/conf.py b/docs/source/conf.py index c023df6e2c4b22c124d133b2fa41d8970f979bda..c9a2bfcb85f2f3d59a3d699e2b340f2bd9d1806b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,8 +3,12 @@ Configuration file for the Sphinx documentation builder. This file only contains a selection of the most common options. For a full list see the documentation: -https://www.sphinx-doc.org/en/master/usage/configuration.html -https://brendanhasz.github.io/2019/01/05/sphinx.html + https://www.sphinx-doc.org/en/master/usage/configuration.html + https://brendanhasz.github.io/2019/01/05/sphinx.html + https://www.sphinx-doc.org/en/1.5/ext/example_google.html + + +https://stackoverflow.com/questions/22256995/restructuredtext-in-sphinx-and-docstrings-single-vs-double-back-quotes-or-back """ # -- Path setup -------------------------------------------------------------- @@ -16,9 +20,100 @@ https://brendanhasz.github.io/2019/01/05/sphinx.html import os import sys -import sphinx_rtd_theme +import m2r2 +import jinja2 + +from git import Repo + +from binarycpython.utils.functions import ( + write_binary_c_parameter_descriptions_to_rst_file, + call_binary_c_config, +) + +from binarycpython.utils.grid import Population + + +def generate_browser_url(ssh_url, branch=None): + """ + Function to generate the browser url for a git repo + """ + + base = ssh_url.split("@")[-1].replace(".git", "").replace(":", "/").strip() + + if not branch: + return "https://{}".format(base) + else: + return "https://{}/-/tree/{}".format(base, branch) + + +def write_custom_footer(): + """ + Function to write the custom footer to the template file + """ + + TARGET_DIR = "./_templates" + + output_text = """ +{{% extends '!footer.html' %}} + +{{%- block extrafooter %}} +<br><br> +Generated on binarycpython git branch: {binarycpython_git_branch} git revision {binarycpython_git_revision} url: <a href="{binarycpython_git_url}">git url</a>. +<br><br> +Using binary_c with bit branch {binary_c_git_branch}: git revision: {binary_c_git_revision} url: <a href="{binary_c_git_url}">git url</a>. + +{{% endblock %}} +""" + + binary_c_git_branch = call_binary_c_config("git_branch").strip() + binary_c_git_revision = call_binary_c_config("git_revision").strip() + binary_c_git_url = generate_browser_url( + call_binary_c_config("git_url").strip(), binary_c_git_branch + ) + + # for binarycpython git + base_dir = os.path.dirname( + os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + ) + local_repo = Repo(path=base_dir) + + binarycpython_git_branch = local_repo.active_branch.name + binarycpython_git_revision = local_repo.active_branch.commit + binarycpython_git_url = generate_browser_url( + local_repo.remotes.origin.url, binarycpython_git_branch + ) + + formatted_text = output_text.format( + binarycpython_git_branch=binarycpython_git_branch, + binarycpython_git_revision=binarycpython_git_revision, + binarycpython_git_url=binarycpython_git_url, + binary_c_git_branch=binary_c_git_branch, + binary_c_git_revision=binary_c_git_revision, + binary_c_git_url=binary_c_git_url, + ).strip() + + # Write to file + with open("_templates/footer.html", "w") as outfile_filehandle: + outfile_filehandle.write(formatted_text) + + +# +def patched_m2r2_setup(app): + """ + Function to handle the markdown parsing better + """ + + try: + return current_m2r2_setup(app) + except (AttributeError): + app.add_source_suffix(".md", "markdown") + app.add_source_parser(m2r2.M2RParser) + return dict( + version=m2r2.__version__, + parallel_read_safe=True, + parallel_write_safe=True, + ) -# https://www.sphinx-doc.org/en/1.5/ext/example_google.html # Include paths for python code sys.path.insert(0, os.path.abspath(".")) @@ -95,44 +190,23 @@ html_static_path = ["_static"] """Patching m2r2""" -import m2r2 - current_m2r2_setup = m2r2.setup - -def patched_m2r2_setup(app): - - try: - return current_m2r2_setup(app) - except (AttributeError): - app.add_source_suffix(".md", "markdown") - app.add_source_parser(m2r2.M2RParser) - return dict( - version=m2r2.__version__, - parallel_read_safe=True, - parallel_write_safe=True, - ) - - +# m2r2.setup = patched_m2r2_setup # Generate some custom documentations for this version of binarycpython and binary_c -from binarycpython.utils.functions import ( - write_binary_c_parameter_descriptions_to_rst_file, -) -from binarycpython.utils.grid_options_defaults import write_grid_options_to_rst_file +docs_pop = Population() print("Generating binary_c_parameters.rst") write_binary_c_parameter_descriptions_to_rst_file("binary_c_parameters.rst") print("Done") print("Generating grid_options_descriptions.rst") -write_grid_options_to_rst_file("grid_options_descriptions.rst") +docs_pop.write_grid_options_to_rst_file("grid_options_descriptions.rst") print("Done") # Generate a custom footer -from functions import write_custom_footer - print("Generating custom footer") write_custom_footer() print("Done") diff --git a/docs/source/dicts.rst b/docs/source/dicts.rst new file mode 100644 index 0000000000000000000000000000000000000000..a2b4ae43db8ec6245001db353c6892239b7acad9 --- /dev/null +++ b/docs/source/dicts.rst @@ -0,0 +1,7 @@ +dicts module +============ + +.. automodule:: binarycpython.utils.dicts + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/distribution_functions.rst b/docs/source/distribution_functions.rst deleted file mode 100644 index 5881ee38299d5af76771ac7312abd140886f99d1..0000000000000000000000000000000000000000 --- a/docs/source/distribution_functions.rst +++ /dev/null @@ -1,7 +0,0 @@ -distribution_functions module -================================= - -.. automodule:: binarycpython.utils.distribution_functions - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/source/ensemble.rst b/docs/source/ensemble.rst new file mode 100644 index 0000000000000000000000000000000000000000..a213b22ad1c788fb273ee09fb5958794e298a97a --- /dev/null +++ b/docs/source/ensemble.rst @@ -0,0 +1,7 @@ +ensemble module +=============== + +.. automodule:: binarycpython.utils.ensemble + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/example_notebooks.rst b/docs/source/example_notebooks.rst index c4e9e34c484b4484c61d959aa33e90cd8c9fe578..bb73b3d6fdca311d8d60ba5aa8159fb55b44bb0d 100644 --- a/docs/source/example_notebooks.rst +++ b/docs/source/example_notebooks.rst @@ -13,6 +13,7 @@ The order of the notebooks below is more or less the recommended order to read. examples/notebook_population.ipynb examples/notebook_extra_features.ipynb examples/notebook_api_functionality.ipynb + examples/notebook_ensembles.ipynb examples/notebook_luminosity_function_single.ipynb examples/notebook_luminosity_function_binaries.ipynb diff --git a/docs/source/examples/notebook_api_functionality.ipynb b/docs/source/examples/notebook_api_functionality.ipynb index 504ae4b16880946428716c496c81cbf82eea63a8..49d6f8d3db7beacc8770e2b86b21b4636bbf8e7a 100644 --- a/docs/source/examples/notebook_api_functionality.ipynb +++ b/docs/source/examples/notebook_api_functionality.ipynb @@ -105,7 +105,7 @@ " Function that contains random snippets. Do not expect this to remain available, or reliable. i.e. dont use it.\n", "\n", "FILE\n", - " /home/izzard/.local/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so\n", + " /home/david/.pyenv/versions/binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so\n", "\n", "\n" ] @@ -166,7 +166,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "<capsule object \"STORE\" at 0x146f912dbc60>\n", + "<capsule object \"STORE\" at 0x7fc1f0c3ff00>\n", "SINGLE_STAR_LIFETIME 10 28.4838\n", "\n" ] @@ -270,586 +270,13 @@ "M_2 : The initial mass of star two (in solar units, internally this is star index 1). : (null)\n", "M_3 : The initial mass of star three (in solar units, internally this is star index 2). : (null)\n", "M_4 : The initial mass of star four (in solar units, internally this is star index 3). : (null)\n", - "vrot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot2,3,4. : (null)\n", - "vrot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,3,4. : (null)\n", - "vrot3 : The initial equatorial rotational velocity of star three (in km/s, internally this is star index 2). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,4. : (null)\n", - "vrot4 : The initial equatorial rotational velocity of star four (in km/s, internally this is star index 3). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,3. : (null)\n", - "Prot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). See also Prot2,3,4. : (null)\n", - "Prot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). See also Prot1,3,4. : (null)\n", - "Prot3 : The initial equatorial rotational period of star three (in days, internally this is star index 2). See also Prot1,2,4. : (null)\n", - "Prot4 : The initial equatorial rotational period of star four (in days, internally this is star index 3). See also Prot1,2,3. : (null)\n", - "inclination1 : The initial inclination of star one (in degrees). : (null)\n", - "inclination2 : The initial inclination of star two (in degrees). : (null)\n", - "inclination3 : The initial inclination of star three (in degrees). : (null)\n", - "inclination4 : The initial inclination of star four (in degrees). : (null)\n", - "B_1 : The initial magnetic field of star one (in Gauss, internally this is star index 0). : (null)\n", - "B_2 : The initial magnetic field of star two (in Gauss, internally this is star index 1). : (null)\n", - "B_3 : The initial magnetic field of star three (in Gauss, internally this is star index 2). : (null)\n", - "B_4 : The initial magnetic field of star four (in Gauss, internally this is star index 3). : (null)\n", - "B_inclination1 : The initial inclination of the magnetic field of star one (in degrees). : (null)\n", - "B_inclination2 : The initial inclination of the magnetic field of star two (in degrees). : (null)\n", - "B_inclination3 : The initial inclination of the magnetic field of star three (in degrees). : (null)\n", - "B_inclination4 : The initial inclination of the magnetic field of star four (in degrees). : (null)\n", - "stellar_type_1 : Set the stellar type of star 1 (internal index 0), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_2 : Set the stellar type of star 2 (internal index 1), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_3 : Set the stellar type of star 3 (internal index 2), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_4 : Set the stellar type of star 4 (internal index 3), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "max_stellar_type_1 : The maximum stellar type of star 1 (internal index 0). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value. \n", - " : (null)\n", - "max_stellar_type_2 : The maximum stellar type of star 2 (internal index 1). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "max_stellar_type_3 : The maximum stellar type of star 3 (internal index 2). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "max_stellar_type_4 : The maximum stellar type of star 4 (internal index 3). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "probability : The probability is a weighting applied to the star based on, say, the initial mass function. When running a grid of stars to simulate *all* stars, the summed probability of all the stars should be 1.0. : (null)\n", - "phasevol : The system's phase volume, used by binary_grid. : (null)\n", - "stellar_structure_algorithm : Set the stellar structure algorithm. 0=modified BSE (default), 1=none, 2=external function (must be defined by the calling code), 3=binary_c (not yet implemented). : (null)\n", - "solver : The type of solver. Default is the Forward-Euler (0), but could be RK2 (1), RK4 (2) or a predictor-corretor (3). : (null)\n", - "max_evolution_time : Set the maximum age for the stars (Myr). : (null)\n", - "max_model_number : Set the maximum number of models, ignored if 0 (default is 0). : (null)\n", - "monte_carlo_kicks : Turn on Monte-Carlo SN kicks. On (True) by default, and indeed other algorithms are probably broken. : (null)\n", - "disable_debug : Disables debug output. Only has an effect when DEBUG is 1, which probably requires a rebuild. Default FALSE. : (null)\n", - "timestep_logging : Turn on timestep logging (default is False). : (null)\n", - "rejects_in_log : Show timestep rejections in the main log (default is False). : (null)\n", - "vandenHeuvel_logging : Turn on van den Heuvel logging (default is False). : (null)\n", - "evolution_splitting : If True, turn on splitting of an evolutionary run if splitpoint (e.g. supernova) occurs. : (null)\n", - "disable_events : Whether to disable the new events code (defaults to False, so we use events by default)\n", - " : (null)\n", - "evolution_splitting_sn_eccentricity_threshold : Threshold eccentricity above which evolution splitting happens in a system with no SN kick. (0.01) : (null)\n", - "evolution_splitting_sn_n : Number of runs to split into when a SN occurs. : (null)\n", - "evolution_splitting_maxdepth : Max number of splits in an evolutionary run. : (null)\n", - "equation_of_state_algorithm : Set the equation of state algorithm. 0 = Paczynski. : (null)\n", - "opacity_algorithm : Set the opacity algorithm. 0 = Paczynski, 1 = Ferguson/Opal. : (null)\n", - "wind_mass_loss : Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018). : 0\n", - "gbwind : Wind prescription for first red giant branch stars. 0=Reimers (Hurley et al 2000/2002; choose gb_reimers_eta=0.5 for their mass loss rate), 1=Schroeder+Cuntz 2005 (set gb_reimers_eta=1.0 for their mass loss rate). : (null)\n", - "postagbwind : Apply special post-(A)GB prescription. Default is POSTAGB_WIND_USE_GIANT which means we just use whatever is prescribed on the giant branch. Other options include: POSTAGB_WIND_NONE = 1 (no wind on the post (A)GB), POSTAGB_WIND_KRTICKA2020 = 2 which uses Krticka, Kubát and Krticková (2020, A&A 635, A173). : (null)\n", - "Teff_postAGB_min : The minimum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_max. (6000 K) : (null)\n", - "Teff_postAGB_max : The maximum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_min. (120000 K) : (null)\n", - "mattsson_Orich_tpagbwind : Experimental : turns on Mattsson's TPAGB wind when the star is oxygen rich. Requires MATTSSON_MASS_LOSS. : (null)\n", - "magnetic_braking_factor : Multiplier for the magnetic braking angular momentum loss rate. : (null)\n", - "magnetic_braking_gamma : gamma factor in Rappaport style magnetic braking expression. : (null)\n", - "magnetic_braking_algorithm : Algorithm for the magnetic braking angular momentum loss rate. 0 = Hurley et al. 2002, 1 = Andronov, Pinnsonneault and Sills 2003, 2 = Barnes and Kim 2010 : (null)\n", - "helium_flash_mass_loss : Mass to be lost at the helium flash. : (null)\n", - "gb_reimers_eta : First red giant branch wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) : (null)\n", - "gbwindfac : Multiplier for the giant branch wind mass loss rate : (null)\n", - "tpagbwindfac : Multiplier for the TPAGB wind mass loss rate : (null)\n", - "eagbwindfac : Multiplier for the EAGB wind mass loss rate : (null)\n", - "nieuwenhuijzen_windfac : Multiplier for the Nieuwenhuijzen & de Jager wind mass loss rate : (null)\n", - "tpagbwind : Wind prescription during the TPAGB. 0=Karakas 2002 (a modified Vassiliadis and Wood 1993), 1=Hurley et al 2000/2002 (Vassiliadis and Wood 1993), 2=Reimers, 3=Bloecker, 4=Van Loon, 5=Rob's C-wind (broken?), 6,7=Vassiliadis and Wood 1993 (Karakas,Hurley variants respectively) when C/O>1, 8=Mattsson, 9 = Goldman et al. (2017), 10 = Beasor et al. (2020). : (null)\n", - "eagbwind : Wind prescription during the EAGB. 0=BSE (Hurley+2002, based on VW93), 1 = Goldman et al. (2017), 2 = Beasor et al. (2020). : (null)\n", - "wind_gas_to_dust_ratio : Gas to dust ratio used in wind calculations (e.g. Goldman et al. 2017). Typically 200 (Milky Way)-500 (Magellanic Clouds). Default is 200, approximately as in MW stars. : (null)\n", - "vwind_multiplier : Multiplier for the stellar wind velocity. : (null)\n", - "vwind_beta : Beta for stellar wind speed calculations, where vwind=sqrt(beta) * escape velocity. Default 0.125 (from BSE, Hurley et al. 2002). : (null)\n", - "superwind_mira_switchon : In the Vassiliadis and Wood (1993) AGB wind prescription, the superwind is turned on at a given Mira period, usually 500 days. You can vary when this switch-on happens with this parameter. : (null)\n", - "vw93_mira_shift : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate depends on the Mira period plus this offset. Requires VW93_MIRA_SHIFT. : (null)\n", - "vw93_multiplier : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate is multiplied by this factor. Requires VW93_MULTIPLIER. : (null)\n", - "tpagb_reimers_eta : TPAGB Reimers wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) Note that Reimers is not the default TPAGB wind prescription. See also tpagbwind. : (null)\n", - "Tout_Pringle_1992_multiplier : Multiplier for the Tout & Pringle (1992) magnetic wind. (0.0) : (null)\n", - "artificial_mass_accretion_rate%d : Constant mass accretion rate for star <n>. : (null)\n", - "artificial_mass_accretion_rate_by_stellar_type%d : Constant mass accretion rate for stellar type <n>. : (null)\n", - "artificial_angular_momentum_accretion_rate%d : Constant angular momentum accretion for star <n>. : (null)\n", - "artificial_orbital_angular_momentum_accretion_rate : Constant angular momentum accretion rate on the orbit. : (null)\n", - "artificial_accretion_start_time : Time at which artificial accretion stars. Ignored if <0 (default is -1). : (null)\n", - "artificial_accretion_end_time : Time at which artificial accretion ends. Ignored if <0 (default is -1). : (null)\n", - "wr_wind : Massive-star (WR) wind prescription. 0 = Hurley et al 2000/2002, 1=Maeder and Meynet, 2=Nugis and Lamers, 3=John Eldridge's version of Vink's early-2000s wind (See Lynnette Dray's thesis, or John Eldridge's thesis) : (null)\n", - "wr_wind_fac : Massive-star (WR) wind multiplication factor. : (null)\n", - "wrwindfac : Massive-star (WR) wind multiplication factor. Synonymous with wr_wind_fac (which you should use instead). : (null)\n", - "BH_prescription : Black hole mass prescrition: relates the mass of a newly formed black hole to its progenitor's (CO) core mass. BH_HURLEY2002 = 0 = Hurley et al 2000/2002, BH_BELCZYNSKI = 1 = Belczynski (early 2000s), BH_SPERA2015 = Spera+ 2015, BH_FRYER12_DELAYED = 3 = Fryer et al. (2012) delayed prescription, BH_FRYER12_RAPID = 4 = Fryer et al. (2012) rapid prescription, BH_FRYER12_STARTRACK = 5 = Fryer et al. (2012) startrack prescription. : (null)\n", - "sn_kick_distribution_II : Set the distribution of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_ECAP : Set the distribution of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_NS_NS : Set the distribution of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IBC : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_GRB_COLLAPSAR : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_TZ : Set the distribution of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_AIC_BH : Set the distribution of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_BH_BH : Set the distribution of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_BH_NS : Set the distribution of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD : Set the distribution of speeds applied to any survivor of a hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD_subluminous : Set the distribution of speeds applied to any survivor of a subluminous hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_II : Set the dispersion of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_ECAP : Set the dispersion of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_NS_NS : Set the dispersion of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IBC : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_GRB_COLLAPSAR : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_TZ : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_AIC_BH : Set the dispersion of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_BH_BH : Set the dispersion of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_BH_NS : Set the dispersion of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD : Set the dispersion of speeds applied to the survivor of a SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD_subluminous : Set the dispersion of speeds applied to the survivor of a subluminous SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_companion_IA_He : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia He supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_ELD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia ELD (sub-Mch) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_CHAND : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_AIC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an accretion induced collapse (supernova) occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_ECAP : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an electron capture supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_He_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia helium merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_CHAND_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_NS_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron-star neutron-star merger. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_GRB_COLLAPSAR : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a GRB Collapsar (rapidly rotating SN Ibc) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_HeStarIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a He-star Ia supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IBC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type Ib/c supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_II : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type II supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type IIa supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_WDKICK : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a WD is kicked. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_TZ : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Thorne-Zytkow object is formed. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_AIC_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron star collapses to a black hole. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_BH_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when two black holes merge. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_BH_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a black hole merges with a neutron star. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_Hybrid_HeCOWD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_Hybrid_HeCOWD_subluminous : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a subluminous hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "wd_sigma : Set the speed at which white dwarfs are kicked when they form, in km/s. Default is zero (i.e. no kick). Requires WD_KICKS. : (null)\n", - "wd_kick_direction : Set the direction of white dwarf kicks. 0 = random, 1 = up, 2 = forward, 3 = backward, 4 = inward, 5 = outward. Requires WD_KICKS. : (null)\n", - "wd_kick_when : Decide when to kick a white dwarf. 0=at birth, 1=at first RLOF, 2=at given pulse number (see wd_kick_pulse_number), 3 at every pulse Requires WD_KICKS. : (null)\n", - "wd_kick_pulse_number : Apply a kick to a star at a desired pulse number on the TPAGB (i.e. pre-WD). Requires WD_KICKS. : (null)\n", - "minimum_helium_ignition_core_mass : Minimum helium core mass required to ignite helium in the case that the hydrogen envelope is stripped on the giant branch, e.g. to make an sdB or sdO star. Typically 0.4, if 0.0 then the BSE algorithm (based on the total mass) is used. : (null)\n", - "minimum_CO_core_mass_for_carbon_ignition : Minimum CO core mass for carbon ignition, assuming Mc,bagb>1.6Msun. Typically around 1.08Msun (Pols+1998). : (null)\n", - "minimum_CO_core_mass_for_neon_ignition : Minimum CO core mass for neon ignition. Typically around 1.42Msun. Stars that have cores that ignite carbon, but not neon explode in electon-capture supernovae. : (null)\n", - "minimum_mcbagb_for_nondegenerate_carbon_ignition : Minimum Mc,bagb (core mass at the base of the AGB) for non-degenerate carbon ignition. Typically around 2.25Msun (Pols+1998). : (null)\n", - "maximum_mcbagb_for_degenerate_carbon_ignition : Maximum Mc,bagb (core mass at the base of the AGB) for degenerate carbon ignition. Typically around 1.6Msun (Pols+1998). : (null)\n", - "max_neutron_star_mass : Maximum mass of a neutron star before it collapses to a black hole. Typically around 2Msun. : (null)\n", - "chandrasekhar_mass : The Chandrasekhar mass, usually 1.44Msun : (null)\n", - "delta_mcmin : A parameter to reduce the minimum core mass for third dredge up to occur on the TPAGB. As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null)\n", - "lambda_min : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. See also lambda_multiplier. : (null)\n", - "lambda_multiplier : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null)\n", - "minimum_envelope_mass_for_third_dredgeup : The minimum envelope mass for third dredge up on the TPAGB. Early, solar metallicity models by Straniero et al suggested 0.5Msun is typical. However, circumstantial evidence (Izzard et al 2009) as well as newer models by Stancliffe and Karakas suggest that at low metallicity a value nearer zero is more appropriate. : (null)\n", - "mass_of_pmz : The mass in the partial mixing zone of a TPAGB star, using the Karakas 2012 tables. Ask Carlo Abate for more details, or see the series of papers Abate et al 2012, 2013, 2014. Requires NUCSYN and USE_TABULAR_INTERSHELL_ABUNDANCES_KARAKAS_2012. : (null)\n", - "c13_eff : The \"efficiency\" of partial mixing in a TPAGB star intershell region, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null)\n", - "mc13_pocket_multiplier : Multiplies the mass in the partial mixing zone of a TPAGB star, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null)\n", - "tides_convective_damping : Tidal convective damping algorithm. 0=TIDES_HURLEY2002 Zahn 197x timescales + Hut, as in Hurley et al (2002), 1 = TIDES_ZAHN1989 : Zahn 1989 lambdas + Hut. : (null)\n", - "E2_prescription : Choose how to calculate the E2 structural parameter (used in tidal timescale calculations). 0=Hurley 1=Izzard (see Siess et al 2013). : (null)\n", - "dtfac : A parameter to decrease the timestep ONLY during the TPAGB phase. : (null)\n", - "hbbtfac : A parameter to modulate the temperature at the base of the hot-bottom burning zone in TPAGB stars. (Works only if NUCSYN is defined) : (null)\n", - "wind_multiplier_%d : Wind multiplier for the stellar type specified by the intger %d. By default these are all 1.0. : (null)\n", - "wind_type_multiplier_%d : Wind multiplier for different types of wind (MS, GB, AGB, WR, LBV, OTHER), given by the integer %d. By default these are all 1.0. : (null)\n", - "pre_main_sequence : Set to True to turn on pre-main sequence evolution. Currently this is not a special stellar type, rather the first (small) fraction of the main sequence has increased radii to match the Railton et al 2014 fits to Tout's pre-main sequence stars. Requires PRE_MAIN_SEQUENCE. See also pre_main_sequence_fit_lobes. : (null)\n", - "pre_main_sequence_fit_lobes : Set to True force a pre-main sequence star into its Roche lobe. This is done by artificially aging it. Requires PRE_MAIN_SEQUENCE : (null)\n", - "small_envelope_method : Choose the method used to determine the stellar radius when the envelope mass is very thin. 0 = Hurley et al. (2002), 1 = Miller Bertolami et al. (2016+) for GB and AGB stars only. : (null)\n", - "timestep_modulator : Multiplier applied to the global timestep. Requires TIMESTEP_MODULATION. : (null)\n", - "timestep_multiplier%d : Multiplier applied to timestep limit <n>. : (null)\n", - "maximum_timestep : The maximum timestep (MYr). : (null)\n", - "zoomfac_multiplier_decrease : When a timestep is rejected, decrease the timestep by this factor (0.5). : (null)\n", - "zoomfac_multiplier_increase : When a timestep is rejected, zooms, then succeeds, increase the timestep by this factor (1.2). : (null)\n", - "maximum_timestep_factor : The maximum factor between two subsequent timesteps (1.2). : (null)\n", - "maximum_nuclear_burning_timestep : The maximum timestep (MYr) in any nuclear burning phase. : (null)\n", - "nova_retention_method : Algorithm used to calculate the amount of mass retained during a nova explosion. 0=use nova_retention_fraction. (other methods pending) : (null)\n", - "MINT_metallicity : This sets the metallicity for MINT. It is ignored if set to -1.0, the default, in which case the normal metallicity parameter is used. : (null)\n", - "gaia_Teff_binwidth : log10(Effective temperature) bin width used to make Gaia-like HRDs\n", - " : (null)\n", - "gaia_L_binwidth : log10(luminosity) bin width used to make Gaia-like HRDs\n", - " : (null)\n", - "gaia_colour_transform_method : Use this to select the method used to transform to Gaia colours from other colour schemes. GAIA_CONVERSION_UBVRI_UNIVARIATE_JORDI2010 = 0 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_UBVRI_BIVARIATE_JORDI2010 = 1 Jordi et al.'s bivariate UBVRI fits, GAIA_CONVERSION_ugriz_UNIVARIATE_JORDI2010 = 2 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_ugriz_BIVARIATE_JORDI2010 = 3 Jordi et al.'s univariate ugriv fits, GAIA_CONVERSION_UBVRI_UNIVARIATE_EVANS2018 = 4 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_ugriz_UNIVARIATE_EVANS2018 = 5 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_UBVRI_RIELLO2020 = 6 Riello et al. (2020, DR3) fits, GAIA_CONVERSION_ugriz_RIELLO2020 = 7 Riello et al. (2020, DR3) fits. : (null)\n", - "rotationally_enhanced_mass_loss : Set to 1 to enable rotationally enhanced mass loss rate algorithms: 0= none, 1=formula cf. Langer models (=ROTATIONALLY_ENHANCED_MASSLOSS_LANGER_FORMULA), 2=limit accretion rate before wind loss is applied, 3 = both 1 and 2. See also rotationally_enhanced_exponent : (null)\n", - "AGB_core_algorithm : Algorithm to use for calculating AGB core masses. 0=Hurley et al. 2002 if no NUCSYN, Karakas 2002 if NUCSYN is defined; 1=Hurley et al. 2002 (overshooting models); 1=Karakas 2002 (non-overshooting models). : (null)\n", - "AGB_radius_algorithm : Algorithm to use for calculating radii on the TPAGB. : (null)\n", - "AGB_luminosity_algorithm : Algorithm to use for calculating luminosities on the TPAGB. : (null)\n", - "AGB_3dup_algorithm : Algorithm to use for calculating third dredge up efficiency on the TPAGB. : (null)\n", - "overspin_algorithm : Algorithm to determine what we do when a star is rotating at its breakup velocity. OVERSPIN_BSE (0) conservatively transfers the angular momentum back to the orbit. OVERSPIN_MASSLOSS uses the rotationally_enhanced_massloss parameter to lose mass which carries away the angular momentum. : (null)\n", - "rotationally_enhanced_exponent : The exponent (power) by which rotationally enhanced mass loss is raised. Requires ROTATIONALLY_ENHANCED_MASS_LOSS. See also rotationally_enhanced_mass_loss. : (null)\n", - "batchmode : Set the batchmode control variable. Use only if you know what you are doing! : (null)\n", - "speedtests : If True, turns on speedtests during version information (off by default). : (null)\n", - "use_fixed_timestep_%d : Set to True to use fixed timestep <n>, False to turn off. Fixed timesteps are on (this is True) by default. : (null)\n", - "task%d : Control tasks to be performed by binary_c. By default, these are all TRUE. For more information see binary_c_macros.h, particularly the BINARY_C_TASK_* macros. : (null)\n", - "orbiting_object : Usage: --orbiting_object mass,spinrate,central_object,period. : 1.0\n", - "orbiting_objects_log : If True, turn on orbiting-object log. : (null)\n", - "orbiting_objects_log : If True, turn on orbiting-object log. : (null)\n", - "orbiting_objects_wind_accretion_multiplier : Multiplier for wind accretion on orbiting objects. Hurley et al 2002 use 1.5, which is the default. : (null)\n", - "orbiting_objects_close_pc_threshold : How close are orbiting objects allowed to be? Set this to be the absolute percentage difference minimum. : (null)\n", - "orbiting_objects_tides_multiplier : Multiplier for tidal torques on orbiting objects. : (null)\n", - "evaporate_escaped_orbiting_objects : If True, evaporate orbiting objects that have escaped the system. : (null)\n", - "RLOF_transition_objects_escape : If True, objects that escape their Roche lobe are ejected from the system, otherwise they are placed just outside the minimum stable orbit. : (null)\n", - "PN_resolve : If True, the timestep will be shortened to resolve better the PN phase (FALSE). : (null)\n", - "PN_resolve_minimum_luminosity : The luminosity above which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_resolve_maximum_envelope_mass : The envelope mass below which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_resolve_minimum_effective_temperature : The minimum effective temperature above which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_fast_wind : If True, thin-envelope PNe will have fast winds (FALSE). : (null)\n", - "PN_fast_wind_dm_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null)\n", - "PN_fast_wind_mdot_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null)\n", - "PN_fast_wind_dm_AGB : The envelope mass below which fast wind used during the AGB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null)\n", - "PN_fast_wind_mdot_AGB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null)\n", - "HeWD_HeWD_ignition_mass : HeWD-HeWD mergers above this mass reignite helium. (0.3) : (null)\n", - "wind_Nieuwenhuijzen_luminosity_lower_limit : Above this luminosity we activate the Nieuwenhuijzen and de Jager wind (4e3 Lsun). : (null)\n", - "wind_LBV_luminosity_lower_limit : Above this luminosity we activate the LBV wind (6e5 Lsun). : (null)\n", - "colour%d : Sets colour %d (0 to NUM_ANSI_COLOURS-1) to the extended ANSI set colour you choose (1-255, 0 means ignore). The colour numbers are defined in src/logging/ansi_colours.h : (null)\n", - "apply_Darwin_Radau_correction : Apply Darwin-Radau correction to the moment of inertia to take rotation into account? : (null)\n", - "degenerate_core_merger_nucsyn : If TRUE, assume that in a degnerate core merger, energy is generated from nucleosynthesis of the whole core, and that this can disrupt the core. The BSE algorithm (Hurley et al. 2002) assumes this to be TRUE, but binary_c assumes FALSE by default. (FALSE) : (null)\n", - "degenerate_core_helium_merger_ignition : If TRUE, assume that when there is a degenerate helium core merger, the star reignites helium. This is required to make R-type carbon stars. (TRUE) : (null)\n", - "degenerate_core_merger_dredgeup_fraction : If non-zero, mix this fraction of the degenerate core during a merger.(0.0). : (null)\n", - "\n", - "############################################################\n", - "##### Section Binary\n", - "############################################################\n", - "separation : Set the orbital separation (actually the semi-major axis) of the binary (internal index 0, stellar indices 0 and 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "separation_triple : Set the orbital separation (actually the semi-major axis) of the triple (internal index 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "separation_quadruple : Set the orbital separation (actually the semi-major axis) of the quadruple (internal index 2) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "orbital_period : Set the initial orbital period of the binary, stars 1 and 2 (internal indices 0 and 1) in days. See also separation. : (null)\n", - "orbital_period_triple : Set the initial orbital period of the triple in days. See also separation. : (null)\n", - "orbital_period_quadruple : Set the orbital period of the outer binary in a quadrulple (stars 3 and 4, internal indices 2 and 3) in days. See also separation. : (null)\n", - "eccentricity : Set the initial eccentricity of the binary orbit (stars 1 and 2, internal indices 0 and 1). : (null)\n", - "eccentricity_triple : Set the initial eccentricity of the triple orbit. : (null)\n", - "eccentricity_quadruple : Set the initial eccentricity of the outer binary of a quadruple (stars 3 and 4, internal indices 2 and 3). : (null)\n", - "incliniation : Set the initial orbital_inclination of the binary relative to zero. : (null)\n", - "incliniation_triple : Set the initial orbital_inclination of the triple orbit relative to zero. : (null)\n", - "incliniation_quadruple : Set the initial orbital_inclinationy of the quadruple orbit relative to zero. : (null)\n", - "orbital_phase : Set the initial orbital phase of the binary orbit. : (null)\n", - "orbital_phase_triple : Set the initial orbital phase of the triple orbit. : (null)\n", - "orbital_phase_quadruple : Set the initial orbital phase of the quadruple orbit. : (null)\n", - "argument_of_periastron : Set the initial argument of periastron of the binary orbit. : (null)\n", - "argument_of_periastron_triple : Set the initial argument of periastron of the triple orbit. : (null)\n", - "argument_of_periastron_quadruple : Set the initial argument of periastron of the quadruple orbit. : (null)\n", - "disc_timestep_factor : Factor that multiplies the natural timestep of a disc. : (null)\n", - "white_dwarf_cooling_model : White dwarf cooling model, relates age to luminosity. WHITE_DWARF_COOLING_MESTEL = 0 is Mestel's model, WHITE_DWARF_COOLING_MESTEL_MODIFIED = 1 is Hurley's modified Mestel model, WHITE_DWARF_COOLING_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null)\n", - "white_dwarf_radius_model : White dwarf radius model, radius to mass (and perhaps age). WHITE_DWARF_RADIUS_NAUENBERG1972 = 0 Nauenberg (1972), WHITE_DWARF_RADIUS_MU = 1 mu-dependent variant, WHITE_DWARF_RADIUS_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null)\n", - "cbdisc_mass_loss_inner_viscous_accretion_method : Chooses where the mass that is accreted from the inner edge of a circumbinary disc goes, i.e. to which star. 0 = Young and Clarke 2015, 1 = Gerosa et al 2015, 2 = 50:50 (i.e. not dependence on mass). : (null)\n", - "cbdisc_inner_edge_stripping : If True, allow inner edge mass stripping. : (null)\n", - "cbdisc_end_evolution_after_disc : If True, stop evolution when a disc evaporates. : (null)\n", - "cbdisc_no_wind_if_cbdisc : If True, disable stellar winds when there is a circumbinary disc. : (null)\n", - "cbdisc_outer_edge_stripping : If True, allow outer edge mass stripping. : (null)\n", - "disc_n_monte_carlo_guesses : Number of monte carlo guesses to try in the disc solver if the normal list of guesses fails (0). : (null)\n", - "disc_log : If 1, turn on the disc log. Requires DISC_LOG to be defined on build. : (null)\n", - "disc_log2d : If 1, turn on the 2d disc log. Requires DISC_LOG to be defined on build. : (null)\n", - "disc_log_dt : If non-zero, only allows disc log output every disc_log_dt Myr. : (null)\n", - "disc_log_directory : Directory into which disc logging is sent (must exist!). : /tmp/\n", - "post_ce_adaptive_menv : If TRUE, and if post_ce_objects_have_envelopes is TRUE, then the envelope mass of a post-CE star is such that it sits just inside its Roche lobe. If FALSE then a fixed (thin) envelope mass is applied that depends on the stellar type (see macros POST_CE_ENVELOPE_DM_GB, POST_CE_ENVELOPE_DM_EAGB and POST_CE_ENVELOPE_DM_TPAGB). : (null)\n", - "post_ce_objects_have_envelopes : If TRUE then post-common-envelope objects have thin envelopes. You need this if you are to have post-CE post-AGB stars. Note that this *may* be unstable, i.e. you may end up having many CEEs. The mass in the envelope is controlled by post_ce_adaptive_menv. TRUE by default. : (null)\n", - "PN_comenv_transition_time : post-common envelope transition time in years (1e2). This is the time taken to move from CEE ejection to Teff > 30e4 K. Hall et al. (2013) suggest ~100 years. : (null)\n", - "minimum_time_between_PNe : The minimum time (Myr) between planetary nebula detections. This prevents multiple, fast common envelopes triggering two PNe (0.1). : (null)\n", - "PN_Hall_fading_time_algorithm : In stars with low mass (<0.45Msun) cores, you can choose to set the PN fading time to either the minimum (PN_HALL_FADING_TIME_ALGORITHM_MINIMUM) or maximum (PN_HALL_FADING_TIME_ALGORITHM_MAXIMUM) as shown in Fig. 6 of Hall et al. (2013). : (null)\n", - "PPN_envelope_mass : Desired pre-planetary nebula (post-AGB) envelope mass. : (null)\n", - "cbdisc_eccentricity_pumping_method : Select from various eccentricity-pumping methods when there is a circumbinary disc. Requires DISCS. 0 = off. : (null)\n", - "cbdisc_viscous_photoevaporative_coupling : Set to 1 to turn on viscous-photoevaporative coupling in circumbinary discs. Requires DISCS. 0 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_NONE = off, 1 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_INSTANT instant, 2 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_VISCOUS slow, viscous wind. : (null)\n", - "cbdisc_inner_edge_stripping_timescale : Defines the timescale for mass loss from by inner edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_in. : (null)\n", - "cbdisc_outer_edge_stripping_timescale : Defines the timescale for mass loss from by outer edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_out. : (null)\n", - "cbdisc_viscous_L2_coupling : Set to 1 to turn on viscous-L2-loss coupling in circumbinary discs. Requires DISCS. 0 = off. : (null)\n", - "gravitational_radiation_model : Model for gravitational radiation from the system. 0=Hurley et al 2002 (Landau and Lifshitz 1951). 1 = as 0 but only when there is no RLOF. 2 = none. : (null)\n", - "nova_irradiation_multiplier : Multiplier for nova-radiative induced mass loss. (Shara+1986) : (null)\n", - "gravitational_radiation_modulator_J : Modulator for gravitational wave radiation angular momentum loss rate (1.0). : (null)\n", - "gravitational_radiation_modulator_e : Modulator for gravitational wave radiation eccentricity pumping rate (1.0). : (null)\n", - "nova_faml_multiplier : Nova friction-induced angular momentum loss multiplier. (Shara+1986) : (null)\n", - "RLOF_angular_momentum_transfer_model : Choose angular momentum transfer model in RLOF. 0=BSE (with discs), 1=conservative : (null)\n", - "post_SN_orbit_method : Method by which the post-SN orbit is calculated. 0=BSE, 1=Tauris&Taken 1998. : (null)\n", - "multiplicity : Multiplicity: 1=single star, 2=binary, 3=triple, 4=quadruple. : (null)\n", - "accretion_limit_eddington_steady_multiplier : Steady accretion is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_steady_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_eddington_LMMS_multiplier : Accretion from a low-mass, convective, main_sequence star is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_LMMS_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_eddington_WD_to_remnant_multiplier : Accretion from a WD onto a remnant star (e.g. another white dwarf, neutron star or black hole) is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_WD_to_remnant_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_thermal_multiplier : Mass transfer onto a MS, HG or CHeB star is limited by the accretor's thermal rate times this multiplier. : (null)\n", - "accretion_limit_dynamical_multiplier : Mass transfer is limited by the accretor's dynamical rate times this multiplier. : (null)\n", - "donor_limit_envelope_multiplier : Mass transfer by RLOF is limited by this fraction of the donor's envelope mass per timestep : (null)\n", - "donor_limit_thermal_multiplier : Mass transfer by RLOF is limited by the accretor's thermal rate times this multiplier. : (null)\n", - "donor_limit_dynamical_multiplier : Mass transfer by RLOF is limited by the donor's dynamical rate times this multiplier. : (null)\n", - "Bondi_Hoyle_accretion_factor : Wind accretion rate, as calculated by the Bondi-Hoyle-Littleton formula, multiplcation factor. Hurley et al 2002 use 1.5, which is the default. : (null)\n", - "tidal_strength_factor : A modulator for the tidal strength. If this factor > 1 then tides are stronger, i.e. tidal timescales are reduced. : (null)\n", - "hachisu_qcrit : Critical q=Maccretor/Mdonor above which Hachisu's disk wind turns on. : (null)\n", - "hachisu_disk_wind : Set to True to turn on Hachisu's disk wind when material accretes too fast onto a white dwarf. This helps to make more SNeIa. See also hachisu_qcrit. : (null)\n", - "mass_accretion_for_eld : The mass that must be accreted onto a COWD for it to ignite as an edge-lit detonation SNIa. : (null)\n", - "WDWD_merger_algorithm : Algorithm to be used when merging two white dwarfs. 0 = Hurley et al. (2002), 1 = Perets+ (2019), 2 = Chen+ (2016, todo) : (null)\n", - "type_Ia_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from Chandrasekhar-mass exploders. 0 = DD7 (Iwamoto 1999), 1 = Seitenzahl 2013 3D hydro yields (you must also set Seitenzahl2013_model) : (null)\n", - "Seitenzahl2013_model : Which of Seitenzahl et al. 2013's models to use? One of N1,N3,N5,N10,N20,N40,N100L,N100,N100H,N150,N200,N300C,N1600,N1600C,N100_Z0.5,N100_Z0.1,N100_Z0.01 (defaults to N100). : N1\n", - "type_Ia_sub_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from sub-Chandrasekhar-mass exploders. (Currently unused.) : (null)\n", - "max_HeWD_mass : The maximum mass a HeWD can have before it ignites helium (0.7). : (null)\n", - "merger_mass_loss_fraction : Fraction of the total mass which is lost when stars merge. : (null)\n", - "merger_angular_momentum_factor : When two stars merge the resulting single star retains a fraction of the total system angular momentum (or the critical spin angular momentum, if it is smaller) multiplied by this factor. : (null)\n", - "wind_angular_momentum_loss : Prescription for losing angular momentum in a stellar wind. 0=Hurley et al 2002 ('Tout') prescription, 1=lw i.e. a factor multiplying the specific orbital angular momentum, 2=lw hybrid for fast winds. Set wind_djorb_fac to the desired factor.. : (null)\n", - "wind_djorb_fac : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=0 (the Tout/Hurley et al 2002 prescription). See wind_angular_momentum_loss. : (null)\n", - "lw : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=1,2 (the 'lw' prescription). See wind_angular_momentum_loss. : (null)\n", - "VW93_EAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null)\n", - "VW93_TPAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null)\n", - "use_periastron_Roche_radius : Set this to True to use the Roche lobe radius at periastron, rather than (the default to) assume a circular orbit. This will be useful one day when we treat RLOF in eccentric orbits properly, hopefully. : (null)\n", - "qcrit_LMMS : Apply critical q=Mdonor/Maccretor value for low-mass main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_LMMS : Apply critical q=Mdonor/Maccretor value for (low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "mass_for_Hestar_Ia_upper : Only helium stars below this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_lower. : (null)\n", - "mass_for_Hestar_Ia_lower : Only helium stars above this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_upper. : (null)\n", - "alphaCB : Circumbinary disk viscosity parameter, alpha. : (null)\n", - "minimum_donor_menv_for_comenv : Minimum donor envelope mass for common envelope evolution to be triggered (Msun). Default 0. : (null)\n", - "comenv_prescription : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null)\n", - "comenv_prescription%d : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null)\n", - "comenv_ejection_spin_method : When a common envelope is ejected, we need to decide how fast the stars are left spinning. COMENV_EJECTION_SPIN_METHOD_DO_NOTHING (0) is the default, this just leaves the stars/stellar cores spinning with the same spin rate (omega = angular velocity) with which they entered the common envelope phase. COMENV_EJECTION_SPIN_METHOD_SYCHRONIZE instead tidally synchronizes the stars with their new orbital angular velocity. : (null)\n", - "comenv_merger_spin_method : When a common envelope binary merges, we need to decide how fast the resulting single star is left spinning. COMENV_MERGER_SPIN_METHOD_SPECIFIC (0) is the default, this preserves angular momentum but limits the specific angular momentum of the merged star to the specific angular momentum of the system at the onset of common envelope evolution. COMENV_MERGER_SPIN_METHOD_CONSERVE_ANGMOM (1) sets the merger's angular momentum to be that of the system at the onset of common envelope evolution (which means the star may be rotating supercritically). COMENV_MERGER_SPIN_METHOD_CONSERVE_OMEGA (2) sets the spin rate (angular frequency = omega) of the merged star to be that of the orbit just at the onset of common envelope evolution. : (null)\n", - "comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null)\n", - "comenv_ms_accretion_fraction : Experimental. During common envelope evolution, a main sequence may accrete a fraction of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_mass. : (null)\n", - "comenv_ns_accretion_mass : Experimental. During common envelope evolution, a neutron star may accrete some of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_fraction. : (null)\n", - "comenv_ns_accretion_fraction : Experimental. During common envelope evolution, a neutron star may accrete a fraction of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_mass. : (null)\n", - "alpha_ce : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null)\n", - "alpha_ce%d : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null)\n", - "lambda_ce : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to LAMBDA_CE_DEWI_TAURIS == -1 binary_c uses the Dewi and Tauris fits instead, LAMBDA_CE_WANG_2016 == -2 uses the formalism of Wang, Jia and Li (2016), if LAMBDA_CE_POLYTROPE == -3 then a polytropic formalism is used (see also comenv_splitmass) and if LAMBDA_CE_KLENCKI_2020 == -4 use Klencki et al. (2020). : (null)\n", - "lambda_ce%d : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to -1 binary_c uses the Dewi and Tauris fits instead, -2 uses the formalism of Wang, Jia and Li (2016) and if -3 then a polytropic formalism is used (see also comenv_splitmass). : (null)\n", - "comenv_splitmass : When lambda_ce=-2, the envelope binding energy, lambda, is calculated using a polytropic formalism. The comenv_splitmass defines the point, in the units of the core mass, above which material is ejected. : (null)\n", - "nelemans_recalc_eccentricity : If True, recalculate the eccentricity after angular momentum is removed. : (null)\n", - "comenv_post_eccentricity : Eccentricity remaining after common envelope ejection. : (null)\n", - "nelemans_gamma : Set the fraction of the orbital specific angular momentum that is used to eject the common envelope according to the Nelemans and Tout prescription. See also nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null)\n", - "nelemans_minq : Only activate the Nelemans and Tout common envelope prescription for q>nelemans_minq. See also nelemans_gamma, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null)\n", - "nelemans_max_frac_j_change : Maximum fractional angular momentum change in the Nelemans and Tout common envelope prescription. See also nelemans_gamma, nelemans_minq, nelemans_n_comenvs. : (null)\n", - "nelemans_n_comenvs : Set the maximum number of common envelope ejections allowed to follow the Nelemans and Tout prescription, after which the standard alpha prescription is used. : (null)\n", - "lambda_ionisation : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null)\n", - "lambda_ionisation%d : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null)\n", - "lambda_enthalpy : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null)\n", - "lambda_enthalpy%d : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null)\n", - "cbdisc_albedo : Circumbinary-disc albedo. Requires DISCS. : (null)\n", - "cbdisc_gamma : Circumbinary disc gamma (equation of state) parameter. Requires DISCS. : (null)\n", - "cbdisc_alpha : Circumbinary disc alpha (viscosity) parameter. Requires DISCS. : (null)\n", - "cbdisc_kappa : Circumbinary disc kappa (opacity) parameter. Requires DISCS. : (null)\n", - "cbdisc_minimum_evaporation_timescale : Circumbinary disc minimum evaporation timescale (years). If (slow, not edge stripped) mass loss would evaporate the disc on a timescale less than this, simply evaporate the disc immediated. Usually set to 1y, ignore if zero. Requires DISCS. : (null)\n", - "cbdisc_torquef : Circumbinary disc binary torque multiplier. Requires DISCS. : (null)\n", - "cbdisc_max_lifetime : Circumbinary disc maximum lifetime (years, ignored if 0). Requires DISCS. : (null)\n", - "cbdisc_init_dM : On cbdisc start, reduce mass by a fraction dM if it won't converge. Requires DISCS. : (null)\n", - "cbdisc_init_dJdM : On cbdisc start, reduce angular momentum by a fraction dJ/dM*dM if it won't converge. Requires DISCS. : (null)\n", - "cbdisc_mass_loss_constant_rate : Circumbinary disc constant mass loss rate (Msun/year). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_FUV_multiplier : Circumbinary disc FUV mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_Xray_multiplier : Circumbinary disc X-ray mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_ISM_ram_pressure_multiplier : Circumbinary disc interstellar medium ram pressure stripping mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_ISM_pressure : Circumbinary disc interstellar medium ram pressure in units of Boltzmann constant per Kelvin (I think...). Requires DISCS. Typically 3000.0. See e.g. http://www.astronomy.ohio-state.edu/~pogge/Ast871/Notes/Intro.pdf page 15 or https://arxiv.org/pdf/0902.0820.pdf Fig. 1 (left panel). : (null)\n", - "cbdisc_mass_loss_inner_viscous_multiplier : Circumbinary disc inner edge viscous mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_inner_viscous_angular_momentum_multiplier : Circumbinary disc inner edge viscous angular momentum multiplier (no units). The inner edge angular momentum Requires DISCS. : (null)\n", - "cbdisc_resonance_multiplier : Circumbinary disc resonant interaction multiplier, affects eccentricity pumping and angular momentum rates. Requires DISCS. : (null)\n", - "cbdisc_resonance_damping : Circumbinary disc resonant interaction damping: should be on (True) to damp the l=1, m=2 resonance when the disc inner edge lies outside the resonance location. Requires DISCS. : (null)\n", - "cbdisc_fail_ring_inside_separation : If True, while converging on a structure, circumbinary discs with Rring < the binary separation are immediately failed. : (null)\n", - "cbdisc_mass_loss_inner_L2_cross_multiplier : Circumbinary disc inner edge L2-crossing mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_minimum_luminosity : Circumbinary disc minimum luminosity. If the disc becomes dimmer than this, the disc is evaporated instantly. Requires DISCS. : (null)\n", - "cbdisc_minimum_mass : Circumbinary disc minimum mass. If the disc becomes less massive than this, the disc is evaporated instantly. Requires DISCS. : (null)\n", - "cbdisc_minimum_fRing : Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = |Rout/Rin-1| < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS. : (null)\n", - "comenv_disc_angmom_fraction : If >0 Fraction of the common envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the moments of inertia to calculate (deprecated), if -2 use the common envelope's specific angular momentum, if -3 uses the L2 point at the end of the common envelope to set the angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null)\n", - "comenv_disc_mass_fraction : Fraction of the common envelope's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null)\n", - "wind_disc_angmom_fraction : If >0 Fraction of the wind envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the L2 point's specific angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null)\n", - "wind_disc_mass_fraction : Fraction of the stellar wind's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null)\n", - "WRLOF_method : Choose whether and how to apply wind-Roche-lobe-overflow. 0=none, 1=q-dependent, 2=quadratic See Abate et al 2013/14 for details. Requires WRLOF_MASS_TRANSFER. : (null)\n", - "minimum_timestep : The minimum timestep (Myr). : (null)\n", - "timestep_solver_factor : Factor applied in timestep_limits, e.g. to prevent X changing too fast by comparing to X/dX/dt, which is usually 1 but can be higher to lengthen timesteps when using an alternative solver. : (null)\n", - "RLOF_mdot_factor : Multiplier applied to the mass transfer rate during Roche-lobe overflow. Requires RLOF_MDOT_MODULATION. : (null)\n", - "RLOF_f : Factor to enlarge a Roche lobe, nominally because of radiation pressure (see Dermine et al paper). Requires RLOF_RADIATION_CORRECTION. : (null)\n", - "minimum_separation_for_instant_RLOF : If True, instead of evolving the system just report the minimum separation (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_orbital_period_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null)\n", - "minimum_orbital_period_for_instant_RLOF : If True, instead of evolving the system just report the minimum orbital period (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_separation_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null)\n", - "maximum_mass_ratio_for_instant_RLOF : If True, instead of evolving the system just report the maximum mass ratio (on the zero-age main sequence) that would lead to instant RLOF, given M1 and orbital period. Used by binary_grid. See also minimum_separation_for_instant_RLOF and minimum_orbital_period_for_instant_RLOF. : (null)\n", - "RLOF_method : Use RLOF_method to choose the algorithm you use for Roche-lobe overflow mass loss rate calculations. 0=Hurley et al 2002, 1=Adaptive (for radiative stars) R=RL method, 2=Ritter (probably broken), 3=Claeys etal 2014 variant on Hurley et al 2002. : (null)\n", - "RLOF_interpolation_method : When a star overflows its Roche lobe, it always has R>RL because of the limited time resolution of the simulation. Binary_c then uses an algorithm to get back to when R~RL (within a desired tolerance, set in RLOF_ENTRY_THRESHOLD which is usually 1.02, i.e. overflow of 2%). You can choose algorithm 0, the Hurley et al 2002 method which reverses time (i.e. uses a Newton-like scheme), or 1 to use the binary_c method which rejects a timestep (and hence does no logging on that timestep) and repeats with half the timestep until R~RL. The latter is now the default, because this means there are no negative timesteps which break various other algorithms (e.g. nucleosynthesis). : (null)\n", - "nova_retention_fraction : The mass accreted during a nova as fraction of mass transferred : (null)\n", - "beta_reverse_nova : The fraction of mass ejected in a nova explosion which is accreted back onto the companion star. Set to -1 to automatically calculate based on a geometric argument, or 0 or positive to set the value. : (null)\n", - "WD_accretion_rate_novae_upper_limit_hydrogen_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is hydrogen rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_novae_upper_limit_helium_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is helium rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_novae_upper_limit_other_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is neither hydrogen nor helium rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_hydrogen_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a hydrogen-rich donor. Below this mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_helium_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a helium-rich donor. Below this mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_other_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope when the donor is neither hydrogen nor helium rich. Below this mass transfer leads to stable burning. : (null)\n", - "CRAP_parameter : Tidally enhanced mass loss parameter. See Tout and Eggleton's paper on the subject. (Was the parameter bb). : (null)\n", - "individual_novae : If individual_novae is True, novae are resolved such that each explosion is performed separtaely. : (null)\n", - "nova_timestep_accelerator_num : The nova timestep is accelerated if the nova number exceeds nova_timestep_accelerator_num. If zero or negative, acceleration is off. See also nova_timestep_accelerator_index and nova_timestep_accelerator_max. Only used if individual_novae is on.\n", - " : (null)\n", - "nova_timestep_accelerator_index : The index at which the nova timestep is accelerated. A larger value gives longer timesteps. See also nova_timestep_accelerator_num and nova_timestep_accelerator_max. Only used if individual_novae is on.\n", - " : (null)\n", - "nova_timestep_accelerator_max : The nova timestep is accelerated by a factor that is capped at nova_timestep_accelerator_max. This parameter is ignored if it is zero or negative. See also nova_timestep_accelerator_num and nova_timestep_accelerator_index. Only used if individual_novae is on.\n", - " : (null)\n", - "nonconservative_angmom_gamma : Mass lost from the system (but NOT from a stellar wind) takes a fraction gamma of the orbital angular momentum with it. Set to -1 to take the specific angular momentum of the donor star. Set to -2 to take super-Eddington, nova and disk-wind angular momenta as if a wind from the accretor. : (null)\n", - "max_stellar_angmom_change : Maxmimum fractional change in stellar angular momentum allowed before a timestep is rejected (0.05). : (null)\n", - "comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null)\n", - "\n", - "############################################################\n", - "##### Section Nucsyn\n", - "############################################################\n", - "third_dup : If True, enables third dredge up. Requires NUCSYN and NUCSYN_THIRD_DREDGE_UP. : (null)\n", - "third_dup_multiplier : Usage: --third_dup_multiplier <i> <f>. Multiplies the abundance of element <i> by <f> during third dredge up. : 1.0\n", - "NeNaMgAl : Enables NeNaMgAl reaction network. Requires NUCSYN and NUCSYN_HBB. : Ignore\n", - "nucsyn_network%d : Usage: --nucsyn_network%d <boolean>. Turn a nuclear network on or off. : (null)\n", - "nucsyn_network_error%d : Usage: --nucsyn_network_error%d <f>. Threshold error in nuclear network solver for network %d. : (null)\n", - "nucreacmult%d : Usage: --nucreacmult%d <f>. Multiply nuclear reaction given by the integer %d (integer) by f (float). : (null)\n", - "nucsyn_metallicity : This sets the metallicity of the nucleosynthesis algorithms, i.e. the amount (by mass) of matter which is not hydrogen or helium. Usually you'd just set this with the metallicity parameter, but if you want the nucleosynthesis to be outside the range of the stellar evolution algorithm (e.g. Z=0 or Z=0.04) then you need to use nucsyn_metallicity. That said, it's also outside the range of some of the nucleosynthesis algorithms as well, so you have been warned! : (null)\n", - "nucsyn_solver : Choose the solver used in nuclear burning. 0 = KAPS_RENTROP is a Kaps-Rentrop scheme (fast, not great for stiff problems), 1 = LSODA (Adams/BSF switcher), 2 = CVODE library (https://computing.llnl.gov/projects/sundials. Default 0. : 0\n", - "initial_abundance_mix : initial abundance mixture: 0=AG89, 1=Karakas 2002, 2=Lodders 2003, 3=Asplund 2005 (not available?), 4=Garcia Berro, 5=Grevesse Noels 1993 : 0\n", - "init_abund : Usage: --init_abund <i> <X>. Sets the initial abundance of isotope number <i> to mass fraction <X>. : 0.02\n", - "init_abund_mult : Usage: --init_abund_mult <i> <f>. Multiplies the initial abundance of isotope number <i> by <f>. : 1.0\n", - "init_abund_dex : Usage: --init_abund_dex <i> <f>. Changes the initial abundance of isotope number <i> by <f> dex. : 0.0\n", - "init_abunds_only : If True, outputs only the initial abundances, then exits. : (null)\n", - "initial_abunds_only : If True, outputs only the initial abundances, then exits. : (null)\n", - "no_thermohaline_mixing : If True, disables thermohaline mixing. : (null)\n", - "lithium_GB_post_Heflash : Sets the lithium abundances after the helium flash. Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "lithium_GB_post_1DUP : Sets the lithium abundance after first dredge up. Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "lithium_hbb_multiplier : Multiplies the lithium abundances on the AGB during HBB (based on Karakas/Fishlock et al models).Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "angelou_lithium_decay_function : Functional form which describes Li7 decay. Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Choices are : 0 expoential (see angelou_lithium_decay_time). : (null)\n", - "angelou_lithium_LMMS_time : Time at which lithium manufacture is triggered in a low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_time : Time at which lithium manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_time : Time at which lithium manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_time : Time at which lithium manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_time : Time at which lithium manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_time : Time at which lithium manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_time : Time at which lithium manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_LMMS_decay_time : Decay time for surface lithium abundance during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_decay_time : Decay time for surface lithium abundance on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_decay_time : Decay time for surface lithium abundance on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_decay_time : Decay time for surface lithium abundance on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_decay_time : Decay time for surface lithium abundance during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_decay_time : Decay time for surface lithium abundance on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_decay_time : Decay time for surface lithium abundance on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_LMMS_massfrac : Lithium mass fraction when its manufacture is triggered during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_massfrac : Lithium mass fraction when its manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_massfrac : Lithium mass fraction when its manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_massfrac : Lithium mass fraction when its manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_massfrac : Lithium mass fraction when its manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_vrot_trigger : Equatorial rotational velocity at which lithium manufacture is triggered (km/s). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0.\n", - " : (null)\n", - "angelou_lithium_vrotfrac_trigger : Fraction of Keplerian (breakup) equatorial rotational velocity at which lithium manufacture is triggered (must be <1, ignored if 0). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0.\n", - " : (null)\n", - "\n", - "############################################################\n", - "##### Section Output\n", - "############################################################\n", - "cf_amanda_log : Enable logging to compare to Amanda's models. : (null)\n", - "float_overflow_checks : Turn on to enable floating-point overflow checks at the end of each timestep, if they are available. 0=off, 1=warn (stderr) on failure, 2=exit on failure (0) : (null)\n", - "save_pre_events_stardata : Enable this to save a copy of stardata to stardata->pre_events_stardata just before an event. : (null)\n", - "disable_end_logging : Disable the logging that happens at the end of the evolution. : (null)\n", - "ensemble : Turn on ensemble calculations and output. : (null)\n", - "ensemble_filters_off : Sets all ensemble filters to be off (FALSE) - these can then be enabled one-by-one with --ensemble_filter_[...] TRUE. : (null)\n", - "ensemble_filter_%d : Turn on or off ensemble filter <n>. For a list of filters, see ensemble_macros.h. : (null)\n", - "ensemble_legacy_ensemble : Turn on ensemble legacy population output. : (null)\n", - "legacy_yields : Turn on ensemble legacy yield output. : (null)\n", - "ensemble_defer : Defer ensemble output. : (null)\n", - "ensemble_dt : When doing ensemble calculations, data are stored and/or output every ensemble_dt Myr. See also ensemble, ensemble_logdt, ensemble_startlogtime. : (null)\n", - "ensemble_logdt : When doing ensemble calculations, and when logensembletimes is set, the ensemble is stored/output every ensemble_logdt Myr. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null)\n", - "ensemble_startlogtime : Start log ensemble data storage/calculations/output at ensemble_startlogtime. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null)\n", - "ensemble_logtimes : When doing ensemble calculations/output, set this to act at log times rather than linear times. : (null)\n", - "postagb_legacy_logging : Turn on post-AGB legacy logging. : (null)\n", - "disc_legacy_logging : Turn on disc legacy logging. : (null)\n", - "EMP_logg_maximum : Maximum logg that EMP stars are allowed to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_minimum_age. : (null)\n", - "EMP_minimum_age : Minimum age that EMP stars are required to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum. : (null)\n", - "EMP_feh_maximum : Maximum [Fe/H] that an EMP stars may have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default -2.0. : (null)\n", - "CEMP_cfe_minimum : Minimum [C/Fe] that CEMP stars are required to have. See Izzard et al 2009. See also NEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 0.7. : (null)\n", - "NEMP_cfe_minimum : Minimum [N/Fe] that NEMP stars are required to have. See Izzard et al 2009, Pols et al. 2012. See also CEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 1.0. : (null)\n", - "thick_disc_start_age : Lookback time for the start of the thick disc star formation, e.g. 13e3 Myr. Units = Myr. : (null)\n", - "thick_disc_end_age : Lookback time for the end of the thick disc star formation, e.g. 4e3 Myr. Units = Myr. : (null)\n", - "thick_disc_logg_min : Minimum logg for thick disc giants to be logged. : (null)\n", - "thick_disc_logg_max : Maximum logg for thick disc giants to be logged. : (null)\n", - "escape_velocity : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 1e9 km/s. See also escape_fraction. : (null)\n", - "escape_fraction : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 0.0. See also escape_velocity. : (null)\n", - "colour_log : If set to True, thelog is coloured with ANSI colour formatting. Requires FILE_LOG to be defined. : \n", - "log_filename : Location of the output logging filename. If set to \"/dev/null\" then there is no logging. : \n", - "log_arrows : Add arrows to the output log to show whether values are increasing or decreasing. : \n", - "stopfile : File which, when it exists, will stop the current binary_c repeat run. : \n", - "stardata_dump_filename : Location of the stardata dump file. : \n", - "stardata_load_filename : Location of the stardata file to load. : \n", - "api_log_filename_prefix : Location of the output logging filename prefix for the API. If set to \"/dev/null\" then there is no logging. : 0\n", - "hrdiag_output : Set to True to output high time-resolution Hertzstrpung-Russell diagram information. Requires HRDIAG. : (null)\n", - "internal_buffering : Experimental. Set to non-zero values to implement internal buffering prior to output. For use with binary_grid, you shouldn't really be playing with this. : (null)\n", - "eccentric_RLOF_model : Chooses which model is used to handle eccentric RLOF. Default is RLOF_ECCENTRIC_AS_CIRCULAR, i.e. ignore the eccentricity. Note: requires force_corotation_of_primary_and_orbit to be FALSE.\n", - " : (null)\n", - "force_circularization_on_RLOF : If True forces circularization of stars and orbit when RLOF starts, this is as in the BSE algorithm. (True) : (null)\n", - "wtts_log : If True, enables log file output for WTTS2. : (null)\n", - "fabian_imf_log_time : Time at which to output for Fabian Schneider's IMF project. Requires FABIAN_IMF_LOG : Ignore\n", - "fabian_imf_log_timestep : Timestep for Fabian Schneider's IMF project logging. Requires FABIAN_IMF_LOG : Ignore\n", - "version : Display binary_c version and build information. Also performs timing tests. : Ignore\n", - "dumpversion : Display binary_c version number (short format). : Ignore\n", - "version_only : Display binary_c version number and build information, but do not perform timing tests or anything that requires stardata to be non-NULL. : Ignore\n", - "tides_diagnosis_log : Enable logging to test MINT tides. Requires MINT. Choices are: 0 disabled, 1 enable lambda test. : Ignore\n", - "\n", - "############################################################\n", - "##### Section Input\n", - "############################################################\n", - "MINT_dir : Location of MINT algorithm data. : \n", - "MINT_data_cleanup : Activate checks on incoming data to try to account for problems. Will make data-loading slower, but may fix a few things. : \n", - "MINT_MS_rejuvenation : Turn on or off (hydrogen) main-sequence rejuvenation. : \n", - "MINT_remesh : Turn on or off MINT's remeshing. : \n", - "MINT_use_ZAMS_profiles : Use chemical profiles at the ZAMS if MINT_use_ZAMS_profiles is TRUE, otherwise set homogeneous abundances. (Default is TRUE, so we use the profiles if they are available.) : \n", - "MINT_fallback_to_test_data : If TRUE, use the MINT test_data directory as a fallback when data is unavailable. (FALSE) : \n", - "MINT_disable_grid_load_warnings : Use this to explicitly disable MINT's warnings when loading a grid with, e.g., missing or too much data. : \n", - "MINT_Kippenhahn : Turn on or off MINT's Kippenhahn diagrams. If 0, off, if 1, output star 1 (index 0), if 2 output star 2 (index 1). Default 0. : \n", - "MINT_nshells : Set the initial number of shells MINT uses in each star when doing nuclear burning. Note: remeshing can change this. If MINT_nshells is 0, shellular burning and other routines that require shells will not be available. (200) : \n", - "MINT_maximum_nshells : Set the maximum number of shells MINT uses in each star when doing nuclear burning. Note that this will be limited to MINT_HARD_MAX_NSHELLS. (1000) : \n", - "MINT_minimum_nshells : Set the minimum number of shells MINT uses in each star when doing nuclear burning. Note that this will be greater than or equal to MINT_HARD_MIN_NSHELLS, which is 0 by default. (0) : \n", - "MINT_Kippenhahn_stellar_type : Stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for which Kippenhahn plot data should be output. : \n", - "MINT_Kippenhahn_companion_stellar_type : Companion stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for the companion for which Kippenhahn plot data should be output. : \n", - "MINT_nuclear_burning : Turn on or off MINT's nuclear burning algorithm. : \n", - "MINT_minimum_shell_mass : Minimum shell mass in MINT's nuclear burning routines. : \n", - "MINT_maximum_shell_mass : Maximum shell mass in MINT's nuclear burning routines. : \n", - "\n", - "############################################################\n", - "##### Section I/O\n", - "############################################################\n", - "go : batchmode control command : Ignore\n", - "gogo : batchmode control command : Ignore\n", - "reset_stars : Reset the star structures. Used in batchmode : Ignore\n", - "reset_stars_defaults : Reset the star structures and set defaults. Used in batchmode : Ignore\n", - "defaults : Reset all defaults. Used in batchmode : Ignore\n", - "echo : Activate batchmode command echoing, i.e. when you enter a command, binary_c repeats the command then executes it. : Ignore\n", - "noecho : Deactivate batchmode command echoing. See 'echo'. : Ignore\n", - "noechonow : Deactivate batchmode command echoing. See 'echo'. : Ignore\n", - "bye : Quit binary_c. Used in batchmode. : Ignore\n", - "fin : batchmode control command : Ignore\n", - "reset_prefs : Reset preferences struct. Used in batchmode : Ignore\n", - "status : Output batchmode status information. : Ignore\n", - "\n", - "############################################################\n", - "##### Section Algorithms\n", - "############################################################\n", - "repeat : If > 1, repeats the system as many times as required. Handy if you're using Monte-Carlo kicks and want to sample the parameter space well. Also, if you are running speed tests this is good to give a statistically more reasonable result. (See e.g. 'tbse pgo'). : (null)\n", - "random_systems : Experimental. Use this to apply random initial system parameters (masses, separations, etc.). Useful for testing only. : (null)\n", - "\n", - "############################################################\n", - "##### Section Misc\n", - "############################################################\n", - "random_seed : Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null)\n", - "random_systems_seed : Random number seed for the generation of random systems. See random_systems and random_seed. : (null)\n", - "random_skip : Skip the first <random_seed> random numbers that are generated. Usually this is 0 so they are all used. : (null)\n", - "idum : [NB: deprecated, please use 'random_seed' instead.] Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null)\n", - "reverse_time : Make time go backwards. To be considered very experimental! : (null)\n", - "start_time : Start time for the simulation. : (null)\n", - "warmup_cpu : Uses the CPU at maximum power the given number of seconds, prior to running normal stellar evolution. : Ignore\n", - "help : Display help pages. Usage: --help <help topic>. : Ignore\n", - "argopts : Display argument options. Usage: --argopts <argument>. : Ignore\n", - "help_all : Display all help pages. : Ignore\n", - "list_args : Display list of arguments with their default values. Useful for batchmode. : Ignore\n", - "\n" + "(abridged)\n" ] } ], "source": [ - "print(_binary_c_bindings.return_help_all())" + "print('\\n'.join(_binary_c_bindings.return_help_all().splitlines()[:10]))\n", + "print(\"(abridged)\")" ] }, { @@ -873,12 +300,14 @@ "__ARG_BEGIN\n", "metallicity = 0.02\n", "effective_metallicity = -1\n", - "M_1 = 0\n" + "M_1 = 0\n", + "(abridged)\n" ] } ], "source": [ - "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))" + "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))\n", + "print(\"(abridged)\")" ] }, { @@ -966,7 +395,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -980,7 +409,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/source/examples/notebook_custom_logging.ipynb b/docs/source/examples/notebook_custom_logging.ipynb index 8dfb85034dd77e1b0ae790c475a1e52bd70d0227..8627ffb4751bfea37ebfc00c67e763a79463eba0 100644 --- a/docs/source/examples/notebook_custom_logging.ipynb +++ b/docs/source/examples/notebook_custom_logging.ipynb @@ -23,7 +23,7 @@ " create_and_load_logging_function,\n", ")\n", "from binarycpython.utils.run_system_wrapper import run_system\n", - "from binarycpython.utils.grid import Population" + "from binarycpython import Population" ] }, { @@ -461,11 +461,19 @@ "# print (abridged) output\n", "print(\"\\n\".join(output.splitlines()[-2:]))" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c708268f-0b0c-48ea-9155-ec632a0acc3a", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -479,7 +487,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/source/examples/notebook_ensembles.ipynb b/docs/source/examples/notebook_ensembles.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..cc9a3ad9f4cfc1efc4c1327878f01b87bad9e8e5 --- /dev/null +++ b/docs/source/examples/notebook_ensembles.ipynb @@ -0,0 +1,42 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d1d00572-29aa-4f27-a59c-f9f05889da7d", + "metadata": {}, + "source": [ + "# Tutorial: Generating and handling ensemble data\n", + "TODO: coming soon!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e8d9fca3-dd16-4c2c-a180-14d9a6b533ed", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docs/source/examples/notebook_extra_features.ipynb b/docs/source/examples/notebook_extra_features.ipynb index 44c19c11274fbd39732e34e03e7a14a371ff9d7c..a0f0fc0d9c66207de88d4c38672d257f9af522c2 100644 --- a/docs/source/examples/notebook_extra_features.ipynb +++ b/docs/source/examples/notebook_extra_features.ipynb @@ -18,11 +18,11 @@ "metadata": {}, "outputs": [], "source": [ + "from binarycpython import Population\n", "from binarycpython.utils.functions import (\n", " get_help,\n", " get_help_all,\n", " get_help_super,\n", - " return_binary_c_version_info,\n", " get_defaults\n", ")\n", "# help(binarycpython.utils.functions)" @@ -116,8 +116,7 @@ "metadata": {}, "source": [ "## Build information of binary_c\n", - "Sometimes we want to know with which settings binary_c has been built. We can use the function `return_binary_c_version_info` for this.\n", - "This function will parse the version info of binary_c and return a dictionary with all the settings." + "It can be useful to fetch the information with which the current version of binary_c has been configured with. We can do that through the Population object, by calling the instance method `return_binary_c_version_info`. This function will parse the version info of binary_c and return a dictionary with all the settings." ] }, { @@ -130,13 +129,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'nucleosynthesis_sources', 'miscellaneous'])\n" + "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'units', 'nucleosynthesis_sources', 'miscellaneous'])\n" ] } ], "source": [ - "version_info_dict = return_binary_c_version_info(parsed=True)\n", - "print(version_info_dict.keys())" + "version_info = Population().return_binary_c_version_info(parsed=True)\n", + "print(version_info.keys())" ] }, { @@ -168,27 +167,11 @@ "\n", "TODO:" ] - }, - { - "cell_type": "markdown", - "id": "b3c259ef-9f89-4b26-9ce3-45af625bc398", - "metadata": {}, - "source": [ - "## Getting help\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bf3c1e28-1662-47a7-abab-aa6fb0ef0882", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -202,7 +185,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/source/examples/notebook_individual_systems.ipynb b/docs/source/examples/notebook_individual_systems.ipynb index deb72fc55ba3785c9c829ab83ba0846cd9b86867..d752fc66ed4fdff229a1bab5d1f5e48921ea8e77 100644 --- a/docs/source/examples/notebook_individual_systems.ipynb +++ b/docs/source/examples/notebook_individual_systems.ipynb @@ -62,7 +62,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "SINGLE_STAR_LIFETIME 1 12461.2\n", + "SINGLE_STAR_LIFETIME 1 12461.1\n", "\n" ] } @@ -90,17 +90,17 @@ "name": "stdout", "output_type": "stream", "text": [ - " TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=62172 RANDOM_COUNT=0\n", + " TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=22065 RANDOM_COUNT=0\n", " 0.0000 1.000 0.000 1 15 -1 -1 -1.00 0.000 0.000 \"INITIAL \"\n", " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 \"OFF_MS\"\n", " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 11582.2424 1.000 0.000 3 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 12325.1085 0.817 0.000 4 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 12457.1301 0.783 0.000 5 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"shrinkAGB\"\n", - " 12461.1627 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 15000.0000 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", + " 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", + " 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"shrinkAGB\"\n", + " 12461.1490 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", + " 15000.0000 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", "\n" ] } @@ -236,13 +236,13 @@ "4 0.000002 1.0 1.0 1.0\n", "5 0.000003 1.0 1.0 1.0\n", "... ... ... ... ...\n", - "1345 12461.080763 0.71617 1.0 6.0\n", - "1346 12461.162734 0.644553 1.0 11.0\n", - "1347 13461.162734 0.644553 1.0 11.0\n", - "1348 14461.162734 0.644553 1.0 11.0\n", - "1349 15000.0 0.644553 1.0 11.0\n", + "1250 12461.061259 0.718593 1.0 6.0\n", + "1251 12461.149038 0.678026 1.0 11.0\n", + "1252 13461.149038 0.678026 1.0 11.0\n", + "1253 14461.149038 0.678026 1.0 11.0\n", + "1254 15000.0 0.678026 1.0 11.0\n", "\n", - "[1349 rows x 4 columns]\n" + "[1254 rows x 4 columns]\n" ] } ], @@ -299,10 +299,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options\n", - "adding: M_1=10 to BSE_options\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", "SINGLE_STAR_LIFETIME 10 28.4838\n", "\n" @@ -360,9 +358,9 @@ ");\n", " to grid_options\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", - "Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_dafa15d2b1e64e19972ac0e9eb5c9a55.so\n", + "Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_34a350b8f15c4d149deab88632948c99.so\n", "EXAMPLE_MASSLOSS 0.000000000000e+00 10 0 10 1\n", "EXAMPLE_MASSLOSS 0.000000000000e+00 10 10 10 1\n", "EXAMPLE_MASSLOSS 1.000000000000e-06 10 10 10 1\n", @@ -381,7 +379,7 @@ "\n", " stardata->star[0].stellar_type //5\n", ");\n", - "\"\"\" \n", + "\"\"\"\n", "\n", "example_pop.set(C_logging_code=custom_logging_print_statement)\n", "\n", @@ -397,7 +395,7 @@ "source": [ "Lastly we can add a parse_function to handle parsing the output again. \n", "\n", - "Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be (self, output). Returning the data is useful when running evolve_single(), but won't be used in a population evolution." + "Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be `(self, output)`. Returning the data is useful when running evolve_single(), but won't be used in a population evolution." ] }, { @@ -464,13 +462,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function object_parse_function at 0x149c2e81ec10> to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to custom_options >>>>\n", - "adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options\n", + "adding: parse_function=<function object_parse_function at 0x7f35b603e9d0> to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-david/notebooks/notebook_individual_systems to custom_options >>>>\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", - "Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_0639ee205c7d4782b4a27378f5d890bd.so\n", + "Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_446fe4cddfa94946bcafd55591ef3730.so\n", "[['time', 'mass', 'initial_mass', 'stellar_type'], [0.0, 10.0, 0.0, 10.0, 1.0], [0.0, 10.0, 10.0, 10.0, 1.0], [1e-06, 10.0, 10.0, 10.0, 1.0]]\n", "dict_keys(['time', 'mass', 'initial_mass', 'stellar_type'])\n" ] @@ -570,7 +567,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -584,7 +581,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/source/examples/notebook_luminosity_function_single.ipynb b/docs/source/examples/notebook_luminosity_function_single.ipynb index 93e041531422571b1a499b0089f9e4e465d4a0f3..0a19202d3d6b54cc27b089c742e1a194a226587a 100644 --- a/docs/source/examples/notebook_luminosity_function_single.ipynb +++ b/docs/source/examples/notebook_luminosity_function_single.ipynb @@ -54,8 +54,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: max_evolution_time=0.1 to BSE_options\n", - "adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_luminosity to grid_options\n", + "adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_luminosity to grid_options\n", "verbosity is 1\n" ] } @@ -104,28 +103,6 @@ "# help(population.add_grid_variable)" ] }, - { - "cell_type": "markdown", - "id": "bd75cebe-2152-4025-b680-dc020b80889b", - "metadata": {}, - "source": [ - "All the distribution functions that we can use are stored in the `binarycpython.utils.distribution_functions` or `binarycpython/utils/distribution_functions.py` on git. If you uncomment the help statement below you can see which functions are available now:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "048db541-3e92-4c5d-a25c-9c5a34b9c857", - "metadata": { - "scrolled": true, - "tags": [] - }, - "outputs": [], - "source": [ - "import binarycpython.utils.distribution_functions\n", - "# help(binarycpython.utils.distribution_functions)" - ] - }, { "cell_type": "markdown", "id": "2a9104fc-4136-4e53-8604-f24ad52fbe56", @@ -141,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "id": "aba3fe4e-18f2-4bb9-8e5c-4c6007ab038b", "metadata": {}, "outputs": [], @@ -165,22 +142,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "id": "47979841-2c26-4b26-8945-603d013dc93a", "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "add_grid_variable() got an unexpected keyword argument 'resolution'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/tmp/ipykernel_519112/518757914.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mtmp_dir\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mTMP_DIR\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m )\n\u001b[0;32m----> 6\u001b[0;31m population.add_grid_variable(\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"M_1\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mlongname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"Primary mass\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mTypeError\u001b[0m: add_grid_variable() got an unexpected keyword argument 'resolution'" - ] - } - ], + "outputs": [], "source": [ "# Mass\n", "population = Population()\n", @@ -191,8 +156,16 @@ " name=\"M_1\",\n", " longname=\"Primary mass\",\n", " valuerange=massrange,\n", - " samplerfunc=\"const({min}, {max}, {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", - " probdist=\"{probtot}/({max} - {min})\".format(probtot = total_probability, min = massrange[0], max = massrange[1]), # dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)\n", + " samplerfunc=\"self.const_linear({min}, {max}, {res})\".format(\n", + " min=massrange[0],\n", + " max=massrange[1],\n", + " res=resolution[\"M_1\"]\n", + " ),\n", + " probdist=\"{probtot}/({max} - {min})\".format(\n", + " probtot=total_probability,\n", + " min=massrange[0],\n", + " max=massrange[1]\n", + " ), # dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)\n", " dphasevol=\"dM_1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -214,7 +187,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "0c986215-93b1-4e30-ad79-f7c397e9ff7d", "metadata": {}, "outputs": [], @@ -258,10 +231,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "fd197154-a8ce-4865-8929-008d3483101a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "adding: parse_function=<function parse_function at 0x7f6920fd2430> to grid_options\n" + ] + } + ], "source": [ "# import the bin_data function so we can construct finite-resolution probability distributions\n", "# import the datalinedict to make a dictionary from each line of data from binary_c\n", @@ -279,18 +260,15 @@ " for line in output.splitlines():\n", " # obtain the line of data in dictionary form \n", " linedata = datalinedict(line,parameters)\n", - " \n", + "\n", " # Check the header and act accordingly\n", " if linedata['header'] == \"ZERO_AGE_MAIN_SEQUENCE_STAR\":\n", - " \n", + "\n", " # bin the log10(luminosity) to the nearest 0.1dex\n", " binned_log_luminosity = bin_data(math.log10(linedata['luminosity']),\n", " binwidth['luminosity'])\n", - " \n", " # append the data to the results_dictionary \n", " self.grid_results['luminosity distribution'][binned_log_luminosity] += linedata['probability'] \n", - " \n", - " #print (self.grid_results)\n", " \n", " # verbose reporting\n", " #print(\"parse out results_dictionary=\",self.grid_results)\n", @@ -316,12 +294,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "8ea376c1-1e92-45af-8cab-9d7fdca564eb", "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "adding: verbosity=0 to grid_options\n", + "Do dry run? True\n", + "Doing dry run to calculate total starcount and probability\n", + "Grid has handled 39 stars with a total probability of 1\n", + "**************************\n", + "* Dry run *\n", + "* Total starcount is 39 *\n", + "* Total probability is 1 *\n", + "**************************\n", + "\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", + "**********************************************************\n", + "* Population-f9b28e4ed6ec4a67b17cd86c5a43c41c finished! *\n", + "* The total probability is 1. *\n", + "* It took a total of 3.99s to run 39 systems on 2 cores *\n", + "* = 7.98s of CPU time. *\n", + "* Maximum memory use 343.570 MB *\n", + "**********************************************************\n", + "\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" + ] + } + ], "source": [ "# set number of threads\n", "population.set(\n", @@ -329,7 +337,7 @@ " verbosity=0,\n", " # set number of threads (i.e. number of CPU cores we use)\n", " num_cores=2,\n", - " )\n", + ")\n", "\n", "# Evolve the population - this is the slow, number-crunching step\n", "analytics = population.evolve() \n", @@ -348,20 +356,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "e1f0464b-0424-4022-b34b-5b744bc2c59d", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'population_id': 'f9b28e4ed6ec4a67b17cd86c5a43c41c', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.9999999999999999, 'total_count': 39, 'start_timestamp': 1655508316.7679594, 'end_timestamp': 1655508320.7581806, 'time_elapsed': 3.9902212619781494, 'total_mass_run': 1951.365, 'total_probability_weighted_mass_run': 50.035, 'zero_prob_stars_skipped': 0}\n" + ] + } + ], "source": [ "print(analytics)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "05c6d132-abee-423e-b1a8-2039c8996fbc", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[None]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaMAAAEdCAYAAAChVQjxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAA9vklEQVR4nO3dd3hUVfrA8e/MpJNAQu81cOhNihB6ExUVVMTeXcva19V1ddfuqj93bWtvgLoqKLZdBAKCoqEjHY4K0gMpJEAgdWZ+f9xJmCSTZCbM5M5M3s/z5Enm3jt33twk8+ace857LE6nEyGEEMJMVrMDEEIIISQZCSGEMJ0kIyGEEKaTZCSEEMJ0koyEEEKYLsLsAEJUNDAYSAfsJscihBChwga0AtYAhe47JBnVzmBgudlBCCFEiBoJ/Oi+QZJR7aQD5OScwOEI7DytJk3iyc7OC+hr1FdybQNHrm3ghPK1tVotJCU1ANd7qDtJRrVjB3A4nAFPRqWvIwJDrm3gyLUNnDC4tpVub8gABiGEEKaTZCSEEMJ0koyEEEKYTpKREEII00kyEkIIYToZTReC8vNPkJeXi91eYnYoIS0jw4rD4TA7jLAk19Z7hcUOrBaIjPCubRCM19ZmiyA+PpHY2Aa1PockoxCTn3+C48dzSExsRmRkFBaLxeyQQlZEhJWSkuD6ow4Xcm29c6KgmIKcfOwWC62aNSDCVnNCCrZr63Q6KS4uIjc3E6DWCUm66UJMXl4uiYnNiIqKlkQkRIg7frLY+MLpJL8wNHs6LBYLUVHRJCY2Iy8vt9bnkWQUYuz2EiIjo8wOQwhxmkrsDgrcElB+UWiXuYyMjDqtWweSjEKQtIiECH0n8ovLPS4oLMHpDN3KCqf7viTJSAgh6pjT6SSvQjJyOJwUB9G9oLomyUgIIepYUYmjLPE0iI0s2x7qXXWnQ5KREAFw8cXn8dRTj5ry2rff/gduv/0Pprx2qYMHDzJixCDmz//GlNdPT6/8+k899SgXX3yeaa89efKYssfuraKk+GhsrlF0BX4YxODp9UOBDO0WpkpPP8j06efXeNxf//oI55xT/o0kOzuLCy88F4fDwdy539CyZctKz7v99j+wYcN6OnXqzAcfzKm0/7vvFvP3v/8FgJdffoOBAweV7du4cQOzZ7/Hzp2/cuzYURITk0hO7saECWcxadJkX7/Vem/lyjS2bt3MDTfcbHYoXtuyZTOrVqVxySWXk5CQ4JdzOp3OsvtFMVERRERYiYmycSLfQUGRHafT6dX9l1C8ntWRZCRMlZiYxN/+9rjHfQ6Hg1deeYH8/JN07aoq7V+yZBExMTHYbBEsXryAK6+81uN5oqKi+P33Xfz2268kJ3ctty81dQFRUdEUFZVbdJLvvlvMI488SNeu3Zg+/VISEhqSnn6QDRvW8803XwR1MnrhhVfNDoFWrVqxZMlPRESceotZtWoFc+d+bNqb5wMPPOzzZNFt2zbz/vtvc84553mdjFq2rPy9u8svLClbAiI+1jgmNtrGifxinE4nhcV2YqJqfmuu6nrW9PrBKrSiFWEnNjaWs846x+O+d999k2PHjnL77XfTtWu3SvtTUxcwYsRooqKiSE1dWGUyat++IydPnmDx4oXlklFe3nFWrUpj2LAUvv9+abnnvPfeW3Tu3IU335xJZGRkuX05OUd8/C7rVsV4zWCxWIiOjjY7jHIC/eZst9ux2+1ERUVV+73n5RtdcRaLhbgY42flnnwKirxLRlUJxmvvDblnJILShg3rmT37PYYNS2HGjCsq7d+3by/bt29j/PhJjB8/iZ07f2XXrp1Vnm/8+EksWbKo3NDZpUuXYLFYGDlyTKXjDx7cT8+evT2+sSclNfb5+3n33TcZMWJQpe3z53/DiBGDSE8/WLbt4ovP48EH/8SaNSu5/vorGDcuheuvv4Jt27YA8O23/+XSSy9k3Ljh3H77Hzh48EC5c1a8Z7R+/VpGjBjE999/x8yZ7zB16tmMGzecu+66lf3791WKacmSRVx33eWMGzecKVMm8o9/PE5ubm65Y/bt28tDD/2Z888/i3HjhjNt2jk88siD5OUZK5BWvGf01FOPMnfuxwCMGDGo7OPkyZNMmDCCF198vlIc+/btZcSIQcybN7faa3v8+HGeeupRzjprNJMnj+HJJx8hL+94peM83TNavHgh119/JRMnjmLSpNFcffUM5swx4nz33Td5+eV/ATB9+vllMZf+rEaMGMRLL/2Tb7/9L5dffhHjxg1ny5ZN1d6z2bN3D39/6G5uuPIc7rxlBh9/PBuACJuVyAgr27ZuYMrkFNavX1vueRXPWdX19HRsqbVrV3PrrdczfnwKkyeP5eGHH6j0u1N6b+vw4UM88MA9TJw4kilTJvDvf7+I3R7YwRXSMhJB59ixozz++N9ISmrMQw895rH/PDV1AQkJDRky5EwsFguNGzchNXUBN9/8R4/nnDhxMh988D5btmyiT59+ACxatJDhw0cSF1e5fEmLFi1Zu3Y1mZkZNGvW3L/foBf27NnNk08+wtSpFzNpUiwffjiL+++/h1tu+SMffTSbCy64kJMnT/DRR7N49tkneeml12s856xZ72K12rj88qs5fvwYH3/8AY899jBvvz2r7Jj587/h6acfo1evPtx6651kZBzm888/Zfv2rbz99myio6MpLi7m3nvvwGazMmPG5TRq1IjDhw+TlvYjeXnHiY+Pr/TaF1xwIdnZ2axevaJct2xcXByjRo1l6dJU7rjjHmw2W9m+RYu+JSIigvHjJ1b5PTmdTh588E9s2rSBqVMvokOHjvzwwzKefPLRGq/HmjUrefTRhxg9eiznnz8Nu93O7t2/s3nzRi655DJGjx7HwYP7WbjwW+68814aNUoEjK5l93N8990ipk2bTkJCAk2bNq3y9UpKSrjvvjtJ7tabS6/8A9s2reb1118B4IorrinXGqppulFV17Pq73UV9913J+3adeDGG2/l5MkTzJ37MbfeegMzZ35MUtKp76mkpIR7772dPn368cc/3sWaNav45JMPadOmLdOmXVzja9WWJCMRdP7xjyfIysrkxRdfIzEx0eMxqakLGDVqTFnXy5gx41i8eCF/+MNtHpNX585d6NIlmdTUBfTp04/s7CzWr1/L448/4/H8V1xxDc888wQzZkylT59+9O3bn8GDh9K7d1+s1sB3KOzdu4e33ppJz569AWjWrAWPPPIgr776Mp98Mq/sjbGkpIQPPnifw4cP0aJF5QEc7kpKSnjvvVll16xhw0a89NLz7Nr1G507J1NSUsLrr79CcnI3XnnlTaKijEofSnXn0Ucf4ptvvuDiiy9l9+5dpKcf4O23Z9GjR6+y81d3L6h377506NCR1atXVOqWPeusc1i06FvWr1/D4MFnlm1PTV3A0KHDyr5XT3788Xs2bFjPHXfcU9aCnjr1Yu6885ZqrwVAWtpPdOrUmaee+j+P+5OTu6JUDxYu/JaRI8fQqlXrSsfs27eXDz6YQ/v2Hcq2ubdy3RUUFHDG4BQuvfIWbDYr1199BffeewczZ77LtGnTiYk+1QovLqm+FVLd9fTktddeIjExkddff7fs3tfQocO55Zbr+PDDmdxxxz3l4pw8+Vyuuuo6wLie119/Bf/971eSjET1dh08xjc//U6ByXMUYqJsnJfSic6tG9b6HJ9/Pofly5dx7bU3lhvZ5m7Hjm3s27eXe+65v2zb+PFnMW/eXDZv3kjfvv09Pm/ChLOYM+dj7rrrPr77bjGxsbEMG5bCypVplY6dMuUCmjVrzqeffsT69WtZt24N77//Nm3atOVvf3uC3r371Pp79EaXLl3LEhFAr17G1yNGjCr35tyzp5EM0tMP1piMzj33/HL3Tfr16w/AwYMH6Nw5mR07tpGTc4Sbbrq1LBEBjBs3kVdffYm0tJ+4+OJLadDAaPn89NNykpO7nfY9qkGDhtCkSVMWLVpQloy2bdvC/v37uOmm26p97ooVPxEZGckFF1xUts1ms3HRRTPYuPHnap8bHx9PRsZhtm7dUnZ9fTVw4KByiagm4yYaI0cbxEZgs9mYNu0i1q1bzaZNGxg85FQiLiz2399yVlYWv/76C1dddV25QRi9e/ehV68+rFjxY7lkBEbLy13fvgNYuHC+32LyRJJRGEhdu4+NO7PNDgOA2OgI/nB+r5oP9GDnzt949dWX6NdvANddd1OVxy1a9C1xcQ1o2bJl2T2Pxo0bk5iYyKJFC6pMRuPHT+LNN19l7drVpKYuYPToseXedCsaOnQYQ4cOo6CgAK23s2TJIr76ah733383H330WbmuDX+rmFhKE0Dz5i08bj9+/JjP50xIaOh6rnF/5dChdIBKb65Wq5W2bdtx+LCxv3XrNsyYcQUzZ77Dp5/+hwEDBjJ8+EgmTZrsscuzJjabjYkTJ/PNN19w330PEh0dzaJFC2jQoAEjRoys9rmHDh2iadPmxMTElNvuTYK48MLpLF26mJtvvpZWrdowePAQxo6dwODBQ72O3VNrqSo2m42mzYyfQbxr4ELbtu0BOHToIDarlUjXfKOiYv9VYqjq5wrQoUNHFi9eVG5bbGwcDRs2KrctISHBq9+x0yHJKAxMHNSOgsKSoGgZTRzcrlbPLSws4JFH/kpMTAyPPPJkuXsH7hwOB0uWpHLy5Akuv7xyl8GyZYu5++77PI6cat26Db169eGDD95n27Yt3HzzrV7FFhMTQ79+A+jXbwCNGiXy/vtvs3LlT5x99hSvv7+q5o04HJ5/ZrYqlhKoqovQm5JmVqvna1qbemh33HEP5557HsuXf8/q1Sv517+eZfbs93jzzfdrdY9t8uRz+eSTD0lLW86oUWP57rtURo8eR3R0TM1PrqWkpMa8//5/WL16JStXprFyZRpff/0F5557Pg8++HevzuFtfO7XOCrSRlSk559FdJSxvdjuwO5wYHP9vOty/aKqfvcCTZJRGOjcuiF3Te9ndhin5cUX/8nu3bt45pl/Vvrv3926dWvIzs7i5ptvp23btuX2ZWZm8PLL/2L16pUMHz7C4/MnTjyLF198nqSkxgwaNMSrN3F33bv3BIyuD1+4t0Lcu0oOHTrkWwAB1LJlK8C4X9W//8Cy7U6nk/3799GpU5dyx3funEznzslcc80NbN26hZtvvpYvv/ycm27ynOSrm8eZnNyVLl26smjRAuLiGnDkSDaTJp3tRcwt+fnntRQUFJRrHe3du6fG54IxDD4lZSQpKSNxOp288MJzzJs3l6uvvp42bdoC/ilK7HA4sdvtZGUeonvXzmXb9+/fC0CLFsa1b5KUCMDJE3kUFNppEGskhtLWjTtv65K6/1wr2rt3j8fJ4maQod3CdEuXLnbdHJ/BiBGjqz02NXUB8fHxXHbZlYwdO6Hcx/Tpl5GU1JjU1AVVPn/8+LO47rqbuOee+6tsfYExDNaTFSt+ArzrBnJnvLHBxo3ry7bl5+fz7bf/9ek8gdS9e0+Skhrz5ZefUVx8qlzN0qVLyMzMYPjwFABOnMijpKR82ZrOnbtgs9koKiqq8vwxMbHAqW7BiiZPPpdVq9L44ou5NG3arMp7hu6GDUuhuLiYr776vGyb3W7n888/rfG5R4/mlntssVjo0sWYh1ZYaEyCjo01YvY0VNwXxXajZZO68CsaxBhtAIfDwRdffE5sbCz9+g0AoF3btlitVnZs21Sup+OLLyoPb6/pepZq2rQpXbt2Y/78b8qG3oNxX27Llk0MG+b5H7e6Ji0jYaqsrEyeffYpYmPjSE7uWuVN0jZt2tK1q+KHH5YyePCZHrvhLBYLw4alsHTpYvLz88veSNwlJSV5VQHgwQf/RKtWrUlJGUWbNm3Izy9g7dpV/PTTcnr06ElKSvX3MioaMuRMWrRoyTPPPMFll+3GarXxv/99TWJiEocPB0frKCIigltvvYOnn36MO+64mQkTJpGRcZjPPvuUzp27cN550wBYt24tL7zwHGPGjKd9+w44HHYWLvwWi8XC6NHjqjy/Uj0AePHF/2Po0GFYrVYmTDirbP/EiZN5441X+PHHH7j00iu9GrWYkjKKPn368eqrL3HgwH46dOjEDz8sLfemW5VnnnmS48ePMXDgIJo3b87hw8b32rVrNzp27OSKuTsAb731GuPHTyIiIoKUlFEef7eq4nA4KbE7iY6O4ee1aTz77BMo1YO0tB9Zt241N998O3FxcQA0bJjAsJSxpC74ApvNikruRFracnJyciqdt6br6e622+7ivvvu5NZbr+fcc8/nxIkTzJ37CU2aNK1ysnhdk2QkTLV3756y/zqfeebJKo87++wppKSMJC8vr8ouOICUlJHMn/8Ny5d/f1olex544GGWL/+e775LJSsrE6fTuOd09dXXc+WV1/g8mz8iIoKnn36ef/7zGd555w0aN27CJZdcRkJCQ55++rFax+lv55xzHlFRUXz00SxeffUlGjRowMSJk7nlljvKZvUnJ3dlyJAzSUtbzldfzSMmJobk5K48//zL1Y4yHDlyNNOnX0Zq6gIWLfoWp9NZ7s2zadOmnHHGENdw5Zq76MC4h/bss//ipZf+ycKF87FYLKSkjOL22+/muusqT5Z2d9ZZZ/P111/wxRefkZd3nMaNmzBu3ASuv/4PZYmwW7fu3HzzH5k3by6rVq1w1UH82qdkdLKwBJzGAIann3mB1155niVLFpGQ0JCbb76dq666ttzxt91+L0VFxSxe+DU/LI1i3LgJ3HbbXVx99Yxyx9V0Pd0NHjyU559/mXfffZO33nqdqKhIBg0awm233RXQgTi+sITyYk4m6gj8np2dV1ZjKlCaNUsgM/NUM/zQoT20bOlbF5HwLCLCSkk9Xj8mkGp7be+//x7S0w94LGobqg4dOUlBYQlWq4V2zeNrLIJaUFTCoeyTADRtFEN8XPkRn8H8e1vT+5PVaqFJk3iATsDucvsCGpkQQngpI+Mwq1aleTWJM1S4Ly3eICbSq2rc0ZE2LFbjuPq0vpF00wkhTHXw4AE2b97IV1/NIyoqmilTppodkt+4Ly0eH+vd5GCLxUJMpI38whIKikq8XlIi1EnLSAhhqg0b1vPEE38nI+MwDz/8WJUloEKN+9LikRFWoiK9f7uNjTbaCXa7s2wkXriTlpEQwlTnnHNepYUTw0HFpcV9ad3ERJ2adlBQaCcqouppCOFCWkZCCBEAebXooisVGWHFVnbf6PSXIg8FkoyEEMLPyi0tHh1BhI8ldiwWCzGurrpC11Lk4U6SUQiqD7+YQoQyT0uL+6q0q87hcPq1cGqgnO77kiSjEGOzRVBcXHXJFSGE+Uq76CwWC3HRtVtiI9Ztsb1Q6KorLi7CZqv9MASvn6mUagI011pvd9vWCbgXaAzM1lovrHUkwivx8Ynk5maSmNiMyMioejHkU4hQYnc4jKoLQFxMBFZr7f5GIyKsZRNcza7IXx2n00lxcRG5uZkkJNS+moMvaewloBswBEApFQ8sB0oX9JihlBqntf6h1tGIGsXGGuvFHD2ahd0e/P8tBTOr1Vqnpfnrk/p8bfML7ZwoMFpGNnsUhwpq3wFVkF9MQZGdE4CzMAaLJTivrc0WQUJCUtn7U234koyGAR+4PZ6BkYjOATYAqcD9gCSjAIuNbXBaP3RhqFhqSfhPfb62T85ey66Dx2jSMJpnbx2O9TR6L9bsyOD1L7cA8OfLBtCjQ1LYXltfUnYLYJ/b47OBtVrrBVrrQ8BMYIAfYxNCiJCSnn2CXQeNFVGH9W55WokIoHv7xLKvt+85clrnCna+JKNiwL1U7Wjge7fHuUATP8QkhBAhacXWU8uBDOt1+ovWJcRF0b65sbT89t2Vl5EIJ74ko1+Ai5RSFqXU+RiDFpa47W8HhHfqFkKIKjicTlZsMZJR59YNadXEP13pPToagwJ+Tz/OyYLwvU/sSzJ6FaM1lAN8BuyifDIaCWz2X2hCCBE69N5cso8ZK8Sm9PbfUt49OjQGjGSn94Vv68jrZKS1ng1cg5GAPgTO1loXQ9mw70QgfBYhEUIIH6RtTgcgwmZhcI8Wfjtvt3aNykoDhXNXnVej6ZRSNqAN8D+t9QcV92uts4Ez/BybEEKEhMIiO2t1JgD9kpv6XIuuOjFREXRp3ZBf9h9l+57wTUbetowiMbrlbghgLEIIEZLW/ZJBYbExMXW4H7voSvXoaHTVHcg6Qc6xAr+fPxh4lYy01gVAFnAisOEIIUToSXMNXIiPjaRPZ/8PKu7R4VRlg42/Zfn9/MHAlwEM84EpgQpECCFC0ZFjBWX3cs7s2cLnCt3e6Ny6IdGRRuHUTb9m+v38wcCXq3Y/0EopNUsp1UcpFROooIQQIlSs2HqI0nrVw/v4v4sOIMJmpVu7RAA2/poZlpX7fSkHlAE4gX7AlQBKqYrHOLXWsnqsEKJecDqdZV10bZo2oEOLhIC9Vo8OSWzelU1GTj6Zufk0T4oL2GuZwZfEMRsIv3QshBC1tPvQcdKzTwLGwIVAVtHv2fHUfaNte3LqbzLSWl8bwDiEECLkpG02WkUWC5zph/I/1WnbPJ742Ejy8ovZtjuHMf3bBPT16posrieEELVQYnewavthAHp2bExSQnRAX89qsZSNqtuxJwdHmN03qtX9HddaRol4SGZa672nGZMQQgS9TTuzy1Z09Wf5n+r06JjEmh0Z5OUXsz8jj/YBvEdV13xKRkqpS4GHgR7VHGY7rYiEECIElA5ciImyMaBbszp5zZ5u84227c4Jq2TkdTedUmoq8B+MBPYmYAE+BuZiLC+xDnjc/yEKIURwycsvLpt8Oqh787I5QIHWLDGW5knGSj7hVhrIl3tG9wHbgf7A313b3tNaXwoMAhTGiq9CCBHWVm07jN1h3LOpqy46AIvFQr+uRivsl325lNiDa/nx0+FLMuoLzHKVBiq9AjYArfUW4C3gQf+GJ4QQwSdti1Ghu0nDGLq6JqPWlb6uZFRYbC9bVTYc+JKMbEC26+t81+dGbvs10NsfQQkhRLA6mHWC39OPA8bcotNdWtxX/ZKbln0dTl11viSj/UAHAK11PkZFBvdlIxRSSFUIEebclxYPRIXumiQ1jKFNU2MV2e27w2dxbV9G06UBEzh1v+hr4G6lVD5GUvsj8I1/wxNCiODhcJwq/5PcphEtGptTBaFHhyQOZJ1g58FjFBSVEBMV+lXYfGkZvQYsU0rFuh4/hNE19yhGgtqJMchBCCHC0o69OeQcN5YWN6NVVKqna30ju8PJL/uOmhaHP/lSDmgNsMbtcSbQXynVF7AD27XW4TO0QwghKvjJVf4nwmZlcI/mpsWh2iditVhwOJ1s33OEvl38v4ZSXfNlntEopVSlmV1a601a661AY6XUKL9GJ4QQQaKgqIR1v2QA0L9rUxrE+G9pcV/FRkfQqZUx4bV0LaVQ50s33VJgYjX7x7uOEUKIsLNOZ1JUbHT+mNlFV6qHq4r33ow8jp8sMjma0+dLMqpp/KKNU/OPhBAirJQOXGgYF0nvTo1NjgZ6dDgVw469ueYF4ie+Vu2urkzscCA8F2cXQtRr+zPy2OGa0zO0Z8uALC3uq+Q2DYmMMOIIhyHe1Q5gUErdBdzltulFpdRTHg5NAhoC7/kxNiGECApzl+3EibGMw5gBrc0OB4DICBtd2zZi2+4ctoXB5NeaRtPlAntcX3fEqMBwuMIxTmALsBJ4wY+xCSGE6bbvPsLmXUbxmVH9WtGqSQOTIzqlR4cktu3OISMnn+yjBTRpFGN2SLVWbTLSWs8CZgEopX4H/qK1/rouAhNCCLM5nE7mLNsJQHSkjQtGdDI5ovJ6dmzM59/vAmDbniOM7Bscrbba8GWeUXD9FIQQIsBWbz/MnkNGHbqzhrSjUXxgV3P1VYcWCcRFR3CysITtu3PqRzJSSjUBmmutt7tt6wTcCzQGZmutF/o/RCGEqHvFJQ7muVodDeMiOWtIe5MjqsxqtdC9QxLrf8lk+54cnE4nljou3OovvgwJeQlXlx2ULT2+HKMm3WXA/2TSqxAiXCz9+QBZRwsAOH9EJ2Kjg7P+Ww/X6q9HTxRxMCt0a1X7koyGAfPdHs8AWgPnuD5vB+73X2hCCGGOkwXF/DdtNwAtkmIZ1S94u796dnRbijyER9X5koxaAPvcHp8NrNVaL9BaHwJmAgP8GJsQQphi/sq95OUXA3DR6C5BMa+oKi0bx5EYHwWEdmkgX65wMRDr9ng08L3b41wg9Kv1CSHqtSPHCkhda/zf3aV1Q86oXJIzqFgslrJqDHpfDnZHaBbC8SUZ/QJcpJSyKKXOxxi0sMRtfzsg9KcBCyHqtS+X/05xifGGPn1sckgMCCjtqssvtLPbNfov1PiSjF7FaA3lAJ8BuyifjEYCm/0XmhBC1K39GXn8tCUdgAFdm9KtXaK5AXmpdBADhG5XndfJSGs9G7gGIwF9CJyttS6GsmHficCcAMQohBB14rPvd+J0gsVi3CsKFY0bxpStOrs9RAcx+DRWUWv9AfCBh+3ZwBn+CkoIIera9j05bNpZWvanNa2bBk/ZH2/07JjE4SMn+XX/UYqK7URF2swOySfBO0RECCHqiMPpZO7S3wCIirQGXdkfb/R0ddWV2B38eiD0liKXZCSEqPfW7sgou/F/1uD2JAZZ2R9vqPZJZYvOheJ9I0lGQoh6rcTu4PPvjWKoCXGRTB4afGV/vBEfG0n7lq6lyPeE3sBmSUZCiHpt6c8HyMx1lf1JCd6yP94o7arbfeg4JwuKTY7GN5KMhBD11smCEr75aTcAzZNiGd0/eMv+eKOHa76R0xl6S5FXmYyUUrtck1tLH/9dKdW7bsISQojA+3bVnrKyPxcHedkfb3Rtm0iEzbhzFGr3jaq78u2BBLfHjwJ9AxqNEELUkZzjhaSuMcr+dA6Bsj/eiI600aV1I8BYbC+UVJeMDgB9KmxzBjAWIYSoM18u30VRadmfMV1CouyPN0q76tKzT5JzvNDkaLxX3Z26r4D7lVKTOVVz7mGl1E3VPMeptR7vt+iEECIADmTm8eNmo+xP/+SmqPZJNTwjdPTs2Jgvl/8OwI49OQzr3dLkiLxTXTJ6AKMO3QSgA0arqBkQVwdxCSFEwHy2zK3sz5jQKfvjjU6tEoiJslFQZGfb7iOhn4y01vnAI64PlFIO4G6t9X/qKDYhhPA7vTeHja6yPyP7tqJNiJX9qYnNaqVbu0Q27cwOqUoMvgwduQ5IC1QgQggRaE6nkzmlZX8irFwworPJEQVGowbGYnulS2GEAq9nd2mtZ5V+7arSXVq86XdXoVQhhAhqa3Zk8Hu6UfZn0pB2JCWEXtmfcOXTVGOlVD/gZWBEhe3LgTu11pv8GJsQQvhNid3BvO93AUbpnLOHdjA5IuHO62TkmvD6IxCDMdJuq2tXL+A8YLlSarjWemsVpxBCCNMs+/kAGbn5AJyf0jGky/6EI19+Go8DxUBKxRaQK1H94DrmIv+FJ4QQpy+/sISvS8v+JMYyZkAbcwMSlfgygGEU8Kqnrjit9RbgNYxlyYUQIqi4l/25cHTnkC/7E458+Yk0AA5Vsz/ddYwQQgSNnOOFLFptlP3p1CqBwd2bmxyR8MSXZLQLmFLN/imuY4QQImh89eOpsj+XjE0Om7I/4caXe0azgX8opf4DPAXscG3vATwITAL+4t/whBCi9g5knWD5JqPsT78uTcKq7E+48SUZPQ8MBC4FZgCls6msgAWYA/zTr9EFiFLqMWA60B24XGv9ickhCSEC4HO3sj8Xh1nZn3Djy6RXOzBDKfUOMJVTk153AV9qrRf7P7yA+RW4C3jC7ECEEIGh9+aw4bcsAEb0aUWbZvEmRySq4/NAe611KpAagFjqjNb6QwCl1ENmxyKE8D+n08ncZTsBo+zP1JHhWfYnnJg660sp1QqjhTIUGATEA2O11ss8HBuNMY/pKiAJ2Ag8pLVeUmcBCyFCwjqdya6DxwCYOFjK/oQCswfbK4ylKtoCNZUSmgncA3yIkcAcwLdKqWGBDFAIEVpK7A4++95oFUnZn9Bhdj2MdUBTrXW2Umoq8IWng5RSQzAGTtyjtX7RtW02sAV4FmNCbumxy6h68u2ftdbP+yt4IUTw+X7DQTJyjLI/5w3vSFyM2W9zwhum/pS01se9PPRijFJE77g9t0Ap9S7wlFKqldY63bV9jN8DFUKEhBK7g/+t2A1As8QYxg6Usj+hIlT+ZRgA7NBa51XYvhpjWHl/jAoQXlFKRQI2jG7KSKVUDFCktQ6dxT+EEJWs2ZFBbl4RAFOGdZSyPyHEq2SklIrFmJejtdarAhuSR62AAx62lyag1j6e723gGtfXIzEm9I4FlvlykiZN6maoaLNmCXXyOvWRXNvAqetr63Q6WbrhIACJ8dFMGZ1MVKStTmOoKzVd25iYSACsVkvI/I572zIqxHgDvwswIxnFumKoqMBtv9e01tcC155eSJCdnYfD4Tzd01SrWbMEMjO97c0UvpBrGzhmXNtf9uXy275cAEb1a8XR3JN1+vp1xZtrW1BgFIV1OJxB9TtutVqq/Cfeqzasq/tqH9DQj3H5Ih/wNDYzxm2/EKIeS11jFEONsFkYO7CtydEIX/nSoToLuMo136eupWN01VVUuu1gHcYihAgymbn5rP81E4ChPVvQqEGUyREJX/kygCENuBDYoJR6DaOkTqV2sNb6Bz/F5m4DcJdSKr7CIIahrs8bA/CaQogQsWTdfpyuHvOJg9qZG4yoFV+SkXsJoJeAijdLLK5tgbhj+BlwH3Aj8CKUVWS4DvhJay0tIyHqqfzCEn7YaLwFdG+fSPsWoXHDXpTnSzK6LhABKKUedn3Zw/X5KqXUCCBXa/1vAK31KqXUXOA5VwmhnRij4Trgh4EIQojQ9eOmdAqK7ABMGtze5GhEbflStXtWgGKoWDn7etfnPcC/3bZf7Tr2aozadJuAc7TWPwUoLiFEkHM4nKSuNQYuNE+KpW9yE5MjErVl+qRXrbVXyy5qrQuAP7s+hBCCDb9lkXXUmOExcVA7rLKKa8jyKRkppdoBj2Gs6tocmKy1/k4p1QyjRtzrWus1/g9TCCEqW+Qazh0bHUFKn5YmRyNOh9dDu5VSnYC1wEXAVtwGKmitMzGWgLjR3wEKIYQnew4d5xfXJNfR/VoTE2V6R484Db789J7CWLahN8Yk04wK++cD5/kpLiGEqFZpq8hqsTD+DJnkGup8mfQ6AXhNa72PysO6wRhwIL8RQoiAy80rZPX2wwCcoZrRpFFMDc8Qwc6XZNSQ6itjRxEEAyKEEOHvu/UHsLvqQk4cLJNcq+J0BrZ2pj/5koz2Ab2q2X8m8NvphSOEENUrKraz7GejiH/n1g1JbtPI5IiCTygOKvQlGc0DrldK9Xbb5gRQSl2EscTEHD/GJoQQlazYeoi8fKMq9SRpFYUNX5LRU8B+jCUkPsRIRH9RSq3ASEIbgX/6PUIhhHBxOp2krt0PQFJCNAO7NTM5IuEvXicjrfUxYBjG0t+DMGrRTQQU8Bow1jUxVQghAmLr7iMczDoBwIQz2spKrmHEpwEHroR0F0YF7WYYCSlTax06d8mEECErdY3RKoqKtDKqv68LPItgVuvRb66JrkIIUScOZp1g865sAFL6tKKBa2ltER58TkZKqUuAaUBn16ZdwBdaaxm8IIQImMWugqggaxaFI6+TkVKqAfAlMA6jey7XtWswcIlS6mbgfK31CT/HKISo5/Lyi0nbcgiAvl2a0LJxnMkRCX/zdTTdeOAVoLXWurHWujHQ2rVtrOsYIYTwq+83HKCoxAHIcO5w5Us33Qxgrtb6bveNWutDwN1KqTauY+6u/FQhhKidEruDJeuMgQttmzWgR4ckkyMSgeBrOaCl1ez/znWMEEL4zdodGeTmFQHGvSJLKJYXEDXyJRltArpWs78rsPn0whFCiFOcTmdZde6EuEjO7NXC5IhEoPiSjB4GblJKVVomQil1AcZaRn/1V2BCCPHbgaPsPnQcgLED2hAZYavhGSJUVXnPSCn1nofNvwNfKqU0sN21rQdGFYbNwBUY3XVCCHHaSltFETYLYwfKCjXhrLoBDNdWs6+768NdX6APcMNpxiSEEGTm5rP+F2Nu/dCeLWjUIMrkiEQgVZmMtNZS9EkIYZol6/ZTuhyPTHINf5JwhBBBJ7+whOWbDgLQvX0i7VskmByRCDRJRkKIoPPj5nTyC+0ATBrc3uRoRF3wqTadUmo48EeMYdxNMMoCuXNqrbv4KTYhRD3kcDjL6tA1T4qlb3ITkyMSdcGX2nQ3AW8ARYAG9gYqKCFE/bXhtywyc42l0SYOaodVJrnWC760jP4KbADO0lpnBSYcIUR9l+oazh0bHUFKn5YmRyPqii/3jFoA70oiEkIEyp5Dx9H7cgEY3a81MVG1XnJNhBhfktF2QCoUCiECJtV1r8hqsTD+DJnkWp/4uoTEbUopWetXCOF3uXmFrNp2GICBqhlNGsWYHJGoS163gbXW85RSccA2pdRXwG7AXuEwp9b6CT/GJ4SoJ75bfwC7w5jlKmsW1T++jKbrBjyOsUzEVVUc5gQkGQkhfFJUbGfZzwcA6Ny6IcltGpkckahrvtwdfA1oDtwFLAdyAhKREKLeWbntMHn5xYCU/qmvfElGw4D/01q/EqhghBD1j9PpLBvOnZQQzRmqmckRCTP4MoDhKJAZqECEEPXTtt05HMg6AcD4M9oSYZMqZfWRLz/1OcCFgQpECFE/la5ZFBVpZXR/GaxbX/nSTfcmMEsp9SXwMsZCexVH06G1ljJBQgivpGefYPOubABS+rSiQUykyRGFF6fZAfjAl2S0FeN7GwRUWnrcjawLLITwSura/WVfT5BJrn4UevX8fElGjxNaiVYI4SdZR/PJchUv9caho4Xk5p6s9pgSh4O0zekA9O3ShFZNGpxWjCK0+TLp9dEAxiGECFJ7Dx/niVlryyakBoJMchUybEUIUa35K/cENBF1adOQHh2k7GV950sFhlHeHKe1/qH24QghgsmRYwWs3WHM6Oif3NTrFkxiYlyN3XQAVquFDi0TsMiaRfWeL/eMluHdPSMZwCBEmFiyfj8Op/Fnf15KRzq1aujV85o1SyAz83ggQxNhxpdkdF0Vz+8CXItROPXN0w9JCBEMCovs/LDhIABd2zbyOhEJURu+DGCYVdU+pdT/Aev9EpEQIiikbUnnREEJIPXiROD5ZQCD1joHeAe43x/nE0KYy+F0ssg1B6hpoxgGdpN6cSKw/DmaLgfo7MfzCSFMsnlnNoePGAMQxp/RFqtVBhiIwPJLMlJKxWCscXTIH+cTQpirdPnv6CgbI/tKvTgReL4M7X6vil2NMZaXaAb82R9BCSHMsz8jj227jeXKRvZtRVyML+OchKgdX37Lrq1i+xHgF+AerfV/TjsiIYSpSltFFqRenKg7voymk2oNQoS5YyeKWLH1MAD9uzaleVKcyRGJ+kISjBCizLKfD1BidwBSL07ULUlGQggAikscfPfzAQDat4inW7tEcwMS9Uq13XRKqa99PJ9Ta33BacQjhDDJ6u2HOXaiCDBaRVIvTtSlmu4ZTfHxfLLekRAhyOl0kupa/rtRgyiG9GhhckSivqk2GXkzaEEpNRp4DhgMpPspLiFEHdJ7c9mbkQfAuIFtiLBJD76oW7WeQKCU6g08C0wGjgN/A/7lp7iEEHVokatVFBlhZfSANiZHI+ojn5ORUqod8ARwBWAHXgae1Fpn+zk2IUQdOJxzko2/ZQEwrFcLGsZFmRyRqI98qcCQBDwE3AZEAx8DD2utdwcmNCFEXVi8dn/ZzV6pzi3MUmMyUkpFA3cDDwCJQCrwgNZ6QyADE0IE3smCYn7cZNzq7dUxiTbN4k2OSNRXNQ3tvgF4FGiNsV7RX7TWS+ogLiFEHfhhYzqFxXYAJg5ub3I0oj6rqWX0NsZw7bXAHKCfUqpfNcc7tdYv+Cs4IUTg2B0OlqwzBi60ahJH786NTY5I1Gfe3DOyYAzbHuzFsU5AkpEQIeDnX7LIPlYIwIRB7bDKJFdhopqS0dg6iUIIUedKh3M3iIlgeO+WJkcj6ruaJr1+X1eBCCHqzq6Dx/jtwFEAxgxoQ3SkzeSIRH0n06yFqIdK1yyyWS2MGyhrFgnzSTISop45cqyAtTsyABjcvTlJCdEmRySEJCMh6p3v1h/A7jCmuU6UNYvCWwiVrpZkJEQ9Ulhk5/sNxppFyW0b0alVQ5MjEoEQigMjJRkJUY+kbUnnREEJAJOk9I8IIpKMhKgnHE4nqWv3A9CkYQwDujU1OSIhTpFkJEQ9sWVXNoeOnARgwqC22Kzy5y+Ch/w2ClFPlK7kGh1lY2Tf1iZHI0R5koyEqAf2Z+axdXcOACP7tCIuptbragoREJKMhKgHSltFFowuOiGCjSQjIcLcsZNFrNh6GID+XZvSPCnO5IiEqEySkRBhbtnPByixOwCYJJNcRZCSZCREGCsucbB0vTHJtX2LeLq1SzQ3ICGqIMlIiDC2evthjp4oAmDioHZYQnFqvqgXJBkJEaacTmfZwIVGDaIY0qOFyREJUTVJRkKEqV/25bI3Iw+AsQPbEBkhf+4ieMlvpxBhqnQl1wiblTED2pgcjRDVk2QkRBg6nHOSDb9mATC8dwsaxkWZHJEQ1ZNkJEQYWrJ2f9lSNhOkOrcIAZKMhAgzJwtKWL45HYBeHZNo2yze5IiEqJkkIyHCzPJNBykssgOykqsIHZKMhAgjdoeDxa41i1o2jqN35yYmRySEdyQZCRFGfv4li+xjBYDRKrLKJFcRIiQZhYEjxwp4ce7GsgmOwn8ycvN5Yc5Glv18wOxQvLJorfE70CAmguG9WpocjRDek2QUBt757zY27czm4yW/4nA4a36C8Npr8zazeVc2sxdqs0OpUWGxnd/2HwUgpU8roqNsJkckhPckGYUBvS/X7BDCVmkFg1Dg/o9IUkK0iZEI4TtJRkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTRZgdQIiyAVitdVNqpabXaZ4Ui9N56ti6iisceHNtvT3WbDabtSzeBrGRpsdr9uuHs5qubcMGUTRPiiU+Liqofg5usVSakW1xOmXGfi2MAJabHYQQQoSokcCP7hskGdVONDAYSAfsJscihBChwga0AtYAhe47JBkJIYQwnQxgEEIIYTpJRkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSW26IKSUigYeB64CkoCNwENa6yWmBhbilFKDgWuBsUAHIBtIAx7WWv9mYmhhRyl1P/AssFFr3d/kcMKC6/f3UWA4EAnsBF7QWs80MSy/kZZRcJoJ3AN8CNwFOIBvlVLDzAwqDDwAXAgsxriubwFjgJ+VUj1MjCusKKVaAg8DJ8yOJVwopc4GfsJIQn8D/oTxe9zOzLj8SVpGQUYpNQS4FLhHa/2ia9tsYAvGf5qjzIsu5P0LuFxrXVS6QSn1KbAZI1Fda1Jc4eYZYC3GP7uJ5oYS+pRSjTD+QX1da32XyeEEjLSMgs/FQDHwTukGrXUB8C4wQinVyqzAQp3WOs09Ebm2/QpsBaRl5Aeuf6auBO41O5YwcjlGUv87gFIqQSkVPOtC+Ikko+AzANihtc6rsH01YAH613lEYcz1R90CyDI7llDnupavALO01htMDiecTAB2AOcopfYBx4AjSqlnlFKV1gUKVdJNF3xaAQc8bE93fW5dh7HUB1cAbYCHzA4kDFwN9ASmmhxHuEnGuDc0E3gO+BmYgtG1HAPcbVZg/iTJKPjEUmGdD5cCt/3CD5RS3YFXMRb5+sDkcEKaUioB417RM1rr9JqOFz6JxxhV+xet9bOubfOUUvHAbUqpJ7XWId+yl2664JOPsXhfRTFu+8Vpco34+h+QA0zXWjtMDinUPQwUYQwSEf5V+jf/cYXtH2GMrhtSt+EEhrSMgk86RlddRaXbDtZhLGHJNTrpW6ARkKK1PmRySCHNNajmbowhxy2UUqW7YoAopVRH4KjWOseUAENfOtALOFxhe+njpLoNJzCkZRR8NgDdXU1wd0NdnzfWbTjhRSkVA3wDdAOmaK21ySGFgxZAFMbUg9/dPoZijFL8HeP+hqidda7PbSpsb+v6nFmHsQSMJKPg8xlG0/vG0g2uigzXAT9praVlVEuukUefAsMwuuZWmhxSuPgdmObhYyuw2/X1bLOCCwNzXZ9vKN3gGrl4I8bE4rD4PbY4nU6zYxAVKKXmYIxIegGj5Mc1wGBgrNb6JxNDC2lKqRcxKi98A8ypsDtPa/1lXccUzpRSy4BEKQd0+pRSszDKg70LrAfOdX3cr7X+PzNj8xe5ZxScrgaecH1OAjYB50giOm39XZ/Pc3242wN8WZfBCOGDm4C9GP+YXgPsAm7RWr9palR+JC0jIYQQppN7RkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSTISQghhOklGQgghTCfJSIQUpdQYpZRTKXWt2bGcLqVUb6VUiVJqotmx1AdKqQuUUkVKqa5mxyIqk2QkhHn+hVGJPdV9o1KqsSvhfmtSXAGjlPq3UuqAq+p0VceU/sNxnz9fW2v9FbAZY6kLEWQkGQlhAqXUMGAinldGHej6vL7uIgo8VwKaCnyltTarKOZLwDSlVC+TXl9UQZKREOa4DcgC5nvYF5bJCGMZlDaYWx19HnASuMXEGIQHsoSECAtKqabAY8D5GCuPHga+Bv6utc6ucGxH4J8YLROApRjLZi8FdmutxwQ41giMFsJ/tdbFHg4J12Q0DcjFuM6m0FrnKaWWAxcDd5gVh6hMWkYi5CmlGgFpwK3AQozEssD1+EelVILbsU2A5RjrGc3EWA77BMYbZIM6CvkMIB5YXcX+gUCO1vr3OoqnrkwD5leRgOvSCqClUqq7yXEIN9IyEuHgfqAr8Eet9WulG5VSG4B/u/b/zbX5AaAtcKXW+iPXtteVUs8Bf66jeHu6Pu+suMOVOJMxsfUQCEqpHoACHjY7Fk5d917ADjMDEadIMhLhYBqQCbxVYfubwCOu/aXJ6DwgHfi4wrHPU3fJqJnr8xEP+wYAFsKvi24qUIDRYvUrpVRLjFWRuwMZwFyt9bpqnlLabdvc37GI2pNkJMJBJ2Ct1rrEfaPWukQp9Qun7sGUHrtaa+2ocGyGUirXfZtS6hLgTozlyrO01h0r7I/AuPd0FUaX9+cYrbOCGuItHUnmaXjzGa7PVSYjpdRIwNOw7yjAprW2VTj+NYwuy+Fa6xUV9i0DRmMsa/+t2/ZLgE+B/2mtp7i2dQOeA1KAGFz35bTW91YVq5tpwGKtdZ4Xx3pNKXURMA54F3gFI8FcrpS6GPhrFaP2Sq+7LHMdRCQZCVG1HIxuvhbAPR72/xUYC/QBijAGTDyHkcCqk+n63NjDvhoHL2itl2PccyqjlGoNrHXF6749FrgcoxV2I8b9kop2ADdQPsHdSOUurP9hjEa7EmNEWheMxFQtpVRbYBBwU03H+kIp1RvoqLX+o9vmPcA/lFJnYoyYe93DU0uve6aHfcIkMoBBhINdgHK1VMq4Hndz7S+1G0hWSlkrHNscSHTfprVO1Vp/gvEG58mNwNNa6wNa60zgUeBapZStiuNLbXF99lQJYCCQB/xSwznKKKWiMZLEj1rrpyvsng44MAZ1XKKUiqeyOcA4pVQz1/k6YLQGv3R7jaYY97Le0Frnaa0dWutftdYzvQhxKkYr5GtvvycvXYjneVporVcCTSv+Trgkuz5v8bBPmESSkQgHX2Lch7mxwvabXNu/cNv2DdAKuKzCsT7N9ldKJQLtgA1um9cDCUDHGp7+M3AMOLPCOeMwbvJv8HFS6BsY3WbXeth3I/AJRsIpBi71cMxxjGt0tevxDcB/gMLSA7TWWcB24D2l1KVKqS4+xDcNI1H6uyVysvQ6KaWGKaWylFLuAyTWYfwzUtGZwGGttfZzPOI0SDedCAfPYbQAXlVKDcR4sx+A8aaqXftLPYvRbfW+UmoIRlfUSGA4xiRUb5NA6XDxXLdtuRX2eaS1tiul5gFTlVLRWuvSN/1+gA2IUUr9xcNT87TWFbvh7gSmAIO11icr7OuG8b39WWtdqJT6BOOavOPh3O8C7yilXsRIaucCF1U4ZgxG0v4r0FMptRf4i9Z6TlXfq1KqMTAKY0Sjr8YrpWI8bM/SWr9RYVs/oAnluw2PUeFn4WoZjgTeq0U8IoCkZSRCntb6KMab0JvAOcDLrs9vACO01sfdjs0CRgD/Ba7HSE4NMO79WIB8L1+29JyN3LYlVthXndddx09x21Z6v2gQ8A8PH9PdT6CUGuuKf7rWereH17gR2KG1XuV6PBM401MpHK11Gsb3/yhwSGu92cMxGVrr+7XWfTHuu7wG/KeG+TpTMP7p/aKaY6oyGXjCw8fdrv2xbse+g9ECu8ZtWz/g1wrnvAiIw/hdEUFEWkYipGitl+FhFJqrC+g210dN5/gd435DGddk2CbAXi/jyFVK7cO4t1La3TMAIxHt9uL5q5VSpRN0P3dtexV41ZvXd1WRmIPR6lnmYX8kRrdbI6XUoQq7bwA8jYB7F6MVeasX8R8DnldKPUj183WmARurSJZVnXsZnkcaVrRbKTVca53mGkn5ZekO10TojlrrisPn7wK+0FrL/aIgI8lI1DtKqVitdcUWUGm3WKrbcTYg0vVhcXUZOd261d4BHnSVlynGaFXM1FrbvQzlT8BGpdQkrfUiH+KPw3jj/bpit52b84AkjATp/oZ8JfCAUuovWuuiCs95C+MeWJqH10zCmIf1EcbgCitGd14cxr2ZqqwA3q72G6q9D4GXlFIN3CufK6U6YbSgyiVcpdRUoDcwI0DxiNMgyUjUR/OVUnswBhxYgfEY3UlplC/ieRXwvtvjfIyRdR1dj58GmgJbXef5DKPCg1e01lup3d/gRRhdUN2UUp7eWHtidNF9rLXe5r5DKfUG8BDGCLdy93pcrZ3FVbxmEdASY0RcC4zBDVuB86tr9Witn6tq3+nSWjuVUncDtyulbsQYNWjFmNR8V8WahFrrLzHmYokgZHE6Zd6XqF+UUn/C6MLqiHHfYT/G0OjH3O8vCSHqjiQjIYQQppPRdEIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSTISQghhuv8HejwwbWv8RfwAAAAASUVORK5CYII=\n", + "text/plain": [ + "<Figure size 432x288 with 1 Axes>" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "# make a plot of the luminosity distribution using Seaborn and Pandas\n", "import seaborn as sns\n", @@ -412,7 +451,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "1f37d2c0-1108-4ab9-a309-20b1e6b6e3fd", "metadata": {}, "outputs": [], @@ -420,16 +459,45 @@ "# Update the probability distribution to use the three-part power law IMF \n", "population.update_grid_variable(\n", " name=\"M_1\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)\",\n", ")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "6f4463e8-1935-45f2-8c5f-e7b215f8dc47", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Do dry run? True\n", + "Doing dry run to calculate total starcount and probability\n", + "Grid has handled 39 stars with a total probability of 0.211729\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 39 *\n", + "* Total probability is 0.211729 *\n", + "**********************************\n", + "\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", + "**********************************************************\n", + "* Population-1d1d556abeae4549aa28f9740807dc84 finished! *\n", + "* The total probability is 0.211729. *\n", + "* It took a total of 3.90s to run 39 systems on 2 cores *\n", + "* = 7.80s of CPU time. *\n", + "* Maximum memory use 519.211 MB *\n", + "**********************************************************\n", + "\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" + ] + } + ], "source": [ "# Clean and re-evolve the population \n", "population.clean()\n", @@ -441,10 +509,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "id": "cfe45a9e-1121-43b6-b6b6-4de6f8946a18", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[None]" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEdCAYAAABDiROIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAABEJElEQVR4nO3dd3hUVfrA8e+kBxJIgAAhIC3wgoCA0nsVxQYKYl97Wxu7lnV1f3ZXXfvaK7ZVwYoFpYnSq3Q80msCAUIJJJAyvz/uJEySSTITZnJnkvfzPDyTnHvmzjuXyX3nnHvuOQ6n04lSSilltzC7A1BKKaVAE5JSSqkgoQlJKaVUUNCEpJRSKihoQlJKKRUUIuwOIERFA92BNCDf5liUUipUhAPJwGLgWMmNmpAqpzsw2+4glFIqRPUH5pQs1IRUOWkAmZlHKCgI7H1c9evHsW9fVkBfo6bSYxs4emwDJ5SPbViYg8TE2uA6h5akCaly8gEKCpwBT0iFr6MCQ49t4OixDZxqcGw9XurQQQ1KKaWCgiYkpZRSQUETklJKqaCgCUkppVRQ0ISklFIqKOgouxCUnX2ErKwD5OfnFZXl5hWQX+AkOjIch8PG4ELInj1hFBQU2B1GtaTHNnCC8diGhYUTERFFfHwCkZFRld6PJqQQk519hMOHM0lISCIyMgqHw0FBgZNtuw9DONSuG0OdWpX/QNQkERFh5OUF1x92daHHNnCC7dg6nU4KCvI5diybzMw9xMcnEhtbu1L70i67EJOVdYCEhCSioqJxuJpCefknPpyHjxy3KzSlVA3kcDgID4+gVq14EhIacOTIwUrvSxNSiMnPzzupJrFSSgVKZGQ0eXm5lX6+JqQQ5NCLREqpIHSy5yZNSEoppYKCJiSllFJBQROSUgEyZsx5PPHEw7a89m233chtt91oy2sXSkvbRb9+3fjxx++C5vWfeOJhxow5z7bXPuusQQF/7bJePxTU2GHfIvIIMBZoB1xmjPnM5pBqrLS0XYwde36F9f75z4cYObL4yWTfvr1ceOE5FBQUMGnSdzRu3LjU82677UaWL19Gy5at+OijiaW2z5w5nf/7v38A8PLLb3D66d2Ktq1YsZwPP3yPjRvXc+jQQRISEklNbcuwYSM488yzfH2rNd6CBfNYs2YV1113k92heG316lUsXDiPiy++jPj4eLvDKSYUj2d5amxCAtYDdwKP2R1ITZeQkMi//vWox20FBQX8978vkJ19lDZtpNT2GTOmEhMTQ3h4BNOn/8QVV1ztcT9RUVFs3ryJDRvWk5rapti2adN+IioqmuPHiy9gOXPmdB566H7atGnL2LGXEB9fh7S0XSxfvozvvvs6qBPSCy+8ancING6czIwZc4mIOHGaWbhwPpMmfWrbCfS++x70+abStWtX8f77bzNy5HleJyRP7z0QyjqeVfX6/hZa0fqRMeZjABF5wO5YarrY2FhGjBjpcdu7777JoUMHue22u2jTpm2p7dOm/US/fgOJiopi2rSfy0xIp5zSgqNHjzB9+s/FElJWVhYLF86jd+++/PrrL8We8957b9GqVWvefHMCkZGRxbZlZu738V1WrZLx2sHhcBAdHW13GMUE+gSdn59Pfn4+UVFRtr73YDz23rD9GpKIJIvIUyLyi4gcFhGniAwqo260iDwtIrtEJFtEFojI0CoOWVWR5cuX8eGH79G7d1/Gjbu81Pbt27exbt1ahg49k6FDz2TjxvVs2rSxzP0NHXomM2ZMxek8sbjZrFkzcDgc9O8/qFT9Xbt2cOqpHT2e3BMT6/n8ft5990369etWqvzHH7+jX79upKXtKiobM+Y87r//7yxevIBrr72cIUP6cu21l7N27WoApkz5nksuuZAhQ/pw2203smvXzmL7LHkNadmyJfTr141ff53JhAnvMGrU2QwZ0oc777yFHTu2l4ppxoypXHPNZQwZ0odzzx3Ov//9KAcOHChWZ/v2bTzwwD2cf/4Ihgzpw+jRI3noofvJyrJWMy15HeOJJx5m0qRPAejXr1vRv6NHjzJsWD9efPHZUnFs376Nfv268dVXk8o9tocPH+aJJx5mxIiBnHXWIB5//CGysg6XqufpGtL06T9z7bVXMHz4AM48cyBXXTWOiROtON99901efvl5AMaOPb8o5sL/q379uvHSS88xZcr3XHbZRQwZ0ofVq1eWew1nx47t3HXXrQwb1o8LLzyHTz75oNj2wv+rZcuWFCsv3Of3308u93i61y35+kuWLOKWW65l6NC+nHXWYB588L5Sn53Ca127d6dz333jGT68P+eeO4xXXnmR/HyP6+r5TTC0kAS4D9gArAT6lFN3AnAR8KKr/tXAFBEZaIyZH9AoVZU6dOggjz76LxIT6/HAA494vL9h2rSfiI+vQ48evXA4HNSrV59p037ippv+6nGfw4efxUcfvc/q1Svp1KkzYJ2M+vTpT61apac6adSoMUuWLCIjYw9JSQ39+wa9sHXrFh5//CFGjRrDmWfG8vHHH3DvveO5+ea/8sknH3LBBRdy9OgRPvnkA55++nFeeun1Cvf5wQfvEhYWzmWXXcXhw4f49NOPeOSRB3n77RMnxR9//I4nn3yEDh06ccstd7Bnz26+/PJz1q1bw9tvf0h0dDS5ubn87W+3Ex4exrhxl1G3bl12797NvHlzyMo6TEJCnVKvfcEFF7Jv3z4WLZpfrIu2Vq1aDBgwmF9+mcbtt48nPDy8aNvUqVOIiIhg6NDhZb4np9PJ/ff/nZUrlzNq1EU0b96C336bxeOPP1zh8Vi8eAEPP/wAAwcO5vzzR5Ofn8+WLZtZtWoFF198KQMHDmHXrh38/PMU7rjjb9StmwBY3czu+5g5cyqjR48lPj6eBg0alPl6eXl5/P3vt9O5c1duueUO5s2bw+uv/xeAyy//S4XxuivreJb9Xhdy99130KxZc66//haOHj3CpEmfcsst1zFhwqckJp54T3l5efztb7fRqVNn/vrXO1m8eCGfffYxKSlNGT16jE9x+iIYEtJSoIExZp+IjAK+9lRJRHoAlwDjjTEvuso+BFYDTwMD3OrOAgaW8Xr3GGNKfxVTQeXf/36MvXszePHF10hISPBYZ9q0nxgwYFBRN8ygQUOYPv1nbrzxVo8JrFWr1rRuncq0aT/RqVNn9u3by++/L+XRR5/yuP/LL/8LTz31GOPGjaJTp86cdloXunfvSceOpxEWFvjOhW3btvLWWxM49dSOACQlNeKhh+7n1Vdf5rPPvio6Oebl5fHRR++ze3c6jRqVHtThLi8vj/fe+6DomNWpU5eXXnqWTZs20KpVKnl5ebz++n9JTW3Lf//7JlFR1qwgIu14+OEH+O67rxkz5hK2bNlEWtpO3n77A9q371C0//KuDXXseBrNm7dg0aL5pbpoR4wYydSpU1i2bDHdu/cqKp827Sd69uxd9F49mTPnV5YvX8btt48vakmPGjWGO+64udxjATBv3lxatmzFE0/8x+P21NQ2iLTn55+n0L//IJKTm5Sqs337Nj76aCKnnNK8qMy9tesuJyeHfv0Gcvvt4wEYPXoM48ffxoQJ7zJ69Fhq1apVYcyFyjuenrz22kskJCTw+uvvFl0L69mzDzfffA0ffzyhKKbCOM866xyuvPIawDqe1157Od9//231TkjGmNLtas/GALnAO27PzRGRd4EnRCTZGJPmKh/k90CD3M6MLH5bmUZuXgHRkeEVPyFAYqLCOa9vS1o1Kf0N2VtffjmR2bNncfXV1xcb8ebujz/Wsn37NsaPv7eobOjQEXz11SRWrVrBaad18fi8YcNGMHHip9x5591Mnz6N2NhYevfuy4IF80rVPffcC0hKasjnn3/CsmVLWLp0Me+//zYpKU35178eo2PHTpV+j95o3bpNUTIC6NDB+rlfvwHFTtCnnmolhLS0XRUmpHPOOb/YdZTOnbsAsGvXTlq1SuWPP9aSmbmfG264pSgZAQwZMpxXX32JefPmMmbMJdSuHQfA3LmzSU1te9LXrLp160H9+g2YOvWnooS0du1qduzYzg033Fruc+fPn0tkZCQXXHBRUVl4eDgXXTSOFSt+L/e5cXFx7NmzmzVrVhcdX1+dfnq3YsmoIhdeOLbo57CwMEaPvoilSxexcuVyevUqr4Oo8vbu3cv69X9y5ZXXFBuY0bFjJzp06MT8+XOKJSSwWmDuTjutKz///GNA4itke0LyQVfgD2NMVonyRYAD6AKkebszEYkEwrGuo0WKSAxw3BgTPNPo+mDhuj2s31H5SQ39KTY6ghvP71BxRQ82btzAq6++ROfOXbnmmhvKrDd16hRq1apN48aNi66B1KtXj4SEBKZO/anMhDR06Jm8+earLFmyiKlTpzBgwOBiJ96SevbsTc+evcnJycGYdcyYMZVvv/2Ke++9i08++aJYN4e/lUwuhUmgYcNGHssPHz7k8z7j4+u4nmt9L0xPt/6ESp5gw8LCaNq0Gbt3W9ubNElh3LjLmTDhHT7//H907Xo6ffr058wzz/LY/VmR8PBwhg8/i++++5q7776f6Ohopk79idq1a9OvX/9yn5uenk6DBg2JiYkpVu5NkrjwwrH88st0brrpapKTU+jevQeDBw+je/eeXsfuqdVUlvDw8FL1mzY9BYD0dM+tKn8o6/8VoHnzFkyfPrVYWWxsLerUqVusLD4+3qvP2MkIpYSUDOz0UF6YhLz/VFjeBgo7bfsDHwKDgVmVCc5uPds35FhuflC0kIZ3b1ap5x47lsNDD/2TmJgYHnro8WLXEtwVFBQwY8Y0jh49wmWXle4+mDVrOnfddbfHEVVNmqTQoUMnPvrofdasWc1111XcrQMQExND585d6dy5K3XrJvD++2+zYMFczj77XK/fX1nzfBUUeL5QHB7uuVuwrO5Ct7EaZQoL83xMnd48uYTbbx/POeecx+zZv7Jo0QKef/5pPvzwPd58832Sk8tvqXly1lnn8NlnHzNv3mwGDBjMzJnTGDhwCNHRMRU/uZISE+vx/vv/Y9GiBSxYMI8FC+YxefLXnHPO+dx///95tQ9/x1f256TqviuX9dkLtFBKSLHAMQ/lOW7bvWaMuRprUESl1a8fdzJP91pS0okm9p49YUREFP+w5DudpCTFcenQNkRFhnNK4+C6ec9b//nPc2zZsolnnnmBJk2Sy6y3aNFi9u3by6233k7TpsWT3549u3nxxedYunQhffta36wdDgcOB0XHbcSIs3n++WdITKxHz549CQ8PIzzcOgmEh5c+viV16GC1/jIz91VY1+FwFNWpW9f6xpmdfaRYt8mePbs9vrb7c+FE/GFhxcsLTx7h4SfKC09qhb97quNeXrjPlBTre92OHdvo1u1Ed6nT6WTHju20bt262PPbtm1L27Ztue66G1i9ehXXX/8XJk/+iptuurXUvgtf3z0ud+3aCampbZg+/Wfi4+PYv38fZ589ssJj3KRJMr//voS8vGPExJw4Dezcua3U65c8LtbP0QwcOJCBAwfidDp57rmn+eKLiVxzzXU0bdrM7dh5/myEhZV+P57eu8PhID8/n4yMdFJSmhbV3bVrh+t9pBAREUZCwonPift+MzLS3WIu/3iWfP2mTU/8v5asu337VpKTk8s9RoX78lRe+niEFTtn+SKUElI24GlgfYzb9iq1b18WBQW+f7P0RVJSPBkZJy6zFRQUlFqcK9/td6fTGVSLd3nrl1+m8+23XzNmzDj69Olf7nv46acfiYuL4+KLLy/VCnI6nXzwwfv89NMUevbsW1TmdFK0z8GDh5OZmUlqaipOp4O8vALy863/x/z8E8d3yZJFdOvWo9Trz5kzB4CUlFMqPNbu/x/JySkALF26hH79rDE32dnZ/PDDd6Veu+Rz4UT8BQXFy/Nd62Hl558oL2zxFP7uqY57eeE+27RpT2JiPb76ahIjRpxTdG1o5szpZGTs4fLLryIvr4AjR7KIjo4pdvybN29FeHg4OTnHPO4bICrK+nPNzDzo8SbTESPO4e23XyM/P58GDZLo3PmMCo9xz559+Oabr/jyyy+KBjXk5+czceJnpV6/5HE5ePBAqQETLVumAnD0aA55eQVFMR88eJCGDUu3/AoKKP036eG9F772xImfF12vKSgo4MsvJxEbG0vHjp3JyysgKakx4eHhLFu2lL59T4zN+uKLE7OMVHQ8S75+QkJ92rRpy/ffT+bSS68iLs76Mr127WpWrVrJuHGXl3mMTrxPz+Wlj0dBsXOWu7AwR7lf5EMpIaVhdduVVFgWuA5YFVB792bw9NNPEBtbi9TUNmVeOE1JaUqbNsJvv/1C9+69PHbJORwOevfuyy+/TCc7O5vY2NIN58TERK677qYKV968//6/k5zchL59B5CSkkJ2dg5Llixk7tzZtG9/alELzFs9evSiUaPGPPXUY1x66RbCwsL54YfJJCQksnt3esU7qAIRERHccsvtPPnkI9x++00MG3Yme/bs5osvPqdVq9acd95owEqqL7zwDIMGDeWUU5pTUJDPzz9PweFwMHDgkDL3L9IegBdf/A89e/YmLCyMYcNGFG0fPvws3njjv8yZ8xuXXHKFV6MZ+/YdQKdOnXn11ZfYuXMHzZu35Lfffim6H6o8Tz31OIcPH+L007vRsGFDdu+23mubNm1p0aKlK+Z2ALz11msMHXomERER9O07wONnqyIxMTHMmfMrhw8fQqQ98+bNYenSRdx0021FI+zi4uIYNGgoX3zxOeAgJaUp8+bNJjMzs9T+Kjqe7m699U7uvvsObrnlWs4553yOHDnCpEmfUb9+gzJvKK9qoZSQlgN3ikhciYENhVcfV1R9SMoftm3bWnQT41NPPV5mvbPPPpe+ffuTlZVFnz79yqzXt29/fvzxO2bP/vWkpve5774HmT37V2bOnMbevRk4nVa3ylVXXcsVV/zF57v+IyIiePLJZ3nuuad45503qFevPhdffCnx8XV48slHKh2nv40ceR5RUVF88skHvPrqS9SuXZvhw8/i5ptvL7r7PzW1DT169GLevNl8++1XxMTEkJrahmeffbnc0Yf9+w9k7NhLmTbtJ6ZOnYLT6Sx2Am3QoAFnnNHDNZT5bK/iDQsL4+mnn+ell57j559/xOFw0LfvAG677S6uuab0DdXuRow4m8mTv+brr78gK+sw9erVZ8iQYVx77Y1FybBt23bcdNNf+eqrSSxcON81b+LkSiWkiIgInnvuvzz77L+ZMWMq8fF1uOmm27jyyquL1Rs//l7y8/P49tsviYyMYsiQYdx6651cddW4YvUqOp7uunfvybPPvsy7777JW2+9TlRUJN269eDWW+8M6OAcXzgqczEzUNzuQxpsjJlVYltPYAHF70OKxroPabcxpuwzlP+1ADbb0WWXnr6Vxo2Lj5Q5npvPrr1HAIiMCCMlqWqubYW6ilpIqvJO5tjee+940tJ2epwIVwX/59bTOaqQW5ddS2BLye1B0UISkQddP7Z3PV4pIv2AA8aYVwCMMQtFZBLwjIgkAxuxRsk15yQHJyilgsOePbtZuHAeN9xwi92hKBsERUKi9Izb17oetwKvuJVf5ap7FZCINdXQSGPM3IBHqJQKmF27drJq1Qq+/fYroqKiOffcUXaHpGwQFAnJGOPVQuzGmBzgHtc/pVQ1sXz5Mp588hEaN07mwQcfKXO6KFW9BUVCUkrVbCNHnldq8UVV89i+/IRSSikFmpCUUkoFCU1IISiYhuorpVShkz03aUIKMeHhEeTmHrc7DKWUKiU39xgREZVfisTrQQ0iUh9oaIxZ51bWEvgbUA/40Bjzc6UjUV6Ji0vgwIEMEhKSiIyMKnNmYKWUqgpOp5OCgnxycrI5cuQg8fGVn/XBl1F2LwFtgR4AIhIHzObEsg/jRGSIMea3SkejKhQba601c/DgXvLz8wDIy3eSlWVNaBkR5iA939MctKqksLCwKp3SvybRYxs4wXhsw8LCiYyMIjGxIZGRZa8vVhFfElJv4CO338dhJaORWPPMTQPuBTQhBVhsbO2ixASwfU8Wz3+9CICUpNo8dp33i4vVZCWnZVL+o8c2cKrzsfXlGlIjYLvb72cDS4wxPxlj0oEJWKu6qiqmnXZKqerAl4SUS/FF8AYCv7r9fgCo74eYlFJK1UC+dNn9CVwkIq8C52ENZJjhtr0ZsN+PsSmllKpBfElIr2J1y2UCtYBNFE9I/YFVfotMKaVUjeJ1l50x5kOs5R5mAB8DZxtjcqFoSHgCoAuYKKWUqhSvWkgiEg6kAD8YYz4qud0Ysw84w8+xKaWUqkG8bSFFYnXRXRfAWJRSStVgXiUk1zpEe4EjgQ1HKaVUTeXLsO8fgXMDFYiqPJ1qVSlVHfiSkO4FkkXkAxHpJCIxgQpKVZ7eJKuUClW+DPveg/VlvDNwBYCIlKzjNMboKrQ20taSUipU+ZI8PkTPd0FJW0VKqerA64RkjLk6gHEopZSq4XSBPqWUUkGhUtd7XGshJeAhoRljtp1kTEoppWognxKSiFwCPAi0L6da+ElFpJRSqkbyustOREYB/8NKYm9iXUv/FJiEtTTFUuBR/4eolFKqJvDlGtLdwDqgC/B/rrL3jDGXAN0AwVo5VimllPKZLwnpNOAD1zRChQu6hwMYY1YDbwH3+zc85Q0di6+Uqg58SUjhwD7Xz9mux7pu2w3Q0R9BqcrTe5KUUqHKl4S0A2gOYIzJxpq5wX3JCUEnX7WdtpaUUqHKl1F284BhnLh+NBm4S0SysRLbX4Hv/Bue8oa2ipRS1YEvLaTXgFkiEuv6/QGsbrqHsZLURqyBD0oppZTPfJk6aDGw2O33DKCLiJwG5APrjDEFZT1fKaWUKo8v9yENEJGkkuXGmJXGmDVAPREZ4NfolFJK1Ri+dNn9AgwvZ/tQVx2llFLKZ74kpIqunYdz4v4kpaqVAqeOX1Qq0Hyd7bu8v8o+wN6TiEVVkp4qA8fpdPKfT3/nntfmkXn4mN3hKFWtlTuoQUTuBO50K3pRRJ7wUDURqAO858fYVCXoEHD/2rTrEOu2ZgLw6fQ/uXV0J5sjUqr6qmiU3QFgq+vnFlgzNewuUccJrAYWAC/4MTalbHc870QvdFZ2ro2RKFX9lZuQjDEfAB8AiMhm4B/GmMlVEZiqHO2+U0qFKl/uQ2oZyECqkohEA29gjRqMB5YBt7mGr4cc7aZTSlUHXickEakPNDTGrHMrawn8DagHfGiM+dn/IQZEBLAJ6AWkYV0n+wZoY2NMSilVo/kyl91LQFugBxQtYz4baOLaPk5EhhhjfvNviP5njDkCPFb4u4i8AjwrIvWNMfvKfqZSSqlA8SUh9QY+cvt9HFYyGom1MN804F7Ap4QkIslYLZSeWAv9xQGDjTGzPNSNxlqV9kqskX0rgAeMMTN8eU0PegN7NBkppZR9fLkPqRGw3e33s4ElxpifjDHpwASgayViEOA+oCmwsoK6E4DxwMdYSawAmCIivSvxutaLiyRgLS74z8ruQyml1MnzpYWUC8S6/T4QK0EUOgDUr0QMS4EGxph9IjIK+NpTJRHpAVwCjDfGvOgq+xBryPnTwAC3urNc8XlyjzHmWVe9GOBb4HtjjN5DpZRSNvIlIf0JXCQirwLnYQ1kcO8qawbs9zUAY8xhL6uOwUqK77g9N0dE3gWeEJFkY0yaq3xQRTsTkXDgM6xWX0gvm6FDvZVS1YEvCelVrBZRJlALa5Sae0LqD6zyW2SldQX+MMZklShfhDXyuQvWiDlvvQ3EAGONMdXmnK5DwJVSocqX+5A+FBEnMAo4CDxpjMmFoiHhCViL+AVKMrDTQ3lhEmriYZtHItIcuAbIATJFpHDT2caY2d7up379OG+rnpSkpPhyt2flnphNICIivML66oSKjlXawZyinyMjI/TY+kCPVeBU12PrSwsJY8xHFB9pV1i+DzjDX0GVIRbwNLtljtt2rxhjtuKHxsS+fVkUFAS2cZWUFE9GRvm9mpmZR4t+zsvLr7C+snhzbA8cyC76OTc3T4+tl7w5tqpyQvnYhoU5yv0i7+ts33bKBqI9lMe4ba/xqk3fo1KqxgmlhJSG1W1XUmHZriqMJajodSOlVHUQSglpOdDONUOEu56uxxVVG45SSil/CqWE9AUQCVxfWOCaueEaYK4xpsa2kJRSqjrwaVBDoIjIg64f27serxSRfsABY8wrAMaYhSIyCXjGNd3QRuAvQHPg6ioOWSmllJ+VmZBEZBNwV+H6RyLyf8BXxpjVAYjjsRK/X+t63Aq84lZ+lavuVVhz2a0ERhpj5gYgJqWUUlWovBbSKVhrBRV6GNiANVWPXxljvLoub4zJAe5x/VMuOrIugJx6dJWqKuVdQ9oJdCpRpn+dQU5H3CmlQlV5LaRvgXtF5CxOzFH3oIjcUM5znMaYoX6LTimlVI1RXkK6D2veumFYAwecQBLWPHZK1QwObXMqVVXKTEjGmGzgIdc/RKQAa5DD/6ooNlUJ2qeqlApVvtyHdA0wL1CBqMrT7/BKqerAl9m+Pyj82TW7d0vXr5t16W+llFIny6cbY0WkM/Ay0K9E+WzgDmNMRUuQK6WUUh55nZBEpCMwB2t27W+BNa5NHbBWkJ0tIn2MMWvK2IVSKsD+3H6Aj6f+SZMGtejVoTEdW9YjIjyUZghTNZkvLaRHsZYQ71uyJeRKVr+56lzkv/CUUr6YvWIXOzKy2JGRxaJ1e4iLjaRH+4b06tCY1k3q4NBRgyqI+ZKQBgCveuqWM8asFpHXgJv9Fpnymo6sC6AQm6khr8SCkVnZucxctpOZy3aSlBBDr1Mb06tDI5Lr17YpQqXK5ktCqg2kl7M9zVVH2Ui//yqA+nWiuXBAa+avTWfN5v04nZBxIIfv5m3hu3lbaNE4nt4dGtPj1EbUrR1ld7hKAb4lpE3AucCrZWw/11VHKWWziPAwendsTO+OjTmYdYxF6/awYG06m9Ospa+3pB9mS/phPp+5gVNbJNK7Q2O6tm1ATFRQLACgaihfPn0fAv8Wkf8BTwB/uMrbA/cDZwL/8G94StmsGlxzqRsXzfDuzRjevRlp+46wYM1uFqxNJ+NADgVOJ6s372f15v1ERYZxepskenVoTIeWiYSH6WAIVbV8SUjPAqcDlwDjgAJXeRhWT9FE4Dm/RqeU8qvk+rUZPaAVo/q3ZOOuQyxYk86idXvIys7leG4BC9buZsHa3cTXiqRH+0b06tCIVsk6GEJVDV9ujM0HxonIO8AoTtwYuwn4xhgz3f/hKV+F1iV4ZReHw0FqSl1SU+pyydA2rN68nwVr0vl9/V5y8wo4fDSXGUt3MGPpDhomxtLr1Eb07tiYRok6laUKHJ87jI0x04BpAYhFVZJ+d1UnIyI8jC6pDeiS2oDsY3ks+zODBWvSWbs1E6cT9mRmM3nuFr6bu4Wxg1M5q+cpdoesqim9gqmUKhIbHUHfTsn07ZTMgaxjLFq7m/lrdrN192GcwMRfNhATHc6gLil2h6qqIU1ISimPEuKiObPHKZzZ4xQ2px3i+c+XcyQnj49+MtSKjqBH+0Z2h6iqGR1Go1Q14gzQjbwtk+sw/uIuREeG4wTe/m4tqzbpnMrKvzQhVQM6kCGAQmymhkBq1aQOt1/UiYhwB/kFTl79ahXrdxywOyxVjWhCqmZ0gIMCAnb/1Kkt6nHzBR1xOOB4XgEvTlrJtt2HA/JaqubxKiGJSKyIXCUiPQMdkFIquJ3eNolrR7YHIPtYHs9/vpz0/UdtjkpVB962kI4BbwNdAxiLUipE9O2UzKVD2wBw6Gguz332O/sP5dgclQp1XiUkY0wBsB2oE9hwlAoyOkNBmYZ3b8b5fVsAsO/QMZ77fDmHjh63NygV0ny5hvQBcKWIRAcqGHXy9BK8qkoX9GvJ0DOaApC27ygvTFxB9rE8m6NSocqX+5DmARcCy11rH60HSnUcG2N+81Nsykv6HV7ZxeFwcOmwNhzNyWP+mnS2ph/m5S9W8sRf+9kdmgpBviQk9+mCXqL0l3GHqyz8ZINSSoWOMIeDa0a2I/tYHss37MVsP8DTHy7mhnPa6/Lpyie+JKRrAhaFUiqkRYSHccuoDrwwcQV/bDvA4rW7CXfA9eeeSpheh1Ne8mW27w8CGYhSKrRFRoRz+0Wn8Z9Pf2dL+mEWrNlNregILh/eVpevUF7R9nQ1oAMZAkhnavBJbHQE4y/uTLNGcQDMXLaTb2ZvtjkqFSp8Skgi0kxE3hORHSJyXESGuMqTXOXdAxOm8pZ+D1Vg7+cgvlYUj97Yh/p1YgD4bt4Wpi7aZmNEKlR4nZBEpCWwBLgIWIPb4AVjTAbQDbje3wEqpUJPg4RY7r60C3VqRwHw2cwNzF6xy+aoVLDzpYX0BNay5R2Byyn9JexHQMd6KqUAaJRYi7+P60KtaOtS9YSf/mCp2WNzVCqY+ZKQhgGvGWO24/myxVagqV+iUipY6MX4k9KsYRx3je1MVGQYTie8OXkNa7bstzssFaR8SUh1gLRytkehC/7ZTi/Bq2CT2rQut43uRHiYg7x8J698uYqNOw/aHZYKQr4kpO1Ah3K29wI2nFw4qjL0O7wKdh1b1efG8zvgcMCx3HxenLSCHXuy7A5LBRlfEtJXwLUi0tGtzAkgIhcBY4GJfoxNKVWNdG/XkL+c1Q6AIzl5PPf5cvZk6rIV6gRfBzXsABYCH2Mlo3+IyHysRLQCeM7vESqlqo0BnZswdnBrAA4eOc6zny0n8/Axm6NSwcLrhGSMOQT0Bt7BGuLtAIYDArwGDDbG6IIoStkoFO7jPbtnc87p3RyAvQdzePqTZXwzexOrN+/jaI7OFF6T+TQIwZWU7gTuFJEkrKSUYYwJgT+DE0TkdWAUUBtrdOD9xpjvbQ3qJITUwQ81oXCGD0EXDmjFkZw8Zv2+kz0Hspk8dwtgnVBSkmqTmlKX1il1SW1al4YJsTr1UA1R6VFxrpthQ9VLwHhjTI6IdAOmi0hLY0ym3YGdLP2zVRD8o9UdDgdXDG9LQu0oFq7bTdo+61qSE9iRcYQdGUeYtdy6kTa+ViSpKXWLklSLxvFEReqiAtWRzwlJRC4GRgOtXEWbgK+NMSEzoMEY80eJomggGQj5hKRUqAgLc3B+v5ac368lWdm5bNx5kA07D7Jx50E2pR3ieG4BAIeP5vL7+r38vn4vAOFhDpo3ji+WpBLjdd3Q6sDrhCQitYFvgCFYX8QPuDZ1By4WkZuA840xR3zYZzJWF2BPrOtScVjXomZ5qBsNPApcCSRiDaJ4wBgzw9vXK7G/17CW1IgBvgfWVWY/SqmTFxcbSefUBnRObQBAXn4BOzKy2LDjRJLad8ga/JBf4GTTrkNs2nWIqYu3A9CgbsyJbr6UujRtWJvwMJ07OtT40kJ6AhgKvAw8ZYxJBxCRxsA/gDtcde7yYZ8C3Id1/9JKoE85dSdgzaP3oqv+1cAUERlojJnvw2sCYIy5VURuBwYDHULtOphS1VlEeBgtGtehReM6DOvWDID9h3LYuOtQUZLatvsw+QXWn+3egznsPZjDgrW7AYiODKdrmwZcOLAVDerG2vY+lG98SUjjgEnGmLvcC12J6S4RSXHVuav0U8u0FGhgjNknIqOArz1VEpEewCVY131edJV9CKwGngYGuNWdBQws4/XuMcY86xZ7Ptb1oztF5A9jzM8+xK5qgmC/GFOD1KsTQ706MXRv1xCA47n5bEk/zIadB4uSVFZ2LmDdfLtg7W6W/pnB2T1P4exezYnW605Bz5eEVAf4pZztM4GRvry4Meawl1XHALlYQ84Ln5sjIu8CT4hIsjEmzVU+yJcYXCKA1pV4XtDRZp6qKaIiw2nbLIG2zRIAcDqd7MnMZsPOgyzfsJelJoPcvAImz93CnFVpXDw4le7tGuqIvSDmS0JaCbQpZ3sbYNXJhVOmrsAfxpiSc40swrqe1YXy59krIiJxWEO+vwFygAuwuu3u9U+oVU//vJSyRu41qleLRvVq0bdTMn9uP8Cn09ezdfdh9h86xhvfrmHmsp1cNqwNpzSKtztc5YEvCelB4GsRmWWM+c59g4hcgLUW0ig/xuYuGdjpobwwCTXxYV9O4FrgFaxz+QbgUmOMz8m0fv04X59SKUlJ5f/xHMk70S6KCA+rsL46oaJjlXbwxL3ekZERQX9so11LPYQHwecgGF6/V5emTF+0jY+mrOVg1nH+3H6ARycs5sxeLbjirHbUjQvN0Xl2H9tAKTMhich7Hoo3A9+IiOHEqLT2WIMTVmGtkzTT30ECsYCn+UVy3LZ7xTUKcIg/gtq3L4uCgsB2kiUlxZORUX7PZub+EwMb8/ILKqyvLN4c2wMHsot+zs3NC/pjm3PMmukg3+bPgTfHtqqc3roe7a7vyeS5W5ixdAf5BU5+mr+F35bt4IJ+LRl8egoR4aEzIi+Yjq2vwsIc5X6RL6+FdHU529q5/rk7DegEXOdtcD7IxrpXqKQYt+01ll43CiCdqaFaqBUTySVD2zCgcxM+m7Ge1Zv3c/RYHp/OWM+vK3Zx6dA2dGhZz+4wa7wyE5IxJpi+MqRhdduVVFimayO76PUkpcrWpEFtxl/cmRUb9vHZjPXsOZDNrr1HeO7z5XRt04BxQ1JpmFjL7jBrrGBKOuVZDrRzDUhw19P1uKJqw1FKhSqHw0GXNg147PqejB3Umugoazj47+v38uA7C/ny143kHNdJXu0QKgnpCyASa+AEUDRzwzXAXGOMtpCUUj6JjAjj7F7N+feNvejbsTEAeflOfpi/lX++tYD5q9NxapdtlfJpLjsR6QP8FWuId31K9xA5jTE+3c8jIg+6fmzverxSRPoBB4wxrwAYYxaKyCTgGdd0QxuBvwDNKf9al1JKlSshLprrzj2VQaen8L9p69mcdogDWcd5+/u1zPx9B5cNa0vL5Dp2h1kj+DKX3Q3AG8BxwADb/BTDYyV+v9b1uBVraHahq1x1r8Kay24lMNIYM9dPcSilarDWTerywFVnMH91Ol/M2sjBI8fZuPMQj32whH6dkrloYKuQHSYeKnxpIf0T61rOCGPMXn8FYIzx6jq8a/G/e1z/VBm0g8HP9K7+GiXM4aBvp2ROb5vE9/O2MHXxdvILnMxZlcYSs4fz+7ZkWLemITVMPJT4clQbAe/6Mxkp/9BTplL+FRsdwdjBqTx+fU+6uGYgzzmez8RfNvDPtxYwZ2Ua+QUFNkdZ/fiSkNZhdZUppVSN0KheLe4Ycxp/u7gzyfWt4eB7D+bw3o/r+Nc7i1i0bjcFOvDBb3xJSE8At4qIL9P0qCqgfw6qiJ4cA6Jjq/o8cm0PrhwhJMRFAZC+/yhvfLuGR95fzPL1e3VEnh94fQ3JGPOViNQC1orIt8AWIL9ENacxpuQgBVWFtPvOz/Qko1wiwsMY3DWFvh0bM+v3nfywYCuHj+ayfU8WL3+5klZN6jB6QCtObZ6oM4pXki+j7NpirdhaB2vVVk+clB41p5SqYnpCDJyoyHDO7HEKA7o0YdqSHfy0cBvZx/LYtOsQz322HGmWwIUDW9GmaYLdoYYcX0bZvQY0xFpyfDaQGZCIlFIqBMRERXBenxYMOT2FnxdtY9riHRzLzcdsP8C/P15Gp1b1GT2gJS0a6z1M3vIlIfUG/mOM+W+gglFKqVBTOyaSCwe0Zli3Zvw4fyszl+0kL7+AVZv2sWrTPs5om8So/i1JSaqa5WpCmS8J6SCQEahAlFIqlNWpFcUlQ9swoscpfD9vC7+t2EV+gZOlf2aw7M8MenZoxAX9WtJIJ28tky+j7CYCFwYqEKWUqg4S46O5coTw5I296NupMQ6HdXF9wZrdPPDWQiZM+YP9h3Iq3E9N5EsL6U3gAxH5BngZa7G+kqPsMMb4a0ohVQk6JszPdHCAqqSkhFiuO+dURvZqzjezN7P4jz0UOJ38tmIX81anMahLCuf0aUHd2lF2hxo0fElIa7DOd92A88qpF35SESmf6SlTqeCVXL82t4zqyDm7D/PN7M0s37CXvHwn05fu4LeVuxh6RlPO7tmcuNhIu0O1nS8J6VH0C7hSSlXKKY3iuWPMaWzcdZCvf9vE2i2ZHM8tYMqCbcz6fRd/H9eFVk1q9og8X26MfTiAcaiToN8SAijEbowNrWhrptZN6nL3JV35Y2smX/22iQ07D5J9LI+JM9fzjyvOsDs8W+mUtdWMdt8pFRraNU/k/itOZ9gZTQH4c8dBtqYftjkqe/kyU8MAb+oZY36rfDhKKX/QLyahweFwcGaPZsxYtgOnE6Yv2c51555qd1i28eUa0iy86xHQQQ1KKeWlBnVjOaNtEktMBgvX7WbM4NQaO/LOl4R0TRnPb421jPgWrKHhSimlfDCsWzOWmAzy8p38+vtOzu/X0u6QbOHLoIYPytomIv8BlvklIqWUqmHaNK1L80bxbN19mF9+38nI3s1r5Kq0fnnHxphM4B3gXn/sTymlahKHw8GwbtbghoNHjrN43R6bI7KHP1NwJtDKj/tTSqkao0f7RtRxXTuatmR7jVzwzy8JSURisNZISvfH/lTl1byPcIDp1EGqikRGhDGoi7Ug95b0w2zcecjmiKqeL8O+3ytjUz2spSmSgHv8EZTyjZ4ylaoeBndN4Yf5W8kvcDJtyXZSm9a1O6Qq5csou6vLKN8P/AmMN8b876QjUj7TVlEAhVq3SYiFq4qrGxdNj/aNmL8mnaUmg/2HcqhXJ8busKqML6Psat6QjxCkrSUF6AchhA3v3pT5a9IpcDqZuWwnYwa1tjukKqNJRimlgkiLxnWKuup+Xb6TY7mlVvmptjQhKaVUkBnerRkAR3LyWLCm5owVK7fLTkQm+7g/pzHmgpOIRymlarzT2zagXp1o9h86xvQlOxjQuQmOGjDis6JrSOf6uD+9pKqUUicpPCyMIac35YtZG9m59whrt2bSoUU9u8MKuHITkjcDGURkIPAM0B1I81NcSilVow3o3ITJczZzPK+A6Yu314iEVOlrSCLSUUR+AGYCAvwLaOOvwJRSqiaLi42kd8fGAKzcuI/dmUdtjijwfE5IItJMRCYAvwNDgZeB1saYJ4wx2X6OT/lI+0z9rAb026vgVbh4nxOYsWSHvcFUAV9makgEHgBuBaKBT4EHjTFbAhOa8paeMpWqnlKS4ji1RSJrt2QyZ1UaowdU7+lCK0xIIhIN3AXcByQA04D7jDHLAxmY8p62igIoxGZqCK1olTeGdWvG2i2Z5BzPZ87KNC5rmmh3SAFTbpediFwHbACeBDYCw40xIzQZBS9tLSnQz0F1clrr+jRMjAVgxtId5BdU368dFbWQ3sb60rUEmAh0FpHO5dR3GmNe8FdwSilV04U5HAw9oymfTl/PngPZLF23m5YNa9sdVkB4cw3JgTWku7sXdZ2AJiSllPKjfp2S+fq3TeQcz2fy7I3cedFpdocUEBUlpMFVEoVSSqkyxUZH0O+0ZKYv2cGK9XvZkZFF06Q4u8Pyu4pujP21qgJRSilVtmFnNGXGkh04gelLdnD12e3sDsnvdHJVpZQKAQ0Ta9E5tQEA89ekk5Wda3NE/lejE5KI9BaRAhH5h92xKKVURYZ3s26Uzc0r4NflO22Oxv9qbEISkTCsARiL7Y7Fn6rvgFClVLvmiTRvHA/AzGU7ycsvsDki/6qxCQm4EVgIrLM7kJOl95wEkE4dpIKIw+HgvP7WCrKZh4+x7M8MmyPyL6+nDgoEEUkG7gR6At2AOGCwMWaWh7rRwKPAlUAisAJ4wBgzoxKvWx9r9olewIuViz54aKsogEJtpoYQi1f5btAZTZnw/RqysnOZvmQHPdo3sjskv7G7hSRYUxI1BVZWUHcCMB74GCuJFQBTRKR3JV73CeBFY8yBSjw3qOn3eWXRT0J1FR0ZzsAuTQDYsPMgm9MO2RyR/9jaQgKWAg2MMftEZBTwtadKItIDuAQYb4x50VX2IbAaeBoY4FZ3FjCwjNe7B5iBdZPvX/3yDpRSqooN7prClAXbKHA6mb5kOzec18HukPzC1oRkjDnsZdUxQC7wjttzc0TkXeAJEUk2xqS5ygeVtyMRuQurZbZTRADqAnki0sIYc7PPb0IppapYvToxdGuXxKJ1e1i0bg9jB6eSEBdtd1gnze4uO291Bf4wxmSVKF+E1TfRxYd9vQWkup7TBZgMvITVdaiUUiFhWLdmAOQXOJn1e/UYAm53l523kgFPR7xwyfQm3u7IGHMUKFp6UUSygSxjzEFfg6pfv2qm7khKii93e1buiaGfERHhFdZXJ1R0rHYdyCn6OSoqIuiPbXS09ScdERFme6x2v351lpQUT4MGcbSZtZH12w/w24o0rj6/I5ER4XaHdlJCJSHFAsc8lOe4ba8UY8zVlX3uvn1ZFAR4KvikpHgyMsrv2cx0W9o4Ly+/wvrK4s2xPXjgxLE9fjwv6I/tsWN5AOTlFdgaqzfHVlWO+7Ed1KUJ67cf4EDWMX74bSN9OyXbHF35wsIc5X6RD5Uuu2ysVWpLinHbrpRSNUr3dg2pGxcFwLQl20N+2H+oJKQ0rG67kgrLdlVhLEopFRQiwsMY3DUFgG27s1i/w+crD0ElVBLScqCdiJRs6/V0Pa6o2nCCV2h/PwpCOlODCnKDuqQQEW59Tqct2W5zNCcnVBLSF0AkcH1hgWvmhmuAucYYbSGpwAjxLhBV/dWpHUXPU63ZGpb9mcHeg6F7BcP2QQ0i8qDrx/auxytFpB9wwBjzCoAxZqGITAKecU03tBH4C9AcuLqKQw5q+n1egTbsaprh3Zoxd1U6Tqc16erFg1PtDqlSbE9IwGMlfr/W9bgVeMWt/CpX3auw5rJbCYw0xswNeIRKKRXETmkUT9tmCfy5/QC/Ld/FBX1bEh0VekPAbU9IxhivvssZY3Kwpv65J7ARKaVU6BnerSl/bj/A0WN5zFuTXjTYIZSEyjUkpZRS5ejaJon6daw7YaaH6BBwTUhKKVUNhIU5GHqGtaJs2r6jrNmy3+aIfKcJSSmlqon+nZOJirRO69OX7LA5Gt9pQlJKqWqidkwkfTta8wWs3LiPtH1HbI7IN5qQlFKqGhnWrWnRzzOWhlYrSRNSNRN6lzGVUv6UXL82HVvWA2DuqnSO5uTZHJH3NCEpVY2E4MAqFQCDT7eGfB/LzWfjrtCZ304TUjWjN+gr0M9BTee+emx+gJfI8SdNSEoppYKCJiSllFJBQROSUkqpoKAJSSmlVFDQhKSUUiooaEJSSikVFDQhKaWUCgq2r4cUosLBml23KlT0OlGR4TRMjAWgXt2YKourOqjoWEVHnTi2ifHRQX9sE+KjaZgYS7069n8O7H796syXc0JMVETQ/F+4xeFx9UBHKK6ZEQT6AbPtDkIppUJUf2BOyUJNSJUTDXQH0oB8m2NRSqlQEQ4kA4uBYyU3akJSSikVFHRQg1JKqaCgCUkppVRQ0ISklFIqKGhCUkopFRQ0ISmllAoKmpCUUkoFBU1ISimlgoImJKWUUkFB57ILQiISDTwKXAkkAiuAB4wxM2wNLMSJSHfgamAw0BzYB8wDHjTGbLAxtGpJRO4FngZWGGO62BxOyHN9fh8G+gCRwEbgBWPMBBvD8ittIQWnCcB44GPgTqAAmCIive0Mqhq4D7gQmI51XN8CBgG/i0h7G+OqdkSkMfAgcMTuWKoDETkbmIuViP4F/B3rc9zMzrj8TVtIQUZEegCXAOONMS+6yj4EVmN92xxgX3Qh73ngMmPM8cICEfkcWIWVrK62Ka7q6ClgCdaX3gR7QwltIlIX60vq68aYO20OJ6C0hRR8xgC5wDuFBcaYHOBdoJ+IJNsVWKgzxsxzT0ausvXAGkBbSH7i+lJ1BfA3u2OpJi7DSur/ByAi8SISHOtJ+JkmpODTFfjDGJNVonwR4AC6VHlE1ZjrD7sRsNfuWKoD1/H8L/CBMWa5zeFUF8OAP4CRIrIdOATsF5GnRMTjukKhSrvsgk8ysNNDeZrrsUkVxlITXA6kAA/YHUg1cRVwKjDK5jiqk1Ssa0UTgGeA34FzsbqZY4C77ArM3zQhBZ9YPKwTAuS4bVd+ICLtgFexFgr7yOZwQp6IxGNdO3rKGJNWUX3ltTis0bb/MMY87Sr7SkTigFtF5HFjTLVo4WuXXfDJxloAsKQYt+3qJLlGgf0AZAJjjTEFNodUHTwIHMcaPKL8p/Bv/tMS5Z9gjbrrUbXhBI62kIJPGla3XUmFZbuqMJZqyTVqaQpQF+hrjEm3OaSQ5xpscxfWkORGIlK4KQaIEpEWwEFjTKYtAYa2NKADsLtEeeHviVUbTuBoCyn4LAfauZrj7nq6HldUbTjVi4jEAN8BbYFzjTHG5pCqi0ZAFNatCZvd/vXEGsG4Geuah/LdUtdjSonypq7HjCqMJaA0IQWfL7Ca4dcXFrhmbrgGmGuM0RZSJblGJH0O9Mbqpltgc0jVyWZgtId/a4Atrp8/tCu4EDfJ9XhdYYFrNOP1WDceV5vPscPpdNodgypBRCZijVJ6AWt6kL8A3YHBxpi5NoYW0kTkRawZGr4DJpbYnGWM+aaqY6ruRGQWkKBTB50cEfkAayqxd4FlwDmuf/caY/5jZ2z+pNeQgtNVwGOux0RgJTBSk9FJ6+J6PM/1z91W4JuqDEYpH9wAbMP6cvoXYBNwszHmTVuj8jNtISmllAoKeg1JKaVUUNCEpJRSKihoQlJKKRUUNCEppZQKCpqQlFJKBQVNSEoppYKCJiSllFJBQROSUkqpoKAJSSmlVFDQhKRCiogMEhGniFxtdywnS0Q6ikieiAy3O5aaQEQuEJHjItLG7liUZ5qQlLLP81gzuE9zLxSReq6kO8WmuAJGRF4RkZ2u2arLqlP4peNuf762MeZbYBXWEhkqCGlCUsoGItIbGI7n1VVPdz0uq7qIAs+VhEYB3xpj7JpE8yVgtIh0sOn1VTk0ISllj1uBvcCPHrZVy4SEtYRKCvbOqv4VcBS42cYYVBl0+QlVLYhIA+AR4Hys1Ut3A5OB/zPG7CtRtwXwHFYLBeAXrOW3fwG2GGMGBTjWCKyWwvfGmFwPVaprQhoNHMA6zrYwxmSJyGxgDHC7XXEoz7SFpEKeiNQF5gG3AD9jJZefXL/PEZF4t7r1gdlY6yFNwFpW+wjWSbJ2FYV8BhAHLCpj++lApjFmcxXFU1VGAz+WkYSr0nygsYi0szkOVYK2kFR1cC/QBvirMea1wkIRWQ684tr+L1fxfUBT4ApjzCeustdF5BngniqK91TX48aSG1zJMxUbWxGBICLtAQEetDsWThz3DsAfdgaiitOEpKqD0UAG8FaJ8jeBh1zbCxPSeUAa8GmJus9SdQkpyfW438O2roCD6tddNwrIwWq5+pWINMZaXbkdsAeYZIxZWs5TCrtwG/o7FnVyNCGp6qAlsMQYk+deaIzJE5E/OXFNprDuImNMQYm6e0TkgHuZiFwM3IG19PleY0yLEtsjsK5FXYnV/f0lVistp4J4C0eYeRr6fIbrscyEJCL9AU9DwqOAcGNMeIn6r2F1X/YxxswvsW0WMBAYaYyZ4lZ+MfA58IMx5lxXWVvgGaAvEIPrOp0x5m9lxepmNDDdGJPlRV2vichFwBDgXeC/WEnmMhEZA/yzjNF8hcddl8sOMpqQlCpbJlaXXyNgvIft/wQGA52A41iDKJ7BSmLlyXA91vOwrcIBDcaY2VjXoIqISBNgiSte9/JY4DKs1tj1WNdPSvoDuI7iSe56Sndn/YA1Su0KrJFqrbGSU7lEpCnQDbihorq+EJGOQAtjzF/dircC/xaRXlgj6V738NTC457hYZuykQ5qUNXBJkBcLZYirt/burYX2gKkikhYiboNgQT3MmPMNGPMZ1gnOU+uB540xuw0xmQADwNXi0h4GfULrXY9epox4HQgC/izgn0UEZForEQxxxjzZInNY4ECrIEeF4tIHKVNBIaISJJrf82xWoXfuL1GA6xrW28YY7KMMQXGmPXGmAlehDgKqzUy2dv35KUL8XwfF8aYBUCDkp8Jl1TX42oP25SNNCGp6uAbrOsy15cov8FV/rVb2XdAMnBpibo+zQogIglAM2C5W/EyIB5oUcHTfwcOAb1K7LMW1oX/5T7eOPoGVhfa1R62XQ98hpV0coFLPNQ5jHWMrnL9fh3wP+BYYQVjzF5gHfCeiFwiIq19iG80VrL0d4vkaOFxEpHeIrJXRNwHTSzF+kJSUi9gtzHG+DkedZK0y05VB89gtQReFZHTsU74XbFOrMa1vdDTWF1Y74tID6xuqf5AH6wbVb1NBIVDyQ+4lR0osc0jY0y+iHwFjBKRaGNM4Ym/MxAOxIjIPzw8NcsYU7JL7g7gXKC7MeZoiW1tsd7bPcaYYyLyGdYxecfDvt8F3hGRF7ES2znARSXqDMJK3P8EThWRbcA/jDETy3qvIlIPGIA10tFXQ0UkxkP5XmPMGyXKOgP1Kd6FeIgS/xeuFmJ/4L1KxKMCTFtIKuQZYw5inYjeBEYCL7se3wD6GWMOu9XdC/QDvgeuxUpQtbGuBTmAbC9ftnCfdd3KEkpsK8/rrvrnupUVXj/qBvzbw7+x7jsQkcGu+McaY7Z4eI3rgT+MMQtdv08AenmaNscYMw/r/T8MpBtjVnmos8cYc68x5jSs6zCvAf+r4H6ec7G++H5dTp2ynAU85uHfXa7tsW5138Fqif3FrawzsL7EPi8CamF9VlSQ0RaSCinGmFl4GJ3m6g661fWvon1sxrr+UMR1w2x9YJuXcRwQke1Y11oKu366YiWjLV48f5GIFN7E+6Wr7FXgVW9e3zXbxESs1s8sD9sjsbrg6opIeonN1wGeRsa9i9WavMWL+A8Bz4rI/ZR/P89oYEUZCbOsfc/C8wjEkraISB9jzDzXCMtvCje4bpZuYYwpObT+TuBrY4xePwpCmpBUjSMiscaYki2hwi6yaW71woFI1z+Hq/vI6dbF9g5wv2sqmlys1sUEY0y+l6H8HVghImcaY6b6EH8trJPv5JJdeG7OAxKxkqT7SfkK4D4R+Ycx5niJ57yFdU1snofXTMS6T+sTrAEXYVhde7WwrtWUZT7wdrlvqPI+Bl4SkdruM6aLSEusllSxpCsio4COwLgAxaNOkiYkVRP9KCJbsQYhhAFDsbqW5lF84s8rgffdfs/GGnHXwvX7k0ADYI1rP19gzQThFWPMGir3N3gRVndUWxHxdHI9Fau77lNjzFr3DSLyBvAA1si3Ytd+XK2e6WW85nGgMdZIuUZYAx7WAOeX1/oxxjxT1raTZYxxishdwG0icj3WaMIwrBuf7yw5h6Ex5huse7VUkHI4nXpvmKpZROTvWN1ZLbCuQ+zAGjb9iPv1JqVU1dKEpJRSKijoKDullFJBQROSUkqpoKAJSSmlVFDQhKSUUiooaEJSSikVFDQhKaWUCgqakJRSSgUFTUhKKaWCwv8DfwO2Q+o/xrYAAAAASUVORK5CYII=\n", + "text/plain": [ + "<Figure size 432x288 with 1 Axes>" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "# plot luminosity distribution\n", "ldist = population.grid_results['luminosity distribution']\n", @@ -491,10 +582,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "id": "5956f746-e3b9-4912-b75f-8eb0af66d3f6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ValueError", + "evalue": "Failed to rename grid variable M_1 to lnM_1.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Input \u001b[0;32mIn [27]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Rename the old variable (M_1) because we want it to be called lnM_1 now\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mpopulation\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrename_grid_variable\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mM_1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mlnM_1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/.pyenv/versions/3.9.9/envs/dev_binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/utils/population_extensions/gridcode.py:965\u001b[0m, in \u001b[0;36mgridcode.rename_grid_variable\u001b[0;34m(self, oldname, newname)\u001b[0m\n\u001b[1;32m 963\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 964\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFailed to rename grid variable \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m to \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(oldname, newname)\n\u001b[0;32m--> 965\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(msg)\n", + "\u001b[0;31mValueError\u001b[0m: Failed to rename grid variable M_1 to lnM_1." + ] + } + ], "source": [ "# Rename the old variable (M_1) because we want it to be called lnM_1 now\n", "population.rename_grid_variable(\"M_1\",\"lnM_1\")" @@ -520,8 +624,8 @@ "# because M * dprob/dM = dprob/dlnM\n", "population.update_grid_variable(\n", " name=\"lnM_1\",\n", - " samplerfunc=\"const(math.log({min}), math.log({max}), {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " samplerfunc=\"self.const_linear(math.log({min}), math.log({max}), {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnM_1\",\n", " parameter_name=\"M_1\",\n", " precode=\"M_1=math.exp(lnM_1)\",\n", @@ -615,7 +719,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -629,7 +733,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/source/examples/notebook_population.ipynb b/docs/source/examples/notebook_population.ipynb index 760b1480e9f9bdcc508ced177f8f0d806cfb53eb..ebc19cff04f8dd9e8e2fe6694fa9b0346425afe9 100644 --- a/docs/source/examples/notebook_population.ipynb +++ b/docs/source/examples/notebook_population.ipynb @@ -25,7 +25,7 @@ "import os\n", "\n", "from binarycpython.utils.custom_logging_functions import temp_dir\n", - "from binarycpython.utils.grid import Population\n", + "from binarycpython import Population\n", "\n", "TMP_DIR = temp_dir(\"notebooks\", \"notebook_population\")\n", "\n", @@ -58,13 +58,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: M_1=10 to BSE_options\n", - "adding: orbital_period=45000000080 to BSE_options\n", - "adding: max_evolution_time=15000 to BSE_options\n", - "adding: eccentricity=0.02 to BSE_options\n", "adding: num_cores=2 to grid_options\n", - "adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_population to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", @@ -139,13 +135,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "Writing settings to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json\n" + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n" ] }, { "data": { "text/plain": [ - "'/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json'" + "'/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz'" ] }, "execution_count": 3, @@ -185,9 +185,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on method add_grid_variable in module binarycpython.utils.grid:\n", + "Help on method add_grid_variable in module binarycpython.utils.population_extensions.gridcode:\n", "\n", - "add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int], gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None) -> None method of binarycpython.utils.grid.Population instance\n", + "add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int] = -1, gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None, index: Optional[int] = None, dry_parallel: Optional[bool] = False) -> 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", @@ -198,17 +198,15 @@ " beware that if you insert some destructive piece of code, it will be executed anyway.\n", " Use at own risk.\n", " \n", - " Tasks:\n", - " - TODO: Fix this complex function.\n", - " \n", " Args:\n", " name:\n", " name of parameter used in the grid Python code.\n", " This is evaluated as a parameter and you can use it throughout\n", " the rest of the function\n", " \n", - " Examples:\n", - " name = 'lnm1'\n", + " Examples::\n", + " \n", + " name = 'lnM_1'\n", " \n", " parameter_name:\n", " name of the parameter in binary_c\n", @@ -223,47 +221,66 @@ " longname:\n", " Long name of parameter\n", " \n", - " Examples:\n", + " Examples::\n", + " \n", " longname = 'Primary mass'\n", + " \n", " range:\n", " Range of values to take. Does not get used really, the samplerfunc is used to\n", " get the values from\n", " \n", - " Examples:\n", + " Examples::\n", + " \n", " range = [math.log(m_min), math.log(m_max)]\n", + " \n", " samplerfunc:\n", " Function returning a list or numpy array of samples spaced appropriately.\n", " You can either use a real function, or a string representation of a function call.\n", " \n", - " Examples:\n", - " samplerfunc = \"const(math.log(m_min), math.log(m_max), {})\".format(resolution['M_1'])\n", + " Examples::\n", + " \n", + " samplerfunc = \"self.const_linear(math.log(m_min), math.log(m_max), {})\".format(resolution['M_1'])\n", " \n", " 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", + " sampling function (i.e. a value for lnM_1 is chosen already)\n", + " \n", + " Examples::\n", + " \n", + " precode = 'M_1=math.exp(lnM_1);'\n", " \n", - " Examples:\n", - " precode = 'M_1=math.exp(lnm1);'\n", " postcode:\n", " Code executed after the probability is calculated.\n", + " \n", " probdist:\n", " Function determining the probability that gets assigned to the sampled parameter\n", " \n", - " Examples:\n", - " probdist = 'Kroupa2001(M_1)*M_1'\n", + " Examples::\n", + " \n", + " probdist = 'self.Kroupa2001(M_1)*M_1'\n", + " \n", " dphasevol:\n", " part of the parameter space that the total probability is calculated with. Put to -1\n", " if you want to ignore any dphasevol calculations and set the value to 1\n", - " Examples:\n", - " dphasevol = 'dlnm1'\n", + " \n", + " Examples::\n", + " \n", + " dphasevol = 'dlnM_1'\n", + " \n", " condition:\n", " condition that has to be met in order for the grid generation to continue\n", - " Examples:\n", - " condition = 'self.grid_options['binary']==1'\n", + " \n", + " Examples::\n", + " \n", + " condition = \"self.grid_options['binary']==1\"\n", + " \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 'centred'\n", - " (steps starting at lower edge + 0.5 * stepsize).\n", + " (steps starting at ``lower edge + 0.5 * stepsize``).\n", + " \n", + " dry_parallel:\n", + " If True, try to parallelize this variable in dry runs.\n", " \n", " topcode:\n", " Code added at the very top of the block.\n", @@ -313,35 +330,7 @@ "execution_count": 6, "id": "47979841-2c26-4b26-8945-603d013dc93a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Added grid variable: {\n", - " \"name\": \"lnm1\",\n", - " \"parameter_name\": \"M_1\",\n", - " \"longname\": \"Primary mass\",\n", - " \"valuerange\": [\n", - " 2,\n", - " 150\n", - " ],\n", - " \"samplerfunc\": \"const(math.log(2), math.log(150), 20)\",\n", - " \"precode\": \"M_1=math.exp(lnm1)\",\n", - " \"postcode\": null,\n", - " \"probdist\": \"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", - " \"dphasevol\": \"dlnm1\",\n", - " \"condition\": \"\",\n", - " \"gridtype\": \"centred\",\n", - " \"branchpoint\": 0,\n", - " \"branchcode\": null,\n", - " \"topcode\": null,\n", - " \"bottomcode\": null,\n", - " \"grid_variable_number\": 0\n", - "}\n" - ] - } - ], + "outputs": [], "source": [ "# Add grid variables\n", "resolution = {\"M_1\": 20}\n", @@ -351,9 +340,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -364,8 +353,8 @@ "# name=\"q\",\n", "# longname=\"Mass ratio\",\n", "# valuerange=[\"0.1/M_1\", 1],\n", - "# samplerfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n", - "# probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", + "# samplerfunc=\"self.const_linear(0.1/M_1, 1, {})\".format(resolution['q']),\n", + "# probdist=\"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", "# dphasevol=\"dq\",\n", "# precode=\"M_2 = q * M_1\",\n", "# parameter_name=\"M_2\",\n", @@ -377,12 +366,12 @@ "# name=\"log10per\", # in days\n", "# longname=\"log10(Orbital_Period)\",\n", "# valuerange=[0.15, 5.5],\n", - "# samplerfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", + "# samplerfunc=\"self.const_linear(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", "# precode=\"\"\"orbital_period = 10** log10per\n", "# sep = calc_sep_from_period(M_1, M_2, orbital_period)\n", "# sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n", "# sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n", - "# probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", + "# probdist=\"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", "# parameter_name=\"orbital_period\",\n", "# dphasevol=\"dlog10per\",\n", "# )\n" @@ -434,7 +423,7 @@ ], "source": [ "# Create custom logging statement: in this case we will log when the star turns into a compact object, and then terminate the evolution.\n", - "custom_logging_statement = \"\"\"\n", + "custom_logging_code = \"\"\"\n", "if(stardata->star[0].stellar_type >= 13) \n", "{\n", " if (stardata->model.time < stardata->model.max_evolution_time)\n", @@ -454,7 +443,7 @@ "\"\"\"\n", "\n", "example_pop.set(\n", - " C_logging_code=custom_logging_statement\n", + " C_logging_code=custom_logging_code\n", ")" ] }, @@ -476,7 +465,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function parse_function at 0x1528ac7290d0> to grid_options\n" + "adding: parse_function=<function parse_function at 0x7f2b6ca163a0> to grid_options\n" ] } ], @@ -552,38 +541,41 @@ "output_type": "stream", "text": [ "adding: verbosity=0 to grid_options\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "**************************************\n", - "* Total starcount for this run is 20 *\n", - "* Total probability is 0.0444029 *\n", - "**************************************\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 19 *\n", + "* Total probability is 0.0443872 *\n", + "**********************************\n", "\n", - "Generating grid code\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.450828476487e+00 1.81563 134.653 5.27143e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 3.598268106227e+01 1.30592 8.75988 0.00193614 13\n", + "EXAMPLE_COMPACT_OBJECT 2.436983545111e+01 1.35842 10.9948 0.00144093 13\n", + "EXAMPLE_COMPACT_OBJECT 1.690157944401e+01 1.43124 13.7998 0.00107238 13\n", + "EXAMPLE_COMPACT_OBJECT 1.242397939068e+01 1.52416 17.3205 0.000798096 13\n", + "EXAMPLE_COMPACT_OBJECT 9.756794139032e+00 1.66914 21.7394 0.000593966 13\n", + "EXAMPLE_COMPACT_OBJECT 8.401414766976e+00 1.73729 27.2857 0.000442046 13\n", + "EXAMPLE_COMPACT_OBJECT 7.536373523810e+00 1.80677 34.247 0.000328983 13\n", + "EXAMPLE_COMPACT_OBJECT 7.393982410080e+00 1.82164 42.9844 0.000244839 13\n", + "EXAMPLE_COMPACT_OBJECT 7.396470605248e+00 1.82129 53.9508 0.000182216 13\n", + "Do join of subprocesses ...\n", + "EXAMPLE_COMPACT_OBJECT 7.399005684057e+00 1.82041 67.7151 0.00013561 13\n", + "EXAMPLE_COMPACT_OBJECT 7.443375325717e+00 1.81645 84.9909 0.000100925 13\n", + "EXAMPLE_COMPACT_OBJECT 7.451195752942e+00 1.81559 106.674 7.51114e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 7.452661646076e+00 1.81543 133.89 5.59e-05 13\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-50fb66cc659c46c8bbc29fe0c8651c2f finished! *\n", - "* The total probability is 0.0444029. *\n", - "* It took a total of 3.30s to run 20 systems on 2 cores *\n", - "* = 6.60s of CPU time. *\n", - "* Maximum memory use 433.070 MB *\n", + "* Population-ce756bb317f64099a459bf8b55a746ac finished! *\n", + "* The total probability is 0.0443872. *\n", + "* It took a total of 0.73s to run 19 systems on 2 cores *\n", + "* = 1.46s of CPU time. *\n", + "* Maximum memory use 293.406 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n" + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" ] } ], @@ -614,7 +606,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'population_name': '50fb66cc659c46c8bbc29fe0c8651c2f', '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': 1635760967.3245144, 'end_timestamp': 1635760970.6249793, 'total_mass_run': 684.2544031669784, 'total_probability_weighted_mass_run': 0.28134439269236855, 'zero_prob_stars_skipped': 0}\n" + "{'population_id': 'ce756bb317f64099a459bf8b55a746ac', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.044387171445641534, 'total_count': 19, 'start_timestamp': 1646563001.7193637, 'end_timestamp': 1646563002.4480088, 'time_elapsed': 0.7286450862884521, 'total_mass_run': 649.905447944397, 'total_probability_weighted_mass_run': 0.28133908148630704, 'zero_prob_stars_skipped': 0}\n" ] } ], @@ -642,9 +634,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on method write_binary_c_calls_to_file in module binarycpython.utils.grid:\n", + "Help on method write_binary_c_calls_to_file in module binarycpython.utils.population_extensions.dataIO:\n", "\n", - "write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False) -> None method of binarycpython.utils.grid.Population instance\n", + "write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False, encoding='utf-8') -> None method of binarycpython.utils.grid.Population instance\n", " Function that loops over the grid code and writes the generated parameters to a file.\n", " In the form of a command line call\n", " \n", @@ -655,10 +647,6 @@ " \n", " On default this will write to the datadir, if it exists\n", " \n", - " Tasks:\n", - " - TODO: test this function\n", - " - TODO: make sure the binary_c_python .. output file has a unique name\n", - " \n", " Args:\n", " output_dir: (optional, default = None) directory where to write the file to. If custom_options['data_dir'] is present, then that one will be used first, and then the output_dir\n", " output_filename: (optional, default = None) filename of the output. If not set it will be called \"binary_c_calls.txt\"\n", @@ -685,19 +673,19 @@ "output_type": "stream", "text": [ "Generating grid code\n", - "Generating grid code\n", - "Saving grid code to grid_options\n", - "Writing grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py [dry_run = False]\n", - "Symlinked grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid-latest2 \n", - "Loading grid code function from /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py\n", + "Save grid code to grid_options\n", + "Write grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py [dry_run = False]\n", + "Symlinked grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid-latest2 \n", + "Load grid code function from /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py\n", "Grid code loaded\n", - "Writing binary_c calls to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "/tmp/binary_c_python-izzard/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.2158744056768156 probability 0.00823663875514986\n", - "binary_c M_1 3.430936289925951 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681537 probability 0.0062211552141636295\n", - "binary_c M_1 4.2576084265970895 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.2158744056768156 probability 0.004698855121516281\n" + "Writing binary_c calls to /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "binary_c M_1 2.2406484012210224 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.011394572976608001\n", + "binary_c M_1 2.812296769855663 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191117 probability 0.008480166685456411\n", + "binary_c M_1 3.5297876799548944 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.006311182276049824\n", + "binary_c M_1 4.430329401616038 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.004696962123378559\n", + "(abridged)\n" ] } ], @@ -707,7 +695,8 @@ "print(calls_filename)\n", "\n", "with open(calls_filename, 'r') as f:\n", - " print('\\n'.join(f.read().splitlines()[:4]))" + " print('\\n'.join(f.read().splitlines()[:4]))\n", + "print(\"(abridged)\")" ] }, { @@ -715,7 +704,15 @@ "id": "60359eb1-4d0c-4d2d-8265-ec5171b944a2", "metadata": {}, "source": [ - "## Full examples of population scripts\n", + "## Full examples of population scripts" + ] + }, + { + "cell_type": "markdown", + "id": "1ee279d6-e120-4aef-9e57-845e534f5c6a", + "metadata": {}, + "source": [ + "### Single star population\n", "Below is a full setup for a population of single stars" ] }, @@ -729,43 +726,51 @@ "name": "stdout", "output_type": "stream", "text": [ - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "**************************************\n", - "* Total starcount for this run is 20 *\n", - "* Total probability is 0.0444029 *\n", - "**************************************\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 19 *\n", + "* Total probability is 0.0443872 *\n", + "**********************************\n", "\n", - "Generating grid code\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-05e51ba114934b37bab48f1db40b7333 finished! *\n", - "* The total probability is 0.0444029. *\n", - "* It took a total of 3.46s to run 20 systems on 2 cores *\n", - "* = 6.93s of CPU time. *\n", - "* Maximum memory use 437.047 MB *\n", + "* Population-0fa4c2b8707741a5ab41d209ef95a3a4 finished! *\n", + "* The total probability is 0.0443872. *\n", + "* It took a total of 0.61s to run 19 systems on 2 cores *\n", + "* = 1.23s of CPU time. *\n", + "* Maximum memory use 299.531 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n", "\n", "\n", "time mass zams_mass probability radius stellar_type\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.450828476487e+00 1.81563 134.653 5.27143e-05 1.72498e-05 13\n", + "3.598268106227e+01 1.30592 8.75988 0.00193614 1.72498e-05 13\n", + "2.436983545111e+01 1.35842 10.9948 0.00144093 1.72498e-05 13\n", + "1.690157944401e+01 1.43124 13.7998 0.00107238 1.72498e-05 13\n", + "1.242397939068e+01 1.52416 17.3205 0.000798096 1.72498e-05 13\n", + "9.756794139032e+00 1.66914 21.7394 0.000593966 1.72498e-05 13\n", + "8.401414766976e+00 1.73729 27.2857 0.000442046 1.72498e-05 13\n", + "7.536373523810e+00 1.80677 34.247 0.000328983 1.72498e-05 13\n", + "7.393982410080e+00 1.82164 42.9844 0.000244839 1.72498e-05 13\n", + "7.396470605248e+00 1.82129 53.9508 0.000182216 1.72498e-05 13\n", + "7.399005684057e+00 1.82041 67.7151 0.00013561 1.72498e-05 13\n", + "7.451195752942e+00 1.81559 106.674 7.51114e-05 1.72498e-05 13\n", + "7.443375325717e+00 1.81645 84.9909 0.000100925 1.72498e-05 13\n", + "7.452661646076e+00 1.81543 133.89 5.59e-05 1.72498e-05 13\n", "\n" ] } @@ -877,9 +882,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\",\n", @@ -908,7 +913,8 @@ "id": "c2ab0979-6575-481d-9c1c-ca98517b2437", "metadata": {}, "source": [ - "We can also set up a population that samples biinary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded top be more useful" + "### Binary star population\n", + "We can also set up a population that samples binary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded to be more useful. Also note that we run very little systems in the following example, as its just intended to show how the code works." ] }, { @@ -921,45 +927,42 @@ "name": "stdout", "output_type": "stream", "text": [ - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 27 stars with a total probability of 0.0248684\n", - "**************************************\n", - "* Total starcount for this run is 27 *\n", - "* Total probability is 0.0248684 *\n", - "**************************************\n", + "Grid has handled 8 stars with a total probability of 0.0211592\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 8 *\n", + "* Total probability is 0.0211592 *\n", + "**********************************\n", "\n", - "Generating grid code\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-8bc1eafea1c34b05894c1618639d8c37 finished! *\n", - "* The total probability is 0.0248684. *\n", - "* It took a total of 16.10s to run 27 systems on 2 cores *\n", - "* = 32.20s of CPU time. *\n", - "* Maximum memory use 437.695 MB *\n", + "* Population-0eb5c0c9abd34607a6ee060b26a7e32f finished! *\n", + "* The total probability is 0.0211592. *\n", + "* It took a total of 0.84s to run 8 systems on 2 cores *\n", + "* = 1.68s of CPU time. *\n", + "* Maximum memory use 300.125 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\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", - "1.219029061236e+01 1.60007 17.3205 0 2.97008 13 5 15 15 0.02 0.000498487\n", - "1.935920339886e+01 1.29448 17.3205 0 8.71025 13 13 15 2 0.02 0.000498487\n", - "2.123794969278e+01 1.30902 17.3205 1.58518 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.548740826516e+01 1.52415 17.3205 1.45407 14.4504 13 13 13 5 0.02 0.000220016\n", - "1.779197348711e+01 1.3228 17.3205 1.71196 14.4504 13 13 13 8 0.02 0.000287968\n", - "1.367065497322e+01 1.66003 73.0434 1.79487 12.2572 13 13 13 8 0.02 7.67586e-05\n", - "1.772169325355e+01 1.81957 73.0434 1.46573 12.2572 13 13 13 5 0.02 4.43422e-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", - "9.823059079115e+00 2.43711 73.0434 1.81689 60.8862 14 14 13 8 0.02 7.67586e-05\n", - "7.394722435913e+00 1.79092 73.0434 1.79092 60.8862 13 8 13 8 0.02 4.43422e-05\n", - "7.396288708628e+00 1.8216 73.0434 1.8216 60.8862 13 8 13 8 0.02 3.38788e-05\n", + "1.378266748188e+01 1.66293 50.9713 1.78767 12.8178 13 13 13 8 0.02 0.000339963\n", + "1.817608462595e+01 1.82104 50.9713 1.41436 12.8178 13 13 13 5 0.02 0.000193036\n", + "7.422997711686e+00 1.82479 50.9713 1.82171 38.2535 13 13 13 8 0.02 0.000193036\n", + "1.205711924468e+01 1.73765 50.9713 0 38.2535 13 13 15 8 0.02 0.000339963\n", "\n" ] } @@ -1089,9 +1092,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -1102,8 +1105,8 @@ " name=\"q\",\n", " longname=\"Mass ratio\",\n", " valuerange=[\"0.1/M_1\", 1],\n", - " samplerfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n", - " probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", + " samplerfunc=\"self.const_linear(0.1/M_1, 1, {})\".format(resolution['q']),\n", + " probdist=\"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", " dphasevol=\"dq\",\n", " precode=\"M_2 = q * M_1\",\n", " parameter_name=\"M_2\",\n", @@ -1115,12 +1118,12 @@ " name=\"log10per\", # in days\n", " longname=\"log10(Orbital_Period)\",\n", " valuerange=[0.15, 5.5],\n", - " samplerfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", + " samplerfunc=\"self.const_linear(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", " precode=\"\"\"orbital_period = 10** log10per\n", "sep = calc_sep_from_period(M_1, M_2, orbital_period)\n", "sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n", "sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n", - " probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", + " probdist=\"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", " parameter_name=\"orbital_period\",\n", " dphasevol=\"dlog10per\",\n", ")\n", @@ -1145,7 +1148,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1159,7 +1162,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/source/examples/old/basic_example.ipynb b/docs/source/examples/old/basic_example.ipynb index 9078cfcb5fdcd35336ee3675accb3f810c21e5fe..7146b97671caad9e82ce7454511dcad2aa416a78 100644 --- a/docs/source/examples/old/basic_example.ipynb +++ b/docs/source/examples/old/basic_example.ipynb @@ -1,5 +1,14 @@ { "cells": [ + { + "cell_type": "markdown", + "id": "c09b9f85-5250-4fd2-8142-bb8097d138b5", + "metadata": {}, + "source": [ + "# Basic example\n", + "Running a single system" + ] + }, { "cell_type": "code", "execution_count": 1, @@ -106,7 +115,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -120,7 +129,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/source/examples/old/workshop_example_notebook.ipynb b/docs/source/examples/old/workshop_example_notebook.ipynb index 4eca5879779a9fec40521c733bda59768c8c4140..78d0860ad1dfc12104b4bb639055957d527c01e7 100644 --- a/docs/source/examples/old/workshop_example_notebook.ipynb +++ b/docs/source/examples/old/workshop_example_notebook.ipynb @@ -619,7 +619,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -633,7 +633,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/docs/source/functions.py b/docs/source/functions.py deleted file mode 100644 index ca960dbdf465e0b77d861a47751cb0588a4e8454..0000000000000000000000000000000000000000 --- a/docs/source/functions.py +++ /dev/null @@ -1,71 +0,0 @@ -import os -import jinja2 -import m2r2 - -from binarycpython.utils.functions import call_binary_c_config - -from git import Repo - - -def generate_browser_url(ssh_url, branch=None): - """ - Function to generate the browser url for a git repo - """ - - base = ssh_url.split("@")[-1].replace(".git", "").replace(":", "/").strip() - - if not branch: - return "https://{}".format(base) - else: - return "https://{}/-/tree/{}".format(base, branch) - - -def write_custom_footer(): - """ - Function to write the custom footer to the template file - """ - - TARGET_DIR = "./_templates" - - output_text = """ -{{% extends '!footer.html' %}} - -{{%- block extrafooter %}} -<br><br> -Generated on binarycpython git branch: {binarycpython_git_branch} git revision {binarycpython_git_revision} url: <a href="{binarycpython_git_url}">git url</a>. -<br><br> -Using binary_c with bit branch {binary_c_git_branch}: git revision: {binary_c_git_revision} url: <a href="{binary_c_git_url}">git url</a>. - -{{% endblock %}} -""" - - binary_c_git_branch = call_binary_c_config("git_branch").strip() - binary_c_git_revision = call_binary_c_config("git_revision").strip() - binary_c_git_url = generate_browser_url( - call_binary_c_config("git_url").strip(), binary_c_git_branch - ) - - # for binarycpython git - base_dir = os.path.dirname( - os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - ) - local_repo = Repo(path=base_dir) - - binarycpython_git_branch = local_repo.active_branch.name - binarycpython_git_revision = local_repo.active_branch.commit - binarycpython_git_url = generate_browser_url( - local_repo.remotes.origin.url, binarycpython_git_branch - ) - - formatted_text = output_text.format( - binarycpython_git_branch=binarycpython_git_branch, - binarycpython_git_revision=binarycpython_git_revision, - binarycpython_git_url=binarycpython_git_url, - binary_c_git_branch=binary_c_git_branch, - binary_c_git_revision=binary_c_git_revision, - binary_c_git_url=binary_c_git_url, - ).strip() - - # Write to file - with open("_templates/footer.html", "w") as outfile_filehandle: - outfile_filehandle.write(formatted_text) diff --git a/docs/source/grid.rst b/docs/source/grid.rst index 5f3347e6f42616884c86dffc98baf5da3bc8ea03..5122d6740bfbbf5649a1837271d3f987bcfe3fd4 100644 --- a/docs/source/grid.rst +++ b/docs/source/grid.rst @@ -1,5 +1,5 @@ -grid\_class module -================================= +Population class module +======================= .. automodule:: binarycpython.utils.grid :members: diff --git a/docs/source/grid_options_defaults.rst b/docs/source/grid_options_defaults.rst deleted file mode 100644 index c66555ac9989dff3ad956f893683dc34c4dc4c46..0000000000000000000000000000000000000000 --- a/docs/source/grid_options_defaults.rst +++ /dev/null @@ -1,7 +0,0 @@ -Grid options and descriptions -============================= - -.. automodule:: binarycpython.utils.grid_options_defaults - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/source/grid_options_descriptions.rst b/docs/source/grid_options_descriptions.rst index 916bbac09db9d0ad680ce8dbc5eebe6917f8ea74..7d765d8cffea4b69f7e03926382da0eaee37df8d 100644 --- a/docs/source/grid_options_descriptions.rst +++ b/docs/source/grid_options_descriptions.rst @@ -1,7 +1,7 @@ Population grid code options ============================ The following chapter contains all grid code options, along with their descriptions -There are 9 options that are not described yet. +There are 29 options that are not described yet. Public options @@ -13,36 +13,118 @@ The following options are meant to be changed by the user. | **C_logging_code**: Variable to store the exact code that is used for the custom_logging. In this way the user can do more complex logging, as well as putting these logging strings in files. +| **HPC_force_join**: Integer, default 0. If 1, and the HPC variable ("slurm" or "condor") is 3, skip checking our own job and force the join. + +| **HPC_rebuild_joinlist**: Integer, default 0. If 1, ignore the joinlist we would usually use and rebuild it automatically + | **Moe2017_options**: No description available yet +| **cache_dir**: No description available yet + | **combine_ensemble_with_thread_joining**: Boolean 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 -| **condor**: Int flag whether to use a condor type population evolution. Not implemented yet. +| **command_line**: No description available yet + +| **condor**: Integer flag used to control HTCondor (referred to as Condor here) jobs. Default is 0 which means no Condor. 1 means launch Condor jobs. Do not manually set this to 2 (run Condor jobs) or 3 (join Condor job data) unless you know what you are doing, this is usually done for you. + +| **condor_ClusterID**: Integer. Condor ClusterID variable, equivalent to Slurm's jobid. Jobs are numbered <ClusterID>.<Process> + +| **condor_Process**: Integer. Condor Process variable, equivalent to Slurm's jobarrayindex. Jobs are numbered <ClusterID>.<Process> + +| **condor_bash**: String. Points the location of the "bash" command, e.g. /bin/bash, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **condor_batchname**: String. Condor batchname option: this is what appears in condor_q. Defaults to "binary_c-condor" + +| **condor_date**: String. Points the location of the "date" command, e.g. /usr/bin/date, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **condor_dir**: String. Working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all jobs). This directory should not exist when you launch the Condor jobs. + +| **condor_env**: String. Points the location of the "env" command, e.g. /usr/bin/env or /bin/env, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **condor_extra_settings**: Dictionary. Place to put extra configuration for the CONDOR submit file. The key and value of the dict will become the key and value of the line in te slurm batch file. Will be put in after all the other settings (and before the command). Take care not to overwrite something without really meaning to do so. + +| **condor_getenv**: Boolean. If True, the default, condor takes the environment at submission and copies it to the jobs. You almost certainly want this to be True. + +| **condor_initial_dir**: String. Directory from which condor scripts are run. If set to the default, None, this is the directory from which your script is run. + +| **condor_kill_sig**: String. Signal Condor should use to stop a process. Note that grid.py expects this to be "SIGINT" which is the default. + +| **condor_memory**: Integer. In MB, the memory use (ImageSize) of the job. + +| **condor_njobs**: Integer. Number of jobs that Condor will run + +| **condor_postpone_join**: Integer. Use to delay the joining of Condor grid data. If 1, data is not joined, e.g. if you want to do it off the condor grid (e.g. with more RAM). Default 0. + +| **condor_postpone_submit**: Integer. Debugging tool. If 1, the condor script is not submitted (useful for debugging). Default 0. + +| **condor_pwd**: String. Points the location of the "pwd" command, e.g. /bin/pwd, that is used in Condor launch scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **condor_q**: String. The Condor_q command, usually "/usr/bin/condor_q" but will depend on your HTCondor installation. + +| **condor_requirements**: String. Condor job requirements. These are passed to Condor directly, you should read the HTCondor manual to learn about this. If no requirements exist, leave as an string. + +| **condor_should_transfer_files**: Integer. Condor's option to transfer files at the end of the job. You should set this to "YES" + +| **condor_snapshot_on_kill**: Integer. If 1 we save a snapshot on SIGKILL before exit. + +| **condor_stream_error**: Boolean. If True, we activate Condor's stderr stream. If False, this data is copied at the end of the job. + +| **condor_stream_output**: Boolean. If True, we activate Condor's stdout stream. If False, this data is copied at the end of the job. + +| **condor_submit**: String. The Condor_submit command, usually "/usr/bin/condor_submit" but will depend on your HTCondor installation. + +| **condor_universe**: String. The HTCondor "universe": this is "vanilla" by default. + +| **condor_warn_max_memory**: Integer. In MB, the memory use (ImageSize) of the job. + +| **condor_when_to_transfer_output**: Integer. Condor's option to decide when output files are transferred. You should usually set this to "ON_EXIT_OR_EVICT" | **custom_generator**: No description available yet | **custom_logging_func_memaddr**: Memory address where the custom_logging_function is stored. Input: int +| **do_analytics**: No description available yet + | **do_dry_run**: Whether to do a dry run to calculate the total probability for this run +| **dry_run_hook**: Function hook to be called for every system in a dry run. The function is passed a dict of the system parameters. Does nothing if None (the default). + +| **dry_run_num_cores**: No description available yet + | **ensemble_factor_in_probability_weighted_mass**: Flag to multiply all the ensemble results with 1/probability_weighted_mass -| **evolution_type**: Variable containing the type of evolution used of the grid. Multiprocessing or linear processing +| **evolution_type**: Variable containing the type of evolution used of the grid. Multiprocessing, linear processing or possibly something else (e.g. for Slurm or Condor). + +| **exit_after_dry_run**: If True, exits after a dry run. Default is False. -| **exit_after_dry_run**: No description available yet +| **exit_code**: No description available yet | **failed_systems_threshold**: Variable storing the maximum number of systems that are allowed to fail before logging their command line arguments to failed_systems log files +| **function_cache**: Boolean, default True. If True, we use a cache for certain function calls. + +| **function_cache_TTL**: No description available yet + +| **function_cache_default_maxsize**: Integer, default 256. The default maxsize of the cache. Should be a power of 2. + +| **function_cache_default_type**: String. One of the following types: LRUCache, LFUCache, FIFOCache, MRUCache, RRCache, TTLCache, NullCache, NoCache. You can find details of what these mean in the Python cachetools manual, except fo NoCache which means no cache is used at all, and NullCache is a dummy cache that never matches, used for testing overheads. + +| **function_cache_functions**: No description available yet + | **gridcode_filename**: Filename for the grid code. Set and used by the population object. TODO: allow the user to provide their own function, rather than only a generated function. -| **log_args**: Boolean to log the arguments. Unused +| **joinlist**: No description available yet + +| **log_args**: Boolean to log the arguments. -| **log_args_dir**: Directory to log the arguments to. Unused +| **log_args_dir**: Directory to log the arguments to. -| **log_dt**: No description available yet +| **log_dt**: Time between verbose logging output. | **log_file**: Log file for the population object. Unused +| **log_newline**: Newline character used at the end of verbose logging statements. This is \n (newline) by default, but \x0d (carriage return) might also be what you want. + | **log_runtime_systems**: Whether to log the runtime of the systems . Each systems run by the thread is logged to a file and is stored in the tmp_dir. (1 file per thread). Don't use this if you are planning to run a lot of systems. This is mostly for debugging and finding systems that take long to run. Integer, default = 0. if value is 1 then the systems are logged | **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 @@ -51,25 +133,95 @@ The following options are meant to be changed by the user. | **multiplicity_fraction_function**: Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: Moe and di Stefano (2017) 2017 -| **n_logging_stats**: No description available yet +| **n_logging_stats**: Number of logging statistics used to calculate time remaining (etc.). E.g., if you set this to 10 the previous 10 calls to the verbose log will be used to construct an estimate of the time remaining. + +| **num_cores**: The number of cores that the population grid will use. You can set this manually by entering an integer great than 0. When 0 uses all logical cores. When -1 uses all physical cores. Input: int -| **num_cores**: The number of cores that the population grid will use. The multiprocessing is useful but make sure to figure out how many logical cores the machine has (use e.g. psutil.cpu_count(logical=False) to find the true number of cores, psutil.cpu_count(logical=True) to find the number of logical cores). The core is multi processed, not multi threaded, and will gain no extra speed when num_cores exceeds the number of logical cores. Input: int +| **num_cores_available**: No description available yet + +| **original_command_line**: No description available yet + +| **original_submission_time**: No description available yet + +| **original_working_diretory**: No description available yet | **parse_function**: Function that the user can provide to handle the output the binary_c. This function has to take the arguments (self, output). Its best not to return anything in this function, and just store stuff in the self.grid_results dictionary, or just output results to a file +| **print_stack_on_exit**: If True, prints a stack trace when the population's exit method is called. + | **repeat**: Factor of how many times a system should be repeated. Consider the evolution splitting binary_c argument for supernovae kick repeating. +| **restore_from_snapshot_dir**: No description available yet + +| **restore_from_snapshot_file**: No description available yet + +| **return_after_dry_run**: If True, return immediately after a dry run (and don't run actual stars). Default is False. + | **run_zero_probability_system**: Whether to run the zero probability systems. Default: True. Input: Boolean +| **rungrid**: No description available yet + | **save_ensemble_chunks**: No description available yet -| **slurm**: Int flag whether to use a Slurm type population evolution. +| **save_population_object**: No description available yet + +| **save_snapshots**: No description available yet + +| **skip_before**: No description available yet + +| **slurm**: Integer flag used to control Slurm jobs. Default is 0 which means no Slurm. 1 means launch Slurm jobs. Do not manually set this to 2 (run Slurm jobs) or 3 (join Slurm job data) unless you know what you are doing, this is usually done for you. + +| **slurm_array**: String. Override for Slurm's --array option, useful for rerunning jobs manually. Default None. + +| **slurm_array_max_jobs**: Integer. Override for the max number of concurrent Slurm array jobs. Default None. + +| **slurm_bash**: String. Points the location of the "bash" command, e.g. /bin/bash, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **slurm_date**: String. Points the location of the "date" command, e.g. /usr/bin/date, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **slurm_dir**: String. Working directory containing e.g. scripts, output, logs (e.g. should be NFS available to all jobs). This directory should not exist when you launch the Slurm jobs. + +| **slurm_env**: String. Points the location of the "env" command, e.g. /usr/bin/env or /bin/env, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **slurm_extra_settings**: Dictionary of extra settings for Slurm to put in its launch script. Please see the Slurm documentation for the many options that are available to you. + +| **slurm_jobarrayindex**: Integer. Slurm job array index. Each job is numbered <slurm_jobid>.<slurm_jobarrayindex>. + +| **slurm_jobid**: Integer. Slurm job id. Each job is numbered <slurm_jobid>.<slurm_jobarrayindex>. + +| **slurm_jobname**: String which names the Slurm jobs, default "binary_c-python". + +| **slurm_memory**: String. Memory required for the job. Should be in megabytes in a format that Slurm understands, e.g. "512MB" (the default). + +| **slurm_njobs**: Integer. Number of Slurm jobs to be launched. + +| **slurm_ntasks**: Integer. Number of CPUs required per array job: usually only need this to be 1 (the default). + +| **slurm_partition**: String containing the Slurm partition name. You should check your local Slurm installation to find out partition information, e.g. using the sview command. + +| **slurm_postpone_join**: Integer, default 0. If 1 do not join job results with Slurm, instead you have to do it later manually. + +| **slurm_postpone_sbatch**: Integer, default 0. If set to 1, do not launch Slurm jobs with sbatch, just make the scripts that would have. + +| **slurm_pwd**: String. Points the location of the "pwd" command, e.g. /bin/pwd, that is used in Slurm scripts. This is set automatically on the submit machine, so if it is different on the nodes, you should set it manually. + +| **slurm_sbatch**: String. The Slurm "sbatch" submission command, usually "/usr/bin/sbatch" but will depend on your Slurm installation. By default is set automatically. + +| **slurm_time**: String. The time a Slurm job is allowed to take. Default is 0 which means no limit. Please check the Slurm documentation for required format of this option. + +| **slurm_warn_max_memory**: String. If we set slurm_memory in excess of this, warn the user because this is usually a mistake. Default "1024MB". | **source_file_filename**: Variable containing the source file containing lines of binary_c command line calls. These all have to start with binary_c. | **start_at**: No description available yet -| **symlink latest gridcode**: No description available yet +| **start_time**: No description available yet + +| **status_dir**: Directory where grid status is stored + +| **stop_queue**: No description available yet + +| **symlink_latest_gridcode**: No description available yet | **tmp_dir**: Directory where certain types of output are stored. The grid code is stored in that directory, as well as the custom logging libraries. Log files and other diagnostics will usually be written to this location, unless specified otherwise @@ -77,6 +229,8 @@ The following options are meant to be changed by the user. | **weight**: Weight factor for each system. The calculated probability is multiplied by this. If the user wants each system to be repeated several times, then this variable should not be changed, rather change the _repeat variable instead, as that handles the reduction in probability per system. This is useful for systems that have a process with some random element in it. +| **working_diretory**: No description available yet + Moe & di Stefano sampler options -------------------------------- The following options are meant to be changed by the user. @@ -87,69 +241,69 @@ The following options are meant to be changed by the user. | **Mmin**: Minimum stellar mass | **multiplicity_model**: - multiplicity model (as a function of log10M1) - - You can use 'Poisson' which uses the system multiplicity - given by Moe and maps this to single/binary/triple/quad - fractions. + multiplicity model (as a function of log10M1) - Alternatively, 'data' takes the fractions directly - from the data, but then triples and quadruples are - combined (and there are NO quadruples). + You can use 'Poisson' which uses the system multiplicity + given by Moe and maps this to single/binary/triple/quad + fractions. + Alternatively, 'data' takes the fractions directly + from the data, but then triples and quadruples are + combined (and there are NO quadruples). + | **multiplicity_modulator**: - [single, binary, triple, quadruple] + [single, binary, triple, quadruple] - e.g. [1,0,0,0] for single stars only - [0,1,0,0] for binary stars only - - defaults to [1,1,0,0] i.e. singles and binaries + e.g. [1,0,0,0] for single stars only + [0,1,0,0] for binary stars only + defaults to [1,1,0,0] i.e. singles and binaries + | **normalize_multiplicities**: - 'norm': normalise so the whole population is 1.0 - after implementing the appropriate fractions - S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) - given a mix of multiplicities, you can either (noting that - here (S,B,T,Q) = appropriate modulator * model(S,B,T,Q) ) - note: if you only set one multiplicity_modulator - to 1, and all the others to 0, then normalising - will mean that you effectively have the same number - of stars as single, binary, triple or quad (whichever - is non-zero) i.e. the multiplicity fraction is ignored. - This is probably not useful except for - testing purposes or comparing to old grids. - - 'raw' : stick to what is predicted, i.e. - S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) - without normalisation - (in which case the total probability < 1.0 unless - all you use single, binary, triple and quadruple) + 'norm': normalise so the whole population is 1.0 + after implementing the appropriate fractions + S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) + given a mix of multiplicities, you can either (noting that + here (S,B,T,Q) = appropriate modulator * model(S,B,T,Q) ) + note: if you only set one multiplicity_modulator + to 1, and all the others to 0, then normalising + will mean that you effectively have the same number + of stars as single, binary, triple or quad (whichever + is non-zero) i.e. the multiplicity fraction is ignored. + This is probably not useful except for + testing purposes or comparing to old grids. - 'merge' : e.g. if you only have single and binary, - add the triples and quadruples to the binaries, so - binaries represent all multiple systems - ... - *** this is canonical binary population synthesis *** + 'raw' : stick to what is predicted, i.e. + S/(S+B+T+Q), B/(S+B+T+Q), T/(S+B+T+Q), Q/(S+B+T+Q) + without normalisation + (in which case the total probability < 1.0 unless + all you use single, binary, triple and quadruple) - It only takes the maximum multiplicity into account, - i.e. it doesn't multiply the resulting array by the multiplicity modulator again. - This prevents the resulting array to always be 1 if only 1 multiplicity modulator element is nonzero + 'merge' : e.g. if you only have single and binary, + add the triples and quadruples to the binaries, so + binaries represent all multiple systems + ... + *** this is canonical binary population synthesis *** - Note: if multiplicity_modulator == [1,1,1,1]. this option does nothing (equivalent to 'raw'). + It only takes the maximum multiplicity into account, + i.e. it doesn't multiply the resulting array by the multiplicity modulator again. + This prevents the resulting array to always be 1 if only 1 multiplicity modulator element is nonzero + Note: if multiplicity_modulator == [1,1,1,1]. this option does nothing (equivalent to 'raw'). + | **q_high_extrapolation_method**: Same as q_low_extrapolation_method | **q_low_extrapolation_method**: - q extrapolation (below 0.15) method - none - flat - linear2 - plaw2 - nolowq - + q extrapolation (below 0.15) method + none + flat + linear2 + plaw2 + nolowq + | **ranges**: @@ -196,6 +350,8 @@ The following options are not meant to be changed by the user, as these options | **_grid_variables**: Dictionary storing the grid_variables. These contain properties which are accessed by the _generate_grid_code function +| **_killed**: No description available yet + | **_loaded_Moe2017_data**: Internal variable storing whether the Moe and di Stefano (2017) data has been loaded into memory | **_main_pid**: Main process ID of the master process. Used and set by the population object. @@ -204,6 +360,8 @@ The following options are not meant to be changed by the user, as these options | **_probtot**: Total probability of the population. +| **_queue_done**: No description available yet + | **_set_Moe2017_grid**: Internal flag whether the Moe and di Stefano (2017) grid has been loaded | **_start_time_evolution**: Variable storing the start timestamp of the population evolution. Set by the object itself. diff --git a/docs/source/hpc_functions.rst b/docs/source/hpc_functions.rst deleted file mode 100644 index d336a0be090ee3eac23c4342286fe8895e0aea6f..0000000000000000000000000000000000000000 --- a/docs/source/hpc_functions.rst +++ /dev/null @@ -1,7 +0,0 @@ -hpc\_functions module -================================= - -.. automodule:: binarycpython.utils.hpc_functions - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/source/modules.rst b/docs/source/modules.rst index d4aaac5025cbb089f2754ed01ef8bd92f70bf81c..ce6f94e48b1de9e38dc33e8c6dceb7b468c3934f 100644 --- a/docs/source/modules.rst +++ b/docs/source/modules.rst @@ -6,13 +6,25 @@ This chapter contains the (auto)documentation for all the functions and modules :maxdepth: 4 custom_logging_functions - distribution_functions + dicts + ensemble functions grid - grid_options_defaults - hpc_functions plot_functions + population_extensions/analytics + population_extensions/cache + population_extensions/condor + population_extensions/dataIO + population_extensions/distribution_functions + population_extensions/gridcode + population_extensions/grid_logging + population_extensions/grid_options_defaults + population_extensions/HPC + population_extensions/metadata + population_extensions/Moe_di_Stefano_2017 + population_extensions/slurm + population_extensions/spacing_functions + population_extensions/version_info run_system_wrapper - spacing_functions stellar_types - useful_funcs \ No newline at end of file + useful_funcs diff --git a/docs/source/plot_functions.rst b/docs/source/plot_functions.rst index 6af374e53223ea93532fcd50ced89130f6f917d7..466637364d3aa55437785329ead662249fc75bf8 100644 --- a/docs/source/plot_functions.rst +++ b/docs/source/plot_functions.rst @@ -1,5 +1,5 @@ plot\_functions module -================================= +====================== .. automodule:: binarycpython.utils.plot_functions :members: diff --git a/docs/source/population_extensions/HPC.rst b/docs/source/population_extensions/HPC.rst new file mode 100644 index 0000000000000000000000000000000000000000..4d615eb33e436fce836190d595b12822e2b573f2 --- /dev/null +++ b/docs/source/population_extensions/HPC.rst @@ -0,0 +1,7 @@ +Population class extension: HPC module +====================================== + +.. automodule:: binarycpython.utils.population_extensions.HPC + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/Moe_di_Stefano_2017.rst b/docs/source/population_extensions/Moe_di_Stefano_2017.rst new file mode 100644 index 0000000000000000000000000000000000000000..703e951622f427c9261d7cdf7d07d6ba276e145f --- /dev/null +++ b/docs/source/population_extensions/Moe_di_Stefano_2017.rst @@ -0,0 +1,7 @@ +Population class extension: Moe\_di\_Stefano\_2017 module +========================================================= + +.. automodule:: binarycpython.utils.population_extensions.Moe_di_Stefano_2017 + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/analytics.rst b/docs/source/population_extensions/analytics.rst new file mode 100644 index 0000000000000000000000000000000000000000..39d6947f399f51ad590442ae0f99f3cf4afa2851 --- /dev/null +++ b/docs/source/population_extensions/analytics.rst @@ -0,0 +1,7 @@ +Population class extension: analytics module +============================================ + +.. automodule:: binarycpython.utils.population_extensions.analytics + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/cache.rst b/docs/source/population_extensions/cache.rst new file mode 100644 index 0000000000000000000000000000000000000000..73d4ebbf69e6614be78f02696f681616c4189d46 --- /dev/null +++ b/docs/source/population_extensions/cache.rst @@ -0,0 +1,7 @@ +Population class extension: cache module +======================================== + +.. automodule:: binarycpython.utils.population_extensions.cache + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/condor.rst b/docs/source/population_extensions/condor.rst new file mode 100644 index 0000000000000000000000000000000000000000..65673b81c0090a608bc2fbbec6346b57418759a2 --- /dev/null +++ b/docs/source/population_extensions/condor.rst @@ -0,0 +1,7 @@ +Population class extension: condor module +========================================= + +.. automodule:: binarycpython.utils.population_extensions.condor + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/dataIO.rst b/docs/source/population_extensions/dataIO.rst new file mode 100644 index 0000000000000000000000000000000000000000..d6ed76285b109a81e9d8cb753aac50fb55a57562 --- /dev/null +++ b/docs/source/population_extensions/dataIO.rst @@ -0,0 +1,7 @@ +Population class extension: dataIO module +========================================= + +.. automodule:: binarycpython.utils.population_extensions.dataIO + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/distribution_functions.rst b/docs/source/population_extensions/distribution_functions.rst new file mode 100644 index 0000000000000000000000000000000000000000..cf6a9071a777c0c3e2a369189559bc07ba499d38 --- /dev/null +++ b/docs/source/population_extensions/distribution_functions.rst @@ -0,0 +1,7 @@ +Population class extension: distribution\_functions module +========================================================== + +.. automodule:: binarycpython.utils.population_extensions.distribution_functions + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/grid_logging.rst b/docs/source/population_extensions/grid_logging.rst new file mode 100644 index 0000000000000000000000000000000000000000..dc607c6ea5031ec2f80de51ec131753e32fcc6e6 --- /dev/null +++ b/docs/source/population_extensions/grid_logging.rst @@ -0,0 +1,7 @@ +Population class extension: grid\_logging module +================================================ + +.. automodule:: binarycpython.utils.population_extensions.grid_logging + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/grid_options_defaults.rst b/docs/source/population_extensions/grid_options_defaults.rst new file mode 100644 index 0000000000000000000000000000000000000000..30a9c025e6c22f19d3a5bb429efb19144152e331 --- /dev/null +++ b/docs/source/population_extensions/grid_options_defaults.rst @@ -0,0 +1,7 @@ +Population class extension: grid\_options\_defaults module +========================================================== + +.. automodule:: binarycpython.utils.population_extensions.grid_options_defaults + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/gridcode.rst b/docs/source/population_extensions/gridcode.rst new file mode 100644 index 0000000000000000000000000000000000000000..c9f554ccba5192b196b05f1fee17e88852372c6f --- /dev/null +++ b/docs/source/population_extensions/gridcode.rst @@ -0,0 +1,7 @@ +Population class extension: gridcode module +=========================================== + +.. automodule:: binarycpython.utils.population_extensions.gridcode + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/metadata.rst b/docs/source/population_extensions/metadata.rst new file mode 100644 index 0000000000000000000000000000000000000000..72a0ca4f2f76d478807b85e85c396d60058019ed --- /dev/null +++ b/docs/source/population_extensions/metadata.rst @@ -0,0 +1,7 @@ +Population class extension: metadata module +=========================================== + +.. automodule:: binarycpython.utils.population_extensions.metadata + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/slurm.rst b/docs/source/population_extensions/slurm.rst new file mode 100644 index 0000000000000000000000000000000000000000..48d1ecb98c121204e17c9076eed8b257e628b75c --- /dev/null +++ b/docs/source/population_extensions/slurm.rst @@ -0,0 +1,7 @@ +Population class extension: slurm module +======================================== + +.. automodule:: binarycpython.utils.population_extensions.slurm + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/spacing_functions.rst b/docs/source/population_extensions/spacing_functions.rst new file mode 100644 index 0000000000000000000000000000000000000000..1a7a70f4e9bce3892fd36359a2485472490f67f5 --- /dev/null +++ b/docs/source/population_extensions/spacing_functions.rst @@ -0,0 +1,7 @@ +Population class extension: spacing\_functions module +===================================================== + +.. automodule:: binarycpython.utils.population_extensions.spacing_functions + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/population_extensions/version_info.rst b/docs/source/population_extensions/version_info.rst new file mode 100644 index 0000000000000000000000000000000000000000..ad9852d0541d656aae9ed9a44a92125ec59c3403 --- /dev/null +++ b/docs/source/population_extensions/version_info.rst @@ -0,0 +1,7 @@ +Population class extension: version\_info module +================================================ + +.. automodule:: binarycpython.utils.population_extensions.version_info + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/run_system_wrapper.rst b/docs/source/run_system_wrapper.rst index 388b6878c2394eed9020aa4e3a48a9d531287ff2..d27e3f6fbd0eb9244cf3eef2481d6b07102c94d4 100644 --- a/docs/source/run_system_wrapper.rst +++ b/docs/source/run_system_wrapper.rst @@ -1,5 +1,5 @@ run\_system\_wrapper module -================================= +=========================== .. automodule:: binarycpython.utils.run_system_wrapper :members: diff --git a/docs/source/spacing_functions.rst b/docs/source/spacing_functions.rst deleted file mode 100644 index be0cf254dd52aafbde7404c588be65abcc46493e..0000000000000000000000000000000000000000 --- a/docs/source/spacing_functions.rst +++ /dev/null @@ -1,7 +0,0 @@ -spacing\_functions module -================================= - -.. automodule:: binarycpython.utils.spacing_functions - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/source/useful_funcs.rst b/docs/source/useful_funcs.rst index 2b8b9d26a6b16af7bd581a2d3a42fc746da039a3..fc1ff3c6ce71d8e7c2cb15516c1e95f84596fe1a 100644 --- a/docs/source/useful_funcs.rst +++ b/docs/source/useful_funcs.rst @@ -1,5 +1,5 @@ useful\_funcs module -================================= +==================== .. automodule:: binarycpython.utils.useful_funcs :members: diff --git a/examples/notebook_api_functionality.ipynb b/examples/notebook_api_functionality.ipynb index 504ae4b16880946428716c496c81cbf82eea63a8..49d6f8d3db7beacc8770e2b86b21b4636bbf8e7a 100644 --- a/examples/notebook_api_functionality.ipynb +++ b/examples/notebook_api_functionality.ipynb @@ -105,7 +105,7 @@ " Function that contains random snippets. Do not expect this to remain available, or reliable. i.e. dont use it.\n", "\n", "FILE\n", - " /home/izzard/.local/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so\n", + " /home/david/.pyenv/versions/binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/_binary_c_bindings.cpython-39-x86_64-linux-gnu.so\n", "\n", "\n" ] @@ -166,7 +166,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "<capsule object \"STORE\" at 0x146f912dbc60>\n", + "<capsule object \"STORE\" at 0x7fc1f0c3ff00>\n", "SINGLE_STAR_LIFETIME 10 28.4838\n", "\n" ] @@ -270,586 +270,13 @@ "M_2 : The initial mass of star two (in solar units, internally this is star index 1). : (null)\n", "M_3 : The initial mass of star three (in solar units, internally this is star index 2). : (null)\n", "M_4 : The initial mass of star four (in solar units, internally this is star index 3). : (null)\n", - "vrot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot2,3,4. : (null)\n", - "vrot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,3,4. : (null)\n", - "vrot3 : The initial equatorial rotational velocity of star three (in km/s, internally this is star index 2). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,4. : (null)\n", - "vrot4 : The initial equatorial rotational velocity of star four (in km/s, internally this is star index 3). If 0.0, the Hurley et al 2000/2002 prescription is used to set the main-sequence velocity, so for a truly non-rotating star, set to something small (e.g. 0.001). See also vrot1,2,3. : (null)\n", - "Prot1 : The initial equatorial rotational velocity of star one (in km/s, internally this is star index 0). See also Prot2,3,4. : (null)\n", - "Prot2 : The initial equatorial rotational velocity of star two (in km/s, internally this is star index 1). See also Prot1,3,4. : (null)\n", - "Prot3 : The initial equatorial rotational period of star three (in days, internally this is star index 2). See also Prot1,2,4. : (null)\n", - "Prot4 : The initial equatorial rotational period of star four (in days, internally this is star index 3). See also Prot1,2,3. : (null)\n", - "inclination1 : The initial inclination of star one (in degrees). : (null)\n", - "inclination2 : The initial inclination of star two (in degrees). : (null)\n", - "inclination3 : The initial inclination of star three (in degrees). : (null)\n", - "inclination4 : The initial inclination of star four (in degrees). : (null)\n", - "B_1 : The initial magnetic field of star one (in Gauss, internally this is star index 0). : (null)\n", - "B_2 : The initial magnetic field of star two (in Gauss, internally this is star index 1). : (null)\n", - "B_3 : The initial magnetic field of star three (in Gauss, internally this is star index 2). : (null)\n", - "B_4 : The initial magnetic field of star four (in Gauss, internally this is star index 3). : (null)\n", - "B_inclination1 : The initial inclination of the magnetic field of star one (in degrees). : (null)\n", - "B_inclination2 : The initial inclination of the magnetic field of star two (in degrees). : (null)\n", - "B_inclination3 : The initial inclination of the magnetic field of star three (in degrees). : (null)\n", - "B_inclination4 : The initial inclination of the magnetic field of star four (in degrees). : (null)\n", - "stellar_type_1 : Set the stellar type of star 1 (internal index 0), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_2 : Set the stellar type of star 2 (internal index 1), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_3 : Set the stellar type of star 3 (internal index 2), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "stellar_type_4 : Set the stellar type of star 4 (internal index 3), usually MAIN_SEQUENCE (main sequence). Note that setting the stellar type only works for stars with both age=0 and core_mass=0, i.e. main sequence (hydrogen or helium), white dwarfs, black holes and neutrn stars. : (null)\n", - "max_stellar_type_1 : The maximum stellar type of star 1 (internal index 0). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value. \n", - " : (null)\n", - "max_stellar_type_2 : The maximum stellar type of star 2 (internal index 1). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "max_stellar_type_3 : The maximum stellar type of star 3 (internal index 2). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "max_stellar_type_4 : The maximum stellar type of star 4 (internal index 3). Evolution is stopped when the star reaches this stellar type. If this is negative, massless remnants are allowed, and the maximum stellar type is the absolute value.\n", - " : (null)\n", - "probability : The probability is a weighting applied to the star based on, say, the initial mass function. When running a grid of stars to simulate *all* stars, the summed probability of all the stars should be 1.0. : (null)\n", - "phasevol : The system's phase volume, used by binary_grid. : (null)\n", - "stellar_structure_algorithm : Set the stellar structure algorithm. 0=modified BSE (default), 1=none, 2=external function (must be defined by the calling code), 3=binary_c (not yet implemented). : (null)\n", - "solver : The type of solver. Default is the Forward-Euler (0), but could be RK2 (1), RK4 (2) or a predictor-corretor (3). : (null)\n", - "max_evolution_time : Set the maximum age for the stars (Myr). : (null)\n", - "max_model_number : Set the maximum number of models, ignored if 0 (default is 0). : (null)\n", - "monte_carlo_kicks : Turn on Monte-Carlo SN kicks. On (True) by default, and indeed other algorithms are probably broken. : (null)\n", - "disable_debug : Disables debug output. Only has an effect when DEBUG is 1, which probably requires a rebuild. Default FALSE. : (null)\n", - "timestep_logging : Turn on timestep logging (default is False). : (null)\n", - "rejects_in_log : Show timestep rejections in the main log (default is False). : (null)\n", - "vandenHeuvel_logging : Turn on van den Heuvel logging (default is False). : (null)\n", - "evolution_splitting : If True, turn on splitting of an evolutionary run if splitpoint (e.g. supernova) occurs. : (null)\n", - "disable_events : Whether to disable the new events code (defaults to False, so we use events by default)\n", - " : (null)\n", - "evolution_splitting_sn_eccentricity_threshold : Threshold eccentricity above which evolution splitting happens in a system with no SN kick. (0.01) : (null)\n", - "evolution_splitting_sn_n : Number of runs to split into when a SN occurs. : (null)\n", - "evolution_splitting_maxdepth : Max number of splits in an evolutionary run. : (null)\n", - "equation_of_state_algorithm : Set the equation of state algorithm. 0 = Paczynski. : (null)\n", - "opacity_algorithm : Set the opacity algorithm. 0 = Paczynski, 1 = Ferguson/Opal. : (null)\n", - "wind_mass_loss : Defines the algorithm used for stellar winds. 0 = none, 1 = Hurley et al. (2002), 2 = Schneider (2018). : 0\n", - "gbwind : Wind prescription for first red giant branch stars. 0=Reimers (Hurley et al 2000/2002; choose gb_reimers_eta=0.5 for their mass loss rate), 1=Schroeder+Cuntz 2005 (set gb_reimers_eta=1.0 for their mass loss rate). : (null)\n", - "postagbwind : Apply special post-(A)GB prescription. Default is POSTAGB_WIND_USE_GIANT which means we just use whatever is prescribed on the giant branch. Other options include: POSTAGB_WIND_NONE = 1 (no wind on the post (A)GB), POSTAGB_WIND_KRTICKA2020 = 2 which uses Krticka, Kubát and Krticková (2020, A&A 635, A173). : (null)\n", - "Teff_postAGB_min : The minimum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_max. (6000 K) : (null)\n", - "Teff_postAGB_max : The maximum temperature for which we apply post-(A)GB winds. See also Teff_postAGB_min. (120000 K) : (null)\n", - "mattsson_Orich_tpagbwind : Experimental : turns on Mattsson's TPAGB wind when the star is oxygen rich. Requires MATTSSON_MASS_LOSS. : (null)\n", - "magnetic_braking_factor : Multiplier for the magnetic braking angular momentum loss rate. : (null)\n", - "magnetic_braking_gamma : gamma factor in Rappaport style magnetic braking expression. : (null)\n", - "magnetic_braking_algorithm : Algorithm for the magnetic braking angular momentum loss rate. 0 = Hurley et al. 2002, 1 = Andronov, Pinnsonneault and Sills 2003, 2 = Barnes and Kim 2010 : (null)\n", - "helium_flash_mass_loss : Mass to be lost at the helium flash. : (null)\n", - "gb_reimers_eta : First red giant branch wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) : (null)\n", - "gbwindfac : Multiplier for the giant branch wind mass loss rate : (null)\n", - "tpagbwindfac : Multiplier for the TPAGB wind mass loss rate : (null)\n", - "eagbwindfac : Multiplier for the EAGB wind mass loss rate : (null)\n", - "nieuwenhuijzen_windfac : Multiplier for the Nieuwenhuijzen & de Jager wind mass loss rate : (null)\n", - "tpagbwind : Wind prescription during the TPAGB. 0=Karakas 2002 (a modified Vassiliadis and Wood 1993), 1=Hurley et al 2000/2002 (Vassiliadis and Wood 1993), 2=Reimers, 3=Bloecker, 4=Van Loon, 5=Rob's C-wind (broken?), 6,7=Vassiliadis and Wood 1993 (Karakas,Hurley variants respectively) when C/O>1, 8=Mattsson, 9 = Goldman et al. (2017), 10 = Beasor et al. (2020). : (null)\n", - "eagbwind : Wind prescription during the EAGB. 0=BSE (Hurley+2002, based on VW93), 1 = Goldman et al. (2017), 2 = Beasor et al. (2020). : (null)\n", - "wind_gas_to_dust_ratio : Gas to dust ratio used in wind calculations (e.g. Goldman et al. 2017). Typically 200 (Milky Way)-500 (Magellanic Clouds). Default is 200, approximately as in MW stars. : (null)\n", - "vwind_multiplier : Multiplier for the stellar wind velocity. : (null)\n", - "vwind_beta : Beta for stellar wind speed calculations, where vwind=sqrt(beta) * escape velocity. Default 0.125 (from BSE, Hurley et al. 2002). : (null)\n", - "superwind_mira_switchon : In the Vassiliadis and Wood (1993) AGB wind prescription, the superwind is turned on at a given Mira period, usually 500 days. You can vary when this switch-on happens with this parameter. : (null)\n", - "vw93_mira_shift : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate depends on the Mira period plus this offset. Requires VW93_MIRA_SHIFT. : (null)\n", - "vw93_multiplier : In the Vassiliadis and Wood (1993) AGB wind prescription, the wind loss rate is multiplied by this factor. Requires VW93_MULTIPLIER. : (null)\n", - "tpagb_reimers_eta : TPAGB Reimers wind multiplication factor, cf. eta in Reimers' mass loss formula. (This multiplies the 4e-13 in Reimers' formula, or the 8e-14 in Schroeder and Cuntz.) Note that Reimers is not the default TPAGB wind prescription. See also tpagbwind. : (null)\n", - "Tout_Pringle_1992_multiplier : Multiplier for the Tout & Pringle (1992) magnetic wind. (0.0) : (null)\n", - "artificial_mass_accretion_rate%d : Constant mass accretion rate for star <n>. : (null)\n", - "artificial_mass_accretion_rate_by_stellar_type%d : Constant mass accretion rate for stellar type <n>. : (null)\n", - "artificial_angular_momentum_accretion_rate%d : Constant angular momentum accretion for star <n>. : (null)\n", - "artificial_orbital_angular_momentum_accretion_rate : Constant angular momentum accretion rate on the orbit. : (null)\n", - "artificial_accretion_start_time : Time at which artificial accretion stars. Ignored if <0 (default is -1). : (null)\n", - "artificial_accretion_end_time : Time at which artificial accretion ends. Ignored if <0 (default is -1). : (null)\n", - "wr_wind : Massive-star (WR) wind prescription. 0 = Hurley et al 2000/2002, 1=Maeder and Meynet, 2=Nugis and Lamers, 3=John Eldridge's version of Vink's early-2000s wind (See Lynnette Dray's thesis, or John Eldridge's thesis) : (null)\n", - "wr_wind_fac : Massive-star (WR) wind multiplication factor. : (null)\n", - "wrwindfac : Massive-star (WR) wind multiplication factor. Synonymous with wr_wind_fac (which you should use instead). : (null)\n", - "BH_prescription : Black hole mass prescrition: relates the mass of a newly formed black hole to its progenitor's (CO) core mass. BH_HURLEY2002 = 0 = Hurley et al 2000/2002, BH_BELCZYNSKI = 1 = Belczynski (early 2000s), BH_SPERA2015 = Spera+ 2015, BH_FRYER12_DELAYED = 3 = Fryer et al. (2012) delayed prescription, BH_FRYER12_RAPID = 4 = Fryer et al. (2012) rapid prescription, BH_FRYER12_STARTRACK = 5 = Fryer et al. (2012) startrack prescription. : (null)\n", - "sn_kick_distribution_II : Set the distribution of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_ECAP : Set the distribution of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_NS_NS : Set the distribution of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IBC : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_GRB_COLLAPSAR : Set the distribution of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_TZ : Set the distribution of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_AIC_BH : Set the distribution of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_BH_BH : Set the distribution of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_BH_NS : Set the distribution of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD : Set the distribution of speeds applied to any survivor of a hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD_subluminous : Set the distribution of speeds applied to any survivor of a subluminous hybrid He-COWD SNIa explosion. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_II : Set the dispersion of speeds applied to kick type II core collapse supernova systems. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_ECAP : Set the dispersion of speeds applied to the remnants of electron-capture supernovae. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_NS_NS : Set the dispersion of speeds applied to kick neutron stars and black holes that survive a NS-NS merger. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IBC : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_GRB_COLLAPSAR : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes after a type Ib/c core-collapse supernova which is also a collapsar. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_TZ : Set the dispersion of speeds applied to kick newly-born neutron stars and black holes at the death of a Thorne-Zytkow object. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_AIC_BH : Set the dispersion of speeds applied to kick newly-born neutron stars black holes after accretion induced collapse of a neutron star. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_BH_BH : Set the dispersion of speeds applied to black holes formed by the merger of two black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_BH_NS : Set the dispersion of speeds applied to black holes formed by the merger of a neutron star and a black holes. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD : Set the dispersion of speeds applied to the survivor of a SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD_subluminous : Set the dispersion of speeds applied to the survivor of a subluminous SNIa explosion of a hybrid He-COWD. 0=fixed, 1=maxwellian (hurley/BSE), 2=custom function (see monte_carlo_kicks.c). : (null)\n", - "sn_kick_companion_IA_He : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia He supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_ELD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia ELD (sub-Mch) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_CHAND : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_AIC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an accretion induced collapse (supernova) occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_ECAP : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when an electron capture supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_He_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia helium merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_CHAND_Coal : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Ia Mch merger supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_NS_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron-star neutron-star merger. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_GRB_COLLAPSAR : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a GRB Collapsar (rapidly rotating SN Ibc) supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_HeStarIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a He-star Ia supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IBC : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type Ib/c supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_II : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type II supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IIa : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a type IIa supernova occurs. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_WDKICK : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a WD is kicked. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_TZ : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a Thorne-Zytkow object is formed. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_AIC_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a neutron star collapses to a black hole. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_BH_BH : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when two black holes merge. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_BH_NS : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the, kick on the companion when a black hole merges with a neutron star. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_Hybrid_HeCOWD : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "sn_kick_companion_IA_Hybrid_HeCOWD_subluminous : Set the speed (if >=0) of, or the algothim (if <0) used to calculate the kick on the companion, if it survives, in a subluminous hybrid He-COWD type Ia explosion. 0 = none, 1 = Liu+2015, 2 = Wheeler+ 1975. : (null)\n", - "wd_sigma : Set the speed at which white dwarfs are kicked when they form, in km/s. Default is zero (i.e. no kick). Requires WD_KICKS. : (null)\n", - "wd_kick_direction : Set the direction of white dwarf kicks. 0 = random, 1 = up, 2 = forward, 3 = backward, 4 = inward, 5 = outward. Requires WD_KICKS. : (null)\n", - "wd_kick_when : Decide when to kick a white dwarf. 0=at birth, 1=at first RLOF, 2=at given pulse number (see wd_kick_pulse_number), 3 at every pulse Requires WD_KICKS. : (null)\n", - "wd_kick_pulse_number : Apply a kick to a star at a desired pulse number on the TPAGB (i.e. pre-WD). Requires WD_KICKS. : (null)\n", - "minimum_helium_ignition_core_mass : Minimum helium core mass required to ignite helium in the case that the hydrogen envelope is stripped on the giant branch, e.g. to make an sdB or sdO star. Typically 0.4, if 0.0 then the BSE algorithm (based on the total mass) is used. : (null)\n", - "minimum_CO_core_mass_for_carbon_ignition : Minimum CO core mass for carbon ignition, assuming Mc,bagb>1.6Msun. Typically around 1.08Msun (Pols+1998). : (null)\n", - "minimum_CO_core_mass_for_neon_ignition : Minimum CO core mass for neon ignition. Typically around 1.42Msun. Stars that have cores that ignite carbon, but not neon explode in electon-capture supernovae. : (null)\n", - "minimum_mcbagb_for_nondegenerate_carbon_ignition : Minimum Mc,bagb (core mass at the base of the AGB) for non-degenerate carbon ignition. Typically around 2.25Msun (Pols+1998). : (null)\n", - "maximum_mcbagb_for_degenerate_carbon_ignition : Maximum Mc,bagb (core mass at the base of the AGB) for degenerate carbon ignition. Typically around 1.6Msun (Pols+1998). : (null)\n", - "max_neutron_star_mass : Maximum mass of a neutron star before it collapses to a black hole. Typically around 2Msun. : (null)\n", - "chandrasekhar_mass : The Chandrasekhar mass, usually 1.44Msun : (null)\n", - "delta_mcmin : A parameter to reduce the minimum core mass for third dredge up to occur on the TPAGB. As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null)\n", - "lambda_min : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. See also lambda_multiplier. : (null)\n", - "lambda_multiplier : A parameter to increase the efficiency of third dredge up on the TPAGB. The efficiency is lambda * lambda_mult, and setting lambda_min>0 implies that, once Mc>Mcmin (see delta_mcmin) lambda=Max(lambda(fit to Karakas), lambda_min). As used by Izzard and Tout (2004) to increase the amount of dredge up, hence carbon, in Magellanic cloud stars. : (null)\n", - "minimum_envelope_mass_for_third_dredgeup : The minimum envelope mass for third dredge up on the TPAGB. Early, solar metallicity models by Straniero et al suggested 0.5Msun is typical. However, circumstantial evidence (Izzard et al 2009) as well as newer models by Stancliffe and Karakas suggest that at low metallicity a value nearer zero is more appropriate. : (null)\n", - "mass_of_pmz : The mass in the partial mixing zone of a TPAGB star, using the Karakas 2012 tables. Ask Carlo Abate for more details, or see the series of papers Abate et al 2012, 2013, 2014. Requires NUCSYN and USE_TABULAR_INTERSHELL_ABUNDANCES_KARAKAS_2012. : (null)\n", - "c13_eff : The \"efficiency\" of partial mixing in a TPAGB star intershell region, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null)\n", - "mc13_pocket_multiplier : Multiplies the mass in the partial mixing zone of a TPAGB star, when using the s-process tables of Gallino, Busso, Lugaro et al. as provided by Maria Lugaro for the Izzard et al. 2009 paper. Requires NUCSYN and NUCSYN_S_PROCESS. : (null)\n", - "tides_convective_damping : Tidal convective damping algorithm. 0=TIDES_HURLEY2002 Zahn 197x timescales + Hut, as in Hurley et al (2002), 1 = TIDES_ZAHN1989 : Zahn 1989 lambdas + Hut. : (null)\n", - "E2_prescription : Choose how to calculate the E2 structural parameter (used in tidal timescale calculations). 0=Hurley 1=Izzard (see Siess et al 2013). : (null)\n", - "dtfac : A parameter to decrease the timestep ONLY during the TPAGB phase. : (null)\n", - "hbbtfac : A parameter to modulate the temperature at the base of the hot-bottom burning zone in TPAGB stars. (Works only if NUCSYN is defined) : (null)\n", - "wind_multiplier_%d : Wind multiplier for the stellar type specified by the intger %d. By default these are all 1.0. : (null)\n", - "wind_type_multiplier_%d : Wind multiplier for different types of wind (MS, GB, AGB, WR, LBV, OTHER), given by the integer %d. By default these are all 1.0. : (null)\n", - "pre_main_sequence : Set to True to turn on pre-main sequence evolution. Currently this is not a special stellar type, rather the first (small) fraction of the main sequence has increased radii to match the Railton et al 2014 fits to Tout's pre-main sequence stars. Requires PRE_MAIN_SEQUENCE. See also pre_main_sequence_fit_lobes. : (null)\n", - "pre_main_sequence_fit_lobes : Set to True force a pre-main sequence star into its Roche lobe. This is done by artificially aging it. Requires PRE_MAIN_SEQUENCE : (null)\n", - "small_envelope_method : Choose the method used to determine the stellar radius when the envelope mass is very thin. 0 = Hurley et al. (2002), 1 = Miller Bertolami et al. (2016+) for GB and AGB stars only. : (null)\n", - "timestep_modulator : Multiplier applied to the global timestep. Requires TIMESTEP_MODULATION. : (null)\n", - "timestep_multiplier%d : Multiplier applied to timestep limit <n>. : (null)\n", - "maximum_timestep : The maximum timestep (MYr). : (null)\n", - "zoomfac_multiplier_decrease : When a timestep is rejected, decrease the timestep by this factor (0.5). : (null)\n", - "zoomfac_multiplier_increase : When a timestep is rejected, zooms, then succeeds, increase the timestep by this factor (1.2). : (null)\n", - "maximum_timestep_factor : The maximum factor between two subsequent timesteps (1.2). : (null)\n", - "maximum_nuclear_burning_timestep : The maximum timestep (MYr) in any nuclear burning phase. : (null)\n", - "nova_retention_method : Algorithm used to calculate the amount of mass retained during a nova explosion. 0=use nova_retention_fraction. (other methods pending) : (null)\n", - "MINT_metallicity : This sets the metallicity for MINT. It is ignored if set to -1.0, the default, in which case the normal metallicity parameter is used. : (null)\n", - "gaia_Teff_binwidth : log10(Effective temperature) bin width used to make Gaia-like HRDs\n", - " : (null)\n", - "gaia_L_binwidth : log10(luminosity) bin width used to make Gaia-like HRDs\n", - " : (null)\n", - "gaia_colour_transform_method : Use this to select the method used to transform to Gaia colours from other colour schemes. GAIA_CONVERSION_UBVRI_UNIVARIATE_JORDI2010 = 0 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_UBVRI_BIVARIATE_JORDI2010 = 1 Jordi et al.'s bivariate UBVRI fits, GAIA_CONVERSION_ugriz_UNIVARIATE_JORDI2010 = 2 Jordi et al.'s univariate UBVRI fits, GAIA_CONVERSION_ugriz_BIVARIATE_JORDI2010 = 3 Jordi et al.'s univariate ugriv fits, GAIA_CONVERSION_UBVRI_UNIVARIATE_EVANS2018 = 4 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_ugriz_UNIVARIATE_EVANS2018 = 5 Evans et al. (2018, DR2) fits, GAIA_CONVERSION_UBVRI_RIELLO2020 = 6 Riello et al. (2020, DR3) fits, GAIA_CONVERSION_ugriz_RIELLO2020 = 7 Riello et al. (2020, DR3) fits. : (null)\n", - "rotationally_enhanced_mass_loss : Set to 1 to enable rotationally enhanced mass loss rate algorithms: 0= none, 1=formula cf. Langer models (=ROTATIONALLY_ENHANCED_MASSLOSS_LANGER_FORMULA), 2=limit accretion rate before wind loss is applied, 3 = both 1 and 2. See also rotationally_enhanced_exponent : (null)\n", - "AGB_core_algorithm : Algorithm to use for calculating AGB core masses. 0=Hurley et al. 2002 if no NUCSYN, Karakas 2002 if NUCSYN is defined; 1=Hurley et al. 2002 (overshooting models); 1=Karakas 2002 (non-overshooting models). : (null)\n", - "AGB_radius_algorithm : Algorithm to use for calculating radii on the TPAGB. : (null)\n", - "AGB_luminosity_algorithm : Algorithm to use for calculating luminosities on the TPAGB. : (null)\n", - "AGB_3dup_algorithm : Algorithm to use for calculating third dredge up efficiency on the TPAGB. : (null)\n", - "overspin_algorithm : Algorithm to determine what we do when a star is rotating at its breakup velocity. OVERSPIN_BSE (0) conservatively transfers the angular momentum back to the orbit. OVERSPIN_MASSLOSS uses the rotationally_enhanced_massloss parameter to lose mass which carries away the angular momentum. : (null)\n", - "rotationally_enhanced_exponent : The exponent (power) by which rotationally enhanced mass loss is raised. Requires ROTATIONALLY_ENHANCED_MASS_LOSS. See also rotationally_enhanced_mass_loss. : (null)\n", - "batchmode : Set the batchmode control variable. Use only if you know what you are doing! : (null)\n", - "speedtests : If True, turns on speedtests during version information (off by default). : (null)\n", - "use_fixed_timestep_%d : Set to True to use fixed timestep <n>, False to turn off. Fixed timesteps are on (this is True) by default. : (null)\n", - "task%d : Control tasks to be performed by binary_c. By default, these are all TRUE. For more information see binary_c_macros.h, particularly the BINARY_C_TASK_* macros. : (null)\n", - "orbiting_object : Usage: --orbiting_object mass,spinrate,central_object,period. : 1.0\n", - "orbiting_objects_log : If True, turn on orbiting-object log. : (null)\n", - "orbiting_objects_log : If True, turn on orbiting-object log. : (null)\n", - "orbiting_objects_wind_accretion_multiplier : Multiplier for wind accretion on orbiting objects. Hurley et al 2002 use 1.5, which is the default. : (null)\n", - "orbiting_objects_close_pc_threshold : How close are orbiting objects allowed to be? Set this to be the absolute percentage difference minimum. : (null)\n", - "orbiting_objects_tides_multiplier : Multiplier for tidal torques on orbiting objects. : (null)\n", - "evaporate_escaped_orbiting_objects : If True, evaporate orbiting objects that have escaped the system. : (null)\n", - "RLOF_transition_objects_escape : If True, objects that escape their Roche lobe are ejected from the system, otherwise they are placed just outside the minimum stable orbit. : (null)\n", - "PN_resolve : If True, the timestep will be shortened to resolve better the PN phase (FALSE). : (null)\n", - "PN_resolve_minimum_luminosity : The luminosity above which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_resolve_maximum_envelope_mass : The envelope mass below which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_resolve_minimum_effective_temperature : The minimum effective temperature above which extra time resolution for PNe is applied (see PN_resolve). : (null)\n", - "PN_fast_wind : If True, thin-envelope PNe will have fast winds (FALSE). : (null)\n", - "PN_fast_wind_dm_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null)\n", - "PN_fast_wind_mdot_GB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_GB) : (null)\n", - "PN_fast_wind_dm_AGB : The envelope mass below which fast wind used during the AGB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null)\n", - "PN_fast_wind_mdot_AGB : The envelope mass below which fast wind used during the GB if PN_fast_wind is TRUE. (See also PN_fast_wind, PN_fast_wind_mdot_AGB) : (null)\n", - "HeWD_HeWD_ignition_mass : HeWD-HeWD mergers above this mass reignite helium. (0.3) : (null)\n", - "wind_Nieuwenhuijzen_luminosity_lower_limit : Above this luminosity we activate the Nieuwenhuijzen and de Jager wind (4e3 Lsun). : (null)\n", - "wind_LBV_luminosity_lower_limit : Above this luminosity we activate the LBV wind (6e5 Lsun). : (null)\n", - "colour%d : Sets colour %d (0 to NUM_ANSI_COLOURS-1) to the extended ANSI set colour you choose (1-255, 0 means ignore). The colour numbers are defined in src/logging/ansi_colours.h : (null)\n", - "apply_Darwin_Radau_correction : Apply Darwin-Radau correction to the moment of inertia to take rotation into account? : (null)\n", - "degenerate_core_merger_nucsyn : If TRUE, assume that in a degnerate core merger, energy is generated from nucleosynthesis of the whole core, and that this can disrupt the core. The BSE algorithm (Hurley et al. 2002) assumes this to be TRUE, but binary_c assumes FALSE by default. (FALSE) : (null)\n", - "degenerate_core_helium_merger_ignition : If TRUE, assume that when there is a degenerate helium core merger, the star reignites helium. This is required to make R-type carbon stars. (TRUE) : (null)\n", - "degenerate_core_merger_dredgeup_fraction : If non-zero, mix this fraction of the degenerate core during a merger.(0.0). : (null)\n", - "\n", - "############################################################\n", - "##### Section Binary\n", - "############################################################\n", - "separation : Set the orbital separation (actually the semi-major axis) of the binary (internal index 0, stellar indices 0 and 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "separation_triple : Set the orbital separation (actually the semi-major axis) of the triple (internal index 1) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "separation_quadruple : Set the orbital separation (actually the semi-major axis) of the quadruple (internal index 2) in solar radii. Note that if the orbital period is given, it is used to calculate the separation. So if you want to set the separation instead, either do not set the orbital period or set the orbital period to zero (0.0). : (null)\n", - "orbital_period : Set the initial orbital period of the binary, stars 1 and 2 (internal indices 0 and 1) in days. See also separation. : (null)\n", - "orbital_period_triple : Set the initial orbital period of the triple in days. See also separation. : (null)\n", - "orbital_period_quadruple : Set the orbital period of the outer binary in a quadrulple (stars 3 and 4, internal indices 2 and 3) in days. See also separation. : (null)\n", - "eccentricity : Set the initial eccentricity of the binary orbit (stars 1 and 2, internal indices 0 and 1). : (null)\n", - "eccentricity_triple : Set the initial eccentricity of the triple orbit. : (null)\n", - "eccentricity_quadruple : Set the initial eccentricity of the outer binary of a quadruple (stars 3 and 4, internal indices 2 and 3). : (null)\n", - "incliniation : Set the initial orbital_inclination of the binary relative to zero. : (null)\n", - "incliniation_triple : Set the initial orbital_inclination of the triple orbit relative to zero. : (null)\n", - "incliniation_quadruple : Set the initial orbital_inclinationy of the quadruple orbit relative to zero. : (null)\n", - "orbital_phase : Set the initial orbital phase of the binary orbit. : (null)\n", - "orbital_phase_triple : Set the initial orbital phase of the triple orbit. : (null)\n", - "orbital_phase_quadruple : Set the initial orbital phase of the quadruple orbit. : (null)\n", - "argument_of_periastron : Set the initial argument of periastron of the binary orbit. : (null)\n", - "argument_of_periastron_triple : Set the initial argument of periastron of the triple orbit. : (null)\n", - "argument_of_periastron_quadruple : Set the initial argument of periastron of the quadruple orbit. : (null)\n", - "disc_timestep_factor : Factor that multiplies the natural timestep of a disc. : (null)\n", - "white_dwarf_cooling_model : White dwarf cooling model, relates age to luminosity. WHITE_DWARF_COOLING_MESTEL = 0 is Mestel's model, WHITE_DWARF_COOLING_MESTEL_MODIFIED = 1 is Hurley's modified Mestel model, WHITE_DWARF_COOLING_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null)\n", - "white_dwarf_radius_model : White dwarf radius model, radius to mass (and perhaps age). WHITE_DWARF_RADIUS_NAUENBERG1972 = 0 Nauenberg (1972), WHITE_DWARF_RADIUS_MU = 1 mu-dependent variant, WHITE_DWARF_RADIUS_CARRASCO2014 = 2 is based on Carrasco (2014) tables. : (null)\n", - "cbdisc_mass_loss_inner_viscous_accretion_method : Chooses where the mass that is accreted from the inner edge of a circumbinary disc goes, i.e. to which star. 0 = Young and Clarke 2015, 1 = Gerosa et al 2015, 2 = 50:50 (i.e. not dependence on mass). : (null)\n", - "cbdisc_inner_edge_stripping : If True, allow inner edge mass stripping. : (null)\n", - "cbdisc_end_evolution_after_disc : If True, stop evolution when a disc evaporates. : (null)\n", - "cbdisc_no_wind_if_cbdisc : If True, disable stellar winds when there is a circumbinary disc. : (null)\n", - "cbdisc_outer_edge_stripping : If True, allow outer edge mass stripping. : (null)\n", - "disc_n_monte_carlo_guesses : Number of monte carlo guesses to try in the disc solver if the normal list of guesses fails (0). : (null)\n", - "disc_log : If 1, turn on the disc log. Requires DISC_LOG to be defined on build. : (null)\n", - "disc_log2d : If 1, turn on the 2d disc log. Requires DISC_LOG to be defined on build. : (null)\n", - "disc_log_dt : If non-zero, only allows disc log output every disc_log_dt Myr. : (null)\n", - "disc_log_directory : Directory into which disc logging is sent (must exist!). : /tmp/\n", - "post_ce_adaptive_menv : If TRUE, and if post_ce_objects_have_envelopes is TRUE, then the envelope mass of a post-CE star is such that it sits just inside its Roche lobe. If FALSE then a fixed (thin) envelope mass is applied that depends on the stellar type (see macros POST_CE_ENVELOPE_DM_GB, POST_CE_ENVELOPE_DM_EAGB and POST_CE_ENVELOPE_DM_TPAGB). : (null)\n", - "post_ce_objects_have_envelopes : If TRUE then post-common-envelope objects have thin envelopes. You need this if you are to have post-CE post-AGB stars. Note that this *may* be unstable, i.e. you may end up having many CEEs. The mass in the envelope is controlled by post_ce_adaptive_menv. TRUE by default. : (null)\n", - "PN_comenv_transition_time : post-common envelope transition time in years (1e2). This is the time taken to move from CEE ejection to Teff > 30e4 K. Hall et al. (2013) suggest ~100 years. : (null)\n", - "minimum_time_between_PNe : The minimum time (Myr) between planetary nebula detections. This prevents multiple, fast common envelopes triggering two PNe (0.1). : (null)\n", - "PN_Hall_fading_time_algorithm : In stars with low mass (<0.45Msun) cores, you can choose to set the PN fading time to either the minimum (PN_HALL_FADING_TIME_ALGORITHM_MINIMUM) or maximum (PN_HALL_FADING_TIME_ALGORITHM_MAXIMUM) as shown in Fig. 6 of Hall et al. (2013). : (null)\n", - "PPN_envelope_mass : Desired pre-planetary nebula (post-AGB) envelope mass. : (null)\n", - "cbdisc_eccentricity_pumping_method : Select from various eccentricity-pumping methods when there is a circumbinary disc. Requires DISCS. 0 = off. : (null)\n", - "cbdisc_viscous_photoevaporative_coupling : Set to 1 to turn on viscous-photoevaporative coupling in circumbinary discs. Requires DISCS. 0 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_NONE = off, 1 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_INSTANT instant, 2 = CBDISC_VISCOUS_PHOTOEVAPORATIVE_COUPLING_VISCOUS slow, viscous wind. : (null)\n", - "cbdisc_inner_edge_stripping_timescale : Defines the timescale for mass loss from by inner edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_in. : (null)\n", - "cbdisc_outer_edge_stripping_timescale : Defines the timescale for mass loss from by outer edge stripping. 0 = instant, 1 = very long, 2 = viscous at Revap_in, 3 = orbital at Revap_out. : (null)\n", - "cbdisc_viscous_L2_coupling : Set to 1 to turn on viscous-L2-loss coupling in circumbinary discs. Requires DISCS. 0 = off. : (null)\n", - "gravitational_radiation_model : Model for gravitational radiation from the system. 0=Hurley et al 2002 (Landau and Lifshitz 1951). 1 = as 0 but only when there is no RLOF. 2 = none. : (null)\n", - "nova_irradiation_multiplier : Multiplier for nova-radiative induced mass loss. (Shara+1986) : (null)\n", - "gravitational_radiation_modulator_J : Modulator for gravitational wave radiation angular momentum loss rate (1.0). : (null)\n", - "gravitational_radiation_modulator_e : Modulator for gravitational wave radiation eccentricity pumping rate (1.0). : (null)\n", - "nova_faml_multiplier : Nova friction-induced angular momentum loss multiplier. (Shara+1986) : (null)\n", - "RLOF_angular_momentum_transfer_model : Choose angular momentum transfer model in RLOF. 0=BSE (with discs), 1=conservative : (null)\n", - "post_SN_orbit_method : Method by which the post-SN orbit is calculated. 0=BSE, 1=Tauris&Taken 1998. : (null)\n", - "multiplicity : Multiplicity: 1=single star, 2=binary, 3=triple, 4=quadruple. : (null)\n", - "accretion_limit_eddington_steady_multiplier : Steady accretion is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_steady_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_eddington_LMMS_multiplier : Accretion from a low-mass, convective, main_sequence star is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_LMMS_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_eddington_WD_to_remnant_multiplier : Accretion from a WD onto a remnant star (e.g. another white dwarf, neutron star or black hole) is limited by the Eddington instability, with limiting rate given by the accretion_limit_eddington_WD_to_remnant_multiplier * the normal (spherically symmetric) Eddington rate. This is known in the trade as the Eddington factor, and anything greater than 1.0 potentially gives you super-Eddington accretion. : (null)\n", - "accretion_limit_thermal_multiplier : Mass transfer onto a MS, HG or CHeB star is limited by the accretor's thermal rate times this multiplier. : (null)\n", - "accretion_limit_dynamical_multiplier : Mass transfer is limited by the accretor's dynamical rate times this multiplier. : (null)\n", - "donor_limit_envelope_multiplier : Mass transfer by RLOF is limited by this fraction of the donor's envelope mass per timestep : (null)\n", - "donor_limit_thermal_multiplier : Mass transfer by RLOF is limited by the accretor's thermal rate times this multiplier. : (null)\n", - "donor_limit_dynamical_multiplier : Mass transfer by RLOF is limited by the donor's dynamical rate times this multiplier. : (null)\n", - "Bondi_Hoyle_accretion_factor : Wind accretion rate, as calculated by the Bondi-Hoyle-Littleton formula, multiplcation factor. Hurley et al 2002 use 1.5, which is the default. : (null)\n", - "tidal_strength_factor : A modulator for the tidal strength. If this factor > 1 then tides are stronger, i.e. tidal timescales are reduced. : (null)\n", - "hachisu_qcrit : Critical q=Maccretor/Mdonor above which Hachisu's disk wind turns on. : (null)\n", - "hachisu_disk_wind : Set to True to turn on Hachisu's disk wind when material accretes too fast onto a white dwarf. This helps to make more SNeIa. See also hachisu_qcrit. : (null)\n", - "mass_accretion_for_eld : The mass that must be accreted onto a COWD for it to ignite as an edge-lit detonation SNIa. : (null)\n", - "WDWD_merger_algorithm : Algorithm to be used when merging two white dwarfs. 0 = Hurley et al. (2002), 1 = Perets+ (2019), 2 = Chen+ (2016, todo) : (null)\n", - "type_Ia_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from Chandrasekhar-mass exploders. 0 = DD7 (Iwamoto 1999), 1 = Seitenzahl 2013 3D hydro yields (you must also set Seitenzahl2013_model) : (null)\n", - "Seitenzahl2013_model : Which of Seitenzahl et al. 2013's models to use? One of N1,N3,N5,N10,N20,N40,N100L,N100,N100H,N150,N200,N300C,N1600,N1600C,N100_Z0.5,N100_Z0.1,N100_Z0.01 (defaults to N100). : N1\n", - "type_Ia_sub_MCh_supernova_algorithm : Algorithm to be used when calculating type Ia yields from sub-Chandrasekhar-mass exploders. (Currently unused.) : (null)\n", - "max_HeWD_mass : The maximum mass a HeWD can have before it ignites helium (0.7). : (null)\n", - "merger_mass_loss_fraction : Fraction of the total mass which is lost when stars merge. : (null)\n", - "merger_angular_momentum_factor : When two stars merge the resulting single star retains a fraction of the total system angular momentum (or the critical spin angular momentum, if it is smaller) multiplied by this factor. : (null)\n", - "wind_angular_momentum_loss : Prescription for losing angular momentum in a stellar wind. 0=Hurley et al 2002 ('Tout') prescription, 1=lw i.e. a factor multiplying the specific orbital angular momentum, 2=lw hybrid for fast winds. Set wind_djorb_fac to the desired factor.. : (null)\n", - "wind_djorb_fac : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=0 (the Tout/Hurley et al 2002 prescription). See wind_angular_momentum_loss. : (null)\n", - "lw : Factor multiplying angular momentum loss in a stellar wind when wind_angular_momentum_loss=1,2 (the 'lw' prescription). See wind_angular_momentum_loss. : (null)\n", - "VW93_EAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null)\n", - "VW93_TPAGB_wind_speed : Activate this to use Vassiliadis and Wood (1993) wind speed during the EAGB. : (null)\n", - "use_periastron_Roche_radius : Set this to True to use the Roche lobe radius at periastron, rather than (the default to) assume a circular orbit. This will be useful one day when we treat RLOF in eccentric orbits properly, hopefully. : (null)\n", - "qcrit_LMMS : Apply critical q=Mdonor/Maccretor value for low-mass main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for non-degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_LMMS : Apply critical q=Mdonor/Maccretor value for (low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_MS : Apply critical q=Mdonor/Maccretor value for (non-low mass) main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HG : Apply critical q=Mdonor/Maccretor value for Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_GB : Apply critical q=Mdonor/Maccretor value for first red giant branch stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_CHeB : Apply critical q=Mdonor/Maccretor value for core helium burning stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_EAGB : Apply critical q=Mdonor/Maccretor value for early-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_TPAGB : Apply critical q=Mdonor/Maccretor value for TP-AGB stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeMS : Apply critical q=Mdonor/Maccretor value for helium main sequence stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeHG : Apply critical q=Mdonor/Maccretor value for helium Hertzsprung gap stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeGB : Apply critical q=Mdonor/Maccretor value for helium red giant stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_HeWD : Apply critical q=Mdonor/Maccretor value for helium white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_COWD : Apply critical q=Mdonor/Maccretor value for carbon-oxygen white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_ONeWD : Apply critical q=Mdonor/Maccretor value for oxygen-neon white dwarf stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_NS : Apply critical q=Mdonor/Maccretor value for neutron stars to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "qcrit_degenerate_BH : Apply critical q=Mdonor/Maccretor value for black holes to determine the stability of Roche-lobe overflow for degenerate accretors. See also qcrits_*, qcrits_degenerate_*. : (null)\n", - "mass_for_Hestar_Ia_upper : Only helium stars below this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_lower. : (null)\n", - "mass_for_Hestar_Ia_lower : Only helium stars above this mass can explode as SNIa. Default is zero, i.e. it never happens. See also mass_for_Hestar_Ia_upper. : (null)\n", - "alphaCB : Circumbinary disk viscosity parameter, alpha. : (null)\n", - "minimum_donor_menv_for_comenv : Minimum donor envelope mass for common envelope evolution to be triggered (Msun). Default 0. : (null)\n", - "comenv_prescription : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null)\n", - "comenv_prescription%d : Use this to choose which common envelope prescription you should use. 0=Hurley et al 2002 (based on the PaczyÅ„ski energy model) or 1=Nelemans and Tout (angular momentum model). See also alpha_ce, comenv_ms_accretion_mass, comenv_ms_accretion_fraction, comenv_ns_accretion_fraction, comenv_ns_accretion_mass, nelemans_gamma, nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs, lambda_ce, lambda_ionisation. : (null)\n", - "comenv_ejection_spin_method : When a common envelope is ejected, we need to decide how fast the stars are left spinning. COMENV_EJECTION_SPIN_METHOD_DO_NOTHING (0) is the default, this just leaves the stars/stellar cores spinning with the same spin rate (omega = angular velocity) with which they entered the common envelope phase. COMENV_EJECTION_SPIN_METHOD_SYCHRONIZE instead tidally synchronizes the stars with their new orbital angular velocity. : (null)\n", - "comenv_merger_spin_method : When a common envelope binary merges, we need to decide how fast the resulting single star is left spinning. COMENV_MERGER_SPIN_METHOD_SPECIFIC (0) is the default, this preserves angular momentum but limits the specific angular momentum of the merged star to the specific angular momentum of the system at the onset of common envelope evolution. COMENV_MERGER_SPIN_METHOD_CONSERVE_ANGMOM (1) sets the merger's angular momentum to be that of the system at the onset of common envelope evolution (which means the star may be rotating supercritically). COMENV_MERGER_SPIN_METHOD_CONSERVE_OMEGA (2) sets the spin rate (angular frequency = omega) of the merged star to be that of the orbit just at the onset of common envelope evolution. : (null)\n", - "comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null)\n", - "comenv_ms_accretion_fraction : Experimental. During common envelope evolution, a main sequence may accrete a fraction of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_mass. : (null)\n", - "comenv_ns_accretion_mass : Experimental. During common envelope evolution, a neutron star may accrete some of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_fraction. : (null)\n", - "comenv_ns_accretion_fraction : Experimental. During common envelope evolution, a neutron star may accrete a fraction of the envelope's mass. Requires COMENV_NS_ACCRETION. See also comenv_ns_accretion_mass. : (null)\n", - "alpha_ce : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null)\n", - "alpha_ce%d : Common envelope energy formalism parameter. A fraction alpha of the orbital energy is used to eject the envelope. See Hurley et al 2002 for details. : (null)\n", - "lambda_ce : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to LAMBDA_CE_DEWI_TAURIS == -1 binary_c uses the Dewi and Tauris fits instead, LAMBDA_CE_WANG_2016 == -2 uses the formalism of Wang, Jia and Li (2016), if LAMBDA_CE_POLYTROPE == -3 then a polytropic formalism is used (see also comenv_splitmass) and if LAMBDA_CE_KLENCKI_2020 == -4 use Klencki et al. (2020). : (null)\n", - "lambda_ce%d : Common envelope parameter. The binding energy of the common envelope is G*M*Menv/(lambda*R). Typically this is taken to be 0.5, but if set to -1 binary_c uses the Dewi and Tauris fits instead, -2 uses the formalism of Wang, Jia and Li (2016) and if -3 then a polytropic formalism is used (see also comenv_splitmass). : (null)\n", - "comenv_splitmass : When lambda_ce=-2, the envelope binding energy, lambda, is calculated using a polytropic formalism. The comenv_splitmass defines the point, in the units of the core mass, above which material is ejected. : (null)\n", - "nelemans_recalc_eccentricity : If True, recalculate the eccentricity after angular momentum is removed. : (null)\n", - "comenv_post_eccentricity : Eccentricity remaining after common envelope ejection. : (null)\n", - "nelemans_gamma : Set the fraction of the orbital specific angular momentum that is used to eject the common envelope according to the Nelemans and Tout prescription. See also nelemans_minq, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null)\n", - "nelemans_minq : Only activate the Nelemans and Tout common envelope prescription for q>nelemans_minq. See also nelemans_gamma, nelemans_max_frac_j_change, nelemans_n_comenvs. : (null)\n", - "nelemans_max_frac_j_change : Maximum fractional angular momentum change in the Nelemans and Tout common envelope prescription. See also nelemans_gamma, nelemans_minq, nelemans_n_comenvs. : (null)\n", - "nelemans_n_comenvs : Set the maximum number of common envelope ejections allowed to follow the Nelemans and Tout prescription, after which the standard alpha prescription is used. : (null)\n", - "lambda_ionisation : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null)\n", - "lambda_ionisation%d : A fraction lambda_ionisation of the recombination energy in the common envelope goes into ejecting the envelope. This is usually 0.0, but a positive value can make a big difference to the outcome of common envelope evolution. : (null)\n", - "lambda_enthalpy : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null)\n", - "lambda_enthalpy%d : A fraction of the enthalpy to be included in the common envelope evolution binding energy. Only used for the Wang 2016 prescription (so far). : (null)\n", - "cbdisc_albedo : Circumbinary-disc albedo. Requires DISCS. : (null)\n", - "cbdisc_gamma : Circumbinary disc gamma (equation of state) parameter. Requires DISCS. : (null)\n", - "cbdisc_alpha : Circumbinary disc alpha (viscosity) parameter. Requires DISCS. : (null)\n", - "cbdisc_kappa : Circumbinary disc kappa (opacity) parameter. Requires DISCS. : (null)\n", - "cbdisc_minimum_evaporation_timescale : Circumbinary disc minimum evaporation timescale (years). If (slow, not edge stripped) mass loss would evaporate the disc on a timescale less than this, simply evaporate the disc immediated. Usually set to 1y, ignore if zero. Requires DISCS. : (null)\n", - "cbdisc_torquef : Circumbinary disc binary torque multiplier. Requires DISCS. : (null)\n", - "cbdisc_max_lifetime : Circumbinary disc maximum lifetime (years, ignored if 0). Requires DISCS. : (null)\n", - "cbdisc_init_dM : On cbdisc start, reduce mass by a fraction dM if it won't converge. Requires DISCS. : (null)\n", - "cbdisc_init_dJdM : On cbdisc start, reduce angular momentum by a fraction dJ/dM*dM if it won't converge. Requires DISCS. : (null)\n", - "cbdisc_mass_loss_constant_rate : Circumbinary disc constant mass loss rate (Msun/year). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_FUV_multiplier : Circumbinary disc FUV mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_Xray_multiplier : Circumbinary disc X-ray mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_ISM_ram_pressure_multiplier : Circumbinary disc interstellar medium ram pressure stripping mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_ISM_pressure : Circumbinary disc interstellar medium ram pressure in units of Boltzmann constant per Kelvin (I think...). Requires DISCS. Typically 3000.0. See e.g. http://www.astronomy.ohio-state.edu/~pogge/Ast871/Notes/Intro.pdf page 15 or https://arxiv.org/pdf/0902.0820.pdf Fig. 1 (left panel). : (null)\n", - "cbdisc_mass_loss_inner_viscous_multiplier : Circumbinary disc inner edge viscous mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_mass_loss_inner_viscous_angular_momentum_multiplier : Circumbinary disc inner edge viscous angular momentum multiplier (no units). The inner edge angular momentum Requires DISCS. : (null)\n", - "cbdisc_resonance_multiplier : Circumbinary disc resonant interaction multiplier, affects eccentricity pumping and angular momentum rates. Requires DISCS. : (null)\n", - "cbdisc_resonance_damping : Circumbinary disc resonant interaction damping: should be on (True) to damp the l=1, m=2 resonance when the disc inner edge lies outside the resonance location. Requires DISCS. : (null)\n", - "cbdisc_fail_ring_inside_separation : If True, while converging on a structure, circumbinary discs with Rring < the binary separation are immediately failed. : (null)\n", - "cbdisc_mass_loss_inner_L2_cross_multiplier : Circumbinary disc inner edge L2-crossing mass loss rate multiplier (no units). Requires DISCS. : (null)\n", - "cbdisc_minimum_luminosity : Circumbinary disc minimum luminosity. If the disc becomes dimmer than this, the disc is evaporated instantly. Requires DISCS. : (null)\n", - "cbdisc_minimum_mass : Circumbinary disc minimum mass. If the disc becomes less massive than this, the disc is evaporated instantly. Requires DISCS. : (null)\n", - "cbdisc_minimum_fRing : Circumbinary disc minimum fRing. If the disc becomes a ring, and fRing = |Rout/Rin-1| < this value (and this value is non-zero), the disc is evaporated instantly. Requires DISCS. : (null)\n", - "comenv_disc_angmom_fraction : If >0 Fraction of the common envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the moments of inertia to calculate (deprecated), if -2 use the common envelope's specific angular momentum, if -3 uses the L2 point at the end of the common envelope to set the angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null)\n", - "comenv_disc_mass_fraction : Fraction of the common envelope's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_COMENV. : (null)\n", - "wind_disc_angmom_fraction : If >0 Fraction of the wind envelope's angular momentum that goes into the circumbinary disc. If -1 then uses the L2 point's specific angular momentum. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null)\n", - "wind_disc_mass_fraction : Fraction of the stellar wind's mass that goes into the circumbinary disc. Requires DISCS and DISCS_CIRCUMBINARY_FROM_WIND. : (null)\n", - "WRLOF_method : Choose whether and how to apply wind-Roche-lobe-overflow. 0=none, 1=q-dependent, 2=quadratic See Abate et al 2013/14 for details. Requires WRLOF_MASS_TRANSFER. : (null)\n", - "minimum_timestep : The minimum timestep (Myr). : (null)\n", - "timestep_solver_factor : Factor applied in timestep_limits, e.g. to prevent X changing too fast by comparing to X/dX/dt, which is usually 1 but can be higher to lengthen timesteps when using an alternative solver. : (null)\n", - "RLOF_mdot_factor : Multiplier applied to the mass transfer rate during Roche-lobe overflow. Requires RLOF_MDOT_MODULATION. : (null)\n", - "RLOF_f : Factor to enlarge a Roche lobe, nominally because of radiation pressure (see Dermine et al paper). Requires RLOF_RADIATION_CORRECTION. : (null)\n", - "minimum_separation_for_instant_RLOF : If True, instead of evolving the system just report the minimum separation (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_orbital_period_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null)\n", - "minimum_orbital_period_for_instant_RLOF : If True, instead of evolving the system just report the minimum orbital period (on the zero-age main sequence) that would lead to instant RLOF. Used by binary_grid. See also minimum_separation_for_instant_RLOF and maximum_mass_ratio_for_instant_RLOF. : (null)\n", - "maximum_mass_ratio_for_instant_RLOF : If True, instead of evolving the system just report the maximum mass ratio (on the zero-age main sequence) that would lead to instant RLOF, given M1 and orbital period. Used by binary_grid. See also minimum_separation_for_instant_RLOF and minimum_orbital_period_for_instant_RLOF. : (null)\n", - "RLOF_method : Use RLOF_method to choose the algorithm you use for Roche-lobe overflow mass loss rate calculations. 0=Hurley et al 2002, 1=Adaptive (for radiative stars) R=RL method, 2=Ritter (probably broken), 3=Claeys etal 2014 variant on Hurley et al 2002. : (null)\n", - "RLOF_interpolation_method : When a star overflows its Roche lobe, it always has R>RL because of the limited time resolution of the simulation. Binary_c then uses an algorithm to get back to when R~RL (within a desired tolerance, set in RLOF_ENTRY_THRESHOLD which is usually 1.02, i.e. overflow of 2%). You can choose algorithm 0, the Hurley et al 2002 method which reverses time (i.e. uses a Newton-like scheme), or 1 to use the binary_c method which rejects a timestep (and hence does no logging on that timestep) and repeats with half the timestep until R~RL. The latter is now the default, because this means there are no negative timesteps which break various other algorithms (e.g. nucleosynthesis). : (null)\n", - "nova_retention_fraction : The mass accreted during a nova as fraction of mass transferred : (null)\n", - "beta_reverse_nova : The fraction of mass ejected in a nova explosion which is accreted back onto the companion star. Set to -1 to automatically calculate based on a geometric argument, or 0 or positive to set the value. : (null)\n", - "WD_accretion_rate_novae_upper_limit_hydrogen_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is hydrogen rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_novae_upper_limit_helium_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is helium rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_novae_upper_limit_other_donor : Upper limit of the stable mass transfer rate onto a white dwarf that leads to novae when the donor is neither hydrogen nor helium rich : above this rate the mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_hydrogen_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a hydrogen-rich donor. Below this mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_helium_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope with a helium-rich donor. Below this mass transfer leads to stable burning. : (null)\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_other_donor : Lower limit of the mass transfer rate onto a white dwarf that leads to a the formation of a new giant envelope when the donor is neither hydrogen nor helium rich. Below this mass transfer leads to stable burning. : (null)\n", - "CRAP_parameter : Tidally enhanced mass loss parameter. See Tout and Eggleton's paper on the subject. (Was the parameter bb). : (null)\n", - "individual_novae : If individual_novae is True, novae are resolved such that each explosion is performed separtaely. : (null)\n", - "nova_timestep_accelerator_num : The nova timestep is accelerated if the nova number exceeds nova_timestep_accelerator_num. If zero or negative, acceleration is off. See also nova_timestep_accelerator_index and nova_timestep_accelerator_max. Only used if individual_novae is on.\n", - " : (null)\n", - "nova_timestep_accelerator_index : The index at which the nova timestep is accelerated. A larger value gives longer timesteps. See also nova_timestep_accelerator_num and nova_timestep_accelerator_max. Only used if individual_novae is on.\n", - " : (null)\n", - "nova_timestep_accelerator_max : The nova timestep is accelerated by a factor that is capped at nova_timestep_accelerator_max. This parameter is ignored if it is zero or negative. See also nova_timestep_accelerator_num and nova_timestep_accelerator_index. Only used if individual_novae is on.\n", - " : (null)\n", - "nonconservative_angmom_gamma : Mass lost from the system (but NOT from a stellar wind) takes a fraction gamma of the orbital angular momentum with it. Set to -1 to take the specific angular momentum of the donor star. Set to -2 to take super-Eddington, nova and disk-wind angular momenta as if a wind from the accretor. : (null)\n", - "max_stellar_angmom_change : Maxmimum fractional change in stellar angular momentum allowed before a timestep is rejected (0.05). : (null)\n", - "comenv_ms_accretion_mass : Experimental. During common envelope evolution, a main sequence star may accrete some of the envelope's mass. Requires COMENV_MS_ACCRETION. See also comenv_ms_accretion_fraction. : (null)\n", - "\n", - "############################################################\n", - "##### Section Nucsyn\n", - "############################################################\n", - "third_dup : If True, enables third dredge up. Requires NUCSYN and NUCSYN_THIRD_DREDGE_UP. : (null)\n", - "third_dup_multiplier : Usage: --third_dup_multiplier <i> <f>. Multiplies the abundance of element <i> by <f> during third dredge up. : 1.0\n", - "NeNaMgAl : Enables NeNaMgAl reaction network. Requires NUCSYN and NUCSYN_HBB. : Ignore\n", - "nucsyn_network%d : Usage: --nucsyn_network%d <boolean>. Turn a nuclear network on or off. : (null)\n", - "nucsyn_network_error%d : Usage: --nucsyn_network_error%d <f>. Threshold error in nuclear network solver for network %d. : (null)\n", - "nucreacmult%d : Usage: --nucreacmult%d <f>. Multiply nuclear reaction given by the integer %d (integer) by f (float). : (null)\n", - "nucsyn_metallicity : This sets the metallicity of the nucleosynthesis algorithms, i.e. the amount (by mass) of matter which is not hydrogen or helium. Usually you'd just set this with the metallicity parameter, but if you want the nucleosynthesis to be outside the range of the stellar evolution algorithm (e.g. Z=0 or Z=0.04) then you need to use nucsyn_metallicity. That said, it's also outside the range of some of the nucleosynthesis algorithms as well, so you have been warned! : (null)\n", - "nucsyn_solver : Choose the solver used in nuclear burning. 0 = KAPS_RENTROP is a Kaps-Rentrop scheme (fast, not great for stiff problems), 1 = LSODA (Adams/BSF switcher), 2 = CVODE library (https://computing.llnl.gov/projects/sundials. Default 0. : 0\n", - "initial_abundance_mix : initial abundance mixture: 0=AG89, 1=Karakas 2002, 2=Lodders 2003, 3=Asplund 2005 (not available?), 4=Garcia Berro, 5=Grevesse Noels 1993 : 0\n", - "init_abund : Usage: --init_abund <i> <X>. Sets the initial abundance of isotope number <i> to mass fraction <X>. : 0.02\n", - "init_abund_mult : Usage: --init_abund_mult <i> <f>. Multiplies the initial abundance of isotope number <i> by <f>. : 1.0\n", - "init_abund_dex : Usage: --init_abund_dex <i> <f>. Changes the initial abundance of isotope number <i> by <f> dex. : 0.0\n", - "init_abunds_only : If True, outputs only the initial abundances, then exits. : (null)\n", - "initial_abunds_only : If True, outputs only the initial abundances, then exits. : (null)\n", - "no_thermohaline_mixing : If True, disables thermohaline mixing. : (null)\n", - "lithium_GB_post_Heflash : Sets the lithium abundances after the helium flash. Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "lithium_GB_post_1DUP : Sets the lithium abundance after first dredge up. Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "lithium_hbb_multiplier : Multiplies the lithium abundances on the AGB during HBB (based on Karakas/Fishlock et al models).Requires NUCSYN and LITHIUM_TABLES. : (null)\n", - "angelou_lithium_decay_function : Functional form which describes Li7 decay. Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Choices are : 0 expoential (see angelou_lithium_decay_time). : (null)\n", - "angelou_lithium_LMMS_time : Time at which lithium manufacture is triggered in a low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_time : Time at which lithium manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_time : Time at which lithium manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_time : Time at which lithium manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_time : Time at which lithium manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_time : Time at which lithium manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_time : Time at which lithium manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_LMMS_decay_time : Decay time for surface lithium abundance during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_decay_time : Decay time for surface lithium abundance on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_decay_time : Decay time for surface lithium abundance on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_decay_time : Decay time for surface lithium abundance on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_decay_time : Decay time for surface lithium abundance during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_decay_time : Decay time for surface lithium abundance on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_decay_time : Decay time for surface lithium abundance on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_LMMS_massfrac : Lithium mass fraction when its manufacture is triggered during the low-mass (convective) main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_MS_massfrac : Lithium mass fraction when its manufacture is triggered on the main sequence (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_HG_massfrac : Lithium mass fraction when its manufacture is triggered on the Hertzsprung gap (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_GB_massfrac : Lithium mass fraction when its manufacture is triggered on the giant branch (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_CHeB_massfrac : Lithium mass fraction when its manufacture is triggered during core helium burning (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_EAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the early AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_TPAGB_massfrac : Lithium mass fraction when its manufacture is triggered on the thermally pulsing AGB (Myr). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0 (for the start, use 1e-6).\n", - " : (null)\n", - "angelou_lithium_vrot_trigger : Equatorial rotational velocity at which lithium manufacture is triggered (km/s). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0.\n", - " : (null)\n", - "angelou_lithium_vrotfrac_trigger : Fraction of Keplerian (breakup) equatorial rotational velocity at which lithium manufacture is triggered (must be <1, ignored if 0). Requires NUCSYN and NUCSYN_ANGELOU_LITHIUM. Ignored if 0.\n", - " : (null)\n", - "\n", - "############################################################\n", - "##### Section Output\n", - "############################################################\n", - "cf_amanda_log : Enable logging to compare to Amanda's models. : (null)\n", - "float_overflow_checks : Turn on to enable floating-point overflow checks at the end of each timestep, if they are available. 0=off, 1=warn (stderr) on failure, 2=exit on failure (0) : (null)\n", - "save_pre_events_stardata : Enable this to save a copy of stardata to stardata->pre_events_stardata just before an event. : (null)\n", - "disable_end_logging : Disable the logging that happens at the end of the evolution. : (null)\n", - "ensemble : Turn on ensemble calculations and output. : (null)\n", - "ensemble_filters_off : Sets all ensemble filters to be off (FALSE) - these can then be enabled one-by-one with --ensemble_filter_[...] TRUE. : (null)\n", - "ensemble_filter_%d : Turn on or off ensemble filter <n>. For a list of filters, see ensemble_macros.h. : (null)\n", - "ensemble_legacy_ensemble : Turn on ensemble legacy population output. : (null)\n", - "legacy_yields : Turn on ensemble legacy yield output. : (null)\n", - "ensemble_defer : Defer ensemble output. : (null)\n", - "ensemble_dt : When doing ensemble calculations, data are stored and/or output every ensemble_dt Myr. See also ensemble, ensemble_logdt, ensemble_startlogtime. : (null)\n", - "ensemble_logdt : When doing ensemble calculations, and when logensembletimes is set, the ensemble is stored/output every ensemble_logdt Myr. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null)\n", - "ensemble_startlogtime : Start log ensemble data storage/calculations/output at ensemble_startlogtime. See also ensemble, ensemble_dt, ensemble_startlogtime. : (null)\n", - "ensemble_logtimes : When doing ensemble calculations/output, set this to act at log times rather than linear times. : (null)\n", - "postagb_legacy_logging : Turn on post-AGB legacy logging. : (null)\n", - "disc_legacy_logging : Turn on disc legacy logging. : (null)\n", - "EMP_logg_maximum : Maximum logg that EMP stars are allowed to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_minimum_age. : (null)\n", - "EMP_minimum_age : Minimum age that EMP stars are required to have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum. : (null)\n", - "EMP_feh_maximum : Maximum [Fe/H] that an EMP stars may have. See Izzard et al 2009. See also CEMP_cfe_minimum, NEMP_nfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default -2.0. : (null)\n", - "CEMP_cfe_minimum : Minimum [C/Fe] that CEMP stars are required to have. See Izzard et al 2009. See also NEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 0.7. : (null)\n", - "NEMP_cfe_minimum : Minimum [N/Fe] that NEMP stars are required to have. See Izzard et al 2009, Pols et al. 2012. See also CEMP_cfe_minimum, EMP_logg_maximum, EMP_minimum_age. Default 1.0. : (null)\n", - "thick_disc_start_age : Lookback time for the start of the thick disc star formation, e.g. 13e3 Myr. Units = Myr. : (null)\n", - "thick_disc_end_age : Lookback time for the end of the thick disc star formation, e.g. 4e3 Myr. Units = Myr. : (null)\n", - "thick_disc_logg_min : Minimum logg for thick disc giants to be logged. : (null)\n", - "thick_disc_logg_max : Maximum logg for thick disc giants to be logged. : (null)\n", - "escape_velocity : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 1e9 km/s. See also escape_fraction. : (null)\n", - "escape_fraction : A parameter used in constructing galactic chemical evolution (GCE) models. If the stellar wind velocity exceeds this value, any chemical yield from the wind is ignored, i.e. assumed lost. (km/s) Requires NUCSYN_GCE_OUTFLOW_CHECKS. Default 0.0. See also escape_velocity. : (null)\n", - "colour_log : If set to True, thelog is coloured with ANSI colour formatting. Requires FILE_LOG to be defined. : \n", - "log_filename : Location of the output logging filename. If set to \"/dev/null\" then there is no logging. : \n", - "log_arrows : Add arrows to the output log to show whether values are increasing or decreasing. : \n", - "stopfile : File which, when it exists, will stop the current binary_c repeat run. : \n", - "stardata_dump_filename : Location of the stardata dump file. : \n", - "stardata_load_filename : Location of the stardata file to load. : \n", - "api_log_filename_prefix : Location of the output logging filename prefix for the API. If set to \"/dev/null\" then there is no logging. : 0\n", - "hrdiag_output : Set to True to output high time-resolution Hertzstrpung-Russell diagram information. Requires HRDIAG. : (null)\n", - "internal_buffering : Experimental. Set to non-zero values to implement internal buffering prior to output. For use with binary_grid, you shouldn't really be playing with this. : (null)\n", - "eccentric_RLOF_model : Chooses which model is used to handle eccentric RLOF. Default is RLOF_ECCENTRIC_AS_CIRCULAR, i.e. ignore the eccentricity. Note: requires force_corotation_of_primary_and_orbit to be FALSE.\n", - " : (null)\n", - "force_circularization_on_RLOF : If True forces circularization of stars and orbit when RLOF starts, this is as in the BSE algorithm. (True) : (null)\n", - "wtts_log : If True, enables log file output for WTTS2. : (null)\n", - "fabian_imf_log_time : Time at which to output for Fabian Schneider's IMF project. Requires FABIAN_IMF_LOG : Ignore\n", - "fabian_imf_log_timestep : Timestep for Fabian Schneider's IMF project logging. Requires FABIAN_IMF_LOG : Ignore\n", - "version : Display binary_c version and build information. Also performs timing tests. : Ignore\n", - "dumpversion : Display binary_c version number (short format). : Ignore\n", - "version_only : Display binary_c version number and build information, but do not perform timing tests or anything that requires stardata to be non-NULL. : Ignore\n", - "tides_diagnosis_log : Enable logging to test MINT tides. Requires MINT. Choices are: 0 disabled, 1 enable lambda test. : Ignore\n", - "\n", - "############################################################\n", - "##### Section Input\n", - "############################################################\n", - "MINT_dir : Location of MINT algorithm data. : \n", - "MINT_data_cleanup : Activate checks on incoming data to try to account for problems. Will make data-loading slower, but may fix a few things. : \n", - "MINT_MS_rejuvenation : Turn on or off (hydrogen) main-sequence rejuvenation. : \n", - "MINT_remesh : Turn on or off MINT's remeshing. : \n", - "MINT_use_ZAMS_profiles : Use chemical profiles at the ZAMS if MINT_use_ZAMS_profiles is TRUE, otherwise set homogeneous abundances. (Default is TRUE, so we use the profiles if they are available.) : \n", - "MINT_fallback_to_test_data : If TRUE, use the MINT test_data directory as a fallback when data is unavailable. (FALSE) : \n", - "MINT_disable_grid_load_warnings : Use this to explicitly disable MINT's warnings when loading a grid with, e.g., missing or too much data. : \n", - "MINT_Kippenhahn : Turn on or off MINT's Kippenhahn diagrams. If 0, off, if 1, output star 1 (index 0), if 2 output star 2 (index 1). Default 0. : \n", - "MINT_nshells : Set the initial number of shells MINT uses in each star when doing nuclear burning. Note: remeshing can change this. If MINT_nshells is 0, shellular burning and other routines that require shells will not be available. (200) : \n", - "MINT_maximum_nshells : Set the maximum number of shells MINT uses in each star when doing nuclear burning. Note that this will be limited to MINT_HARD_MAX_NSHELLS. (1000) : \n", - "MINT_minimum_nshells : Set the minimum number of shells MINT uses in each star when doing nuclear burning. Note that this will be greater than or equal to MINT_HARD_MIN_NSHELLS, which is 0 by default. (0) : \n", - "MINT_Kippenhahn_stellar_type : Stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for which Kippenhahn plot data should be output. : \n", - "MINT_Kippenhahn_companion_stellar_type : Companion stellar type selector for Kippenhahn plots. Set to -1 to ignore, otherwise the stellar type number for the companion for which Kippenhahn plot data should be output. : \n", - "MINT_nuclear_burning : Turn on or off MINT's nuclear burning algorithm. : \n", - "MINT_minimum_shell_mass : Minimum shell mass in MINT's nuclear burning routines. : \n", - "MINT_maximum_shell_mass : Maximum shell mass in MINT's nuclear burning routines. : \n", - "\n", - "############################################################\n", - "##### Section I/O\n", - "############################################################\n", - "go : batchmode control command : Ignore\n", - "gogo : batchmode control command : Ignore\n", - "reset_stars : Reset the star structures. Used in batchmode : Ignore\n", - "reset_stars_defaults : Reset the star structures and set defaults. Used in batchmode : Ignore\n", - "defaults : Reset all defaults. Used in batchmode : Ignore\n", - "echo : Activate batchmode command echoing, i.e. when you enter a command, binary_c repeats the command then executes it. : Ignore\n", - "noecho : Deactivate batchmode command echoing. See 'echo'. : Ignore\n", - "noechonow : Deactivate batchmode command echoing. See 'echo'. : Ignore\n", - "bye : Quit binary_c. Used in batchmode. : Ignore\n", - "fin : batchmode control command : Ignore\n", - "reset_prefs : Reset preferences struct. Used in batchmode : Ignore\n", - "status : Output batchmode status information. : Ignore\n", - "\n", - "############################################################\n", - "##### Section Algorithms\n", - "############################################################\n", - "repeat : If > 1, repeats the system as many times as required. Handy if you're using Monte-Carlo kicks and want to sample the parameter space well. Also, if you are running speed tests this is good to give a statistically more reasonable result. (See e.g. 'tbse pgo'). : (null)\n", - "random_systems : Experimental. Use this to apply random initial system parameters (masses, separations, etc.). Useful for testing only. : (null)\n", - "\n", - "############################################################\n", - "##### Section Misc\n", - "############################################################\n", - "random_seed : Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null)\n", - "random_systems_seed : Random number seed for the generation of random systems. See random_systems and random_seed. : (null)\n", - "random_skip : Skip the first <random_seed> random numbers that are generated. Usually this is 0 so they are all used. : (null)\n", - "idum : [NB: deprecated, please use 'random_seed' instead.] Random number seed, usually a (possibly negative) integer. Useful for exactly reproducing the evolution of a system which involves a kick (which is a Monte-Carlo, i.e. pseudorandom, process). : (null)\n", - "reverse_time : Make time go backwards. To be considered very experimental! : (null)\n", - "start_time : Start time for the simulation. : (null)\n", - "warmup_cpu : Uses the CPU at maximum power the given number of seconds, prior to running normal stellar evolution. : Ignore\n", - "help : Display help pages. Usage: --help <help topic>. : Ignore\n", - "argopts : Display argument options. Usage: --argopts <argument>. : Ignore\n", - "help_all : Display all help pages. : Ignore\n", - "list_args : Display list of arguments with their default values. Useful for batchmode. : Ignore\n", - "\n" + "(abridged)\n" ] } ], "source": [ - "print(_binary_c_bindings.return_help_all())" + "print('\\n'.join(_binary_c_bindings.return_help_all().splitlines()[:10]))\n", + "print(\"(abridged)\")" ] }, { @@ -873,12 +300,14 @@ "__ARG_BEGIN\n", "metallicity = 0.02\n", "effective_metallicity = -1\n", - "M_1 = 0\n" + "M_1 = 0\n", + "(abridged)\n" ] } ], "source": [ - "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))" + "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))\n", + "print(\"(abridged)\")" ] }, { @@ -966,7 +395,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -980,7 +409,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/examples/notebook_custom_logging.ipynb b/examples/notebook_custom_logging.ipynb index 8dfb85034dd77e1b0ae790c475a1e52bd70d0227..8627ffb4751bfea37ebfc00c67e763a79463eba0 100644 --- a/examples/notebook_custom_logging.ipynb +++ b/examples/notebook_custom_logging.ipynb @@ -23,7 +23,7 @@ " create_and_load_logging_function,\n", ")\n", "from binarycpython.utils.run_system_wrapper import run_system\n", - "from binarycpython.utils.grid import Population" + "from binarycpython import Population" ] }, { @@ -461,11 +461,19 @@ "# print (abridged) output\n", "print(\"\\n\".join(output.splitlines()[-2:]))" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c708268f-0b0c-48ea-9155-ec632a0acc3a", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -479,7 +487,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/examples/notebook_ensembles.ipynb b/examples/notebook_ensembles.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..cc9a3ad9f4cfc1efc4c1327878f01b87bad9e8e5 --- /dev/null +++ b/examples/notebook_ensembles.ipynb @@ -0,0 +1,42 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d1d00572-29aa-4f27-a59c-f9f05889da7d", + "metadata": {}, + "source": [ + "# Tutorial: Generating and handling ensemble data\n", + "TODO: coming soon!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e8d9fca3-dd16-4c2c-a180-14d9a6b533ed", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/notebook_extra_features.ipynb b/examples/notebook_extra_features.ipynb index 44c19c11274fbd39732e34e03e7a14a371ff9d7c..a0f0fc0d9c66207de88d4c38672d257f9af522c2 100644 --- a/examples/notebook_extra_features.ipynb +++ b/examples/notebook_extra_features.ipynb @@ -18,11 +18,11 @@ "metadata": {}, "outputs": [], "source": [ + "from binarycpython import Population\n", "from binarycpython.utils.functions import (\n", " get_help,\n", " get_help_all,\n", " get_help_super,\n", - " return_binary_c_version_info,\n", " get_defaults\n", ")\n", "# help(binarycpython.utils.functions)" @@ -116,8 +116,7 @@ "metadata": {}, "source": [ "## Build information of binary_c\n", - "Sometimes we want to know with which settings binary_c has been built. We can use the function `return_binary_c_version_info` for this.\n", - "This function will parse the version info of binary_c and return a dictionary with all the settings." + "It can be useful to fetch the information with which the current version of binary_c has been configured with. We can do that through the Population object, by calling the instance method `return_binary_c_version_info`. This function will parse the version info of binary_c and return a dictionary with all the settings." ] }, { @@ -130,13 +129,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'nucleosynthesis_sources', 'miscellaneous'])\n" + "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'ensemble_filters', 'macros', 'elements', 'dt_limits', 'units', 'nucleosynthesis_sources', 'miscellaneous'])\n" ] } ], "source": [ - "version_info_dict = return_binary_c_version_info(parsed=True)\n", - "print(version_info_dict.keys())" + "version_info = Population().return_binary_c_version_info(parsed=True)\n", + "print(version_info.keys())" ] }, { @@ -168,27 +167,11 @@ "\n", "TODO:" ] - }, - { - "cell_type": "markdown", - "id": "b3c259ef-9f89-4b26-9ce3-45af625bc398", - "metadata": {}, - "source": [ - "## Getting help\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bf3c1e28-1662-47a7-abab-aa6fb0ef0882", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -202,7 +185,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/examples/notebook_individual_systems.ipynb b/examples/notebook_individual_systems.ipynb index deb72fc55ba3785c9c829ab83ba0846cd9b86867..d752fc66ed4fdff229a1bab5d1f5e48921ea8e77 100644 --- a/examples/notebook_individual_systems.ipynb +++ b/examples/notebook_individual_systems.ipynb @@ -62,7 +62,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "SINGLE_STAR_LIFETIME 1 12461.2\n", + "SINGLE_STAR_LIFETIME 1 12461.1\n", "\n" ] } @@ -90,17 +90,17 @@ "name": "stdout", "output_type": "stream", "text": [ - " TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=62172 RANDOM_COUNT=0\n", + " TIME M1 M2 K1 K2 SEP PER ECC R1/ROL1 R2/ROL2 TYPE RANDOM_SEED=22065 RANDOM_COUNT=0\n", " 0.0000 1.000 0.000 1 15 -1 -1 -1.00 0.000 0.000 \"INITIAL \"\n", " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 \"OFF_MS\"\n", " 11003.1302 1.000 0.000 2 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 11582.2424 1.000 0.000 3 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 12325.1085 0.817 0.000 4 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 12457.1301 0.783 0.000 5 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 12460.9983 0.716 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"shrinkAGB\"\n", - " 12461.1627 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", - " 15000.0000 0.645 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", + " 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", + " 12460.8955 0.774 0.000 6 15 -1 -1 -1.00 0.000 0.000 \"shrinkAGB\"\n", + " 12461.1490 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", + " 15000.0000 0.678 0.000 11 15 -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", "\n" ] } @@ -236,13 +236,13 @@ "4 0.000002 1.0 1.0 1.0\n", "5 0.000003 1.0 1.0 1.0\n", "... ... ... ... ...\n", - "1345 12461.080763 0.71617 1.0 6.0\n", - "1346 12461.162734 0.644553 1.0 11.0\n", - "1347 13461.162734 0.644553 1.0 11.0\n", - "1348 14461.162734 0.644553 1.0 11.0\n", - "1349 15000.0 0.644553 1.0 11.0\n", + "1250 12461.061259 0.718593 1.0 6.0\n", + "1251 12461.149038 0.678026 1.0 11.0\n", + "1252 13461.149038 0.678026 1.0 11.0\n", + "1253 14461.149038 0.678026 1.0 11.0\n", + "1254 15000.0 0.678026 1.0 11.0\n", "\n", - "[1349 rows x 4 columns]\n" + "[1254 rows x 4 columns]\n" ] } ], @@ -299,10 +299,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options\n", - "adding: M_1=10 to BSE_options\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", "SINGLE_STAR_LIFETIME 10 28.4838\n", "\n" @@ -360,9 +358,9 @@ ");\n", " to grid_options\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", - "Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_dafa15d2b1e64e19972ac0e9eb5c9a55.so\n", + "Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_34a350b8f15c4d149deab88632948c99.so\n", "EXAMPLE_MASSLOSS 0.000000000000e+00 10 0 10 1\n", "EXAMPLE_MASSLOSS 0.000000000000e+00 10 10 10 1\n", "EXAMPLE_MASSLOSS 1.000000000000e-06 10 10 10 1\n", @@ -381,7 +379,7 @@ "\n", " stardata->star[0].stellar_type //5\n", ");\n", - "\"\"\" \n", + "\"\"\"\n", "\n", "example_pop.set(C_logging_code=custom_logging_print_statement)\n", "\n", @@ -397,7 +395,7 @@ "source": [ "Lastly we can add a parse_function to handle parsing the output again. \n", "\n", - "Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be (self, output). Returning the data is useful when running evolve_single(), but won't be used in a population evolution." + "Because the parse_function will now be part of the population object, it can access information of the object. We need to make a new parse function that is fit for an object: we the arguments now need to be `(self, output)`. Returning the data is useful when running evolve_single(), but won't be used in a population evolution." ] }, { @@ -464,13 +462,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function object_parse_function at 0x149c2e81ec10> to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to custom_options >>>>\n", - "adding: api_log_filename_prefix=/tmp/binary_c_python-izzard/notebooks/notebook_individual_systems to BSE_options\n", + "adding: parse_function=<function object_parse_function at 0x7f35b603e9d0> to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: output_dir=/tmp/binary_c_python-david/notebooks/notebook_individual_systems to custom_options >>>>\n", "Creating and loading custom logging functionality\n", - "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-izzard/notebooks/notebook_individual_systems\n", + "Running binary_c M_1 10 api_log_filename_prefix /tmp/binary_c_python-david/notebooks/notebook_individual_systems\n", "Cleaning up the custom logging stuff. type: single\n", - "Removed /tmp/binary_c_python-izzard/custom_logging/libcustom_logging_0639ee205c7d4782b4a27378f5d890bd.so\n", + "Removed /tmp/binary_c_python-david/custom_logging/libcustom_logging_446fe4cddfa94946bcafd55591ef3730.so\n", "[['time', 'mass', 'initial_mass', 'stellar_type'], [0.0, 10.0, 0.0, 10.0, 1.0], [0.0, 10.0, 10.0, 10.0, 1.0], [1e-06, 10.0, 10.0, 10.0, 1.0]]\n", "dict_keys(['time', 'mass', 'initial_mass', 'stellar_type'])\n" ] @@ -570,7 +567,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -584,7 +581,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/examples/notebook_luminosity_function_single.ipynb b/examples/notebook_luminosity_function_single.ipynb index 93e041531422571b1a499b0089f9e4e465d4a0f3..0a19202d3d6b54cc27b089c742e1a194a226587a 100644 --- a/examples/notebook_luminosity_function_single.ipynb +++ b/examples/notebook_luminosity_function_single.ipynb @@ -54,8 +54,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: max_evolution_time=0.1 to BSE_options\n", - "adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_luminosity to grid_options\n", + "adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_luminosity to grid_options\n", "verbosity is 1\n" ] } @@ -104,28 +103,6 @@ "# help(population.add_grid_variable)" ] }, - { - "cell_type": "markdown", - "id": "bd75cebe-2152-4025-b680-dc020b80889b", - "metadata": {}, - "source": [ - "All the distribution functions that we can use are stored in the `binarycpython.utils.distribution_functions` or `binarycpython/utils/distribution_functions.py` on git. If you uncomment the help statement below you can see which functions are available now:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "048db541-3e92-4c5d-a25c-9c5a34b9c857", - "metadata": { - "scrolled": true, - "tags": [] - }, - "outputs": [], - "source": [ - "import binarycpython.utils.distribution_functions\n", - "# help(binarycpython.utils.distribution_functions)" - ] - }, { "cell_type": "markdown", "id": "2a9104fc-4136-4e53-8604-f24ad52fbe56", @@ -141,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "id": "aba3fe4e-18f2-4bb9-8e5c-4c6007ab038b", "metadata": {}, "outputs": [], @@ -165,22 +142,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "id": "47979841-2c26-4b26-8945-603d013dc93a", "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "add_grid_variable() got an unexpected keyword argument 'resolution'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/tmp/ipykernel_519112/518757914.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mtmp_dir\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mTMP_DIR\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m )\n\u001b[0;32m----> 6\u001b[0;31m population.add_grid_variable(\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"M_1\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mlongname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"Primary mass\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mTypeError\u001b[0m: add_grid_variable() got an unexpected keyword argument 'resolution'" - ] - } - ], + "outputs": [], "source": [ "# Mass\n", "population = Population()\n", @@ -191,8 +156,16 @@ " name=\"M_1\",\n", " longname=\"Primary mass\",\n", " valuerange=massrange,\n", - " samplerfunc=\"const({min}, {max}, {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", - " probdist=\"{probtot}/({max} - {min})\".format(probtot = total_probability, min = massrange[0], max = massrange[1]), # dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)\n", + " samplerfunc=\"self.const_linear({min}, {max}, {res})\".format(\n", + " min=massrange[0],\n", + " max=massrange[1],\n", + " res=resolution[\"M_1\"]\n", + " ),\n", + " probdist=\"{probtot}/({max} - {min})\".format(\n", + " probtot=total_probability,\n", + " min=massrange[0],\n", + " max=massrange[1]\n", + " ), # dprob/dm1 : all stars are equally likely so this is 1.0 / (Mmax - Mmin)\n", " dphasevol=\"dM_1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -214,7 +187,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "0c986215-93b1-4e30-ad79-f7c397e9ff7d", "metadata": {}, "outputs": [], @@ -258,10 +231,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "fd197154-a8ce-4865-8929-008d3483101a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "adding: parse_function=<function parse_function at 0x7f6920fd2430> to grid_options\n" + ] + } + ], "source": [ "# import the bin_data function so we can construct finite-resolution probability distributions\n", "# import the datalinedict to make a dictionary from each line of data from binary_c\n", @@ -279,18 +260,15 @@ " for line in output.splitlines():\n", " # obtain the line of data in dictionary form \n", " linedata = datalinedict(line,parameters)\n", - " \n", + "\n", " # Check the header and act accordingly\n", " if linedata['header'] == \"ZERO_AGE_MAIN_SEQUENCE_STAR\":\n", - " \n", + "\n", " # bin the log10(luminosity) to the nearest 0.1dex\n", " binned_log_luminosity = bin_data(math.log10(linedata['luminosity']),\n", " binwidth['luminosity'])\n", - " \n", " # append the data to the results_dictionary \n", " self.grid_results['luminosity distribution'][binned_log_luminosity] += linedata['probability'] \n", - " \n", - " #print (self.grid_results)\n", " \n", " # verbose reporting\n", " #print(\"parse out results_dictionary=\",self.grid_results)\n", @@ -316,12 +294,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "8ea376c1-1e92-45af-8cab-9d7fdca564eb", "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "adding: verbosity=0 to grid_options\n", + "Do dry run? True\n", + "Doing dry run to calculate total starcount and probability\n", + "Grid has handled 39 stars with a total probability of 1\n", + "**************************\n", + "* Dry run *\n", + "* Total starcount is 39 *\n", + "* Total probability is 1 *\n", + "**************************\n", + "\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", + "**********************************************************\n", + "* Population-f9b28e4ed6ec4a67b17cd86c5a43c41c finished! *\n", + "* The total probability is 1. *\n", + "* It took a total of 3.99s to run 39 systems on 2 cores *\n", + "* = 7.98s of CPU time. *\n", + "* Maximum memory use 343.570 MB *\n", + "**********************************************************\n", + "\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" + ] + } + ], "source": [ "# set number of threads\n", "population.set(\n", @@ -329,7 +337,7 @@ " verbosity=0,\n", " # set number of threads (i.e. number of CPU cores we use)\n", " num_cores=2,\n", - " )\n", + ")\n", "\n", "# Evolve the population - this is the slow, number-crunching step\n", "analytics = population.evolve() \n", @@ -348,20 +356,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "e1f0464b-0424-4022-b34b-5b744bc2c59d", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'population_id': 'f9b28e4ed6ec4a67b17cd86c5a43c41c', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.9999999999999999, 'total_count': 39, 'start_timestamp': 1655508316.7679594, 'end_timestamp': 1655508320.7581806, 'time_elapsed': 3.9902212619781494, 'total_mass_run': 1951.365, 'total_probability_weighted_mass_run': 50.035, 'zero_prob_stars_skipped': 0}\n" + ] + } + ], "source": [ "print(analytics)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "05c6d132-abee-423e-b1a8-2039c8996fbc", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[None]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaMAAAEdCAYAAAChVQjxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAA9vklEQVR4nO3dd3hUVfrA8e/MpJNAQu81cOhNihB6ExUVVMTeXcva19V1ddfuqj93bWtvgLoqKLZdBAKCoqEjHY4K0gMpJEAgdWZ+f9xJmCSTZCbM5M5M3s/z5Enm3jt33twk8+ace857LE6nEyGEEMJMVrMDEEIIISQZCSGEMJ0kIyGEEKaTZCSEEMJ0koyEEEKYLsLsAEJUNDAYSAfsJscihBChwga0AtYAhe47JBnVzmBgudlBCCFEiBoJ/Oi+QZJR7aQD5OScwOEI7DytJk3iyc7OC+hr1FdybQNHrm3ghPK1tVotJCU1ANd7qDtJRrVjB3A4nAFPRqWvIwJDrm3gyLUNnDC4tpVub8gABiGEEKaTZCSEEMJ0koyEEEKYTpKREEII00kyEkIIYToZTReC8vNPkJeXi91eYnYoIS0jw4rD4TA7jLAk19Z7hcUOrBaIjPCubRCM19ZmiyA+PpHY2Aa1PockoxCTn3+C48dzSExsRmRkFBaLxeyQQlZEhJWSkuD6ow4Xcm29c6KgmIKcfOwWC62aNSDCVnNCCrZr63Q6KS4uIjc3E6DWCUm66UJMXl4uiYnNiIqKlkQkRIg7frLY+MLpJL8wNHs6LBYLUVHRJCY2Iy8vt9bnkWQUYuz2EiIjo8wOQwhxmkrsDgrcElB+UWiXuYyMjDqtWweSjEKQtIiECH0n8ovLPS4oLMHpDN3KCqf7viTJSAgh6pjT6SSvQjJyOJwUB9G9oLomyUgIIepYUYmjLPE0iI0s2x7qXXWnQ5KREAFw8cXn8dRTj5ry2rff/gduv/0Pprx2qYMHDzJixCDmz//GlNdPT6/8+k899SgXX3yeaa89efKYssfuraKk+GhsrlF0BX4YxODp9UOBDO0WpkpPP8j06efXeNxf//oI55xT/o0kOzuLCy88F4fDwdy539CyZctKz7v99j+wYcN6OnXqzAcfzKm0/7vvFvP3v/8FgJdffoOBAweV7du4cQOzZ7/Hzp2/cuzYURITk0hO7saECWcxadJkX7/Vem/lyjS2bt3MDTfcbHYoXtuyZTOrVqVxySWXk5CQ4JdzOp3OsvtFMVERRERYiYmycSLfQUGRHafT6dX9l1C8ntWRZCRMlZiYxN/+9rjHfQ6Hg1deeYH8/JN07aoq7V+yZBExMTHYbBEsXryAK6+81uN5oqKi+P33Xfz2268kJ3ctty81dQFRUdEUFZVbdJLvvlvMI488SNeu3Zg+/VISEhqSnn6QDRvW8803XwR1MnrhhVfNDoFWrVqxZMlPRESceotZtWoFc+d+bNqb5wMPPOzzZNFt2zbz/vtvc84553mdjFq2rPy9u8svLClbAiI+1jgmNtrGifxinE4nhcV2YqJqfmuu6nrW9PrBKrSiFWEnNjaWs846x+O+d999k2PHjnL77XfTtWu3SvtTUxcwYsRooqKiSE1dWGUyat++IydPnmDx4oXlklFe3nFWrUpj2LAUvv9+abnnvPfeW3Tu3IU335xJZGRkuX05OUd8/C7rVsV4zWCxWIiOjjY7jHIC/eZst9ux2+1ERUVV+73n5RtdcRaLhbgY42flnnwKirxLRlUJxmvvDblnJILShg3rmT37PYYNS2HGjCsq7d+3by/bt29j/PhJjB8/iZ07f2XXrp1Vnm/8+EksWbKo3NDZpUuXYLFYGDlyTKXjDx7cT8+evT2+sSclNfb5+3n33TcZMWJQpe3z53/DiBGDSE8/WLbt4ovP48EH/8SaNSu5/vorGDcuheuvv4Jt27YA8O23/+XSSy9k3Ljh3H77Hzh48EC5c1a8Z7R+/VpGjBjE999/x8yZ7zB16tmMGzecu+66lf3791WKacmSRVx33eWMGzecKVMm8o9/PE5ubm65Y/bt28tDD/2Z888/i3HjhjNt2jk88siD5OUZK5BWvGf01FOPMnfuxwCMGDGo7OPkyZNMmDCCF198vlIc+/btZcSIQcybN7faa3v8+HGeeupRzjprNJMnj+HJJx8hL+94peM83TNavHgh119/JRMnjmLSpNFcffUM5swx4nz33Td5+eV/ATB9+vllMZf+rEaMGMRLL/2Tb7/9L5dffhHjxg1ny5ZN1d6z2bN3D39/6G5uuPIc7rxlBh9/PBuACJuVyAgr27ZuYMrkFNavX1vueRXPWdX19HRsqbVrV3PrrdczfnwKkyeP5eGHH6j0u1N6b+vw4UM88MA9TJw4kilTJvDvf7+I3R7YwRXSMhJB59ixozz++N9ISmrMQw895rH/PDV1AQkJDRky5EwsFguNGzchNXUBN9/8R4/nnDhxMh988D5btmyiT59+ACxatJDhw0cSF1e5fEmLFi1Zu3Y1mZkZNGvW3L/foBf27NnNk08+wtSpFzNpUiwffjiL+++/h1tu+SMffTSbCy64kJMnT/DRR7N49tkneeml12s856xZ72K12rj88qs5fvwYH3/8AY899jBvvz2r7Jj587/h6acfo1evPtx6651kZBzm888/Zfv2rbz99myio6MpLi7m3nvvwGazMmPG5TRq1IjDhw+TlvYjeXnHiY+Pr/TaF1xwIdnZ2axevaJct2xcXByjRo1l6dJU7rjjHmw2W9m+RYu+JSIigvHjJ1b5PTmdTh588E9s2rSBqVMvokOHjvzwwzKefPLRGq/HmjUrefTRhxg9eiznnz8Nu93O7t2/s3nzRi655DJGjx7HwYP7WbjwW+68814aNUoEjK5l93N8990ipk2bTkJCAk2bNq3y9UpKSrjvvjtJ7tabS6/8A9s2reb1118B4IorrinXGqppulFV17Pq73UV9913J+3adeDGG2/l5MkTzJ37MbfeegMzZ35MUtKp76mkpIR7772dPn368cc/3sWaNav45JMPadOmLdOmXVzja9WWJCMRdP7xjyfIysrkxRdfIzEx0eMxqakLGDVqTFnXy5gx41i8eCF/+MNtHpNX585d6NIlmdTUBfTp04/s7CzWr1/L448/4/H8V1xxDc888wQzZkylT59+9O3bn8GDh9K7d1+s1sB3KOzdu4e33ppJz569AWjWrAWPPPIgr776Mp98Mq/sjbGkpIQPPnifw4cP0aJF5QEc7kpKSnjvvVll16xhw0a89NLz7Nr1G507J1NSUsLrr79CcnI3XnnlTaKijEofSnXn0Ucf4ptvvuDiiy9l9+5dpKcf4O23Z9GjR6+y81d3L6h377506NCR1atXVOqWPeusc1i06FvWr1/D4MFnlm1PTV3A0KHDyr5XT3788Xs2bFjPHXfcU9aCnjr1Yu6885ZqrwVAWtpPdOrUmaee+j+P+5OTu6JUDxYu/JaRI8fQqlXrSsfs27eXDz6YQ/v2Hcq2ubdy3RUUFHDG4BQuvfIWbDYr1199BffeewczZ77LtGnTiYk+1QovLqm+FVLd9fTktddeIjExkddff7fs3tfQocO55Zbr+PDDmdxxxz3l4pw8+Vyuuuo6wLie119/Bf/971eSjET1dh08xjc//U6ByXMUYqJsnJfSic6tG9b6HJ9/Pofly5dx7bU3lhvZ5m7Hjm3s27eXe+65v2zb+PFnMW/eXDZv3kjfvv09Pm/ChLOYM+dj7rrrPr77bjGxsbEMG5bCypVplY6dMuUCmjVrzqeffsT69WtZt24N77//Nm3atOVvf3uC3r371Pp79EaXLl3LEhFAr17G1yNGjCr35tyzp5EM0tMP1piMzj33/HL3Tfr16w/AwYMH6Nw5mR07tpGTc4Sbbrq1LBEBjBs3kVdffYm0tJ+4+OJLadDAaPn89NNykpO7nfY9qkGDhtCkSVMWLVpQloy2bdvC/v37uOmm26p97ooVPxEZGckFF1xUts1ms3HRRTPYuPHnap8bHx9PRsZhtm7dUnZ9fTVw4KByiagm4yYaI0cbxEZgs9mYNu0i1q1bzaZNGxg85FQiLiz2399yVlYWv/76C1dddV25QRi9e/ehV68+rFjxY7lkBEbLy13fvgNYuHC+32LyRJJRGEhdu4+NO7PNDgOA2OgI/nB+r5oP9GDnzt949dWX6NdvANddd1OVxy1a9C1xcQ1o2bJl2T2Pxo0bk5iYyKJFC6pMRuPHT+LNN19l7drVpKYuYPToseXedCsaOnQYQ4cOo6CgAK23s2TJIr76ah733383H330WbmuDX+rmFhKE0Dz5i08bj9+/JjP50xIaOh6rnF/5dChdIBKb65Wq5W2bdtx+LCxv3XrNsyYcQUzZ77Dp5/+hwEDBjJ8+EgmTZrsscuzJjabjYkTJ/PNN19w330PEh0dzaJFC2jQoAEjRoys9rmHDh2iadPmxMTElNvuTYK48MLpLF26mJtvvpZWrdowePAQxo6dwODBQ72O3VNrqSo2m42mzYyfQbxr4ELbtu0BOHToIDarlUjXfKOiYv9VYqjq5wrQoUNHFi9eVG5bbGwcDRs2KrctISHBq9+x0yHJKAxMHNSOgsKSoGgZTRzcrlbPLSws4JFH/kpMTAyPPPJkuXsH7hwOB0uWpHLy5Akuv7xyl8GyZYu5++77PI6cat26Db169eGDD95n27Yt3HzzrV7FFhMTQ79+A+jXbwCNGiXy/vtvs3LlT5x99hSvv7+q5o04HJ5/ZrYqlhKoqovQm5JmVqvna1qbemh33HEP5557HsuXf8/q1Sv517+eZfbs93jzzfdrdY9t8uRz+eSTD0lLW86oUWP57rtURo8eR3R0TM1PrqWkpMa8//5/WL16JStXprFyZRpff/0F5557Pg8++HevzuFtfO7XOCrSRlSk559FdJSxvdjuwO5wYHP9vOty/aKqfvcCTZJRGOjcuiF3Te9ndhin5cUX/8nu3bt45pl/Vvrv3926dWvIzs7i5ptvp23btuX2ZWZm8PLL/2L16pUMHz7C4/MnTjyLF198nqSkxgwaNMSrN3F33bv3BIyuD1+4t0Lcu0oOHTrkWwAB1LJlK8C4X9W//8Cy7U6nk/3799GpU5dyx3funEznzslcc80NbN26hZtvvpYvv/ycm27ynOSrm8eZnNyVLl26smjRAuLiGnDkSDaTJp3tRcwt+fnntRQUFJRrHe3du6fG54IxDD4lZSQpKSNxOp288MJzzJs3l6uvvp42bdoC/ilK7HA4sdvtZGUeonvXzmXb9+/fC0CLFsa1b5KUCMDJE3kUFNppEGskhtLWjTtv65K6/1wr2rt3j8fJ4maQod3CdEuXLnbdHJ/BiBGjqz02NXUB8fHxXHbZlYwdO6Hcx/Tpl5GU1JjU1AVVPn/8+LO47rqbuOee+6tsfYExDNaTFSt+ArzrBnJnvLHBxo3ry7bl5+fz7bf/9ek8gdS9e0+Skhrz5ZefUVx8qlzN0qVLyMzMYPjwFABOnMijpKR82ZrOnbtgs9koKiqq8vwxMbHAqW7BiiZPPpdVq9L44ou5NG3arMp7hu6GDUuhuLiYr776vGyb3W7n888/rfG5R4/mlntssVjo0sWYh1ZYaEyCjo01YvY0VNwXxXajZZO68CsaxBhtAIfDwRdffE5sbCz9+g0AoF3btlitVnZs21Sup+OLLyoPb6/pepZq2rQpXbt2Y/78b8qG3oNxX27Llk0MG+b5H7e6Ji0jYaqsrEyeffYpYmPjSE7uWuVN0jZt2tK1q+KHH5YyePCZHrvhLBYLw4alsHTpYvLz88veSNwlJSV5VQHgwQf/RKtWrUlJGUWbNm3Izy9g7dpV/PTTcnr06ElKSvX3MioaMuRMWrRoyTPPPMFll+3GarXxv/99TWJiEocPB0frKCIigltvvYOnn36MO+64mQkTJpGRcZjPPvuUzp27cN550wBYt24tL7zwHGPGjKd9+w44HHYWLvwWi8XC6NHjqjy/Uj0AePHF/2Po0GFYrVYmTDirbP/EiZN5441X+PHHH7j00iu9GrWYkjKKPn368eqrL3HgwH46dOjEDz8sLfemW5VnnnmS48ePMXDgIJo3b87hw8b32rVrNzp27OSKuTsAb731GuPHTyIiIoKUlFEef7eq4nA4KbE7iY6O4ee1aTz77BMo1YO0tB9Zt241N998O3FxcQA0bJjAsJSxpC74ApvNikruRFracnJyciqdt6br6e622+7ivvvu5NZbr+fcc8/nxIkTzJ37CU2aNK1ysnhdk2QkTLV3756y/zqfeebJKo87++wppKSMJC8vr8ouOICUlJHMn/8Ny5d/f1olex544GGWL/+e775LJSsrE6fTuOd09dXXc+WV1/g8mz8iIoKnn36ef/7zGd555w0aN27CJZdcRkJCQ55++rFax+lv55xzHlFRUXz00SxeffUlGjRowMSJk7nlljvKZvUnJ3dlyJAzSUtbzldfzSMmJobk5K48//zL1Y4yHDlyNNOnX0Zq6gIWLfoWp9NZ7s2zadOmnHHGENdw5Zq76MC4h/bss//ipZf+ycKF87FYLKSkjOL22+/muusqT5Z2d9ZZZ/P111/wxRefkZd3nMaNmzBu3ASuv/4PZYmwW7fu3HzzH5k3by6rVq1w1UH82qdkdLKwBJzGAIann3mB1155niVLFpGQ0JCbb76dq666ttzxt91+L0VFxSxe+DU/LI1i3LgJ3HbbXVx99Yxyx9V0Pd0NHjyU559/mXfffZO33nqdqKhIBg0awm233RXQgTi+sITyYk4m6gj8np2dV1ZjKlCaNUsgM/NUM/zQoT20bOlbF5HwLCLCSkk9Xj8mkGp7be+//x7S0w94LGobqg4dOUlBYQlWq4V2zeNrLIJaUFTCoeyTADRtFEN8XPkRn8H8e1vT+5PVaqFJk3iATsDucvsCGpkQQngpI+Mwq1aleTWJM1S4Ly3eICbSq2rc0ZE2LFbjuPq0vpF00wkhTHXw4AE2b97IV1/NIyoqmilTppodkt+4Ly0eH+vd5GCLxUJMpI38whIKikq8XlIi1EnLSAhhqg0b1vPEE38nI+MwDz/8WJUloEKN+9LikRFWoiK9f7uNjTbaCXa7s2wkXriTlpEQwlTnnHNepYUTw0HFpcV9ad3ERJ2adlBQaCcqouppCOFCWkZCCBEAebXooisVGWHFVnbf6PSXIg8FkoyEEMLPyi0tHh1BhI8ldiwWCzGurrpC11Lk4U6SUQiqD7+YQoQyT0uL+6q0q87hcPq1cGqgnO77kiSjEGOzRVBcXHXJFSGE+Uq76CwWC3HRtVtiI9Ztsb1Q6KorLi7CZqv9MASvn6mUagI011pvd9vWCbgXaAzM1lovrHUkwivx8Ynk5maSmNiMyMioejHkU4hQYnc4jKoLQFxMBFZr7f5GIyKsZRNcza7IXx2n00lxcRG5uZkkJNS+moMvaewloBswBEApFQ8sB0oX9JihlBqntf6h1tGIGsXGGuvFHD2ahd0e/P8tBTOr1Vqnpfnrk/p8bfML7ZwoMFpGNnsUhwpq3wFVkF9MQZGdE4CzMAaLJTivrc0WQUJCUtn7U234koyGAR+4PZ6BkYjOATYAqcD9gCSjAIuNbXBaP3RhqFhqSfhPfb62T85ey66Dx2jSMJpnbx2O9TR6L9bsyOD1L7cA8OfLBtCjQ1LYXltfUnYLYJ/b47OBtVrrBVrrQ8BMYIAfYxNCiJCSnn2CXQeNFVGH9W55WokIoHv7xLKvt+85clrnCna+JKNiwL1U7Wjge7fHuUATP8QkhBAhacXWU8uBDOt1+ovWJcRF0b65sbT89t2Vl5EIJ74ko1+Ai5RSFqXU+RiDFpa47W8HhHfqFkKIKjicTlZsMZJR59YNadXEP13pPToagwJ+Tz/OyYLwvU/sSzJ6FaM1lAN8BuyifDIaCWz2X2hCCBE69N5cso8ZK8Sm9PbfUt49OjQGjGSn94Vv68jrZKS1ng1cg5GAPgTO1loXQ9mw70QgfBYhEUIIH6RtTgcgwmZhcI8Wfjtvt3aNykoDhXNXnVej6ZRSNqAN8D+t9QcV92uts4Ez/BybEEKEhMIiO2t1JgD9kpv6XIuuOjFREXRp3ZBf9h9l+57wTUbetowiMbrlbghgLEIIEZLW/ZJBYbExMXW4H7voSvXoaHTVHcg6Qc6xAr+fPxh4lYy01gVAFnAisOEIIUToSXMNXIiPjaRPZ/8PKu7R4VRlg42/Zfn9/MHAlwEM84EpgQpECCFC0ZFjBWX3cs7s2cLnCt3e6Ny6IdGRRuHUTb9m+v38wcCXq3Y/0EopNUsp1UcpFROooIQQIlSs2HqI0nrVw/v4v4sOIMJmpVu7RAA2/poZlpX7fSkHlAE4gX7AlQBKqYrHOLXWsnqsEKJecDqdZV10bZo2oEOLhIC9Vo8OSWzelU1GTj6Zufk0T4oL2GuZwZfEMRsIv3QshBC1tPvQcdKzTwLGwIVAVtHv2fHUfaNte3LqbzLSWl8bwDiEECLkpG02WkUWC5zph/I/1WnbPJ742Ejy8ovZtjuHMf3bBPT16posrieEELVQYnewavthAHp2bExSQnRAX89qsZSNqtuxJwdHmN03qtX9HddaRol4SGZa672nGZMQQgS9TTuzy1Z09Wf5n+r06JjEmh0Z5OUXsz8jj/YBvEdV13xKRkqpS4GHgR7VHGY7rYiEECIElA5ciImyMaBbszp5zZ5u84227c4Jq2TkdTedUmoq8B+MBPYmYAE+BuZiLC+xDnjc/yEKIURwycsvLpt8Oqh787I5QIHWLDGW5knGSj7hVhrIl3tG9wHbgf7A313b3tNaXwoMAhTGiq9CCBHWVm07jN1h3LOpqy46AIvFQr+uRivsl325lNiDa/nx0+FLMuoLzHKVBiq9AjYArfUW4C3gQf+GJ4QQwSdti1Ghu0nDGLq6JqPWlb6uZFRYbC9bVTYc+JKMbEC26+t81+dGbvs10NsfQQkhRLA6mHWC39OPA8bcotNdWtxX/ZKbln0dTl11viSj/UAHAK11PkZFBvdlIxRSSFUIEebclxYPRIXumiQ1jKFNU2MV2e27w2dxbV9G06UBEzh1v+hr4G6lVD5GUvsj8I1/wxNCiODhcJwq/5PcphEtGptTBaFHhyQOZJ1g58FjFBSVEBMV+lXYfGkZvQYsU0rFuh4/hNE19yhGgtqJMchBCCHC0o69OeQcN5YWN6NVVKqna30ju8PJL/uOmhaHP/lSDmgNsMbtcSbQXynVF7AD27XW4TO0QwghKvjJVf4nwmZlcI/mpsWh2iditVhwOJ1s33OEvl38v4ZSXfNlntEopVSlmV1a601a661AY6XUKL9GJ4QQQaKgqIR1v2QA0L9rUxrE+G9pcV/FRkfQqZUx4bV0LaVQ50s33VJgYjX7x7uOEUKIsLNOZ1JUbHT+mNlFV6qHq4r33ow8jp8sMjma0+dLMqpp/KKNU/OPhBAirJQOXGgYF0nvTo1NjgZ6dDgVw469ueYF4ie+Vu2urkzscCA8F2cXQtRr+zPy2OGa0zO0Z8uALC3uq+Q2DYmMMOIIhyHe1Q5gUErdBdzltulFpdRTHg5NAhoC7/kxNiGECApzl+3EibGMw5gBrc0OB4DICBtd2zZi2+4ctoXB5NeaRtPlAntcX3fEqMBwuMIxTmALsBJ4wY+xCSGE6bbvPsLmXUbxmVH9WtGqSQOTIzqlR4cktu3OISMnn+yjBTRpFGN2SLVWbTLSWs8CZgEopX4H/qK1/rouAhNCCLM5nE7mLNsJQHSkjQtGdDI5ovJ6dmzM59/vAmDbniOM7Bscrbba8GWeUXD9FIQQIsBWbz/MnkNGHbqzhrSjUXxgV3P1VYcWCcRFR3CysITtu3PqRzJSSjUBmmutt7tt6wTcCzQGZmutF/o/RCGEqHvFJQ7muVodDeMiOWtIe5MjqsxqtdC9QxLrf8lk+54cnE4nljou3OovvgwJeQlXlx2ULT2+HKMm3WXA/2TSqxAiXCz9+QBZRwsAOH9EJ2Kjg7P+Ww/X6q9HTxRxMCt0a1X7koyGAfPdHs8AWgPnuD5vB+73X2hCCGGOkwXF/DdtNwAtkmIZ1S94u796dnRbijyER9X5koxaAPvcHp8NrNVaL9BaHwJmAgP8GJsQQphi/sq95OUXA3DR6C5BMa+oKi0bx5EYHwWEdmkgX65wMRDr9ng08L3b41wg9Kv1CSHqtSPHCkhda/zf3aV1Q86oXJIzqFgslrJqDHpfDnZHaBbC8SUZ/QJcpJSyKKXOxxi0sMRtfzsg9KcBCyHqtS+X/05xifGGPn1sckgMCCjtqssvtLPbNfov1PiSjF7FaA3lAJ8BuyifjEYCm/0XmhBC1K39GXn8tCUdgAFdm9KtXaK5AXmpdBADhG5XndfJSGs9G7gGIwF9CJyttS6GsmHficCcAMQohBB14rPvd+J0gsVi3CsKFY0bxpStOrs9RAcx+DRWUWv9AfCBh+3ZwBn+CkoIIera9j05bNpZWvanNa2bBk/ZH2/07JjE4SMn+XX/UYqK7URF2swOySfBO0RECCHqiMPpZO7S3wCIirQGXdkfb/R0ddWV2B38eiD0liKXZCSEqPfW7sgou/F/1uD2JAZZ2R9vqPZJZYvOheJ9I0lGQoh6rcTu4PPvjWKoCXGRTB4afGV/vBEfG0n7lq6lyPeE3sBmSUZCiHpt6c8HyMx1lf1JCd6yP94o7arbfeg4JwuKTY7GN5KMhBD11smCEr75aTcAzZNiGd0/eMv+eKOHa76R0xl6S5FXmYyUUrtck1tLH/9dKdW7bsISQojA+3bVnrKyPxcHedkfb3Rtm0iEzbhzFGr3jaq78u2BBLfHjwJ9AxqNEELUkZzjhaSuMcr+dA6Bsj/eiI600aV1I8BYbC+UVJeMDgB9KmxzBjAWIYSoM18u30VRadmfMV1CouyPN0q76tKzT5JzvNDkaLxX3Z26r4D7lVKTOVVz7mGl1E3VPMeptR7vt+iEECIADmTm8eNmo+xP/+SmqPZJNTwjdPTs2Jgvl/8OwI49OQzr3dLkiLxTXTJ6AKMO3QSgA0arqBkQVwdxCSFEwHy2zK3sz5jQKfvjjU6tEoiJslFQZGfb7iOhn4y01vnAI64PlFIO4G6t9X/qKDYhhPA7vTeHja6yPyP7tqJNiJX9qYnNaqVbu0Q27cwOqUoMvgwduQ5IC1QgQggRaE6nkzmlZX8irFwworPJEQVGowbGYnulS2GEAq9nd2mtZ5V+7arSXVq86XdXoVQhhAhqa3Zk8Hu6UfZn0pB2JCWEXtmfcOXTVGOlVD/gZWBEhe3LgTu11pv8GJsQQvhNid3BvO93AUbpnLOHdjA5IuHO62TkmvD6IxCDMdJuq2tXL+A8YLlSarjWemsVpxBCCNMs+/kAGbn5AJyf0jGky/6EI19+Go8DxUBKxRaQK1H94DrmIv+FJ4QQpy+/sISvS8v+JMYyZkAbcwMSlfgygGEU8Kqnrjit9RbgNYxlyYUQIqi4l/25cHTnkC/7E458+Yk0AA5Vsz/ddYwQQgSNnOOFLFptlP3p1CqBwd2bmxyR8MSXZLQLmFLN/imuY4QQImh89eOpsj+XjE0Om7I/4caXe0azgX8opf4DPAXscG3vATwITAL+4t/whBCi9g5knWD5JqPsT78uTcKq7E+48SUZPQ8MBC4FZgCls6msgAWYA/zTr9EFiFLqMWA60B24XGv9ickhCSEC4HO3sj8Xh1nZn3Djy6RXOzBDKfUOMJVTk153AV9qrRf7P7yA+RW4C3jC7ECEEIGh9+aw4bcsAEb0aUWbZvEmRySq4/NAe611KpAagFjqjNb6QwCl1ENmxyKE8D+n08ncZTsBo+zP1JHhWfYnnJg660sp1QqjhTIUGATEA2O11ss8HBuNMY/pKiAJ2Ag8pLVeUmcBCyFCwjqdya6DxwCYOFjK/oQCswfbK4ylKtoCNZUSmgncA3yIkcAcwLdKqWGBDFAIEVpK7A4++95oFUnZn9Bhdj2MdUBTrXW2Umoq8IWng5RSQzAGTtyjtX7RtW02sAV4FmNCbumxy6h68u2ftdbP+yt4IUTw+X7DQTJyjLI/5w3vSFyM2W9zwhum/pS01se9PPRijFJE77g9t0Ap9S7wlFKqldY63bV9jN8DFUKEhBK7g/+t2A1As8QYxg6Usj+hIlT+ZRgA7NBa51XYvhpjWHl/jAoQXlFKRQI2jG7KSKVUDFCktQ6dxT+EEJWs2ZFBbl4RAFOGdZSyPyHEq2SklIrFmJejtdarAhuSR62AAx62lyag1j6e723gGtfXIzEm9I4FlvlykiZN6maoaLNmCXXyOvWRXNvAqetr63Q6WbrhIACJ8dFMGZ1MVKStTmOoKzVd25iYSACsVkvI/I572zIqxHgDvwswIxnFumKoqMBtv9e01tcC155eSJCdnYfD4Tzd01SrWbMEMjO97c0UvpBrGzhmXNtf9uXy275cAEb1a8XR3JN1+vp1xZtrW1BgFIV1OJxB9TtutVqq/Cfeqzasq/tqH9DQj3H5Ih/wNDYzxm2/EKIeS11jFEONsFkYO7CtydEIX/nSoToLuMo136eupWN01VVUuu1gHcYihAgymbn5rP81E4ChPVvQqEGUyREJX/kygCENuBDYoJR6DaOkTqV2sNb6Bz/F5m4DcJdSKr7CIIahrs8bA/CaQogQsWTdfpyuHvOJg9qZG4yoFV+SkXsJoJeAijdLLK5tgbhj+BlwH3Aj8CKUVWS4DvhJay0tIyHqqfzCEn7YaLwFdG+fSPsWoXHDXpTnSzK6LhABKKUedn3Zw/X5KqXUCCBXa/1vAK31KqXUXOA5VwmhnRij4Trgh4EIQojQ9eOmdAqK7ABMGtze5GhEbflStXtWgGKoWDn7etfnPcC/3bZf7Tr2aozadJuAc7TWPwUoLiFEkHM4nKSuNQYuNE+KpW9yE5MjErVl+qRXrbVXyy5qrQuAP7s+hBCCDb9lkXXUmOExcVA7rLKKa8jyKRkppdoBj2Gs6tocmKy1/k4p1QyjRtzrWus1/g9TCCEqW+Qazh0bHUFKn5YmRyNOh9dDu5VSnYC1wEXAVtwGKmitMzGWgLjR3wEKIYQnew4d5xfXJNfR/VoTE2V6R484Db789J7CWLahN8Yk04wK++cD5/kpLiGEqFZpq8hqsTD+DJnkGup8mfQ6AXhNa72PysO6wRhwIL8RQoiAy80rZPX2wwCcoZrRpFFMDc8Qwc6XZNSQ6itjRxEEAyKEEOHvu/UHsLvqQk4cLJNcq+J0BrZ2pj/5koz2Ab2q2X8m8NvphSOEENUrKraz7GejiH/n1g1JbtPI5IiCTygOKvQlGc0DrldK9Xbb5gRQSl2EscTEHD/GJoQQlazYeoi8fKMq9SRpFYUNX5LRU8B+jCUkPsRIRH9RSq3ASEIbgX/6PUIhhHBxOp2krt0PQFJCNAO7NTM5IuEvXicjrfUxYBjG0t+DMGrRTQQU8Bow1jUxVQghAmLr7iMczDoBwIQz2spKrmHEpwEHroR0F0YF7WYYCSlTax06d8mEECErdY3RKoqKtDKqv68LPItgVuvRb66JrkIIUScOZp1g865sAFL6tKKBa2ltER58TkZKqUuAaUBn16ZdwBdaaxm8IIQImMWugqggaxaFI6+TkVKqAfAlMA6jey7XtWswcIlS6mbgfK31CT/HKISo5/Lyi0nbcgiAvl2a0LJxnMkRCX/zdTTdeOAVoLXWurHWujHQ2rVtrOsYIYTwq+83HKCoxAHIcO5w5Us33Qxgrtb6bveNWutDwN1KqTauY+6u/FQhhKidEruDJeuMgQttmzWgR4ckkyMSgeBrOaCl1ez/znWMEEL4zdodGeTmFQHGvSJLKJYXEDXyJRltArpWs78rsPn0whFCiFOcTmdZde6EuEjO7NXC5IhEoPiSjB4GblJKVVomQil1AcZaRn/1V2BCCPHbgaPsPnQcgLED2hAZYavhGSJUVXnPSCn1nofNvwNfKqU0sN21rQdGFYbNwBUY3XVCCHHaSltFETYLYwfKCjXhrLoBDNdWs6+768NdX6APcMNpxiSEEGTm5rP+F2Nu/dCeLWjUIMrkiEQgVZmMtNZS9EkIYZol6/ZTuhyPTHINf5JwhBBBJ7+whOWbDgLQvX0i7VskmByRCDRJRkKIoPPj5nTyC+0ATBrc3uRoRF3wqTadUmo48EeMYdxNMMoCuXNqrbv4KTYhRD3kcDjL6tA1T4qlb3ITkyMSdcGX2nQ3AW8ARYAG9gYqKCFE/bXhtywyc42l0SYOaodVJrnWC760jP4KbADO0lpnBSYcIUR9l+oazh0bHUFKn5YmRyPqii/3jFoA70oiEkIEyp5Dx9H7cgEY3a81MVG1XnJNhBhfktF2QCoUCiECJtV1r8hqsTD+DJnkWp/4uoTEbUopWetXCOF3uXmFrNp2GICBqhlNGsWYHJGoS163gbXW85RSccA2pdRXwG7AXuEwp9b6CT/GJ4SoJ75bfwC7w5jlKmsW1T++jKbrBjyOsUzEVVUc5gQkGQkhfFJUbGfZzwcA6Ny6IcltGpkckahrvtwdfA1oDtwFLAdyAhKREKLeWbntMHn5xYCU/qmvfElGw4D/01q/EqhghBD1j9PpLBvOnZQQzRmqmckRCTP4MoDhKJAZqECEEPXTtt05HMg6AcD4M9oSYZMqZfWRLz/1OcCFgQpECFE/la5ZFBVpZXR/GaxbX/nSTfcmMEsp9SXwMsZCexVH06G1ljJBQgivpGefYPOubABS+rSiQUykyRGFF6fZAfjAl2S0FeN7GwRUWnrcjawLLITwSura/WVfT5BJrn4UevX8fElGjxNaiVYI4SdZR/PJchUv9caho4Xk5p6s9pgSh4O0zekA9O3ShFZNGpxWjCK0+TLp9dEAxiGECFJ7Dx/niVlryyakBoJMchUybEUIUa35K/cENBF1adOQHh2k7GV950sFhlHeHKe1/qH24QghgsmRYwWs3WHM6Oif3NTrFkxiYlyN3XQAVquFDi0TsMiaRfWeL/eMluHdPSMZwCBEmFiyfj8Op/Fnf15KRzq1aujV85o1SyAz83ggQxNhxpdkdF0Vz+8CXItROPXN0w9JCBEMCovs/LDhIABd2zbyOhEJURu+DGCYVdU+pdT/Aev9EpEQIiikbUnnREEJIPXiROD5ZQCD1joHeAe43x/nE0KYy+F0ssg1B6hpoxgGdpN6cSKw/DmaLgfo7MfzCSFMsnlnNoePGAMQxp/RFqtVBhiIwPJLMlJKxWCscXTIH+cTQpirdPnv6CgbI/tKvTgReL4M7X6vil2NMZaXaAb82R9BCSHMsz8jj227jeXKRvZtRVyML+OchKgdX37Lrq1i+xHgF+AerfV/TjsiIYSpSltFFqRenKg7voymk2oNQoS5YyeKWLH1MAD9uzaleVKcyRGJ+kISjBCizLKfD1BidwBSL07ULUlGQggAikscfPfzAQDat4inW7tEcwMS9Uq13XRKqa99PJ9Ta33BacQjhDDJ6u2HOXaiCDBaRVIvTtSlmu4ZTfHxfLLekRAhyOl0kupa/rtRgyiG9GhhckSivqk2GXkzaEEpNRp4DhgMpPspLiFEHdJ7c9mbkQfAuIFtiLBJD76oW7WeQKCU6g08C0wGjgN/A/7lp7iEEHVokatVFBlhZfSANiZHI+ojn5ORUqod8ARwBWAHXgae1Fpn+zk2IUQdOJxzko2/ZQEwrFcLGsZFmRyRqI98qcCQBDwE3AZEAx8DD2utdwcmNCFEXVi8dn/ZzV6pzi3MUmMyUkpFA3cDDwCJQCrwgNZ6QyADE0IE3smCYn7cZNzq7dUxiTbN4k2OSNRXNQ3tvgF4FGiNsV7RX7TWS+ogLiFEHfhhYzqFxXYAJg5ub3I0oj6rqWX0NsZw7bXAHKCfUqpfNcc7tdYv+Cs4IUTg2B0OlqwzBi60ahJH786NTY5I1Gfe3DOyYAzbHuzFsU5AkpEQIeDnX7LIPlYIwIRB7bDKJFdhopqS0dg6iUIIUedKh3M3iIlgeO+WJkcj6ruaJr1+X1eBCCHqzq6Dx/jtwFEAxgxoQ3SkzeSIRH0n06yFqIdK1yyyWS2MGyhrFgnzSTISop45cqyAtTsyABjcvTlJCdEmRySEJCMh6p3v1h/A7jCmuU6UNYvCWwiVrpZkJEQ9Ulhk5/sNxppFyW0b0alVQ5MjEoEQigMjJRkJUY+kbUnnREEJAJOk9I8IIpKMhKgnHE4nqWv3A9CkYQwDujU1OSIhTpFkJEQ9sWVXNoeOnARgwqC22Kzy5y+Ch/w2ClFPlK7kGh1lY2Tf1iZHI0R5koyEqAf2Z+axdXcOACP7tCIuptbragoREJKMhKgHSltFFowuOiGCjSQjIcLcsZNFrNh6GID+XZvSPCnO5IiEqEySkRBhbtnPByixOwCYJJNcRZCSZCREGCsucbB0vTHJtX2LeLq1SzQ3ICGqIMlIiDC2evthjp4oAmDioHZYQnFqvqgXJBkJEaacTmfZwIVGDaIY0qOFyREJUTVJRkKEqV/25bI3Iw+AsQPbEBkhf+4ieMlvpxBhqnQl1wiblTED2pgcjRDVk2QkRBg6nHOSDb9mATC8dwsaxkWZHJEQ1ZNkJEQYWrJ2f9lSNhOkOrcIAZKMhAgzJwtKWL45HYBeHZNo2yze5IiEqJkkIyHCzPJNBykssgOykqsIHZKMhAgjdoeDxa41i1o2jqN35yYmRySEdyQZCRFGfv4li+xjBYDRKrLKJFcRIiQZhYEjxwp4ce7GsgmOwn8ycvN5Yc5Glv18wOxQvLJorfE70CAmguG9WpocjRDek2QUBt757zY27czm4yW/4nA4a36C8Npr8zazeVc2sxdqs0OpUWGxnd/2HwUgpU8roqNsJkckhPckGYUBvS/X7BDCVmkFg1Dg/o9IUkK0iZEI4TtJRkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTRZgdQIiyAVitdVNqpabXaZ4Ui9N56ti6iisceHNtvT3WbDabtSzeBrGRpsdr9uuHs5qubcMGUTRPiiU+Liqofg5usVSakW1xOmXGfi2MAJabHYQQQoSokcCP7hskGdVONDAYSAfsJscihBChwga0AtYAhe47JBkJIYQwnQxgEEIIYTpJRkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSW26IKSUigYeB64CkoCNwENa6yWmBhbilFKDgWuBsUAHIBtIAx7WWv9mYmhhRyl1P/AssFFr3d/kcMKC6/f3UWA4EAnsBF7QWs80MSy/kZZRcJoJ3AN8CNwFOIBvlVLDzAwqDDwAXAgsxriubwFjgJ+VUj1MjCusKKVaAg8DJ8yOJVwopc4GfsJIQn8D/oTxe9zOzLj8SVpGQUYpNQS4FLhHa/2ia9tsYAvGf5qjzIsu5P0LuFxrXVS6QSn1KbAZI1Fda1Jc4eYZYC3GP7uJ5oYS+pRSjTD+QX1da32XyeEEjLSMgs/FQDHwTukGrXUB8C4wQinVyqzAQp3WOs09Ebm2/QpsBaRl5Aeuf6auBO41O5YwcjlGUv87gFIqQSkVPOtC+Ikko+AzANihtc6rsH01YAH613lEYcz1R90CyDI7llDnupavALO01htMDiecTAB2AOcopfYBx4AjSqlnlFKV1gUKVdJNF3xaAQc8bE93fW5dh7HUB1cAbYCHzA4kDFwN9ASmmhxHuEnGuDc0E3gO+BmYgtG1HAPcbVZg/iTJKPjEUmGdD5cCt/3CD5RS3YFXMRb5+sDkcEKaUioB417RM1rr9JqOFz6JxxhV+xet9bOubfOUUvHAbUqpJ7XWId+yl2664JOPsXhfRTFu+8Vpco34+h+QA0zXWjtMDinUPQwUYQwSEf5V+jf/cYXtH2GMrhtSt+EEhrSMgk86RlddRaXbDtZhLGHJNTrpW6ARkKK1PmRySCHNNajmbowhxy2UUqW7YoAopVRH4KjWOseUAENfOtALOFxhe+njpLoNJzCkZRR8NgDdXU1wd0NdnzfWbTjhRSkVA3wDdAOmaK21ySGFgxZAFMbUg9/dPoZijFL8HeP+hqidda7PbSpsb+v6nFmHsQSMJKPg8xlG0/vG0g2uigzXAT9praVlVEuukUefAsMwuuZWmhxSuPgdmObhYyuw2/X1bLOCCwNzXZ9vKN3gGrl4I8bE4rD4PbY4nU6zYxAVKKXmYIxIegGj5Mc1wGBgrNb6JxNDC2lKqRcxKi98A8ypsDtPa/1lXccUzpRSy4BEKQd0+pRSszDKg70LrAfOdX3cr7X+PzNj8xe5ZxScrgaecH1OAjYB50giOm39XZ/Pc3242wN8WZfBCOGDm4C9GP+YXgPsAm7RWr9palR+JC0jIYQQppN7RkIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSTISQghhOklGQgghTCfJSIQUpdQYpZRTKXWt2bGcLqVUb6VUiVJqotmx1AdKqQuUUkVKqa5mxyIqk2QkhHn+hVGJPdV9o1KqsSvhfmtSXAGjlPq3UuqAq+p0VceU/sNxnz9fW2v9FbAZY6kLEWQkGQlhAqXUMGAinldGHej6vL7uIgo8VwKaCnyltTarKOZLwDSlVC+TXl9UQZKREOa4DcgC5nvYF5bJCGMZlDaYWx19HnASuMXEGIQHsoSECAtKqabAY8D5GCuPHga+Bv6utc6ucGxH4J8YLROApRjLZi8FdmutxwQ41giMFsJ/tdbFHg4J12Q0DcjFuM6m0FrnKaWWAxcDd5gVh6hMWkYi5CmlGgFpwK3AQozEssD1+EelVILbsU2A5RjrGc3EWA77BMYbZIM6CvkMIB5YXcX+gUCO1vr3OoqnrkwD5leRgOvSCqClUqq7yXEIN9IyEuHgfqAr8Eet9WulG5VSG4B/u/b/zbX5AaAtcKXW+iPXtteVUs8Bf66jeHu6Pu+suMOVOJMxsfUQCEqpHoACHjY7Fk5d917ADjMDEadIMhLhYBqQCbxVYfubwCOu/aXJ6DwgHfi4wrHPU3fJqJnr8xEP+wYAFsKvi24qUIDRYvUrpVRLjFWRuwMZwFyt9bpqnlLabdvc37GI2pNkJMJBJ2Ct1rrEfaPWukQp9Qun7sGUHrtaa+2ocGyGUirXfZtS6hLgTozlyrO01h0r7I/AuPd0FUaX9+cYrbOCGuItHUnmaXjzGa7PVSYjpdRIwNOw7yjAprW2VTj+NYwuy+Fa6xUV9i0DRmMsa/+t2/ZLgE+B/2mtp7i2dQOeA1KAGFz35bTW91YVq5tpwGKtdZ4Xx3pNKXURMA54F3gFI8FcrpS6GPhrFaP2Sq+7LHMdRCQZCVG1HIxuvhbAPR72/xUYC/QBijAGTDyHkcCqk+n63NjDvhoHL2itl2PccyqjlGoNrHXF6749FrgcoxV2I8b9kop2ADdQPsHdSOUurP9hjEa7EmNEWheMxFQtpVRbYBBwU03H+kIp1RvoqLX+o9vmPcA/lFJnYoyYe93DU0uve6aHfcIkMoBBhINdgHK1VMq4Hndz7S+1G0hWSlkrHNscSHTfprVO1Vp/gvEG58mNwNNa6wNa60zgUeBapZStiuNLbXF99lQJYCCQB/xSwznKKKWiMZLEj1rrpyvsng44MAZ1XKKUiqeyOcA4pVQz1/k6YLQGv3R7jaYY97Le0Frnaa0dWutftdYzvQhxKkYr5GtvvycvXYjneVporVcCTSv+Trgkuz5v8bBPmESSkQgHX2Lch7mxwvabXNu/cNv2DdAKuKzCsT7N9ldKJQLtgA1um9cDCUDHGp7+M3AMOLPCOeMwbvJv8HFS6BsY3WbXeth3I/AJRsIpBi71cMxxjGt0tevxDcB/gMLSA7TWWcB24D2l1KVKqS4+xDcNI1H6uyVysvQ6KaWGKaWylFLuAyTWYfwzUtGZwGGttfZzPOI0SDedCAfPYbQAXlVKDcR4sx+A8aaqXftLPYvRbfW+UmoIRlfUSGA4xiRUb5NA6XDxXLdtuRX2eaS1tiul5gFTlVLRWuvSN/1+gA2IUUr9xcNT87TWFbvh7gSmAIO11icr7OuG8b39WWtdqJT6BOOavOPh3O8C7yilXsRIaucCF1U4ZgxG0v4r0FMptRf4i9Z6TlXfq1KqMTAKY0Sjr8YrpWI8bM/SWr9RYVs/oAnluw2PUeFn4WoZjgTeq0U8IoCkZSRCntb6KMab0JvAOcDLrs9vACO01sfdjs0CRgD/Ba7HSE4NMO79WIB8L1+29JyN3LYlVthXndddx09x21Z6v2gQ8A8PH9PdT6CUGuuKf7rWereH17gR2KG1XuV6PBM401MpHK11Gsb3/yhwSGu92cMxGVrr+7XWfTHuu7wG/KeG+TpTMP7p/aKaY6oyGXjCw8fdrv2xbse+g9ECu8ZtWz/g1wrnvAiIw/hdEUFEWkYipGitl+FhFJqrC+g210dN5/gd435DGddk2CbAXi/jyFVK7cO4t1La3TMAIxHt9uL5q5VSpRN0P3dtexV41ZvXd1WRmIPR6lnmYX8kRrdbI6XUoQq7bwA8jYB7F6MVeasX8R8DnldKPUj183WmARurSJZVnXsZnkcaVrRbKTVca53mGkn5ZekO10TojlrrisPn7wK+0FrL/aIgI8lI1DtKqVitdcUWUGm3WKrbcTYg0vVhcXUZOd261d4BHnSVlynGaFXM1FrbvQzlT8BGpdQkrfUiH+KPw3jj/bpit52b84AkjATp/oZ8JfCAUuovWuuiCs95C+MeWJqH10zCmIf1EcbgCitGd14cxr2ZqqwA3q72G6q9D4GXlFIN3CufK6U6YbSgyiVcpdRUoDcwI0DxiNMgyUjUR/OVUnswBhxYgfEY3UlplC/ieRXwvtvjfIyRdR1dj58GmgJbXef5DKPCg1e01lup3d/gRRhdUN2UUp7eWHtidNF9rLXe5r5DKfUG8BDGCLdy93pcrZ3FVbxmEdASY0RcC4zBDVuB86tr9Witn6tq3+nSWjuVUncDtyulbsQYNWjFmNR8V8WahFrrLzHmYokgZHE6Zd6XqF+UUn/C6MLqiHHfYT/G0OjH3O8vCSHqjiQjIYQQppPRdEIIIUwnyUgIIYTpJBkJIYQwnSQjIYQQppNkJIQQwnSSjIQQQphOkpEQQgjTSTISQghhuv8HejwwbWv8RfwAAAAASUVORK5CYII=\n", + "text/plain": [ + "<Figure size 432x288 with 1 Axes>" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "# make a plot of the luminosity distribution using Seaborn and Pandas\n", "import seaborn as sns\n", @@ -412,7 +451,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "1f37d2c0-1108-4ab9-a309-20b1e6b6e3fd", "metadata": {}, "outputs": [], @@ -420,16 +459,45 @@ "# Update the probability distribution to use the three-part power law IMF \n", "population.update_grid_variable(\n", " name=\"M_1\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)\",\n", ")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "6f4463e8-1935-45f2-8c5f-e7b215f8dc47", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Do dry run? True\n", + "Doing dry run to calculate total starcount and probability\n", + "Grid has handled 39 stars with a total probability of 0.211729\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 39 *\n", + "* Total probability is 0.211729 *\n", + "**********************************\n", + "\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", + "**********************************************************\n", + "* Population-1d1d556abeae4549aa28f9740807dc84 finished! *\n", + "* The total probability is 0.211729. *\n", + "* It took a total of 3.90s to run 39 systems on 2 cores *\n", + "* = 7.80s of CPU time. *\n", + "* Maximum memory use 519.211 MB *\n", + "**********************************************************\n", + "\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" + ] + } + ], "source": [ "# Clean and re-evolve the population \n", "population.clean()\n", @@ -441,10 +509,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "id": "cfe45a9e-1121-43b6-b6b6-4de6f8946a18", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[None]" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEdCAYAAABDiROIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAABEJElEQVR4nO3dd3hUVfrA8e+kBxJIgAAhIC3wgoCA0nsVxQYKYl97Wxu7lnV1f3ZXXfvaK7ZVwYoFpYnSq3Q80msCAUIJJJAyvz/uJEySSTITZnJnkvfzPDyTnHvmzjuXyX3nnHvuOQ6n04lSSilltzC7A1BKKaVAE5JSSqkgoQlJKaVUUNCEpJRSKihoQlJKKRUUIuwOIERFA92BNCDf5liUUipUhAPJwGLgWMmNmpAqpzsw2+4glFIqRPUH5pQs1IRUOWkAmZlHKCgI7H1c9evHsW9fVkBfo6bSYxs4emwDJ5SPbViYg8TE2uA6h5akCaly8gEKCpwBT0iFr6MCQ49t4OixDZxqcGw9XurQQQ1KKaWCgiYkpZRSQUETklJKqaCgCUkppVRQ0ISklFIqKOgouxCUnX2ErKwD5OfnFZXl5hWQX+AkOjIch8PG4ELInj1hFBQU2B1GtaTHNnCC8diGhYUTERFFfHwCkZFRld6PJqQQk519hMOHM0lISCIyMgqHw0FBgZNtuw9DONSuG0OdWpX/QNQkERFh5OUF1x92daHHNnCC7dg6nU4KCvI5diybzMw9xMcnEhtbu1L70i67EJOVdYCEhCSioqJxuJpCefknPpyHjxy3KzSlVA3kcDgID4+gVq14EhIacOTIwUrvSxNSiMnPzzupJrFSSgVKZGQ0eXm5lX6+JqQQ5NCLREqpIHSy5yZNSEoppYKCJiSllFJBQROSUgEyZsx5PPHEw7a89m233chtt91oy2sXSkvbRb9+3fjxx++C5vWfeOJhxow5z7bXPuusQQF/7bJePxTU2GHfIvIIMBZoB1xmjPnM5pBqrLS0XYwde36F9f75z4cYObL4yWTfvr1ceOE5FBQUMGnSdzRu3LjU82677UaWL19Gy5at+OijiaW2z5w5nf/7v38A8PLLb3D66d2Ktq1YsZwPP3yPjRvXc+jQQRISEklNbcuwYSM488yzfH2rNd6CBfNYs2YV1113k92heG316lUsXDiPiy++jPj4eLvDKSYUj2d5amxCAtYDdwKP2R1ITZeQkMi//vWox20FBQX8978vkJ19lDZtpNT2GTOmEhMTQ3h4BNOn/8QVV1ztcT9RUVFs3ryJDRvWk5rapti2adN+IioqmuPHiy9gOXPmdB566H7atGnL2LGXEB9fh7S0XSxfvozvvvs6qBPSCy+8ancING6czIwZc4mIOHGaWbhwPpMmfWrbCfS++x70+abStWtX8f77bzNy5HleJyRP7z0QyjqeVfX6/hZa0fqRMeZjABF5wO5YarrY2FhGjBjpcdu7777JoUMHue22u2jTpm2p7dOm/US/fgOJiopi2rSfy0xIp5zSgqNHjzB9+s/FElJWVhYLF86jd+++/PrrL8We8957b9GqVWvefHMCkZGRxbZlZu738V1WrZLx2sHhcBAdHW13GMUE+gSdn59Pfn4+UVFRtr73YDz23rD9GpKIJIvIUyLyi4gcFhGniAwqo260iDwtIrtEJFtEFojI0CoOWVWR5cuX8eGH79G7d1/Gjbu81Pbt27exbt1ahg49k6FDz2TjxvVs2rSxzP0NHXomM2ZMxek8sbjZrFkzcDgc9O8/qFT9Xbt2cOqpHT2e3BMT6/n8ft5990369etWqvzHH7+jX79upKXtKiobM+Y87r//7yxevIBrr72cIUP6cu21l7N27WoApkz5nksuuZAhQ/pw2203smvXzmL7LHkNadmyJfTr141ff53JhAnvMGrU2QwZ0oc777yFHTu2l4ppxoypXHPNZQwZ0odzzx3Ov//9KAcOHChWZ/v2bTzwwD2cf/4Ihgzpw+jRI3noofvJyrJWMy15HeOJJx5m0qRPAejXr1vRv6NHjzJsWD9efPHZUnFs376Nfv268dVXk8o9tocPH+aJJx5mxIiBnHXWIB5//CGysg6XqufpGtL06T9z7bVXMHz4AM48cyBXXTWOiROtON99901efvl5AMaOPb8o5sL/q379uvHSS88xZcr3XHbZRQwZ0ofVq1eWew1nx47t3HXXrQwb1o8LLzyHTz75oNj2wv+rZcuWFCsv3Of3308u93i61y35+kuWLOKWW65l6NC+nHXWYB588L5Sn53Ca127d6dz333jGT68P+eeO4xXXnmR/HyP6+r5TTC0kAS4D9gArAT6lFN3AnAR8KKr/tXAFBEZaIyZH9AoVZU6dOggjz76LxIT6/HAA494vL9h2rSfiI+vQ48evXA4HNSrV59p037ippv+6nGfw4efxUcfvc/q1Svp1KkzYJ2M+vTpT61apac6adSoMUuWLCIjYw9JSQ39+wa9sHXrFh5//CFGjRrDmWfG8vHHH3DvveO5+ea/8sknH3LBBRdy9OgRPvnkA55++nFeeun1Cvf5wQfvEhYWzmWXXcXhw4f49NOPeOSRB3n77RMnxR9//I4nn3yEDh06ccstd7Bnz26+/PJz1q1bw9tvf0h0dDS5ubn87W+3Ex4exrhxl1G3bl12797NvHlzyMo6TEJCnVKvfcEFF7Jv3z4WLZpfrIu2Vq1aDBgwmF9+mcbtt48nPDy8aNvUqVOIiIhg6NDhZb4np9PJ/ff/nZUrlzNq1EU0b96C336bxeOPP1zh8Vi8eAEPP/wAAwcO5vzzR5Ofn8+WLZtZtWoFF198KQMHDmHXrh38/PMU7rjjb9StmwBY3czu+5g5cyqjR48lPj6eBg0alPl6eXl5/P3vt9O5c1duueUO5s2bw+uv/xeAyy//S4XxuivreJb9Xhdy99130KxZc66//haOHj3CpEmfcsst1zFhwqckJp54T3l5efztb7fRqVNn/vrXO1m8eCGfffYxKSlNGT16jE9x+iIYEtJSoIExZp+IjAK+9lRJRHoAlwDjjTEvuso+BFYDTwMD3OrOAgaW8Xr3GGNKfxVTQeXf/36MvXszePHF10hISPBYZ9q0nxgwYFBRN8ygQUOYPv1nbrzxVo8JrFWr1rRuncq0aT/RqVNn9u3by++/L+XRR5/yuP/LL/8LTz31GOPGjaJTp86cdloXunfvSceOpxEWFvjOhW3btvLWWxM49dSOACQlNeKhh+7n1Vdf5rPPvio6Oebl5fHRR++ze3c6jRqVHtThLi8vj/fe+6DomNWpU5eXXnqWTZs20KpVKnl5ebz++n9JTW3Lf//7JlFR1qwgIu14+OEH+O67rxkz5hK2bNlEWtpO3n77A9q371C0//KuDXXseBrNm7dg0aL5pbpoR4wYydSpU1i2bDHdu/cqKp827Sd69uxd9F49mTPnV5YvX8btt48vakmPGjWGO+64udxjATBv3lxatmzFE0/8x+P21NQ2iLTn55+n0L//IJKTm5Sqs337Nj76aCKnnNK8qMy9tesuJyeHfv0Gcvvt4wEYPXoM48ffxoQJ7zJ69Fhq1apVYcyFyjuenrz22kskJCTw+uvvFl0L69mzDzfffA0ffzyhKKbCOM866xyuvPIawDqe1157Od9//231TkjGmNLtas/GALnAO27PzRGRd4EnRCTZGJPmKh/k90CD3M6MLH5bmUZuXgHRkeEVPyFAYqLCOa9vS1o1Kf0N2VtffjmR2bNncfXV1xcb8ebujz/Wsn37NsaPv7eobOjQEXz11SRWrVrBaad18fi8YcNGMHHip9x5591Mnz6N2NhYevfuy4IF80rVPffcC0hKasjnn3/CsmVLWLp0Me+//zYpKU35178eo2PHTpV+j95o3bpNUTIC6NDB+rlfvwHFTtCnnmolhLS0XRUmpHPOOb/YdZTOnbsAsGvXTlq1SuWPP9aSmbmfG264pSgZAQwZMpxXX32JefPmMmbMJdSuHQfA3LmzSU1te9LXrLp160H9+g2YOvWnooS0du1qduzYzg033Fruc+fPn0tkZCQXXHBRUVl4eDgXXTSOFSt+L/e5cXFx7NmzmzVrVhcdX1+dfnq3YsmoIhdeOLbo57CwMEaPvoilSxexcuVyevUqr4Oo8vbu3cv69X9y5ZXXFBuY0bFjJzp06MT8+XOKJSSwWmDuTjutKz///GNA4itke0LyQVfgD2NMVonyRYAD6AKkebszEYkEwrGuo0WKSAxw3BgTPNPo+mDhuj2s31H5SQ39KTY6ghvP71BxRQ82btzAq6++ROfOXbnmmhvKrDd16hRq1apN48aNi66B1KtXj4SEBKZO/anMhDR06Jm8+earLFmyiKlTpzBgwOBiJ96SevbsTc+evcnJycGYdcyYMZVvv/2Ke++9i08++aJYN4e/lUwuhUmgYcNGHssPHz7k8z7j4+u4nmt9L0xPt/6ESp5gw8LCaNq0Gbt3W9ubNElh3LjLmTDhHT7//H907Xo6ffr058wzz/LY/VmR8PBwhg8/i++++5q7776f6Ohopk79idq1a9OvX/9yn5uenk6DBg2JiYkpVu5NkrjwwrH88st0brrpapKTU+jevQeDBw+je/eeXsfuqdVUlvDw8FL1mzY9BYD0dM+tKn8o6/8VoHnzFkyfPrVYWWxsLerUqVusLD4+3qvP2MkIpYSUDOz0UF6YhLz/VFjeBgo7bfsDHwKDgVmVCc5uPds35FhuflC0kIZ3b1ap5x47lsNDD/2TmJgYHnro8WLXEtwVFBQwY8Y0jh49wmWXle4+mDVrOnfddbfHEVVNmqTQoUMnPvrofdasWc1111XcrQMQExND585d6dy5K3XrJvD++2+zYMFczj77XK/fX1nzfBUUeL5QHB7uuVuwrO5Ct7EaZQoL83xMnd48uYTbbx/POeecx+zZv7Jo0QKef/5pPvzwPd58832Sk8tvqXly1lnn8NlnHzNv3mwGDBjMzJnTGDhwCNHRMRU/uZISE+vx/vv/Y9GiBSxYMI8FC+YxefLXnHPO+dx///95tQ9/x1f256TqviuX9dkLtFBKSLHAMQ/lOW7bvWaMuRprUESl1a8fdzJP91pS0okm9p49YUREFP+w5DudpCTFcenQNkRFhnNK4+C6ec9b//nPc2zZsolnnnmBJk2Sy6y3aNFi9u3by6233k7TpsWT3549u3nxxedYunQhffta36wdDgcOB0XHbcSIs3n++WdITKxHz549CQ8PIzzcOgmEh5c+viV16GC1/jIz91VY1+FwFNWpW9f6xpmdfaRYt8mePbs9vrb7c+FE/GFhxcsLTx7h4SfKC09qhb97quNeXrjPlBTre92OHdvo1u1Ed6nT6WTHju20bt262PPbtm1L27Ztue66G1i9ehXXX/8XJk/+iptuurXUvgtf3z0ud+3aCampbZg+/Wfi4+PYv38fZ589ssJj3KRJMr//voS8vGPExJw4Dezcua3U65c8LtbP0QwcOJCBAwfidDp57rmn+eKLiVxzzXU0bdrM7dh5/myEhZV+P57eu8PhID8/n4yMdFJSmhbV3bVrh+t9pBAREUZCwonPift+MzLS3WIu/3iWfP2mTU/8v5asu337VpKTk8s9RoX78lRe+niEFTtn+SKUElI24GlgfYzb9iq1b18WBQW+f7P0RVJSPBkZJy6zFRQUlFqcK9/td6fTGVSLd3nrl1+m8+23XzNmzDj69Olf7nv46acfiYuL4+KLLy/VCnI6nXzwwfv89NMUevbsW1TmdFK0z8GDh5OZmUlqaipOp4O8vALy863/x/z8E8d3yZJFdOvWo9Trz5kzB4CUlFMqPNbu/x/JySkALF26hH79rDE32dnZ/PDDd6Veu+Rz4UT8BQXFy/Nd62Hl558oL2zxFP7uqY57eeE+27RpT2JiPb76ahIjRpxTdG1o5szpZGTs4fLLryIvr4AjR7KIjo4pdvybN29FeHg4OTnHPO4bICrK+nPNzDzo8SbTESPO4e23XyM/P58GDZLo3PmMCo9xz559+Oabr/jyyy+KBjXk5+czceJnpV6/5HE5ePBAqQETLVumAnD0aA55eQVFMR88eJCGDUu3/AoKKP036eG9F772xImfF12vKSgo4MsvJxEbG0vHjp3JyysgKakx4eHhLFu2lL59T4zN+uKLE7OMVHQ8S75+QkJ92rRpy/ffT+bSS68iLs76Mr127WpWrVrJuHGXl3mMTrxPz+Wlj0dBsXOWu7AwR7lf5EMpIaVhdduVVFgWuA5YFVB792bw9NNPEBtbi9TUNmVeOE1JaUqbNsJvv/1C9+69PHbJORwOevfuyy+/TCc7O5vY2NIN58TERK677qYKV968//6/k5zchL59B5CSkkJ2dg5Llixk7tzZtG9/alELzFs9evSiUaPGPPXUY1x66RbCwsL54YfJJCQksnt3esU7qAIRERHccsvtPPnkI9x++00MG3Yme/bs5osvPqdVq9acd95owEqqL7zwDIMGDeWUU5pTUJDPzz9PweFwMHDgkDL3L9IegBdf/A89e/YmLCyMYcNGFG0fPvws3njjv8yZ8xuXXHKFV6MZ+/YdQKdOnXn11ZfYuXMHzZu35Lfffim6H6o8Tz31OIcPH+L007vRsGFDdu+23mubNm1p0aKlK+Z2ALz11msMHXomERER9O07wONnqyIxMTHMmfMrhw8fQqQ98+bNYenSRdx0021FI+zi4uIYNGgoX3zxOeAgJaUp8+bNJjMzs9T+Kjqe7m699U7uvvsObrnlWs4553yOHDnCpEmfUb9+gzJvKK9qoZSQlgN3ikhciYENhVcfV1R9SMoftm3bWnQT41NPPV5mvbPPPpe+ffuTlZVFnz79yqzXt29/fvzxO2bP/vWkpve5774HmT37V2bOnMbevRk4nVa3ylVXXcsVV/zF57v+IyIiePLJZ3nuuad45503qFevPhdffCnx8XV48slHKh2nv40ceR5RUVF88skHvPrqS9SuXZvhw8/i5ptvL7r7PzW1DT169GLevNl8++1XxMTEkJrahmeffbnc0Yf9+w9k7NhLmTbtJ6ZOnYLT6Sx2Am3QoAFnnNHDNZT5bK/iDQsL4+mnn+ell57j559/xOFw0LfvAG677S6uuab0DdXuRow4m8mTv+brr78gK+sw9erVZ8iQYVx77Y1FybBt23bcdNNf+eqrSSxcON81b+LkSiWkiIgInnvuvzz77L+ZMWMq8fF1uOmm27jyyquL1Rs//l7y8/P49tsviYyMYsiQYdx6651cddW4YvUqOp7uunfvybPPvsy7777JW2+9TlRUJN269eDWW+8M6OAcXzgqczEzUNzuQxpsjJlVYltPYAHF70OKxroPabcxpuwzlP+1ADbb0WWXnr6Vxo2Lj5Q5npvPrr1HAIiMCCMlqWqubYW6ilpIqvJO5tjee+940tJ2epwIVwX/59bTOaqQW5ddS2BLye1B0UISkQddP7Z3PV4pIv2AA8aYVwCMMQtFZBLwjIgkAxuxRsk15yQHJyilgsOePbtZuHAeN9xwi92hKBsERUKi9Izb17oetwKvuJVf5ap7FZCINdXQSGPM3IBHqJQKmF27drJq1Qq+/fYroqKiOffcUXaHpGwQFAnJGOPVQuzGmBzgHtc/pVQ1sXz5Mp588hEaN07mwQcfKXO6KFW9BUVCUkrVbCNHnldq8UVV89i+/IRSSikFmpCUUkoFCU1IISiYhuorpVShkz03aUIKMeHhEeTmHrc7DKWUKiU39xgREZVfisTrQQ0iUh9oaIxZ51bWEvgbUA/40Bjzc6UjUV6Ji0vgwIEMEhKSiIyMKnNmYKWUqgpOp5OCgnxycrI5cuQg8fGVn/XBl1F2LwFtgR4AIhIHzObEsg/jRGSIMea3SkejKhQba601c/DgXvLz8wDIy3eSlWVNaBkR5iA939MctKqksLCwKp3SvybRYxs4wXhsw8LCiYyMIjGxIZGRZa8vVhFfElJv4CO338dhJaORWPPMTQPuBTQhBVhsbO2ixASwfU8Wz3+9CICUpNo8dp33i4vVZCWnZVL+o8c2cKrzsfXlGlIjYLvb72cDS4wxPxlj0oEJWKu6qiqmnXZKqerAl4SUS/FF8AYCv7r9fgCo74eYlFJK1UC+dNn9CVwkIq8C52ENZJjhtr0ZsN+PsSmllKpBfElIr2J1y2UCtYBNFE9I/YFVfotMKaVUjeJ1l50x5kOs5R5mAB8DZxtjcqFoSHgCoAuYKKWUqhSvWkgiEg6kAD8YYz4qud0Ysw84w8+xKaWUqkG8bSFFYnXRXRfAWJRSStVgXiUk1zpEe4EjgQ1HKaVUTeXLsO8fgXMDFYiqPJ1qVSlVHfiSkO4FkkXkAxHpJCIxgQpKVZ7eJKuUClW+DPveg/VlvDNwBYCIlKzjNMboKrQ20taSUipU+ZI8PkTPd0FJW0VKqerA64RkjLk6gHEopZSq4XSBPqWUUkGhUtd7XGshJeAhoRljtp1kTEoppWognxKSiFwCPAi0L6da+ElFpJRSqkbyustOREYB/8NKYm9iXUv/FJiEtTTFUuBR/4eolFKqJvDlGtLdwDqgC/B/rrL3jDGXAN0AwVo5VimllPKZLwnpNOAD1zRChQu6hwMYY1YDbwH3+zc85Q0di6+Uqg58SUjhwD7Xz9mux7pu2w3Q0R9BqcrTe5KUUqHKl4S0A2gOYIzJxpq5wX3JCUEnX7WdtpaUUqHKl1F284BhnLh+NBm4S0SysRLbX4Hv/Bue8oa2ipRS1YEvLaTXgFkiEuv6/QGsbrqHsZLURqyBD0oppZTPfJk6aDGw2O33DKCLiJwG5APrjDEFZT1fKaWUKo8v9yENEJGkkuXGmJXGmDVAPREZ4NfolFJK1Ri+dNn9AgwvZ/tQVx2llFLKZ74kpIqunYdz4v4kpaqVAqeOX1Qq0Hyd7bu8v8o+wN6TiEVVkp4qA8fpdPKfT3/nntfmkXn4mN3hKFWtlTuoQUTuBO50K3pRRJ7wUDURqAO858fYVCXoEHD/2rTrEOu2ZgLw6fQ/uXV0J5sjUqr6qmiU3QFgq+vnFlgzNewuUccJrAYWAC/4MTalbHc870QvdFZ2ro2RKFX9lZuQjDEfAB8AiMhm4B/GmMlVEZiqHO2+U0qFKl/uQ2oZyECqkohEA29gjRqMB5YBt7mGr4cc7aZTSlUHXickEakPNDTGrHMrawn8DagHfGiM+dn/IQZEBLAJ6AWkYV0n+wZoY2NMSilVo/kyl91LQFugBxQtYz4baOLaPk5EhhhjfvNviP5njDkCPFb4u4i8AjwrIvWNMfvKfqZSSqlA8SUh9QY+cvt9HFYyGom1MN804F7Ap4QkIslYLZSeWAv9xQGDjTGzPNSNxlqV9kqskX0rgAeMMTN8eU0PegN7NBkppZR9fLkPqRGw3e33s4ElxpifjDHpwASgayViEOA+oCmwsoK6E4DxwMdYSawAmCIivSvxutaLiyRgLS74z8ruQyml1MnzpYWUC8S6/T4QK0EUOgDUr0QMS4EGxph9IjIK+NpTJRHpAVwCjDfGvOgq+xBryPnTwAC3urNc8XlyjzHmWVe9GOBb4HtjjN5DpZRSNvIlIf0JXCQirwLnYQ1kcO8qawbs9zUAY8xhL6uOwUqK77g9N0dE3gWeEJFkY0yaq3xQRTsTkXDgM6xWX0gvm6FDvZVS1YEvCelVrBZRJlALa5Sae0LqD6zyW2SldQX+MMZklShfhDXyuQvWiDlvvQ3EAGONMdXmnK5DwJVSocqX+5A+FBEnMAo4CDxpjMmFoiHhCViL+AVKMrDTQ3lhEmriYZtHItIcuAbIATJFpHDT2caY2d7up379OG+rnpSkpPhyt2flnphNICIivML66oSKjlXawZyinyMjI/TY+kCPVeBU12PrSwsJY8xHFB9pV1i+DzjDX0GVIRbwNLtljtt2rxhjtuKHxsS+fVkUFAS2cZWUFE9GRvm9mpmZR4t+zsvLr7C+snhzbA8cyC76OTc3T4+tl7w5tqpyQvnYhoU5yv0i7+ts33bKBqI9lMe4ba/xqk3fo1KqxgmlhJSG1W1XUmHZriqMJajodSOlVHUQSglpOdDONUOEu56uxxVVG45SSil/CqWE9AUQCVxfWOCaueEaYK4xpsa2kJRSqjrwaVBDoIjIg64f27serxSRfsABY8wrAMaYhSIyCXjGNd3QRuAvQHPg6ioOWSmllJ+VmZBEZBNwV+H6RyLyf8BXxpjVAYjjsRK/X+t63Aq84lZ+lavuVVhz2a0ERhpj5gYgJqWUUlWovBbSKVhrBRV6GNiANVWPXxljvLoub4zJAe5x/VMuOrIugJx6dJWqKuVdQ9oJdCpRpn+dQU5H3CmlQlV5LaRvgXtF5CxOzFH3oIjcUM5znMaYoX6LTimlVI1RXkK6D2veumFYAwecQBLWPHZK1QwObXMqVVXKTEjGmGzgIdc/RKQAa5DD/6ooNlUJ2qeqlApVvtyHdA0wL1CBqMrT7/BKqerAl9m+Pyj82TW7d0vXr5t16W+llFIny6cbY0WkM/Ay0K9E+WzgDmNMRUuQK6WUUh55nZBEpCMwB2t27W+BNa5NHbBWkJ0tIn2MMWvK2IVSKsD+3H6Aj6f+SZMGtejVoTEdW9YjIjyUZghTNZkvLaRHsZYQ71uyJeRKVr+56lzkv/CUUr6YvWIXOzKy2JGRxaJ1e4iLjaRH+4b06tCY1k3q4NBRgyqI+ZKQBgCveuqWM8asFpHXgJv9Fpnymo6sC6AQm6khr8SCkVnZucxctpOZy3aSlBBDr1Mb06tDI5Lr17YpQqXK5ktCqg2kl7M9zVVH2Ui//yqA+nWiuXBAa+avTWfN5v04nZBxIIfv5m3hu3lbaNE4nt4dGtPj1EbUrR1ld7hKAb4lpE3AucCrZWw/11VHKWWziPAwendsTO+OjTmYdYxF6/awYG06m9Ospa+3pB9mS/phPp+5gVNbJNK7Q2O6tm1ATFRQLACgaihfPn0fAv8Wkf8BTwB/uMrbA/cDZwL/8G94StmsGlxzqRsXzfDuzRjevRlp+46wYM1uFqxNJ+NADgVOJ6s372f15v1ERYZxepskenVoTIeWiYSH6WAIVbV8SUjPAqcDlwDjgAJXeRhWT9FE4Dm/RqeU8qvk+rUZPaAVo/q3ZOOuQyxYk86idXvIys7leG4BC9buZsHa3cTXiqRH+0b06tCIVsk6GEJVDV9ujM0HxonIO8AoTtwYuwn4xhgz3f/hKV+F1iV4ZReHw0FqSl1SU+pyydA2rN68nwVr0vl9/V5y8wo4fDSXGUt3MGPpDhomxtLr1Eb07tiYRok6laUKHJ87jI0x04BpAYhFVZJ+d1UnIyI8jC6pDeiS2oDsY3ks+zODBWvSWbs1E6cT9mRmM3nuFr6bu4Wxg1M5q+cpdoesqim9gqmUKhIbHUHfTsn07ZTMgaxjLFq7m/lrdrN192GcwMRfNhATHc6gLil2h6qqIU1ISimPEuKiObPHKZzZ4xQ2px3i+c+XcyQnj49+MtSKjqBH+0Z2h6iqGR1Go1Q14gzQjbwtk+sw/uIuREeG4wTe/m4tqzbpnMrKvzQhVQM6kCGAQmymhkBq1aQOt1/UiYhwB/kFTl79ahXrdxywOyxVjWhCqmZ0gIMCAnb/1Kkt6nHzBR1xOOB4XgEvTlrJtt2HA/JaqubxKiGJSKyIXCUiPQMdkFIquJ3eNolrR7YHIPtYHs9/vpz0/UdtjkpVB962kI4BbwNdAxiLUipE9O2UzKVD2wBw6Gguz332O/sP5dgclQp1XiUkY0wBsB2oE9hwlAoyOkNBmYZ3b8b5fVsAsO/QMZ77fDmHjh63NygV0ny5hvQBcKWIRAcqGHXy9BK8qkoX9GvJ0DOaApC27ygvTFxB9rE8m6NSocqX+5DmARcCy11rH60HSnUcG2N+81Nsykv6HV7ZxeFwcOmwNhzNyWP+mnS2ph/m5S9W8sRf+9kdmgpBviQk9+mCXqL0l3GHqyz8ZINSSoWOMIeDa0a2I/tYHss37MVsP8DTHy7mhnPa6/Lpyie+JKRrAhaFUiqkRYSHccuoDrwwcQV/bDvA4rW7CXfA9eeeSpheh1Ne8mW27w8CGYhSKrRFRoRz+0Wn8Z9Pf2dL+mEWrNlNregILh/eVpevUF7R9nQ1oAMZAkhnavBJbHQE4y/uTLNGcQDMXLaTb2ZvtjkqFSp8Skgi0kxE3hORHSJyXESGuMqTXOXdAxOm8pZ+D1Vg7+cgvlYUj97Yh/p1YgD4bt4Wpi7aZmNEKlR4nZBEpCWwBLgIWIPb4AVjTAbQDbje3wEqpUJPg4RY7r60C3VqRwHw2cwNzF6xy+aoVLDzpYX0BNay5R2Byyn9JexHQMd6KqUAaJRYi7+P60KtaOtS9YSf/mCp2WNzVCqY+ZKQhgGvGWO24/myxVagqV+iUipY6MX4k9KsYRx3je1MVGQYTie8OXkNa7bstzssFaR8SUh1gLRytkehC/7ZTi/Bq2CT2rQut43uRHiYg7x8J698uYqNOw/aHZYKQr4kpO1Ah3K29wI2nFw4qjL0O7wKdh1b1efG8zvgcMCx3HxenLSCHXuy7A5LBRlfEtJXwLUi0tGtzAkgIhcBY4GJfoxNKVWNdG/XkL+c1Q6AIzl5PPf5cvZk6rIV6gRfBzXsABYCH2Mlo3+IyHysRLQCeM7vESqlqo0BnZswdnBrAA4eOc6zny0n8/Axm6NSwcLrhGSMOQT0Bt7BGuLtAIYDArwGDDbG6IIoStkoFO7jPbtnc87p3RyAvQdzePqTZXwzexOrN+/jaI7OFF6T+TQIwZWU7gTuFJEkrKSUYYwJgT+DE0TkdWAUUBtrdOD9xpjvbQ3qJITUwQ81oXCGD0EXDmjFkZw8Zv2+kz0Hspk8dwtgnVBSkmqTmlKX1il1SW1al4YJsTr1UA1R6VFxrpthQ9VLwHhjTI6IdAOmi0hLY0ym3YGdLP2zVRD8o9UdDgdXDG9LQu0oFq7bTdo+61qSE9iRcYQdGUeYtdy6kTa+ViSpKXWLklSLxvFEReqiAtWRzwlJRC4GRgOtXEWbgK+NMSEzoMEY80eJomggGQj5hKRUqAgLc3B+v5ac368lWdm5bNx5kA07D7Jx50E2pR3ieG4BAIeP5vL7+r38vn4vAOFhDpo3ji+WpBLjdd3Q6sDrhCQitYFvgCFYX8QPuDZ1By4WkZuA840xR3zYZzJWF2BPrOtScVjXomZ5qBsNPApcCSRiDaJ4wBgzw9vXK7G/17CW1IgBvgfWVWY/SqmTFxcbSefUBnRObQBAXn4BOzKy2LDjRJLad8ga/JBf4GTTrkNs2nWIqYu3A9CgbsyJbr6UujRtWJvwMJ07OtT40kJ6AhgKvAw8ZYxJBxCRxsA/gDtcde7yYZ8C3Id1/9JKoE85dSdgzaP3oqv+1cAUERlojJnvw2sCYIy5VURuBwYDHULtOphS1VlEeBgtGtehReM6DOvWDID9h3LYuOtQUZLatvsw+QXWn+3egznsPZjDgrW7AYiODKdrmwZcOLAVDerG2vY+lG98SUjjgEnGmLvcC12J6S4RSXHVuav0U8u0FGhgjNknIqOArz1VEpEewCVY131edJV9CKwGngYGuNWdBQws4/XuMcY86xZ7Ptb1oztF5A9jzM8+xK5qgmC/GFOD1KsTQ706MXRv1xCA47n5bEk/zIadB4uSVFZ2LmDdfLtg7W6W/pnB2T1P4exezYnW605Bz5eEVAf4pZztM4GRvry4Meawl1XHALlYQ84Ln5sjIu8CT4hIsjEmzVU+yJcYXCKA1pV4XtDRZp6qKaIiw2nbLIG2zRIAcDqd7MnMZsPOgyzfsJelJoPcvAImz93CnFVpXDw4le7tGuqIvSDmS0JaCbQpZ3sbYNXJhVOmrsAfxpiSc40swrqe1YXy59krIiJxWEO+vwFygAuwuu3u9U+oVU//vJSyRu41qleLRvVq0bdTMn9uP8Cn09ezdfdh9h86xhvfrmHmsp1cNqwNpzSKtztc5YEvCelB4GsRmWWM+c59g4hcgLUW0ig/xuYuGdjpobwwCTXxYV9O4FrgFaxz+QbgUmOMz8m0fv04X59SKUlJ5f/xHMk70S6KCA+rsL46oaJjlXbwxL3ekZERQX9so11LPYQHwecgGF6/V5emTF+0jY+mrOVg1nH+3H6ARycs5sxeLbjirHbUjQvN0Xl2H9tAKTMhich7Hoo3A9+IiOHEqLT2WIMTVmGtkzTT30ECsYCn+UVy3LZ7xTUKcIg/gtq3L4uCgsB2kiUlxZORUX7PZub+EwMb8/ILKqyvLN4c2wMHsot+zs3NC/pjm3PMmukg3+bPgTfHtqqc3roe7a7vyeS5W5ixdAf5BU5+mr+F35bt4IJ+LRl8egoR4aEzIi+Yjq2vwsIc5X6RL6+FdHU529q5/rk7DegEXOdtcD7IxrpXqKQYt+01ll43CiCdqaFaqBUTySVD2zCgcxM+m7Ge1Zv3c/RYHp/OWM+vK3Zx6dA2dGhZz+4wa7wyE5IxJpi+MqRhdduVVFimayO76PUkpcrWpEFtxl/cmRUb9vHZjPXsOZDNrr1HeO7z5XRt04BxQ1JpmFjL7jBrrGBKOuVZDrRzDUhw19P1uKJqw1FKhSqHw0GXNg147PqejB3Umugoazj47+v38uA7C/ny143kHNdJXu0QKgnpCyASa+AEUDRzwzXAXGOMtpCUUj6JjAjj7F7N+feNvejbsTEAeflOfpi/lX++tYD5q9NxapdtlfJpLjsR6QP8FWuId31K9xA5jTE+3c8jIg+6fmzverxSRPoBB4wxrwAYYxaKyCTgGdd0QxuBvwDNKf9al1JKlSshLprrzj2VQaen8L9p69mcdogDWcd5+/u1zPx9B5cNa0vL5Dp2h1kj+DKX3Q3AG8BxwADb/BTDYyV+v9b1uBVraHahq1x1r8Kay24lMNIYM9dPcSilarDWTerywFVnMH91Ol/M2sjBI8fZuPMQj32whH6dkrloYKuQHSYeKnxpIf0T61rOCGPMXn8FYIzx6jq8a/G/e1z/VBm0g8HP9K7+GiXM4aBvp2ROb5vE9/O2MHXxdvILnMxZlcYSs4fz+7ZkWLemITVMPJT4clQbAe/6Mxkp/9BTplL+FRsdwdjBqTx+fU+6uGYgzzmez8RfNvDPtxYwZ2Ua+QUFNkdZ/fiSkNZhdZUppVSN0KheLe4Ycxp/u7gzyfWt4eB7D+bw3o/r+Nc7i1i0bjcFOvDBb3xJSE8At4qIL9P0qCqgfw6qiJ4cA6Jjq/o8cm0PrhwhJMRFAZC+/yhvfLuGR95fzPL1e3VEnh94fQ3JGPOViNQC1orIt8AWIL9ENacxpuQgBVWFtPvOz/Qko1wiwsMY3DWFvh0bM+v3nfywYCuHj+ayfU8WL3+5klZN6jB6QCtObZ6oM4pXki+j7NpirdhaB2vVVk+clB41p5SqYnpCDJyoyHDO7HEKA7o0YdqSHfy0cBvZx/LYtOsQz322HGmWwIUDW9GmaYLdoYYcX0bZvQY0xFpyfDaQGZCIlFIqBMRERXBenxYMOT2FnxdtY9riHRzLzcdsP8C/P15Gp1b1GT2gJS0a6z1M3vIlIfUG/mOM+W+gglFKqVBTOyaSCwe0Zli3Zvw4fyszl+0kL7+AVZv2sWrTPs5om8So/i1JSaqa5WpCmS8J6SCQEahAlFIqlNWpFcUlQ9swoscpfD9vC7+t2EV+gZOlf2aw7M8MenZoxAX9WtJIJ28tky+j7CYCFwYqEKWUqg4S46O5coTw5I296NupMQ6HdXF9wZrdPPDWQiZM+YP9h3Iq3E9N5EsL6U3gAxH5BngZa7G+kqPsMMb4a0ohVQk6JszPdHCAqqSkhFiuO+dURvZqzjezN7P4jz0UOJ38tmIX81anMahLCuf0aUHd2lF2hxo0fElIa7DOd92A88qpF35SESmf6SlTqeCVXL82t4zqyDm7D/PN7M0s37CXvHwn05fu4LeVuxh6RlPO7tmcuNhIu0O1nS8J6VH0C7hSSlXKKY3iuWPMaWzcdZCvf9vE2i2ZHM8tYMqCbcz6fRd/H9eFVk1q9og8X26MfTiAcaiToN8SAijEbowNrWhrptZN6nL3JV35Y2smX/22iQ07D5J9LI+JM9fzjyvOsDs8W+mUtdWMdt8pFRraNU/k/itOZ9gZTQH4c8dBtqYftjkqe/kyU8MAb+oZY36rfDhKKX/QLyahweFwcGaPZsxYtgOnE6Yv2c51555qd1i28eUa0iy86xHQQQ1KKeWlBnVjOaNtEktMBgvX7WbM4NQaO/LOl4R0TRnPb421jPgWrKHhSimlfDCsWzOWmAzy8p38+vtOzu/X0u6QbOHLoIYPytomIv8BlvklIqWUqmHaNK1L80bxbN19mF9+38nI3s1r5Kq0fnnHxphM4B3gXn/sTymlahKHw8GwbtbghoNHjrN43R6bI7KHP1NwJtDKj/tTSqkao0f7RtRxXTuatmR7jVzwzy8JSURisNZISvfH/lTl1byPcIDp1EGqikRGhDGoi7Ug95b0w2zcecjmiKqeL8O+3ytjUz2spSmSgHv8EZTyjZ4ylaoeBndN4Yf5W8kvcDJtyXZSm9a1O6Qq5csou6vLKN8P/AmMN8b876QjUj7TVlEAhVq3SYiFq4qrGxdNj/aNmL8mnaUmg/2HcqhXJ8busKqML6Psat6QjxCkrSUF6AchhA3v3pT5a9IpcDqZuWwnYwa1tjukKqNJRimlgkiLxnWKuup+Xb6TY7mlVvmptjQhKaVUkBnerRkAR3LyWLCm5owVK7fLTkQm+7g/pzHmgpOIRymlarzT2zagXp1o9h86xvQlOxjQuQmOGjDis6JrSOf6uD+9pKqUUicpPCyMIac35YtZG9m59whrt2bSoUU9u8MKuHITkjcDGURkIPAM0B1I81NcSilVow3o3ITJczZzPK+A6Yu314iEVOlrSCLSUUR+AGYCAvwLaOOvwJRSqiaLi42kd8fGAKzcuI/dmUdtjijwfE5IItJMRCYAvwNDgZeB1saYJ4wx2X6OT/lI+0z9rAb026vgVbh4nxOYsWSHvcFUAV9makgEHgBuBaKBT4EHjTFbAhOa8paeMpWqnlKS4ji1RSJrt2QyZ1UaowdU7+lCK0xIIhIN3AXcByQA04D7jDHLAxmY8p62igIoxGZqCK1olTeGdWvG2i2Z5BzPZ87KNC5rmmh3SAFTbpediFwHbACeBDYCw40xIzQZBS9tLSnQz0F1clrr+jRMjAVgxtId5BdU368dFbWQ3sb60rUEmAh0FpHO5dR3GmNe8FdwSilV04U5HAw9oymfTl/PngPZLF23m5YNa9sdVkB4cw3JgTWku7sXdZ2AJiSllPKjfp2S+fq3TeQcz2fy7I3cedFpdocUEBUlpMFVEoVSSqkyxUZH0O+0ZKYv2cGK9XvZkZFF06Q4u8Pyu4pujP21qgJRSilVtmFnNGXGkh04gelLdnD12e3sDsnvdHJVpZQKAQ0Ta9E5tQEA89ekk5Wda3NE/lejE5KI9BaRAhH5h92xKKVURYZ3s26Uzc0r4NflO22Oxv9qbEISkTCsARiL7Y7Fn6rvgFClVLvmiTRvHA/AzGU7ycsvsDki/6qxCQm4EVgIrLM7kJOl95wEkE4dpIKIw+HgvP7WCrKZh4+x7M8MmyPyL6+nDgoEEUkG7gR6At2AOGCwMWaWh7rRwKPAlUAisAJ4wBgzoxKvWx9r9olewIuViz54aKsogEJtpoYQi1f5btAZTZnw/RqysnOZvmQHPdo3sjskv7G7hSRYUxI1BVZWUHcCMB74GCuJFQBTRKR3JV73CeBFY8yBSjw3qOn3eWXRT0J1FR0ZzsAuTQDYsPMgm9MO2RyR/9jaQgKWAg2MMftEZBTwtadKItIDuAQYb4x50VX2IbAaeBoY4FZ3FjCwjNe7B5iBdZPvX/3yDpRSqooN7prClAXbKHA6mb5kOzec18HukPzC1oRkjDnsZdUxQC7wjttzc0TkXeAJEUk2xqS5ygeVtyMRuQurZbZTRADqAnki0sIYc7PPb0IppapYvToxdGuXxKJ1e1i0bg9jB6eSEBdtd1gnze4uO291Bf4wxmSVKF+E1TfRxYd9vQWkup7TBZgMvITVdaiUUiFhWLdmAOQXOJn1e/UYAm53l523kgFPR7xwyfQm3u7IGHMUKFp6UUSygSxjzEFfg6pfv2qm7khKii93e1buiaGfERHhFdZXJ1R0rHYdyCn6OSoqIuiPbXS09ScdERFme6x2v351lpQUT4MGcbSZtZH12w/w24o0rj6/I5ER4XaHdlJCJSHFAsc8lOe4ba8UY8zVlX3uvn1ZFAR4KvikpHgyMsrv2cx0W9o4Ly+/wvrK4s2xPXjgxLE9fjwv6I/tsWN5AOTlFdgaqzfHVlWO+7Ed1KUJ67cf4EDWMX74bSN9OyXbHF35wsIc5X6RD5Uuu2ysVWpLinHbrpRSNUr3dg2pGxcFwLQl20N+2H+oJKQ0rG67kgrLdlVhLEopFRQiwsMY3DUFgG27s1i/w+crD0ElVBLScqCdiJRs6/V0Pa6o2nCCV2h/PwpCOlODCnKDuqQQEW59Tqct2W5zNCcnVBLSF0AkcH1hgWvmhmuAucYYbSGpwAjxLhBV/dWpHUXPU63ZGpb9mcHeg6F7BcP2QQ0i8qDrx/auxytFpB9wwBjzCoAxZqGITAKecU03tBH4C9AcuLqKQw5q+n1egTbsaprh3Zoxd1U6Tqc16erFg1PtDqlSbE9IwGMlfr/W9bgVeMWt/CpX3auw5rJbCYw0xswNeIRKKRXETmkUT9tmCfy5/QC/Ld/FBX1bEh0VekPAbU9IxhivvssZY3Kwpv65J7ARKaVU6BnerSl/bj/A0WN5zFuTXjTYIZSEyjUkpZRS5ejaJon6daw7YaaH6BBwTUhKKVUNhIU5GHqGtaJs2r6jrNmy3+aIfKcJSSmlqon+nZOJirRO69OX7LA5Gt9pQlJKqWqidkwkfTta8wWs3LiPtH1HbI7IN5qQlFKqGhnWrWnRzzOWhlYrSRNSNRN6lzGVUv6UXL82HVvWA2DuqnSO5uTZHJH3NCEpVY2E4MAqFQCDT7eGfB/LzWfjrtCZ304TUjWjN+gr0M9BTee+emx+gJfI8SdNSEoppYKCJiSllFJBQROSUkqpoKAJSSmlVFDQhKSUUiooaEJSSikVFDQhKaWUCgq2r4cUosLBml23KlT0OlGR4TRMjAWgXt2YKourOqjoWEVHnTi2ifHRQX9sE+KjaZgYS7069n8O7H796syXc0JMVETQ/F+4xeFx9UBHKK6ZEQT6AbPtDkIppUJUf2BOyUJNSJUTDXQH0oB8m2NRSqlQEQ4kA4uBYyU3akJSSikVFHRQg1JKqaCgCUkppVRQ0ISklFIqKGhCUkopFRQ0ISmllAoKmpCUUkoFBU1ISimlgoImJKWUUkFB57ILQiISDTwKXAkkAiuAB4wxM2wNLMSJSHfgamAw0BzYB8wDHjTGbLAxtGpJRO4FngZWGGO62BxOyHN9fh8G+gCRwEbgBWPMBBvD8ittIQWnCcB44GPgTqAAmCIive0Mqhq4D7gQmI51XN8CBgG/i0h7G+OqdkSkMfAgcMTuWKoDETkbmIuViP4F/B3rc9zMzrj8TVtIQUZEegCXAOONMS+6yj4EVmN92xxgX3Qh73ngMmPM8cICEfkcWIWVrK62Ka7q6ClgCdaX3gR7QwltIlIX60vq68aYO20OJ6C0hRR8xgC5wDuFBcaYHOBdoJ+IJNsVWKgzxsxzT0ausvXAGkBbSH7i+lJ1BfA3u2OpJi7DSur/ByAi8SISHOtJ+JkmpODTFfjDGJNVonwR4AC6VHlE1ZjrD7sRsNfuWKoD1/H8L/CBMWa5zeFUF8OAP4CRIrIdOATsF5GnRMTjukKhSrvsgk8ysNNDeZrrsUkVxlITXA6kAA/YHUg1cRVwKjDK5jiqk1Ssa0UTgGeA34FzsbqZY4C77ArM3zQhBZ9YPKwTAuS4bVd+ICLtgFexFgr7yOZwQp6IxGNdO3rKGJNWUX3ltTis0bb/MMY87Sr7SkTigFtF5HFjTLVo4WuXXfDJxloAsKQYt+3qJLlGgf0AZAJjjTEFNodUHTwIHMcaPKL8p/Bv/tMS5Z9gjbrrUbXhBI62kIJPGla3XUmFZbuqMJZqyTVqaQpQF+hrjEm3OaSQ5xpscxfWkORGIlK4KQaIEpEWwEFjTKYtAYa2NKADsLtEeeHviVUbTuBoCyn4LAfauZrj7nq6HldUbTjVi4jEAN8BbYFzjTHG5pCqi0ZAFNatCZvd/vXEGsG4Geuah/LdUtdjSonypq7HjCqMJaA0IQWfL7Ca4dcXFrhmbrgGmGuM0RZSJblGJH0O9Mbqpltgc0jVyWZgtId/a4Atrp8/tCu4EDfJ9XhdYYFrNOP1WDceV5vPscPpdNodgypBRCZijVJ6AWt6kL8A3YHBxpi5NoYW0kTkRawZGr4DJpbYnGWM+aaqY6ruRGQWkKBTB50cEfkAayqxd4FlwDmuf/caY/5jZ2z+pNeQgtNVwGOux0RgJTBSk9FJ6+J6PM/1z91W4JuqDEYpH9wAbMP6cvoXYBNwszHmTVuj8jNtISmllAoKeg1JKaVUUNCEpJRSKihoQlJKKRUUNCEppZQKCpqQlFJKBQVNSEoppYKCJiSllFJBQROSUkqpoKAJSSmlVFDQhKRCiogMEhGniFxtdywnS0Q6ikieiAy3O5aaQEQuEJHjItLG7liUZ5qQlLLP81gzuE9zLxSReq6kO8WmuAJGRF4RkZ2u2arLqlP4peNuf762MeZbYBXWEhkqCGlCUsoGItIbGI7n1VVPdz0uq7qIAs+VhEYB3xpj7JpE8yVgtIh0sOn1VTk0ISllj1uBvcCPHrZVy4SEtYRKCvbOqv4VcBS42cYYVBl0+QlVLYhIA+AR4Hys1Ut3A5OB/zPG7CtRtwXwHFYLBeAXrOW3fwG2GGMGBTjWCKyWwvfGmFwPVaprQhoNHMA6zrYwxmSJyGxgDHC7XXEoz7SFpEKeiNQF5gG3AD9jJZefXL/PEZF4t7r1gdlY6yFNwFpW+wjWSbJ2FYV8BhAHLCpj++lApjFmcxXFU1VGAz+WkYSr0nygsYi0szkOVYK2kFR1cC/QBvirMea1wkIRWQ684tr+L1fxfUBT4ApjzCeustdF5BngniqK91TX48aSG1zJMxUbWxGBICLtAQEetDsWThz3DsAfdgaiitOEpKqD0UAG8FaJ8jeBh1zbCxPSeUAa8GmJus9SdQkpyfW438O2roCD6tddNwrIwWq5+pWINMZaXbkdsAeYZIxZWs5TCrtwG/o7FnVyNCGp6qAlsMQYk+deaIzJE5E/OXFNprDuImNMQYm6e0TkgHuZiFwM3IG19PleY0yLEtsjsK5FXYnV/f0lVistp4J4C0eYeRr6fIbrscyEJCL9AU9DwqOAcGNMeIn6r2F1X/YxxswvsW0WMBAYaYyZ4lZ+MfA58IMx5lxXWVvgGaAvEIPrOp0x5m9lxepmNDDdGJPlRV2vichFwBDgXeC/WEnmMhEZA/yzjNF8hcddl8sOMpqQlCpbJlaXXyNgvIft/wQGA52A41iDKJ7BSmLlyXA91vOwrcIBDcaY2VjXoIqISBNgiSte9/JY4DKs1tj1WNdPSvoDuI7iSe56Sndn/YA1Su0KrJFqrbGSU7lEpCnQDbihorq+EJGOQAtjzF/dircC/xaRXlgj6V738NTC457hYZuykQ5qUNXBJkBcLZYirt/burYX2gKkikhYiboNgQT3MmPMNGPMZ1gnOU+uB540xuw0xmQADwNXi0h4GfULrXY9epox4HQgC/izgn0UEZForEQxxxjzZInNY4ECrIEeF4tIHKVNBIaISJJrf82xWoXfuL1GA6xrW28YY7KMMQXGmPXGmAlehDgKqzUy2dv35KUL8XwfF8aYBUCDkp8Jl1TX42oP25SNNCGp6uAbrOsy15cov8FV/rVb2XdAMnBpibo+zQogIglAM2C5W/EyIB5oUcHTfwcOAb1K7LMW1oX/5T7eOPoGVhfa1R62XQ98hpV0coFLPNQ5jHWMrnL9fh3wP+BYYQVjzF5gHfCeiFwiIq19iG80VrL0d4vkaOFxEpHeIrJXRNwHTSzF+kJSUi9gtzHG+DkedZK0y05VB89gtQReFZHTsU74XbFOrMa1vdDTWF1Y74tID6xuqf5AH6wbVb1NBIVDyQ+4lR0osc0jY0y+iHwFjBKRaGNM4Ym/MxAOxIjIPzw8NcsYU7JL7g7gXKC7MeZoiW1tsd7bPcaYYyLyGdYxecfDvt8F3hGRF7ES2znARSXqDMJK3P8EThWRbcA/jDETy3qvIlIPGIA10tFXQ0UkxkP5XmPMGyXKOgP1Kd6FeIgS/xeuFmJ/4L1KxKMCTFtIKuQZYw5inYjeBEYCL7se3wD6GWMOu9XdC/QDvgeuxUpQtbGuBTmAbC9ftnCfdd3KEkpsK8/rrvrnupUVXj/qBvzbw7+x7jsQkcGu+McaY7Z4eI3rgT+MMQtdv08AenmaNscYMw/r/T8MpBtjVnmos8cYc68x5jSs6zCvAf+r4H6ec7G++H5dTp2ynAU85uHfXa7tsW5138Fqif3FrawzsL7EPi8CamF9VlSQ0RaSCinGmFl4GJ3m6g661fWvon1sxrr+UMR1w2x9YJuXcRwQke1Y11oKu366YiWjLV48f5GIFN7E+6Wr7FXgVW9e3zXbxESs1s8sD9sjsbrg6opIeonN1wGeRsa9i9WavMWL+A8Bz4rI/ZR/P89oYEUZCbOsfc/C8wjEkraISB9jzDzXCMtvCje4bpZuYYwpObT+TuBrY4xePwpCmpBUjSMiscaYki2hwi6yaW71woFI1z+Hq/vI6dbF9g5wv2sqmlys1sUEY0y+l6H8HVghImcaY6b6EH8trJPv5JJdeG7OAxKxkqT7SfkK4D4R+Ycx5niJ57yFdU1snofXTMS6T+sTrAEXYVhde7WwrtWUZT7wdrlvqPI+Bl4SkdruM6aLSEusllSxpCsio4COwLgAxaNOkiYkVRP9KCJbsQYhhAFDsbqW5lF84s8rgffdfs/GGnHXwvX7k0ADYI1rP19gzQThFWPMGir3N3gRVndUWxHxdHI9Fau77lNjzFr3DSLyBvAA1si3Ytd+XK2e6WW85nGgMdZIuUZYAx7WAOeX1/oxxjxT1raTZYxxishdwG0icj3WaMIwrBuf7yw5h6Ex5huse7VUkHI4nXpvmKpZROTvWN1ZLbCuQ+zAGjb9iPv1JqVU1dKEpJRSKijoKDullFJBQROSUkqpoKAJSSmlVFDQhKSUUiooaEJSSikVFDQhKaWUCgqakJRSSgUFTUhKKaWCwv8DfwO2Q+o/xrYAAAAASUVORK5CYII=\n", + "text/plain": [ + "<Figure size 432x288 with 1 Axes>" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "# plot luminosity distribution\n", "ldist = population.grid_results['luminosity distribution']\n", @@ -491,10 +582,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "id": "5956f746-e3b9-4912-b75f-8eb0af66d3f6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ValueError", + "evalue": "Failed to rename grid variable M_1 to lnM_1.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Input \u001b[0;32mIn [27]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Rename the old variable (M_1) because we want it to be called lnM_1 now\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mpopulation\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrename_grid_variable\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mM_1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mlnM_1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/.pyenv/versions/3.9.9/envs/dev_binarycpython3.9.9/lib/python3.9/site-packages/binarycpython/utils/population_extensions/gridcode.py:965\u001b[0m, in \u001b[0;36mgridcode.rename_grid_variable\u001b[0;34m(self, oldname, newname)\u001b[0m\n\u001b[1;32m 963\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 964\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFailed to rename grid variable \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m to \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(oldname, newname)\n\u001b[0;32m--> 965\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(msg)\n", + "\u001b[0;31mValueError\u001b[0m: Failed to rename grid variable M_1 to lnM_1." + ] + } + ], "source": [ "# Rename the old variable (M_1) because we want it to be called lnM_1 now\n", "population.rename_grid_variable(\"M_1\",\"lnM_1\")" @@ -520,8 +624,8 @@ "# because M * dprob/dM = dprob/dlnM\n", "population.update_grid_variable(\n", " name=\"lnM_1\",\n", - " samplerfunc=\"const(math.log({min}), math.log({max}), {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " samplerfunc=\"self.const_linear(math.log({min}), math.log({max}), {res})\".format(min = massrange[0], max = massrange[1], res = resolution[\"M_1\"]),\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnM_1\",\n", " parameter_name=\"M_1\",\n", " precode=\"M_1=math.exp(lnM_1)\",\n", @@ -615,7 +719,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -629,7 +733,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/examples/notebook_population.ipynb b/examples/notebook_population.ipynb index 760b1480e9f9bdcc508ced177f8f0d806cfb53eb..ebc19cff04f8dd9e8e2fe6694fa9b0346425afe9 100644 --- a/examples/notebook_population.ipynb +++ b/examples/notebook_population.ipynb @@ -25,7 +25,7 @@ "import os\n", "\n", "from binarycpython.utils.custom_logging_functions import temp_dir\n", - "from binarycpython.utils.grid import Population\n", + "from binarycpython import Population\n", "\n", "TMP_DIR = temp_dir(\"notebooks\", \"notebook_population\")\n", "\n", @@ -58,13 +58,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: M_1=10 to BSE_options\n", - "adding: orbital_period=45000000080 to BSE_options\n", - "adding: max_evolution_time=15000 to BSE_options\n", - "adding: eccentricity=0.02 to BSE_options\n", "adding: num_cores=2 to grid_options\n", - "adding: tmp_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "adding: tmp_dir=/tmp/binary_c_python-david/notebooks/notebook_population to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", @@ -139,13 +135,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "Writing settings to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json\n" + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n" ] }, { "data": { "text/plain": [ - "'/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/example_pop_settings.json'" + "'/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz'" ] }, "execution_count": 3, @@ -185,9 +185,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on method add_grid_variable in module binarycpython.utils.grid:\n", + "Help on method add_grid_variable in module binarycpython.utils.population_extensions.gridcode:\n", "\n", - "add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int], gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None) -> None method of binarycpython.utils.grid.Population instance\n", + "add_grid_variable(name: str, parameter_name: str, longname: str, valuerange: Union[list, str], samplerfunc: str, probdist: str, dphasevol: Union[str, int] = -1, gridtype: str = 'centred', branchpoint: int = 0, branchcode: Optional[str] = None, precode: Optional[str] = None, postcode: Optional[str] = None, topcode: Optional[str] = None, bottomcode: Optional[str] = None, condition: Optional[str] = None, index: Optional[int] = None, dry_parallel: Optional[bool] = False) -> 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", @@ -198,17 +198,15 @@ " beware that if you insert some destructive piece of code, it will be executed anyway.\n", " Use at own risk.\n", " \n", - " Tasks:\n", - " - TODO: Fix this complex function.\n", - " \n", " Args:\n", " name:\n", " name of parameter used in the grid Python code.\n", " This is evaluated as a parameter and you can use it throughout\n", " the rest of the function\n", " \n", - " Examples:\n", - " name = 'lnm1'\n", + " Examples::\n", + " \n", + " name = 'lnM_1'\n", " \n", " parameter_name:\n", " name of the parameter in binary_c\n", @@ -223,47 +221,66 @@ " longname:\n", " Long name of parameter\n", " \n", - " Examples:\n", + " Examples::\n", + " \n", " longname = 'Primary mass'\n", + " \n", " range:\n", " Range of values to take. Does not get used really, the samplerfunc is used to\n", " get the values from\n", " \n", - " Examples:\n", + " Examples::\n", + " \n", " range = [math.log(m_min), math.log(m_max)]\n", + " \n", " samplerfunc:\n", " Function returning a list or numpy array of samples spaced appropriately.\n", " You can either use a real function, or a string representation of a function call.\n", " \n", - " Examples:\n", - " samplerfunc = \"const(math.log(m_min), math.log(m_max), {})\".format(resolution['M_1'])\n", + " Examples::\n", + " \n", + " samplerfunc = \"self.const_linear(math.log(m_min), math.log(m_max), {})\".format(resolution['M_1'])\n", " \n", " 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", + " sampling function (i.e. a value for lnM_1 is chosen already)\n", + " \n", + " Examples::\n", + " \n", + " precode = 'M_1=math.exp(lnM_1);'\n", " \n", - " Examples:\n", - " precode = 'M_1=math.exp(lnm1);'\n", " postcode:\n", " Code executed after the probability is calculated.\n", + " \n", " probdist:\n", " Function determining the probability that gets assigned to the sampled parameter\n", " \n", - " Examples:\n", - " probdist = 'Kroupa2001(M_1)*M_1'\n", + " Examples::\n", + " \n", + " probdist = 'self.Kroupa2001(M_1)*M_1'\n", + " \n", " dphasevol:\n", " part of the parameter space that the total probability is calculated with. Put to -1\n", " if you want to ignore any dphasevol calculations and set the value to 1\n", - " Examples:\n", - " dphasevol = 'dlnm1'\n", + " \n", + " Examples::\n", + " \n", + " dphasevol = 'dlnM_1'\n", + " \n", " condition:\n", " condition that has to be met in order for the grid generation to continue\n", - " Examples:\n", - " condition = 'self.grid_options['binary']==1'\n", + " \n", + " Examples::\n", + " \n", + " condition = \"self.grid_options['binary']==1\"\n", + " \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 'centred'\n", - " (steps starting at lower edge + 0.5 * stepsize).\n", + " (steps starting at ``lower edge + 0.5 * stepsize``).\n", + " \n", + " dry_parallel:\n", + " If True, try to parallelize this variable in dry runs.\n", " \n", " topcode:\n", " Code added at the very top of the block.\n", @@ -313,35 +330,7 @@ "execution_count": 6, "id": "47979841-2c26-4b26-8945-603d013dc93a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Added grid variable: {\n", - " \"name\": \"lnm1\",\n", - " \"parameter_name\": \"M_1\",\n", - " \"longname\": \"Primary mass\",\n", - " \"valuerange\": [\n", - " 2,\n", - " 150\n", - " ],\n", - " \"samplerfunc\": \"const(math.log(2), math.log(150), 20)\",\n", - " \"precode\": \"M_1=math.exp(lnm1)\",\n", - " \"postcode\": null,\n", - " \"probdist\": \"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", - " \"dphasevol\": \"dlnm1\",\n", - " \"condition\": \"\",\n", - " \"gridtype\": \"centred\",\n", - " \"branchpoint\": 0,\n", - " \"branchcode\": null,\n", - " \"topcode\": null,\n", - " \"bottomcode\": null,\n", - " \"grid_variable_number\": 0\n", - "}\n" - ] - } - ], + "outputs": [], "source": [ "# Add grid variables\n", "resolution = {\"M_1\": 20}\n", @@ -351,9 +340,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -364,8 +353,8 @@ "# name=\"q\",\n", "# longname=\"Mass ratio\",\n", "# valuerange=[\"0.1/M_1\", 1],\n", - "# samplerfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n", - "# probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", + "# samplerfunc=\"self.const_linear(0.1/M_1, 1, {})\".format(resolution['q']),\n", + "# probdist=\"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", "# dphasevol=\"dq\",\n", "# precode=\"M_2 = q * M_1\",\n", "# parameter_name=\"M_2\",\n", @@ -377,12 +366,12 @@ "# name=\"log10per\", # in days\n", "# longname=\"log10(Orbital_Period)\",\n", "# valuerange=[0.15, 5.5],\n", - "# samplerfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", + "# samplerfunc=\"self.const_linear(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", "# precode=\"\"\"orbital_period = 10** log10per\n", "# sep = calc_sep_from_period(M_1, M_2, orbital_period)\n", "# sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n", "# sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n", - "# probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", + "# probdist=\"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", "# parameter_name=\"orbital_period\",\n", "# dphasevol=\"dlog10per\",\n", "# )\n" @@ -434,7 +423,7 @@ ], "source": [ "# Create custom logging statement: in this case we will log when the star turns into a compact object, and then terminate the evolution.\n", - "custom_logging_statement = \"\"\"\n", + "custom_logging_code = \"\"\"\n", "if(stardata->star[0].stellar_type >= 13) \n", "{\n", " if (stardata->model.time < stardata->model.max_evolution_time)\n", @@ -454,7 +443,7 @@ "\"\"\"\n", "\n", "example_pop.set(\n", - " C_logging_code=custom_logging_statement\n", + " C_logging_code=custom_logging_code\n", ")" ] }, @@ -476,7 +465,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function parse_function at 0x1528ac7290d0> to grid_options\n" + "adding: parse_function=<function parse_function at 0x7f2b6ca163a0> to grid_options\n" ] } ], @@ -552,38 +541,41 @@ "output_type": "stream", "text": [ "adding: verbosity=0 to grid_options\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "**************************************\n", - "* Total starcount for this run is 20 *\n", - "* Total probability is 0.0444029 *\n", - "**************************************\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 19 *\n", + "* Total probability is 0.0443872 *\n", + "**********************************\n", "\n", - "Generating grid code\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.450828476487e+00 1.81563 134.653 5.27143e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 3.598268106227e+01 1.30592 8.75988 0.00193614 13\n", + "EXAMPLE_COMPACT_OBJECT 2.436983545111e+01 1.35842 10.9948 0.00144093 13\n", + "EXAMPLE_COMPACT_OBJECT 1.690157944401e+01 1.43124 13.7998 0.00107238 13\n", + "EXAMPLE_COMPACT_OBJECT 1.242397939068e+01 1.52416 17.3205 0.000798096 13\n", + "EXAMPLE_COMPACT_OBJECT 9.756794139032e+00 1.66914 21.7394 0.000593966 13\n", + "EXAMPLE_COMPACT_OBJECT 8.401414766976e+00 1.73729 27.2857 0.000442046 13\n", + "EXAMPLE_COMPACT_OBJECT 7.536373523810e+00 1.80677 34.247 0.000328983 13\n", + "EXAMPLE_COMPACT_OBJECT 7.393982410080e+00 1.82164 42.9844 0.000244839 13\n", + "EXAMPLE_COMPACT_OBJECT 7.396470605248e+00 1.82129 53.9508 0.000182216 13\n", + "Do join of subprocesses ...\n", + "EXAMPLE_COMPACT_OBJECT 7.399005684057e+00 1.82041 67.7151 0.00013561 13\n", + "EXAMPLE_COMPACT_OBJECT 7.443375325717e+00 1.81645 84.9909 0.000100925 13\n", + "EXAMPLE_COMPACT_OBJECT 7.451195752942e+00 1.81559 106.674 7.51114e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 7.452661646076e+00 1.81543 133.89 5.59e-05 13\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-50fb66cc659c46c8bbc29fe0c8651c2f finished! *\n", - "* The total probability is 0.0444029. *\n", - "* It took a total of 3.30s to run 20 systems on 2 cores *\n", - "* = 6.60s of CPU time. *\n", - "* Maximum memory use 433.070 MB *\n", + "* Population-ce756bb317f64099a459bf8b55a746ac finished! *\n", + "* The total probability is 0.0443872. *\n", + "* It took a total of 0.73s to run 19 systems on 2 cores *\n", + "* = 1.46s of CPU time. *\n", + "* Maximum memory use 293.406 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n" + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n" ] } ], @@ -614,7 +606,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'population_name': '50fb66cc659c46c8bbc29fe0c8651c2f', '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': 1635760967.3245144, 'end_timestamp': 1635760970.6249793, 'total_mass_run': 684.2544031669784, 'total_probability_weighted_mass_run': 0.28134439269236855, 'zero_prob_stars_skipped': 0}\n" + "{'population_id': 'ce756bb317f64099a459bf8b55a746ac', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.044387171445641534, 'total_count': 19, 'start_timestamp': 1646563001.7193637, 'end_timestamp': 1646563002.4480088, 'time_elapsed': 0.7286450862884521, 'total_mass_run': 649.905447944397, 'total_probability_weighted_mass_run': 0.28133908148630704, 'zero_prob_stars_skipped': 0}\n" ] } ], @@ -642,9 +634,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on method write_binary_c_calls_to_file in module binarycpython.utils.grid:\n", + "Help on method write_binary_c_calls_to_file in module binarycpython.utils.population_extensions.dataIO:\n", "\n", - "write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False) -> None method of binarycpython.utils.grid.Population instance\n", + "write_binary_c_calls_to_file(output_dir: Optional[str] = None, output_filename: Optional[str] = None, include_defaults: bool = False, encoding='utf-8') -> None method of binarycpython.utils.grid.Population instance\n", " Function that loops over the grid code and writes the generated parameters to a file.\n", " In the form of a command line call\n", " \n", @@ -655,10 +647,6 @@ " \n", " On default this will write to the datadir, if it exists\n", " \n", - " Tasks:\n", - " - TODO: test this function\n", - " - TODO: make sure the binary_c_python .. output file has a unique name\n", - " \n", " Args:\n", " output_dir: (optional, default = None) directory where to write the file to. If custom_options['data_dir'] is present, then that one will be used first, and then the output_dir\n", " output_filename: (optional, default = None) filename of the output. If not set it will be called \"binary_c_calls.txt\"\n", @@ -685,19 +673,19 @@ "output_type": "stream", "text": [ "Generating grid code\n", - "Generating grid code\n", - "Saving grid code to grid_options\n", - "Writing grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py [dry_run = False]\n", - "Symlinked grid code to /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid-latest2 \n", - "Loading grid code function from /tmp/binary_c_python-izzard/notebooks/notebook_population/binary_c_grid_50fb66cc659c46c8bbc29fe0c8651c2f.py\n", + "Save grid code to grid_options\n", + "Write grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py [dry_run = False]\n", + "Symlinked grid code to /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid-latest2 \n", + "Load grid code function from /tmp/binary_c_python-david/notebooks/notebook_population/binary_c_grid_ce756bb317f64099a459bf8b55a746ac.py\n", "Grid code loaded\n", - "Writing binary_c calls to /tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "/tmp/binary_c_python-izzard/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.2158744056768156 probability 0.00823663875514986\n", - "binary_c M_1 3.430936289925951 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681537 probability 0.0062211552141636295\n", - "binary_c M_1 4.2576084265970895 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.2158744056768156 probability 0.004698855121516281\n" + "Writing binary_c calls to /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "/tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "binary_c M_1 2.2406484012210224 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.011394572976608001\n", + "binary_c M_1 2.812296769855663 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191117 probability 0.008480166685456411\n", + "binary_c M_1 3.5297876799548944 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.006311182276049824\n", + "binary_c M_1 4.430329401616038 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.004696962123378559\n", + "(abridged)\n" ] } ], @@ -707,7 +695,8 @@ "print(calls_filename)\n", "\n", "with open(calls_filename, 'r') as f:\n", - " print('\\n'.join(f.read().splitlines()[:4]))" + " print('\\n'.join(f.read().splitlines()[:4]))\n", + "print(\"(abridged)\")" ] }, { @@ -715,7 +704,15 @@ "id": "60359eb1-4d0c-4d2d-8265-ec5171b944a2", "metadata": {}, "source": [ - "## Full examples of population scripts\n", + "## Full examples of population scripts" + ] + }, + { + "cell_type": "markdown", + "id": "1ee279d6-e120-4aef-9e57-845e534f5c6a", + "metadata": {}, + "source": [ + "### Single star population\n", "Below is a full setup for a population of single stars" ] }, @@ -729,43 +726,51 @@ "name": "stdout", "output_type": "stream", "text": [ - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 20 stars with a total probability of 0.0444029\n", - "**************************************\n", - "* Total starcount for this run is 20 *\n", - "* Total probability is 0.0444029 *\n", - "**************************************\n", + "Grid has handled 19 stars with a total probability of 0.0443872\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 19 *\n", + "* Total probability is 0.0443872 *\n", + "**********************************\n", "\n", - "Generating grid code\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-05e51ba114934b37bab48f1db40b7333 finished! *\n", - "* The total probability is 0.0444029. *\n", - "* It took a total of 3.46s to run 20 systems on 2 cores *\n", - "* = 6.93s of CPU time. *\n", - "* Maximum memory use 437.047 MB *\n", + "* Population-0fa4c2b8707741a5ab41d209ef95a3a4 finished! *\n", + "* The total probability is 0.0443872. *\n", + "* It took a total of 0.61s to run 19 systems on 2 cores *\n", + "* = 1.23s of CPU time. *\n", + "* Maximum memory use 299.531 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\n", "\n", "\n", "time mass zams_mass probability radius stellar_type\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.450828476487e+00 1.81563 134.653 5.27143e-05 1.72498e-05 13\n", + "3.598268106227e+01 1.30592 8.75988 0.00193614 1.72498e-05 13\n", + "2.436983545111e+01 1.35842 10.9948 0.00144093 1.72498e-05 13\n", + "1.690157944401e+01 1.43124 13.7998 0.00107238 1.72498e-05 13\n", + "1.242397939068e+01 1.52416 17.3205 0.000798096 1.72498e-05 13\n", + "9.756794139032e+00 1.66914 21.7394 0.000593966 1.72498e-05 13\n", + "8.401414766976e+00 1.73729 27.2857 0.000442046 1.72498e-05 13\n", + "7.536373523810e+00 1.80677 34.247 0.000328983 1.72498e-05 13\n", + "7.393982410080e+00 1.82164 42.9844 0.000244839 1.72498e-05 13\n", + "7.396470605248e+00 1.82129 53.9508 0.000182216 1.72498e-05 13\n", + "7.399005684057e+00 1.82041 67.7151 0.00013561 1.72498e-05 13\n", + "7.451195752942e+00 1.81559 106.674 7.51114e-05 1.72498e-05 13\n", + "7.443375325717e+00 1.81645 84.9909 0.000100925 1.72498e-05 13\n", + "7.452661646076e+00 1.81543 133.89 5.59e-05 1.72498e-05 13\n", "\n" ] } @@ -877,9 +882,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\",\n", @@ -908,7 +913,8 @@ "id": "c2ab0979-6575-481d-9c1c-ca98517b2437", "metadata": {}, "source": [ - "We can also set up a population that samples biinary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded top be more useful" + "### Binary star population\n", + "We can also set up a population that samples binary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded to be more useful. Also note that we run very little systems in the following example, as its just intended to show how the code works." ] }, { @@ -921,45 +927,42 @@ "name": "stdout", "output_type": "stream", "text": [ - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-izzard/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python-david/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", + "ok\n", + "File at /tmp/binary_c_python-david/notebooks/notebook_population/example_python_population_result/example_pop_settings.json.gz already exists: cannot write to it\n", + "ok\n", + "ok pre\n", + "ok ret\n", + "Do dry run? True\n", "Doing dry run to calculate total starcount and probability\n", - "Generating grid code\n", - "Grid has handled 27 stars with a total probability of 0.0248684\n", - "**************************************\n", - "* Total starcount for this run is 27 *\n", - "* Total probability is 0.0248684 *\n", - "**************************************\n", + "Grid has handled 8 stars with a total probability of 0.0211592\n", + "**********************************\n", + "* Dry run *\n", + "* Total starcount is 8 *\n", + "* Total probability is 0.0211592 *\n", + "**********************************\n", "\n", - "Generating grid code\n", + "Do join of subprocesses ...\n", + "Joined subprocesses.\n", "**********************************************************\n", - "* Population-8bc1eafea1c34b05894c1618639d8c37 finished! *\n", - "* The total probability is 0.0248684. *\n", - "* It took a total of 16.10s to run 27 systems on 2 cores *\n", - "* = 32.20s of CPU time. *\n", - "* Maximum memory use 437.695 MB *\n", + "* Population-0eb5c0c9abd34607a6ee060b26a7e32f finished! *\n", + "* The total probability is 0.0211592. *\n", + "* It took a total of 0.84s to run 8 systems on 2 cores *\n", + "* = 1.68s of CPU time. *\n", + "* Maximum memory use 300.125 MB *\n", "**********************************************************\n", "\n", - "There were no errors found in this run.\n", + "No failed systems were found in this run.\n", + "Do analytics\n", + "Added analytics to metadata\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", - "1.219029061236e+01 1.60007 17.3205 0 2.97008 13 5 15 15 0.02 0.000498487\n", - "1.935920339886e+01 1.29448 17.3205 0 8.71025 13 13 15 2 0.02 0.000498487\n", - "2.123794969278e+01 1.30902 17.3205 1.58518 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.548740826516e+01 1.52415 17.3205 1.45407 14.4504 13 13 13 5 0.02 0.000220016\n", - "1.779197348711e+01 1.3228 17.3205 1.71196 14.4504 13 13 13 8 0.02 0.000287968\n", - "1.367065497322e+01 1.66003 73.0434 1.79487 12.2572 13 13 13 8 0.02 7.67586e-05\n", - "1.772169325355e+01 1.81957 73.0434 1.46573 12.2572 13 13 13 5 0.02 4.43422e-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", - "9.823059079115e+00 2.43711 73.0434 1.81689 60.8862 14 14 13 8 0.02 7.67586e-05\n", - "7.394722435913e+00 1.79092 73.0434 1.79092 60.8862 13 8 13 8 0.02 4.43422e-05\n", - "7.396288708628e+00 1.8216 73.0434 1.8216 60.8862 13 8 13 8 0.02 3.38788e-05\n", + "1.378266748188e+01 1.66293 50.9713 1.78767 12.8178 13 13 13 8 0.02 0.000339963\n", + "1.817608462595e+01 1.82104 50.9713 1.41436 12.8178 13 13 13 5 0.02 0.000193036\n", + "7.422997711686e+00 1.82479 50.9713 1.82171 38.2535 13 13 13 8 0.02 0.000193036\n", + "1.205711924468e+01 1.73765 50.9713 0 38.2535 13 13 15 8 0.02 0.000339963\n", "\n" ] } @@ -1089,9 +1092,9 @@ " name=\"lnm1\",\n", " longname=\"Primary mass\",\n", " valuerange=[2, 150],\n", - " samplerfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", + " samplerfunc=\"self.const_linear(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n", " precode=\"M_1=math.exp(lnm1)\",\n", - " probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", + " probdist=\"self.three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n", " dphasevol=\"dlnm1\",\n", " parameter_name=\"M_1\",\n", " condition=\"\", # Impose a condition on this grid variable. Mostly for a check for yourself\n", @@ -1102,8 +1105,8 @@ " name=\"q\",\n", " longname=\"Mass ratio\",\n", " valuerange=[\"0.1/M_1\", 1],\n", - " samplerfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n", - " probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", + " samplerfunc=\"self.const_linear(0.1/M_1, 1, {})\".format(resolution['q']),\n", + " probdist=\"self.flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n", " dphasevol=\"dq\",\n", " precode=\"M_2 = q * M_1\",\n", " parameter_name=\"M_2\",\n", @@ -1115,12 +1118,12 @@ " name=\"log10per\", # in days\n", " longname=\"log10(Orbital_Period)\",\n", " valuerange=[0.15, 5.5],\n", - " samplerfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", + " samplerfunc=\"self.const_linear(0.15, 5.5, {})\".format(resolution[\"per\"]),\n", " precode=\"\"\"orbital_period = 10** log10per\n", "sep = calc_sep_from_period(M_1, M_2, orbital_period)\n", "sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n", "sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n", - " probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", + " probdist=\"self.sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n", " parameter_name=\"orbital_period\",\n", " dphasevol=\"dlog10per\",\n", ")\n", @@ -1145,7 +1148,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1159,7 +1162,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/examples/old/basic_example.ipynb b/examples/old/basic_example.ipynb index 9078cfcb5fdcd35336ee3675accb3f810c21e5fe..7146b97671caad9e82ce7454511dcad2aa416a78 100644 --- a/examples/old/basic_example.ipynb +++ b/examples/old/basic_example.ipynb @@ -1,5 +1,14 @@ { "cells": [ + { + "cell_type": "markdown", + "id": "c09b9f85-5250-4fd2-8142-bb8097d138b5", + "metadata": {}, + "source": [ + "# Basic example\n", + "Running a single system" + ] + }, { "cell_type": "code", "execution_count": 1, @@ -106,7 +115,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -120,7 +129,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/examples/old/workshop_example_notebook.ipynb b/examples/old/workshop_example_notebook.ipynb index 4eca5879779a9fec40521c733bda59768c8c4140..78d0860ad1dfc12104b4bb639055957d527c01e7 100644 --- a/examples/old/workshop_example_notebook.ipynb +++ b/examples/old/workshop_example_notebook.ipynb @@ -619,7 +619,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -633,7 +633,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.9.9" } }, "nbformat": 4, diff --git a/install_without_dependencies.sh b/install_without_dependencies.sh deleted file mode 100755 index 2a7775c07c0991eb163c2e96bfa0a9217211ec87..0000000000000000000000000000000000000000 --- a/install_without_dependencies.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Script to install binarycpython in the current venv - -VERSION_NUMBER=$(cat "VERSION") -echo "installing binarcpython version $VERSION_NUMBER" - -python setup.py clean -pip uninstall binarycpython -python setup.py build --force -python setup.py sdist -pip install --ignore-installed --no-dependencies -v dist/binarycpython-$VERSION_NUMBER.tar.gz diff --git a/pyproject.toml b/pyproject.toml index a9149c38999c8353e5e2657f6d3c3ae0698c44bc..e12491148af538f4fb14dbeca767548362129a28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.black] target-version = ['py36'] - [tool.coverage] -# todo +#omit = +# test_*.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..11f1705f0fbd767e8d1af873873d33e2b32d8ca6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,25 @@ +astropy +cachetools +colorama +compress_pickle +datasize +diskcache +flufl.lock +h5py +halo +humanize +lib_programname +matplotlib +msgpack +numpy +pandas +pathos +psutil +pytest +py_rinterpolate +seaborn +setproctitle +str2bool +psutil +simplejson +strip-ansi \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 3287428db22241272940680c4ede46aeac7df5a5..f35356367f3e0927513a4ec802b34f4a2d3b066f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,6 @@ # Inside of setup.cfg [metadata] description-file = README.md + +[egg_info] +egg_base = ./build/ diff --git a/setup.py b/setup.py index 624e08e87911755a945068ddd26fda7620148017..db1e9f5a0e257247b02d0bbecba7266d062d3918 100644 --- a/setup.py +++ b/setup.py @@ -11,9 +11,18 @@ import setuptools from distutils.core import setup, Extension import distutils.command.build -# TODO: replace the tasks that call binary_c-config with a single function that handles the return status a bit better. +# +this_file = os.path.abspath(__file__) +this_file_dir = os.path.dirname(this_file) +### +REQUIRED_BINARY_C_VERSIONS = ["2.1.7", "2.2pre1", "2.2.0", "2.2.1"] +############################################################ +# Defining functionality +############################################################ + +# Functions def version(): """ opens VERSION and returns version number @@ -22,21 +31,36 @@ def version(): with open("VERSION") as file: return file.read().strip() - -VERSION_NUMBER = version() - -# Functions def readme(): - """Opens readme file and returns content""" + """ + Opens readme file and returns content + """ + with open("README.md") as file: return file.read() - def license(): - """Opens license file and returns the content""" + """ + Opens license file and returns the content + """ + with open("LICENSE.md") as file: return file.read() +def requirements(directory): + """ + Opens requirements.txt and returns content as a list + """ + + requirements_file = os.path.join(directory, 'requirements.txt') + + # Read out file and construct list + requirements_list = [] + with open(requirements_file) as f: + for el in f.readlines(): + requirements_list.append(el.strip()) + + return requirements_list def check_version(installed_binary_c_version, required_binary_c_versions): """Function to check the installed version and compare it to the required version""" @@ -49,7 +73,6 @@ def check_version(installed_binary_c_version, required_binary_c_versions): ) assert installed_binary_c_version in required_binary_c_versions, message - def execute_make(): """ Function to execute the makefile. @@ -74,9 +97,25 @@ def execute_make(): print(stdout.decode("utf-8")) print("Successfully built the libbinary_c_api.so") +def call_binary_c_config(binary_c_dir, command): + """ + Function to call the binary_c config + """ -### -REQUIRED_BINARY_C_VERSIONS = ["2.1.7", "2.2pre1", "2.2.0", "2.2.1"] + + binary_c_config = os.path.join(BINARY_C_DIR, "binary_c-config") + + command_result = ( + subprocess.run([binary_c_config, command], stdout=subprocess.PIPE, check=True) + .stdout.decode("utf-8") + .split() + ) + + return command_result + +############################################################ +# First level checks +############################################################ #### GSL_DIR = os.getenv("GSL_DIR", None) @@ -87,65 +126,31 @@ if not GSL_DIR: ) BINARY_C_DIR = os.getenv("BINARY_C", None) if not BINARY_C_DIR: - print("\n\n****\n**** Error: the BINARY_C environment variable is not set.\n**** This environment variable should point to the root of your binary_c\n**** installation (i.e. the directory you acquired from the repository).\n**** Aborting setup.\n****\n\n") + print( + "\n\n****\n**** Error: the BINARY_C environment variable is not set.\n**** This environment variable should point to the root of your binary_c\n**** installation (i.e. the directory you acquired from the repository).\n**** Aborting setup.\n****\n\n" + ) quit(1) -# TODO: write code to know exact parent directory of this file. -CWD = os.getcwd() - ############################################################ # Getting information from binary_c ############################################################ # binary_c must be installed. -BINARY_C_CONFIG = os.path.join(BINARY_C_DIR, "binary_c-config") - -BINARY_C_VERSION = ( - subprocess.run([BINARY_C_CONFIG, "version"], stdout=subprocess.PIPE, check=True) - .stdout.decode("utf-8") - .split() -) +BINARY_C_VERSION = call_binary_c_config(BINARY_C_DIR, "version") check_version(BINARY_C_VERSION[0], REQUIRED_BINARY_C_VERSIONS) -BINARY_C_INCDIRS = ( - subprocess.run( - [BINARY_C_CONFIG, "incdirs_list"], stdout=subprocess.PIPE, check=True - ) - .stdout.decode("utf-8") - .split() -) -BINARY_C_LIBDIRS = ( - subprocess.run( - [BINARY_C_CONFIG, "libdirs_list"], stdout=subprocess.PIPE, check=True - ) - .stdout.decode("utf-8") - .split() -) -BINARY_C_CFLAGS = ( - subprocess.run([BINARY_C_CONFIG, "cflags"], stdout=subprocess.PIPE, check=True) - .stdout.decode("utf-8") - .split() -) +BINARY_C_INCDIRS = call_binary_c_config(BINARY_C_DIR, "incdirs_list") +BINARY_C_LIBDIRS = call_binary_c_config(BINARY_C_DIR, "libdirs_list") +BINARY_C_CFLAGS = call_binary_c_config(BINARY_C_DIR, "cflags") # BINARY_C_CFLAGS.remove('-fvisibility=hidden') -BINARY_C_LIBS = ( - subprocess.run([BINARY_C_CONFIG, "libs_list"], stdout=subprocess.PIPE, check=True) - .stdout.decode("utf-8") - .split() -) +BINARY_C_LIBS = call_binary_c_config(BINARY_C_DIR, "libs_list") +BINARY_C_DEFINES = call_binary_c_config(BINARY_C_DIR, "define_macros") # create list of tuples of defined macros BINARY_C_DEFINE_MACROS = [] -DEFINES = ( - subprocess.run( - [BINARY_C_CONFIG, "define_macros"], stdout=subprocess.PIPE, check=True - ) - .stdout.decode("utf-8") - .split() -) - LONE = re.compile("^-D(.+)$") PARTNER = re.compile("^-D(.+)=(.+)$") -for x in DEFINES: +for x in BINARY_C_DEFINES: y = PARTNER.match(x) if y: BINARY_C_DEFINE_MACROS.extend([(y.group(1), y.group(2))]) @@ -158,8 +163,9 @@ for x in DEFINES: API_h = os.path.join(BINARY_C_DIR, "src", "API", "binary_c_API.h") ############################################################ -# Setting all directories and LIBRARIES to their final values +# Determine all directories and libraries ############################################################ + INCLUDE_DIRS = [ os.path.join(BINARY_C_DIR, "src"), os.path.join(BINARY_C_DIR, "src", "API"), @@ -174,14 +180,14 @@ LIBRARIES = ["binary_c"] + BINARY_C_LIBS LIBRARY_DIRS = [ os.path.join(BINARY_C_DIR, "src"), "./", - os.path.join(CWD, "lib/"), - os.path.join(CWD, "binarycpython/"), + os.path.join(this_file_dir, "lib/"), + os.path.join(this_file_dir, "binarycpython/"), ] + BINARY_C_LIBDIRS RUNTIME_LIBRARY_DIRS = [ os.path.join(BINARY_C_DIR, "src"), "./", - os.path.join(CWD, "lib/"), + os.path.join(this_file_dir, "lib/"), ] + BINARY_C_LIBDIRS # filter out duplicates @@ -191,26 +197,11 @@ LIBRARIES = list(dict.fromkeys(LIBRARIES)) LIBRARY_DIRS = list(dict.fromkeys(LIBRARY_DIRS)) RUNTIME_LIBRARY_DIRS = list(dict.fromkeys(RUNTIME_LIBRARY_DIRS)) -# -# print('\n') -# print("BINARY_C_CONFIG: ", str(BINARY_C_CONFIG) + "\n") -# print("incdirs: ", str(INCLUDE_DIRS) + "\n") -# print("BINARY_C_LIBS: ", str(BINARY_C_LIBS) + "\n") -# print("LIBRARIES: ", str(LIBRARIES) + "\n") -# print("LIBRARY_DIRS: ", str(LIBRARY_DIRS) + "\n") -# print("RUNTIME_LIBRARY_DIRS: ", str(RUNTIME_LIBRARY_DIRS) + "\n") -# print("BINARY_C_CFLAGS: ", str(BINARY_C_CFLAGS) + "\n") -# print("API_h: ", str(API_h) + "\n") -# print("macros: ", str(BINARY_C_DEFINE_MACROS) + "\n") -# print('\n') - ############################################################ -# Making the extension function +# Making the python-c binding module ############################################################ -# TODO: fix that this one also compiles the code itself BINARY_C_PYTHON_API_MODULE = Extension( - # name="binarycpython.core.binary_c", name="binarycpython._binary_c_bindings", sources=["src/binary_c_python.c"], include_dirs=INCLUDE_DIRS, @@ -223,8 +214,9 @@ BINARY_C_PYTHON_API_MODULE = Extension( language="C", ) headers = ["src/includes/header.h"] + ############################################################ -# Making the extension function +# Custom build command ############################################################ # Override build command @@ -233,10 +225,13 @@ class CustomBuildCommand(distutils.command.build.build): # Run the original build command distutils.command.build.build.run(self) +############################################################ +# Main setup function call +############################################################ setup( name="binarycpython", - version=VERSION_NUMBER, + version=version(), description="""This is a python API for binary_c (versions {}) by David Hendriks, Rob Izzard and collaborators. Based on the initial set up by Jeff andrews.""".format( ",".join(REQUIRED_BINARY_C_VERSIONS), ",".join(REQUIRED_BINARY_C_VERSIONS), @@ -244,7 +239,6 @@ setup( author="David Hendriks", author_email="davidhendriks93@gmail.com", long_description=readme(), - # long_description="hello", long_description_content_type="text/markdown", url="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python", license="gpl", @@ -257,29 +251,11 @@ setup( packages=[ "binarycpython", "binarycpython.utils", - "binarycpython.core", + "binarycpython.utils.population_extensions", "binarycpython.tests", + "binarycpython.tests.tests_population_extensions", ], - install_requires=[ - "astropy", - "colorama", - "h5py", - "halo", - "humanize", - "matplotlib", - "msgpack", - "numpy", - "pandas", - "pathos", - "psutil", - "pytest", - "py_rinterpolate", - "seaborn", - "setproctitle", - "psutil", - "simplejson", - "strip-ansi", - ], + install_requires=requirements(this_file_dir), include_package_data=True, ext_modules=[BINARY_C_PYTHON_API_MODULE], # binary_c must be loaded classifiers=[