{ "cells": [ { "cell_type": "markdown", "id": "3b489806", "metadata": {}, "source": [ "# **Notebook 2**: The data clases in sheap." ] }, { "cell_type": "code", "execution_count": 15, "id": "f7f3fe99", "metadata": {}, "outputs": [], "source": [ "from jax import config\n", "config.update(\"jax_enable_x64\", True)" ] }, { "cell_type": "markdown", "id": "3a2f9e4d", "metadata": {}, "source": [ "Throughout this notebook, we will delve deeper into the dataclasses that belong to `sheap`. There are three: `SpectralLine`, `SheapModelBuilder`. If you want to check it by your self you can look in `sheap.Core`" ] }, { "cell_type": "code", "execution_count": 16, "id": "83b39786", "metadata": {}, "outputs": [], "source": [ "from sheap.SheapModelBuilder.SheapModelBuilder import SheapModelBuilder" ] }, { "cell_type": "code", "execution_count": null, "id": "a96d6128", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 17, "id": "99b12876", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The autoreload extension is already loaded. To reload it, use:\n", " %reload_ext autoreload\n" ] } ], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "markdown", "id": "6b364c2e", "metadata": {}, "source": [ "`SheapModelBuilder` is the class that is use to create the region that will be fitted but to do this. it use a set up of lines. It currently shows the different variables that can handle from the number of narrow, broad, the method for the Fe, the continuum profile, if is prefered a group method or not, if the user wants to add outflows or winds or add a balmer continuum, and also the posibility to acces to uncoomon narrow lines. The classical way to handle this in sheap is ``group_method = True``, but for the sanity of the example we weill show the lines for separated in the begining " ] }, { "cell_type": "code", "execution_count": 18, "id": "d59c4a70", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "SheapModelBuilder(6500, 6600, n_narrow=2, n_broad=1, add_outflow=True)" ] }, { "cell_type": "code", "execution_count": 20, "id": "9b8c451b", "metadata": {}, "outputs": [], "source": [ "sheapmodel_class = SheapModelBuilder(4000,5000,n_narrow=1,n_broad=1,fe_mode=\"none\",continuum_profile=\"powerlaw\",verbose=False,group_method=False,add_outflow=False,add_winds=False,\n", " add_balmer_continuum=False,add_uncommon_narrow = False)" ] }, { "cell_type": "code", "execution_count": 21, "id": "3c314b7e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[PosixPath('/share/cav/data/favila/smbh_mass/sheap/sheap/SuportData/LineRepository/broad_and_narrow.yaml'),\n", " PosixPath('/share/cav/data/favila/smbh_mass/sheap/sheap/SuportData/LineRepository/broads.yaml'),\n", " PosixPath('/share/cav/data/favila/smbh_mass/sheap/sheap/SuportData/LineRepository/feii_IZw1.yaml'),\n", " PosixPath('/share/cav/data/favila/smbh_mass/sheap/sheap/SuportData/LineRepository/feii_coronal.yaml'),\n", " PosixPath('/share/cav/data/favila/smbh_mass/sheap/sheap/SuportData/LineRepository/feii_forbidden.yaml'),\n", " PosixPath('/share/cav/data/favila/smbh_mass/sheap/sheap/SuportData/LineRepository/feii_model.yaml'),\n", " PosixPath('/share/cav/data/favila/smbh_mass/sheap/sheap/SuportData/LineRepository/feii_uv.yaml'),\n", " PosixPath('/share/cav/data/favila/smbh_mass/sheap/sheap/SuportData/LineRepository/narrows.yaml')]" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sheapmodel_class.line_repository_path" ] }, { "cell_type": "markdown", "id": "996b9dfd", "metadata": {}, "source": [ "The property ``line_repository_path`` shows the list of lines in the repository has can be seen the lines are separated in broad and narrow for lines that can express, narrow and broad lines, broad lines that can only shows broad, narrows the lines that only can show narrow, also narrows are separated between common and uncommon lines. then you can see a list of feii set of lines from those for the classical fitting feii_model is use when the ``fe_mode = \"model\"`` is selected this model is based on the presented in fantasy code REF, you are also able to add your own set of lines that will follow the logic of sheap, see example ?, to see how to do it." ] }, { "cell_type": "markdown", "id": "8c1e128b", "metadata": {}, "source": [ "the RegionBuilder constants are the following ones, as you can see sheap contains a series of assumptions and relation that came from the literature, this are also able to be re-define for the user " ] }, { "cell_type": "code", "execution_count": 22, "id": "be327f73", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(['CII]',\n", " '[NeV]a',\n", " '[NeV]b',\n", " 'OIIIc',\n", " 'OIIIb',\n", " 'NeIIIa',\n", " 'OIIb',\n", " 'OIIa',\n", " '[NeIV]'],\n", " ['Lyalpha', 'CIV', 'AlIII', 'MgII', 'Halpha', 'Hbeta'],\n", " ['template', 'model', 'none'],\n", " ['linear',\n", " 'powerlaw',\n", " 'brokenpowerlaw',\n", " 'logparabola',\n", " 'exp_cutoff',\n", " 'polynomial'],\n", " 1000,\n", " [(('OIIIb', 'OIIIc'),\n", " ['amplitude_OIIIb_component_narrow',\n", " 'amplitude_OIIIc_component_narrow',\n", " '*0.3']),\n", " (('NIIa', 'NIIb'),\n", " ['amplitude_NIIa_component_narrow',\n", " 'amplitude_NIIb_component_narrow',\n", " '*0.3']),\n", " (('NIIa', 'NIIb'),\n", " ['center_NIIa_component_narrow', 'center_NIIb_component_narrow', '*1']),\n", " (('OIIIb', 'OIIIc'),\n", " ['center_OIIIb_component_narrow', 'center_OIIIc_component_narrow'])])" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sheapmodel_class.lines_prone_outflow,sheapmodel_class.lines_prone_winds,sheapmodel_class.available_fe_modes,sheapmodel_class.available_continuum_profiles,sheapmodel_class.LINEAR_RANGE_THRESHOLD,sheapmodel_class.known_tied_relations" ] }, { "cell_type": "markdown", "id": "957f782e", "metadata": {}, "source": [ "The ``ComplexRegion`` class, is the main handler of the clases in sheap, it contains information of the lines, the regions, and how they are co-related between them. Is builded with lines " ] }, { "cell_type": "code", "execution_count": 23, "id": "9c93cfb5", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "SheapModel(lines=[SpectralLine(line_name='Hδ', center=4101.742, region='narrow', component=1, subregion=None, amplitude=1.0, element='Hydrogen', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='Hδ', center=4101.742, region='broad', component=1, subregion=None, amplitude=1.0, element='Hydrogen', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='HeIc', center=4143.761, region='narrow', component=1, subregion=None, amplitude=1.0, element='Helium', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='HeIc', center=4143.761, region='broad', component=1, subregion=None, amplitude=1.0, element='Helium', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='Hg', center=4340.471, region='narrow', component=1, subregion=None, amplitude=1.0, element='Hydrogen', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='Hg', center=4340.471, region='broad', component=1, subregion=None, amplitude=1.0, element='Hydrogen', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='HeId', center=4471.479, region='narrow', component=1, subregion=None, amplitude=1.0, element='Helium', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='HeId', center=4471.479, region='broad', component=1, subregion=None, amplitude=1.0, element='Helium', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='HeIId', center=4685.71, region='narrow', component=1, subregion=None, amplitude=1.0, element='Helium', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='HeIId', center=4685.71, region='broad', component=1, subregion=None, amplitude=1.0, element='Helium', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='Hbeta', center=4861.333, region='narrow', component=1, subregion=None, amplitude=1.0, element='Hydrogen', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='Hbeta', center=4861.333, region='broad', component=1, subregion=None, amplitude=1.0, element='Hydrogen', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None), SpectralLine(line_name='OIIIb', center=4958.896072, region='narrow', component=1, subregion=None, amplitude=1.0, element='Oxygen', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity='common', template_info=None), SpectralLine(line_name='OIIIa', center=4363.213686, region='narrow', component=1, subregion=None, amplitude=1.0, element='Oxygen', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity='common', template_info=None), SpectralLine(line_name='powerlaw', center=None, region='continuum', component=0, subregion=None, amplitude=None, element=None, profile='powerlaw', region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None)], profile_functions=[], profile_names=[], params_dict={}, profile_params_index_list=[], params=None, uncertainty_params=None, original_idx=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], _master_param_names=[], global_profile_params_index_list=[])" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sheapmodel_class.sheapmodel" ] }, { "cell_type": "markdown", "id": "5177d91c", "metadata": {}, "source": [ "And this class is constructed for ``SpectralLines`` DataClasses, if we call the property lines of ``SheapModel``, we can see a list of lines separated for regions, a ``SpectralLines``, is and object defined for his name, the center, the region, the component and the element and in some cases rarity and subregion." ] }, { "cell_type": "code", "execution_count": 24, "id": "494a3d46", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "SpectralLine(line_name='Hδ', center=4101.742, region='narrow', component=1, subregion=None, amplitude=1.0, element='Hydrogen', profile=None, region_lines=None, amplitude_relations=None, subprofile=None, rarity=None, template_info=None)" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sheapmodel_class.sheapmodel.lines[0]" ] }, { "cell_type": "code", "execution_count": null, "id": "0c7e9530", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "74b50963", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "jax", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.8" } }, "nbformat": 4, "nbformat_minor": 5 }