Skip to content
Snippets Groups Projects
Commit 6c50cae3 authored by dh00601's avatar dh00601
Browse files

added header to example notebook

parent 12968c3f
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:c09b9f85-5250-4fd2-8142-bb8097d138b5 tags:
# Basic example
Running a single system
%% Cell type:code id:66ca8e31-7cbf-4484-bb6c-c9235e14bda2 tags:
``` python
import pandas as pd
import numpy as np
import binarycpython
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 example_parse_output
```
%% Cell type:code id:31851c7f-4ccf-4b5a-9f74-8a3e06c6b2d8 tags:
``` python
# You can decide to `write` your own logging_line, which allows you to write a more complex logging statement with conditionals.
logging_line = 'Printf("MY_STELLAR_DATA time=%g radius=%g\\n",stardata->model.time,stardata->star[0].radius)'
# Generate entire shared lib code around logging lines
custom_logging_code = binary_c_log_code(logging_line, verbose=-1)
# Run system. all arguments can be given as optional arguments. the custom_logging_code is
# one of them and will be processed automatically.
output = run_system(
M_1=1, metallicity=0.002, M_2=0.1, separation=0, orbital_period=100000000000, \
custom_logging_code=custom_logging_code,
)
df = pd.DataFrame.from_dict(example_parse_output(output, 'MY_STELLAR_DATA'), dtype=np.float64)
df.plot('time', 'radius', logy=True)
```
%% Output
<AxesSubplot:xlabel='time'>
%% Cell type:code id:db0f3990-8680-4ea7-80d3-cdb430950c7f tags:
``` python
```
%% Output
<AxesSubplot:xlabel='time'>
%% Cell type:code id:39509b1c-f5fb-4edd-847a-97757c2197df tags:
``` python
```
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment