# Constraining line ratios¶

Some line doublets (e.g. [NII]6548,6583, [OIII]4959,5007) have known line ratios which then should be constrained to inject more information and optimize the unceratinty on the best fit parameters by minimizing the number of free parameters (especially if the SNR is low and if small variations of the ratio could not be measured anyway).

[1]:

# inline plotting for jupyter notebook. Do not put this line in a real python script.
%matplotlib inline
# import base class for the manipulation of a SITELLE spectral cube: HDFCube
from orcs.process import SpectralCube
import pylab as pl
cube = SpectralCube('/home/thomas/M31_SN3.merged.cm1.1.0.hdf5')

INFO| Data shape : (2048, 2064, 840)
INFO| Cube is in WAVENUMBER (cm-1)
INFO| Cube is CALIBRATED in wavenumber


## Fit with no amplitude constraint¶

[2]:

axis, spectrum, fit = cube.fit_lines_in_spectrum(998, 1198, 2, ['[NII]6548', 'Halpha', '[NII]6583'],
fmodel='gaussian',
pos_cov=-350,
pos_def=['1'],
fwhm_def='fixed')

print '\n===== Results ======'
print 'Velocity: ', fit['velocity_gvar']
print 'Flux:', fit['flux_gvar']
print 'NII 6584/6548 ratio', fit['flux'][2]/fit['flux'][0]

pl.figure(figsize=(10,6))
pl.plot(axis, spectrum, ls=':', c='black')
pl.plot(axis, fit['fitted_vector'], ls='-', c='orange')
pl.xlim(14500, 15500)

INFO| Number of integrated pixels: 13

 [==========] [100%] [completed in 0.062 s]

INFO| Init of the parallel processing server with 4 threads

 [==========] [100%] [completed in 0.734 s]

WARNING| /home/thomas/Astro/Python/ORB/Orcs/orcs/core.py:1673: RuntimeWarning: invalid value encountered in sqrt
noise_counts = np.sqrt(total_counts)




===== Results ======
Velocity:  [-293.11(96) -293.11(96) -293.11(96)]
Flux: [6.75(73)e-16 2.120(73)e-15 2.257(73)e-15]
NII 6584/6548 ratio 3.34348459029

[2]:

(14500, 15500)


## Fit with naive amplitude ratio constraint¶

Only the amplitude parameter can be constrained but not the flux (flux is a function of fwhm, broadening and amplitude). However, the natural axis of interferometric spectra is in wavenumber so that their fwhm (instrumental line shape) is constant in wavenumber. It means that, in wavelength (which is the axis on which the flux is evaluated when the flux unit are erg/cm2/s/A), for a given amplitude the flux will also depend on the wavelength. i.e. for a given amplitude ratio of 3 between two lines, the flux ratio will be slightly different from 3.

This problem will be answered next. For the moment we will see how we can constraint the amplitude ratio between two lines. When two lines are covarying in amplitude, the covariance parameter will be multiplicative over the initial guess of the lines amplitude. We can thus set a line to a guessed amplitude of 1 and the other at 3 and their amplitude ratio will always be 3. The covarying parameter which is free will multiply both lines by e.g. 3.2e-17 and the first line will have a final amplitude of 3.2e-17 while the second one will have a final amplitude of 9.6e-17.

[3]:

axis, spectrum, fit = cube.fit_lines_in_spectrum(998, 1198, 2, ['[NII]6548', 'Halpha', '[NII]6583'],
fmodel='gaussian',
pos_cov=-350,
pos_def=['1'],
fwhm_def='fixed',
amp_def=['1', '2', '1'],
amp_guess=[1, 1, 3])

print '\n===== Results ======'
print 'Velocity: ', fit['velocity_gvar']
print 'Flux:', fit['flux_gvar']
lines_amp = fit['lines_params'][:,1]
print 'NII 6584/6548 amplitude ratio', lines_amp[2]/lines_amp[0]
print 'NII 6584/6548 flux ratio', fit['flux'][2]/fit['flux'][0]

pl.figure(figsize=(10,6))
pl.plot(axis, spectrum, ls=':', c='black')
pl.plot(axis, fit['fitted_vector'], ls='-', c='orange')
pl.xlim(14500, 15500)

INFO| Number of integrated pixels: 13

 [==========] [100%] [completed in 0.021 s]

INFO| Init of the parallel processing server with 4 threads


[==========] [100%] [completed in 0.481 s]

===== Results ======
Velocity:  [-292.68(95) -292.68(95) -292.68(95)]
Flux: [7.38(23)e-16 2.120(73)e-15 2.237(69)e-15]
NII 6584/6548 amplitude ratio 3.0
NII 6584/6548 flux ratio 3.03250649287

[3]:

(14500, 15500)


## Fit with a flux ratio constraint¶

In the preceding example you can see that the amplitude ratio is 3 but the flux ratio (which is generally the parameter we want to constraint) is not exactly 3. To compute the amplitude ratio you must set to obtain a flux ratio of 3 you can use the method cube.get_amp_ratio_from_flux_ratio and use its output to set the correct amplitude ratio.

[4]:

amp_ratio = cube.get_amp_ratio_from_flux_ratio('[NII]6583', '[NII]6548', 3)
print amp_ratio

2.96784195554

[5]:

axis, spectrum, fit = cube.fit_lines_in_spectrum(998, 1198, 2, ['[NII]6548', 'Halpha', '[NII]6583'],
fmodel='gaussian',
pos_cov=-350,
pos_def=['1'],
fwhm_def='fixed',
amp_def=['1', '2', '1'],
amp_guess=[1, 1, amp_ratio])

print '\n===== Results ======'
print 'Velocity: ', fit['velocity_gvar']
print 'Flux:', fit['flux_gvar']
lines_amp = fit['lines_params'][:,1]
print 'NII 6584/6548 amplitude ratio', lines_amp[2]/lines_amp[0]
print 'NII 6584/6548 flux ratio', fit['flux'][2]/fit['flux'][0]

pl.figure(figsize=(10,6))
pl.plot(axis, spectrum, ls=':', c='black')
pl.plot(axis, fit['fitted_vector'], ls='-', c='orange')
pl.xlim(14500, 15500)

INFO| Number of integrated pixels: 13

 [==========] [100%] [completed in 0.023 s]

INFO| Init of the parallel processing server with 4 threads


[==========] [100%] [completed in 0.458 s]

===== Results ======
Velocity:  [-292.68(95) -292.68(95) -292.68(95)]
Flux: [7.45(23)e-16 2.120(73)e-15 2.234(69)e-15]
NII 6584/6548 amplitude ratio 2.96784195554
NII 6584/6548 flux ratio 3.0

[5]:

(14500, 15500)

[ ]: