<jupyter_start><jupyter_text>Example of fitting regions in NGC6888In this notebook, we go through fitting two regions of NGC 6888. This notebook exists for the sole purpose of demonstrating LUCI's prowess at fitting regions :)This notebook thus assumes that you have already gone through the tutorials.<jupyter_code># Imports
import os
import sys

import numpy as np
import matplotlib.pyplot as plt

# Get location of LUCI 
path = '/home/carterrhea/Documents/LUCI/'
sys.path.insert(0, path)  # add LUCI to the available paths

from LuciBase import Luci
import LUCI.LuciPlotting as lplt

%config Completer.use_jedi=False  # enable autocompletion when typing in Jupyter notebooks<jupyter_output><empty_output><jupyter_text>Now we need to define all the variables...<jupyter_code># Initialize paths and set parameters
Luci_path = path
cube_dir = '/home/carterrhea/Documents/NGC6888'  # Full path to data cube 
cube_name = 'NGC6888_SN3'  # don't add .hdf5 extension
object_name = 'NGC6888'
redshift = 0.00  # Redshift of object
resolution = 5000<jupyter_output><empty_output><jupyter_text>Intialize our LUCI object<jupyter_code>cube = Luci(Luci_path, cube_dir + '/' + cube_name, cube_dir, object_name, redshift, resolution)<jupyter_output>Reading in data...<jupyter_text>Create a deep frame quickly<jupyter_code>cube.create_deep_image()<jupyter_output>Existing deep frame extracted from hdf5 file.<jupyter_text>Picking the regionsNow let's take a quick look at the deep image to decide the regions we will fit. ![NGC6888-deep.png](NGC6888-deep.png) I've highlighted the background red in green and the two fit regions in magenta. Region 1 is near the right edge of the image and reigon 2 is at the center3. Let's take a look at the background<jupyter_code># We use 'mean = True' to take the mean of the emission in the region instead of the sum
bkg_axis, bkg_sky = cube.extract_spectrum_region(cube_dir+'/bkg.reg', mean=True)
lplt.plot_spectrum(bkg_axis, bkg_sky)<jupyter_output>100%|█████████████████████████████████████| 2064/2064 [00:00<00:00, 5970.81it/s]<jupyter_text>And now let's fit our regions and take a look at them<jupyter_code>axis, sky, fit_dict = cube.fit_spectrum_region(
                                ['NII6548', 'Halpha', 'NII6583', 'SII6716', 'SII6731'],
                                'sincgauss',
                                [1,1,1,1,1], [1,1,1,1,1],
                                region=cube_dir+'/region1.reg', bkg=bkg_sky,
                                bayes_bool=False)
lplt.plot_fit(axis, sky, fit_dict['fit_vector'])
axis, sky, fit_dict = cube.fit_spectrum_region(
                                ['NII6548', 'Halpha', 'NII6583', 'SII6716', 'SII6731'],
                                'sincgauss',
                                [1,1,1,1,1], [1,1,1,1,1],
                                region=cube_dir+'/region2.reg', bkg=bkg_sky,
                                bayes_bool=False)
lplt.plot_fit(axis, sky, fit_dict['fit_vector'])<jupyter_output>100%|█████████████████████████████████████| 2064/2064 [00:00<00:00, 6231.06it/s]
{'fraction_non_alphanumeric': 0.12022214962430579, 'fraction_numerical': 0.047696831100947405, 'mean_word_length': 3.4897360703812317, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '648722', 'license': 'MIT', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1028, 'n_words': 278, 'path': 'Examples/FitNGC6888.ipynb', 'repo_name': 'lyalcorn/LUCI', 'size': '3061'}