Commit aeda145f authored by David Hendriks's avatar David Hendriks
Browse files

Trying out things with automatic reading of the output line and parameter...

Trying out things with automatic reading of the output line and parameter names. Also, trying to fix that the import binaryc works as its supposed
parent e29b6ecb
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -39,14 +39,31 @@ You will require whatever libraries with which binary_c was compiled, as well as

If you want to be able to import the binary_c module correctly for child directories (or anywhere for that matter), execute or put the following code in your .bashrc/.zshrc: 
```
export LD_LIBRARY_PATH=<full path to directory containing libbinary_c_api.so>
export LD_LIBRARY_PATH=<full path to directory containing libbinary_c_api.so>:$LD_LIBRARY_PATH
export PYTHONPATH=<full path to directory containing libbinary_c_api.so>:$PYTHONPATH
```

Usage notes
---------------------
When running a jupyter notebook and importing binary_c, it might happen that the module binary_c cannot be found. I experienced this when I executed Jupyter Notebook from a virtual environment which didnt use the same python (version/binary/shim) as the one I built this library with. Make sure jupyter does use the same underlying python version/binary/shim. That resolved the issue for me.

Also: I figured that having binaryc output the log like "<LOG HEADER> t=10e4 ..." (i.e. printing the parameter names as well as their values) would be useful because in that way one can easily have python read that out automatically instead of having to manually copy the list of parameter names.



TODO 
---------------------
General:
- ?Put the header and src files in a dedicated directory. 
- ?Have the compiled files be written into build
- Get a more reliable way of loading the default values (running a ./tbse echo or something?)
- make routine that reads out all the lines, splits them into pieces and reads out the correct key
- Add PYTHONPATH thing to readme
- Make sure importing binary_c is not a problem

If we're going to do populations:
- Use sphinx for auto generation of docs
- Use queueing system/asynchronous task queue
- Make some parse-data that can be easily used
- Make some simple script to assign probabilities
- rebuild all perl stuff into a python grid code.
 No newline at end of file
+165 −0

File added.

Preview size limit exceeded, changes collapsed.

+165 −0

File added.

Preview size limit exceeded, changes collapsed.

+1 −6
Original line number Diff line number Diff line
import os, sys
import matplotlib.pyplot as plt

import binary_c

# Append root dir of this project to include functionality
sys.path.append(os.path.dirname(os.getcwd()))
import binary_c
from utils.defaults import physics_defaults
from utils.functions import create_arg_string




def example_with_loading_default_args():
    """
    Example function loading the default physics args for a binary_c system. Got
@@ -29,7 +25,6 @@ def example_with_loading_default_args():
    physics_args['orbital_period'] = 4530.0

    arg_string = create_arg_string(physics_args)

    arg_string = f'binary_c {arg_string}' 

    buffer = ""
Loading