Fit Single Spectrum
In this example, we will extract a region of M33 Field 7 SN3 and fit is using LUCI. This is a very basic example.
# Imports
from luci import SitelleCube
import luci.viz.plotting as lplt
We now will set the required parameters. W
# Initialize paths and set parameters
cube_dir = '/export/home/carterrhea/M33' # Path to data cube
#cube_dir = '/mnt/carterrhea/carterrhea/NGC628' # Full path to data cube (example 2)
cube_name = 'M33_SN3' # don't add .hdf5 extension
object_name = 'M33'
filter_name = 'SN3'
redshift = -0.0006 # Redshift of object
resolution = 5000
We intialize our LUCI object
# Create Luci object
cube = SitelleCube(cube_path=cube_dir+'/'+cube_name, output_dir=cube_dir,
object_name=object_name, redshift=redshift, resolution=resolution)
Let’s extract a background region and take a look at it. The background region is defined in a ds9 region file called Examples/regions/bkg_M33.reg.
bkg_axis, bkg_sky = cube.extract_spectrum_region('regions/bkg_M33.reg', mean=True)
lplt.plot_spectrum(bkg_axis, bkg_sky)
Now we can define our fit region and fit it!
axis, sky, fit_dict = cube.fit_spectrum_region(
['NII6548', 'Halpha', 'NII6583'],
'sincgauss',
[1,1,1], [1,1,1],
region='regions/M33_reg1.reg',
bkg=bkg_sky)
lplt.plot_fit(axis, sky, fit_dict['fit_vector'], units='nm')
plt.xlim(650, 670)
And let’s see how this looks