jkrogager / VoigtFit

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

fit to every data #18

Closed AminFarhang closed 6 years ago

AminFarhang commented 6 years ago

Hi, Is it possible to make a simple example to show how simply fit an absorption with voigt profile with VoigtFit package? suppose I already have wave and flux in a text file for NaI, how can I fit it with VoigtFit?

Here is my example:

data already is loaded

wave = np.array([...]) flux = np.array([---])

z_DLA = 0 res_UVB = 5890.22 dataset = VoigtFit.DataSet(z_DLA) dataset.add_data(wave, flux, 299792./res_UVB, err=None, normalized=False)

dataset.add_line('NaI_5891')

dataset.prepare_dataset() popt, chi2 = dataset.fit(verbose=True, plot=True) dataset.plot_fit()

But the output is the following error: ValueError: max() arg is an empty sequence

Thanks

jkrogager commented 6 years ago

Hi, you must define the components (minimum 1 for each ion) using the dataset.add_component() method or the .add_component_velocity() method. See details in the documentation.