TeamCOMPAS / COMPAS

COMPAS rapid binary population synthesis code
http://compas.science
MIT License
65 stars 66 forks source link

Commandline Options error: Missing ']' for option 'metallicity' #695

Closed HeloiseS closed 2 years ago

HeloiseS commented 3 years ago

This issue is submitted as part of the JOSS review #3838

:bug: Description So I'm trying to make models for a range of metallicities following the instructions on this page.

The command I'm trying to parse is as follows (note i have aliased the location of COMPAS to compas): compas --metallicity [0.0012, 3, 0.01] --number-of-systems 5000 I tried with having the rand range in front of the square brackets to no avail. I tried within the pythonSubmit.py file with metallicity = [0.0112, 3, 0.01] and got the same error.

EDIT: your example works though, so I clearly did something wrong, just not sure what :)

jeffriley commented 3 years ago

@HeloiseS Leave the spaces out inside the [ ]. If you have spaces there the shell parser thinks it's a new command-line argument (command-line arguments are space-delimited). COMPAS can't do anything about that - the shell parser does it's work before COMPAS gets to see the options. I thought I documented that in the online documentation, but I can't find it. I'm sure it was in the PDF documentation (the predecessor to the online documentation), so I must have inadvertently left it out. I'll update the documentation. Please leave this issue open, and I'll close it once I have updated the documentation.

I note that I do document the spaces issue for vector options here:

https://compas.readthedocs.io/en/latest/pages/User%20guide/Program%20options/program-options-vector-options.html

Edit: Also, if you want to specify ranges and sets in pythonSubmit, you need to put quotes around the range/set value. i.e.

This will fail in pythonSubmit:

metallicity = [0.0112,3,0.01]

but this will work:

metallicity = '[0.0112,3,0.01]'

Python will try to parse the first one, and fail, but for the second it will pass the quoted parameter through to the command line.

This is documented here:

https://compas.readthedocs.io/en/latest/pages/User%20guide/Running%20COMPAS/running-via-python.html

(maybe it should also be on t he ranges/sets pages).

(Note to self: also fix "correspodning" in program-options-vector-options.rst)

HeloiseS commented 3 years ago

Cheers!

It now runs with the spces removed but when i run compas --metallicity [0.012,3,0.001] -n 5000 i only get 3 models. I thought it would give me 5000 models per mets but it seems to ignore the -n? switching order doesn't help is there priorities in commnds i need to consider?

jeffriley commented 3 years ago

I did that because the ranges and sets were meant to make it easy to specify a range (and set) of initial conditions. and if the user specified ranges and sets for multiple options (e.g. metallicity, initial-mass-1, initial-mass-2, etc. - the ones that otherwise would be sampled by COMPAS), then also using -n/--number-of-systems would just produce multiple copies of the same binaries - so I ignore -n/--number-of-systems. I probably didn't document that, did I...? I'll fix that.

However, if you use a grid file, then the ranges and sets on the command-line will be played out for each grid file line.

So this:

./compas --metallicity [0.012,3,0.001] --eccentricity s[0.1,0.2,0.3] --grid mygrid.txt

and 5 lines in mygrid.txt

will result in 45 binaries (3 x 3 x 5)

ilyamandel commented 2 years ago

@jeffriley -- do I understand correctly that the only action item on this is to document the existing behaviour?

jeffriley commented 2 years ago

@ilyamandel indeed you do. I'll get to it soon...

ilyamandel commented 2 years ago

Thanks, @jeffriley !

jeffriley commented 2 years ago

Documentation changes in PR #724

Close when merged