Skip to content
Snippets Groups Projects
Commit 1edcae4c authored by David Hendriks's avatar David Hendriks
Browse files

fixed functionality for fetching default args via binaryc interface. making...

fixed functionality for fetching default args via binaryc interface. making some evolution plots now
parent f0d5a6a7
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,6 @@ def create_arg_string(arg_dict):
"""
Function that creates the arg string
"""
arg_string = ''
for key in arg_dict.keys():
arg_string += "{key} {value} ".format(key=key, value=arg_dict[key])
......@@ -27,17 +26,26 @@ def get_defaults():
key, value = default.split(' = ')
# Filter out NULLS (not compiled anyway)
if not value=='NULL':
default_dict[key] = value
if not value in ['NULL', 'Function']:
if not value=='':
default_dict[key] = value
return default_dict
def get_arg_keys():
"""
Function that return the list of possible keys to give in the arg string
"""
return get_defaults().keys()
def run_system(**kwargs):
"""
Wrapper to run a system with settings
"""
# Load default args
physics_args = get_defaults()
args = get_defaults()
# args = {}
# For example
# physics_args['M_1'] = 20
......@@ -46,11 +54,12 @@ def run_system(**kwargs):
# Use kwarg value to override defaults and add new args
for key in kwargs.keys():
physics_args[key] = kwargs[key]
args[key] = kwargs[key]
# Construct arguments string and final execution string
arg_string = create_arg_string(physics_args)
arg_string = create_arg_string(args)
arg_string = f'binary_c {arg_string}'
# print(arg_string)
# Run it and get output
buffer = ""
......@@ -58,7 +67,6 @@ def run_system(**kwargs):
return output
def parse_output(output, selected_header):
"""
Function that parses output of binaryc when it is construction like this:
......@@ -98,5 +106,4 @@ def parse_output(output, selected_header):
for key in keys:
final_values_dict[key].append(value_dict[key])
return final_values_dict
return final_values_dict
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
david_results/s.png

17.4 KiB

......@@ -9,7 +9,6 @@ import pandas as pd
import binary_c
from binaryc_python_utils.defaults import physics_defaults
from binaryc_python_utils.functions import create_arg_string, parse_output, run_system
"""
......@@ -31,13 +30,15 @@ print("The following keys are present in the results:\n{}".format(result.keys())
# Cast the data into a dataframe.
df = pd.DataFrame.from_dict(result, dtype=np.float64)
print(df)
# sliced_df = df[df.t < 1000] # Cut off late parts of evolution
sliced_df = df[df.t < 1000] # Cut off late parts of evolution
# print(sliced_df["t"])
# plt.plot(sliced_df['t'], sliced_df['radius'])
# plt.xlabel('Time (Myr)')
# plt.ylabel('Radius (Rsol)')
# plt.show()
\ No newline at end of file
plt.plot(sliced_df['omega'], sliced_df['radius'])
plt.xlabel('Time (Myr)')
plt.ylabel('omega (Rsol)')
plt.show()
\ No newline at end of file
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