jkrogager / VoigtFit

Python code to fit absorption lines semi-interactively
http://voigtfit.readthedocs.io/
MIT License
28 stars 12 forks source link

Value Error when running VoigtFit #32

Closed mtnuss closed 4 years ago

mtnuss commented 4 years ago

Made an input file in Sublime and I get the same "Value Error: could not convert string to float: 'VoigtFit.DataSetz'" when running the file through VoigtFit in a miniconda command prompt. Works when I run it a line at a time on the prompt, however, it does not work if I try to run the entire input file through VoigtFit at one time like I should be able to. This is the beginning of the input file code, VoigtFit.DataSet(z) is on line 9.

import numpy as np
import VoigtFit
import matplotlib

# -- Add the redshift of the cloud doing the absorption
#   Estimating 0 for everything.
z = 0.0

dataset = VoigtFit.DataSet(z)
dataset.set_name("CII_1335")
dataset.verbose = True

# -- If log(NHI) is not known use:
logNHI = None

This is the error given after running it in the miniconda command prompt as VoigtFit "input_file_name.py" as told by the VoigtFit instructions.

Traceback (most recent call last):
  File "c:\users\mn\miniconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\mn\miniconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\mn\miniconda3\Scripts\VoigtFit.exe\__main__.py", line 7, in <module>
  File "c:\users\mn\miniconda3\lib\site-packages\VoigtFit\main.py", line 96, in main
    parameters = parse_parameters(parfile)
  File "c:\users\mn\miniconda3\lib\site-packages\VoigtFit\parse_input.py", line 75, in parse_parameters
    resolution = float(resolution)
ValueError: could not convert string to float: 'VoigtFit.DataSetz'

Not sure what to do from here. Was told it might be a pathing issue but not sure what to do if it is, also unsure since running it line by line got results. Thanks!

jkrogager commented 4 years ago

The problem lies with your input file. There are two options for running VoigtFit:

1) you write a python script (as you've done) and run this in Python, either in a notebook or in an iPython terminal (or plain python terminal if you like it even more manually). For more information check the API in the documentation.

2) you write a "VoigtFit Input File" which does not follow python syntax and run this from terminal using the VoigtFit command. See the manual on the parameter file language.

You seem to have mixed both. You cannot run a python script through the VoigtFit command line tool.