Skip to content

Commit 5acb9d6

Browse files
authored
Updated methods paper figures (#584)
* update figure 5 to newest COMPAS version * update figure 6 to latest COMPAS version
1 parent 8938905 commit 5acb9d6

File tree

6 files changed

+1115
-93
lines changed

6 files changed

+1115
-93
lines changed
0 Bytes
Binary file not shown.

examples/methods_paper_plots/fig_5_HR_diagram/pythonSubmit.py

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import numpy as np
2-
import subprocess
32
import sys
43
import os
5-
import pickle
6-
import itertools
74
from subprocess import call
5+
import re
86

97
# Check if we are using python 3
108
python_version = sys.version_info[0]
@@ -52,6 +50,7 @@ class pythonProgramOptions:
5250
# if COMPAS_LOGS_OUTPUT_DIR_PATH is not set (== None) the current working directory
5351
# is used as the value for the --output-path option
5452
compas_logs_output_override = os.environ.get('COMPAS_LOGS_OUTPUT_DIR_PATH')
53+
5554
if (compas_logs_output_override is None):
5655
output = os.getcwd()
5756
output_container = None # names the directory to be created and in which log files are created. Default in COMPAS is "COMPAS_Output"
@@ -77,21 +76,21 @@ class pythonProgramOptions:
7776

7877
mode = 'BSE' # evolving single stars (SSE) or binaries (BSE)?
7978

80-
grid_filename = "grid.txt" # grid file name (e.g. 'mygrid.txt')
79+
grid_filename = 'grid.txt' # grid file name (e.g. 'mygrid.txt')
8180

8281
if grid_filename != None:
8382
if compas_input_path_override == None:
84-
grid_filename = os.getcwd() + '/' + grid_filename
83+
grid_filename = os.getcwd() + '/' + grid_filename.strip("'\"")
8584
else:
86-
grid_filename = compas_input_path_override + '/' + grid_filename
85+
grid_filename = compas_input_path_override + '/' + grid_filename.strip("'\"")
8786

8887
logfile_definitions = None # logfile record definitions file name (e.g. 'logdefs.txt')
8988

9089
if logfile_definitions != None:
9190
if compas_input_path_override == None:
92-
logfile_definitions = os.getcwd() + '/' + logfile_definitions
91+
logfile_definitions = os.getcwd() + '/' + logfile_definitions.strip("'\"")
9392
else:
94-
logfile_definitions = compas_input_path_override + '/' + logfile_definitions
93+
logfile_definitions = compas_input_path_override + '/' + logfile_definitions.strip("'\"")
9594

9695
initial_mass = None # initial mass for SSE
9796
initial_mass_1 = None # primary initial mass for BSE
@@ -111,7 +110,7 @@ class pythonProgramOptions:
111110
evolve_unbound_systems = False
112111
quiet = False
113112

114-
metallicity = None # metallicity for both SSE and BSE - Solar metallicity Asplund+2010
113+
metallicity = 0.0142 # metallicity for both SSE and BSE - Solar metallicity Asplund+2010
115114

116115
allow_rlof_at_birth = True # allow binaries that have one or both stars in RLOF at birth to evolve?
117116
allow_touching_at_birth = False # record binaries that have stars touching at birth in output files?
@@ -211,7 +210,7 @@ class pythonProgramOptions:
211210

212211
neutrino_mass_loss_BH_formation = "FIXED_MASS" # "FIXED_FRACTION"
213212
neutrino_mass_loss_BH_formation_value = 0.1 # Either fraction or mass (Msol) to lose
214-
213+
215214
remnant_mass_prescription = 'FRYER2012' #
216215
fryer_supernova_engine = 'DELAYED'
217216
black_hole_kicks = 'FALLBACK'
@@ -300,7 +299,6 @@ class pythonProgramOptions:
300299
debug_to_file = False
301300
errors_to_file = False
302301

303-
304302
def booleanChoices(self):
305303
booleanChoices = [
306304
self.enable_warnings,
@@ -659,12 +657,12 @@ def generateCommandLineOptionsDict(self):
659657
and run directly as a terminal command, or passed to the stroopwafel interface
660658
where some of them may be overwritten. Options not to be included in the command
661659
line should be set to pythons None (except booleans, which should be set to False)
662-
660+
663661
Parameters
664662
-----------
665663
self : pythonProgramOptions
666664
Contains program options
667-
665+
668666
Returns
669667
--------
670668
commands : str or list of strs
@@ -673,17 +671,17 @@ def generateCommandLineOptionsDict(self):
673671
booleanCommands = self.booleanCommands()
674672
nBoolean = len(booleanChoices)
675673
assert len(booleanCommands) == nBoolean
676-
674+
677675
numericalChoices = self.numericalChoices()
678676
numericalCommands = self.numericalCommands()
679677
nNumerical = len(numericalChoices)
680678
assert len(numericalCommands) == nNumerical
681-
679+
682680
stringChoices = self.stringChoices()
683681
stringCommands = self.stringCommands()
684682
nString = len(stringChoices)
685683
assert len(stringCommands) == nString
686-
684+
687685
listChoices = self.listChoices()
688686
listCommands = self.listCommands()
689687
nList = len(listChoices)
@@ -693,23 +691,23 @@ def generateCommandLineOptionsDict(self):
693691
### Collect all options into a dictionary mapping option name to option value
694692

695693
command = {'compas_executable' : self.compas_executable}
696-
694+
697695
for i in range(nBoolean):
698696
if booleanChoices[i] == True:
699697
command.update({booleanCommands[i] : ''})
700-
698+
701699
for i in range(nNumerical):
702700
if not numericalChoices[i] == None:
703701
command.update({numericalCommands[i] : str(numericalChoices[i])})
704-
702+
705703
for i in range(nString):
706704
if not stringChoices[i] == None:
707-
command.update({stringCommands[i] : stringChoices[i]})
708-
705+
command.update({stringCommands[i] : cleanStringParameter(stringChoices[i])})
706+
709707
for i in range(nList):
710708
if listChoices[i]:
711709
command.update({listCommands[i] : ' '.join(map(str,listChoices[i]))})
712-
710+
713711
return command
714712

715713

@@ -721,13 +719,26 @@ def combineCommandLineOptionsDictIntoShellCommand(commandOptions):
721719
"""
722720

723721
shellCommand = commandOptions['compas_executable']
724-
del commandOptions['compas_executable']
722+
del commandOptions['compas_executable']
725723
for key, val in commandOptions.items():
726724
shellCommand += ' ' + key + ' ' + val
727725

728726
return shellCommand
729727

730728

729+
def cleanStringParameter(str_param):
730+
""" clean up string parameters to avoid confusing Boost """
731+
if str_param is not None:
732+
# strip any quotes from the ends of the string
733+
str_param = str_param.strip("'\"")
734+
735+
# escape any unescaped spaces or quotes within the string
736+
escapes = [" ", "'", "\""]
737+
for escape in escapes:
738+
str_param = re.sub(r"(?<!\\){}".format(escape), r"\{}".format(escape), str_param)
739+
return str_param
740+
741+
731742
if __name__ == "__main__":
732743

733744
#-- Get the program options

0 commit comments

Comments
 (0)