.wrapper\u001b[39m\u001b[34m(*args, **kwargs)\u001b[39m\n\u001b[32m 121\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m hook:\n\u001b[32m 122\u001b[39m hook()\n\u001b[32m--> \u001b[39m\u001b[32m123\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_interfaces/Pyenv/lib/python3.11/site-packages/botocore/client.py:1078\u001b[39m, in \u001b[36mBaseClient._make_api_call\u001b[39m\u001b[34m(self, operation_name, api_params)\u001b[39m\n\u001b[32m 1074\u001b[39m error_code = request_context.get(\n\u001b[32m 1075\u001b[39m \u001b[33m'\u001b[39m\u001b[33merror_code_override\u001b[39m\u001b[33m'\u001b[39m\n\u001b[32m 1076\u001b[39m ) \u001b[38;5;129;01mor\u001b[39;00m error_info.get(\u001b[33m\"\u001b[39m\u001b[33mCode\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 1077\u001b[39m error_class = \u001b[38;5;28mself\u001b[39m.exceptions.from_code(error_code)\n\u001b[32m-> \u001b[39m\u001b[32m1078\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m error_class(parsed_response, operation_name)\n\u001b[32m 1079\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 1080\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m parsed_response\n",
+ "\u001b[31mClientError\u001b[39m: An error occurred (404) when calling the HeadObject operation: Not Found"
+ ]
+ }
+ ],
+ "source": [
+ "#Download the extended sourde response\n",
+ "#Choose the response depending on your model\n",
+ "\n",
+ "#Model for a 511 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC3/Data/Responses/extended_source_response/extended_source_response_511_merged.h5.gz', unzip=True,checksum = 'afcf551d3a8f800a268bef1490d0d48a')\n",
+ "\n",
+ "#Model for a 1157 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC3/Data/Responses/extended_source_response/extended_source_response_Ti44_merged.h5.gz',unzip=True,checksum = '7ac6e1d9651ae33cccf94102f5356d9e')\n",
+ "\n",
+ "#Model for a 1173 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC3/Data/Responses/extended_source_response/extended_source_response_Fe60_low_merged.h5.gz', unzip=True ,checksum = '2562f2ac0be44a60ea2d1adcea8e3b4a')\n",
+ "\n",
+ "#Model for a 1333 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC3/Data/Responses/extended_source_response/extended_source_response_Fe60_high_merged.h5.gz', unzip=True ,checksum = '037217db2e8ca8a9a74a247e8fab9eb3')\n",
+ "\n",
+ "#Model for a 1809 keV line\n",
+ "fetch_wasabi_file('COSI-SMEX/DC3/Data/Responses/extended_source_response/extended_source_response_Al26_merged.h5.gz',unzip=True,checksum = '218d088159c6e11d0ddecc03ca9fa399')\n",
+ "\n",
+ "\n",
+ "#Model for an other line or continuum source\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC3/Data/Responses/extended_source_response/extended_source_response_continuum_merged.h5.gz' ,unzip=True,checksum = 'a3a4a57acfbfe00378507441fa7a5891')\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "8056e551-7058-48dd-b6b0-505391bd5153",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Download the background model \n",
+ "#Choose the file depending on your model\n",
+ "\n",
+ "#Model for a 511 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_511_binned_smoothed_fwhm_10.0deg.hdf5', checksum = '1b437be9b4d9e85a230dfe4f4d2ca67e')\n",
+ "\n",
+ "#Model for a 1157 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_Ti44_binned_smoothed_fwhm_10.0deg.hdf5',checksum = 'bd62bfde46628a6e68434a6c68c7167d')\n",
+ "\n",
+ "#Model for a 1173 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_Fe60_low_binned_smoothed_fwhm_10.0deg.hdf5',checksum = '57f972b0a1c2ece4626c85ced3cc050f')\n",
+ "\n",
+ "#Model for a 1333 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_Fe60_high_binned_smoothed_fwhm_10.0deg.hdf5',checksum = 'db56a9fd9d8fc37cb03fba5e907a80c3')\n",
+ "\n",
+ "#Model for a 1809 keV line\n",
+ "fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_Al26_binned_smoothed_fwhm_10.0deg.hdf5',checksum = 'bd6a32f8abee5b989b87149111487faa')\n",
+ "\n",
+ "\n",
+ "#Model for an other line or continuum source\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_continuum_binned_smoothed_fwhm_10.0deg.hdf5',checksum = 'b06599be5e32a53a6afd96a13e9ff37a')\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "cd9ed8aa-bb64-48cb-bce2-1845936b4faa",
+ "metadata": {},
+ "source": [
+ "# Define your source model\n",
+ "\n",
+ "For an extended source we need to define a spectrum shape and a spatial shape : \n",
+ "\n",
+ "### Spectrum Shape\n",
+ "For this example we are using a Gaussian but other functions can be used (see https://astromodels.readthedocs.io/en/latest/notebooks/function_list.html#Included-1D-Functions) \n",
+ "\n",
+ "Additionaly you can also provide your own spectrum template from a file. See Template (Table) Models in :\n",
+ "https://threeml.readthedocs.io/en/stable/notebooks/spectral_models.html\n",
+ "\n",
+ "Threeml expect the spectrum shape to have units of cm2/s/keV"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "20b2a4fa-3584-4918-84a5-ce38ba06b098",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "F = 3e-5 / u.cm / u.cm / u.s \n",
+ "mu = 1809*u.keV\n",
+ "sigma = 0.3*u.keV\n",
+ "spectrum = Gaussian()\n",
+ "spectrum.F.value = F.value\n",
+ "spectrum.F.unit = F.unit\n",
+ "spectrum.mu.value = mu.value\n",
+ "spectrum.mu.unit = mu.unit\n",
+ "spectrum.sigma.value = sigma.value\n",
+ "spectrum.sigma.unit = sigma.unit\n",
+ "\n",
+ "# Set spectral parameters for fitting:\n",
+ "spectrum.F.free = True\n",
+ "spectrum.mu.free = False\n",
+ "spectrum.sigma.free = False\n",
+ "\n",
+ "#set limit for the param\n",
+ "spectrum.F.min_value = 0\n",
+ "spectrum.F.max_value = 1\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "60650681-5f3a-4f43-9edc-8d81170f90e1",
+ "metadata": {},
+ "source": [
+ "### Spatial shape\n",
+ "\n",
+ "For the spatial shape you need to provide a Healpix map in a fits file. The map should be normalized to the pixel area so that sum(map)*pixelarea = 1 /sr"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "67b5a1ed-1d74-4cb7-8a87-4d7ed03c0efe",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#For this example we will create here the spatial shape model but the fits file containing the spatial distribution can come\n",
+ "#from any source (ex : CLUMPY) \n",
+ "skymap = HealpixMap(nside = 16, scheme = \"ring\", dtype = float, coordsys='G')\n",
+ "skymap[:] = 1 #fill the map with 1, so no particular spatial distribution\n",
+ "\n",
+ "\n",
+ "#normalized the map to 1/sr\n",
+ "pix_area = skymap.pixarea().value\n",
+ "skymap[:] = skymap[:]/(np.sum(skymap)*pix_area)\n",
+ "\n",
+ "\n",
+ "#save the map example to a fits file\n",
+ "skymap.write_map(\"HealpixMap_example.fits\",overwrite=True)\n",
+ "\n",
+ "#declare the spatial shape\n",
+ "spatial_shape = SpatialTemplate_2D_Healpix(fits_file=\"HealpixMap_example.fits\")\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "82513f39-cc7f-4883-a5cf-5f64a4e53d38",
+ "metadata": {},
+ "source": [
+ "## Extended source model\n",
+ "Now that we declare our spectral shape and spatial shape, we can create our extended source model"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "fb001ad1-ba23-4fbe-8176-0cf9fe95dc7a",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "source = ExtendedSource('source', spectral_shape=spectrum, spatial_shape=spatial_shape)\n",
+ "\n",
+ "\n",
+ "model = Model(source) # Model with single source. If we had multiple sources, we would do Model(source1, source2, ...)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "d27be424-4525-476c-afc7-cb3610cbff98",
+ "metadata": {},
+ "source": [
+ "# Open the Response, Orientation and background files"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "5e7d1a4b-13ca-400c-8357-b6a24992c93c",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "WARNING: XDG_CACHE_HOME is set to '/localscratch/.cache/sgallego', but the default location, /uni-mainz.de/homes/sgallego/.astropy/cache, already exists, and takes precedence. This environment variable will be ignored. [astropy.config.paths]\n",
+ "WARNING: XDG_CACHE_HOME is set to '/localscratch/.cache/sgallego', but the default location, /uni-mainz.de/homes/sgallego/.astropy/cache, already exists, and takes precedence. This environment variable will be ignored. [astropy.config.paths]\n"
+ ]
+ }
+ ],
+ "source": [
+ "#open the Response file\n",
+ "\n",
+ "#replace the background and response file by the one you want to use\n",
+ "extendedsourceresponse = \"extended_source_response_Al26_merged.h5\"\n",
+ "bkgfile = \"gal_DC4_bkg_Al26_binned_smoothed_fwhm_10.0deg.hdf5\"\n",
+ "sc_orientation_path = \"DC3_final_530km_3_month_with_slew_15sbins_GalacticEarth_SAA.fits\"\n",
+ "\n",
+ "#open the extended source response\n",
+ "dr = ExtendedSourceResponse.open(data_path / extendedsourceresponse )\n",
+ "\n",
+ "#Create the extended source injector \n",
+ "injector = SourceInjector(response_path=data_path / extendedsourceresponse, response_frame = \"galactic\")\n",
+ "\n",
+ "#open the background model \n",
+ "bg_model = Histogram.open(data_path / bkgfile)\n",
+ "\n",
+ "#open the Orientation file\n",
+ "sc_orientation = SpacecraftHistory.open(data_path / sc_orientation_path)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "dcf349e9-4640-4c11-99ed-df9431ece3e7",
+ "metadata": {},
+ "source": [
+ "# Compute the sensitivity\n",
+ "\n",
+ "The Likelihood (LH) fit is ran hundred times (more would be better but depending on how fast it is you could increase this number).\n",
+ "Each time a new signal dataset is created by convolving the model with the response and applying some poisson statistic (also called the source injector). Similarly for the background, a dataset is created by taking a poisson sample of the background model.\n",
+ "\n",
+ "For each iteration the LH ratio test is computed : \n",
+ "\n",
+ "$$\n",
+ "\\text{LHtest} = -2 * (L_0 - L_1)\n",
+ "$$\n",
+ "\n",
+ "$L_0$ being the LH value for the background only hypothesis and $L_1$ for background+signal . Assuming the Wilk's theorem is applying, the LH ratio test should follow a $\\chi^2$ distribution with dof = nb of parameters. The median value of the LH ratio test distribution should tell us if COSI is sensitive or not to this flux value.\n",
+ "\n",
+ "For our example we have only one parameter we test : the signal strength . So for a 3 $\\sigma$ sensitivity we want to have the median superior or equal to 9.\n",
+ "\n",
+ "Keep in mind we are testing only 3 months of observations but we will scale the flux later to 2 years of observation if it is already sensitive after 3 months."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "8d8cf924-67ba-4b67-b8fa-24b0f4ada9d9",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 0\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "WARNING RuntimeWarning: divide by zero encountered in divide\n",
+ "\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "16:20:06 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m16:20:06\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=945035;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=107889;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Reading Extended source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (1.9 +/- 0.8) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.207 +/- 0.006) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (1.9 +/- 0.8) x 10^-5 1 / (s cm2)\n",
+ "Background (1.207 +/- 0.006) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.71 |
\n",
+ "| -0.71 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.71\n",
+ "-0.71 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 114883.174293119 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 114883.174293119 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 114883.174293119\n",
+ "total 114883.174293119"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 229770.34865134323 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 229790.59744355097 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 229770.34865134323\n",
+ "BIC 229790.59744355097"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 1\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "16:21:14 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m16:21:14\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=846971;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=181297;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "16:21:14 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m16:21:14\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=183926;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=522279;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Reading Extended source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (3.8 +/- 0.9) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.193 +/- 0.007) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (3.8 +/- 0.9) x 10^-5 1 / (s cm2)\n",
+ "Background (1.193 +/- 0.007) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.76 |
\n",
+ "| -0.76 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.76\n",
+ "-0.76 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115225.86038326901 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115225.86038326901 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115225.86038326901\n",
+ "total 115225.86038326901"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 230455.72083164327 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 230475.969623851 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 230455.72083164327\n",
+ "BIC 230475.969623851"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 2\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "16:22:14 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m16:22:14\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=10667;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=113623;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "16:22:14 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m16:22:14\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=206964;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=993405;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Reading Extended source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (3.1 +/- 0.8) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.201 +/- 0.006) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (3.1 +/- 0.8) x 10^-5 1 / (s cm2)\n",
+ "Background (1.201 +/- 0.006) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.71 |
\n",
+ "| -0.71 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.71\n",
+ "-0.71 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115388.38831784404 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115388.38831784404 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115388.38831784404\n",
+ "total 115388.38831784404"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 230780.77670079333 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 230801.02549300107 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 230780.77670079333\n",
+ "BIC 230801.02549300107"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "\n",
+ "# We start with 100 but higher would be better\n",
+ "# To adjust depending on how fast the LH fit is\n",
+ "# You can also run a script in parallel and save the likelihood ratio test\n",
+ "\n",
+ "nbiter = 3 # put this number to 100\n",
+ "\n",
+ "LHratiotest = []\n",
+ "\n",
+ "for i in range(nbiter) :\n",
+ "\n",
+ " print(f\"ITERATION {i}\")\n",
+ " \n",
+ " #create a signal dataset with the source injector\n",
+ " spectrum.F.value = F.value\n",
+ " signal = injector.inject_model(model = model, make_spectrum_plot = False ,data_save_path = None)#,fluctuate=True)\n",
+ "\n",
+ " \n",
+ " #create a bkg dataset from the bkg model\n",
+ " bkg_poissonsamp = Histogram(bg_model.axes)\n",
+ " bkg_poissonsamp[:] += np.random.poisson(lam = bg_model.to_dense()[:])\n",
+ "\n",
+ " # Set background parameter, which is used to fit the amplitude of the background, and instantiate the COSI 3ML plugin\n",
+ " # here we define only one bkg model but we could add more\n",
+ " bkg_dist = {\"Background\":bg_model.project('Em', 'Phi', 'PsiChi')}\n",
+ " \n",
+ " # Workaround to avoid inf values. Out bkg should be smooth, but currently it's not.\n",
+ " for bckfile in bkg_dist.keys() :\n",
+ " bkg_dist[bckfile] += sys.float_info.min\n",
+ "\n",
+ " #combine the data + the bck like we would get for real data\n",
+ " data = EmCDSBinnedData(signal.project('Em', 'Phi', 'PsiChi') \n",
+ " + bkg_poissonsamp.project('Em', 'Phi', 'PsiChi')\n",
+ " )\n",
+ " bkg = FreeNormBinnedBackground(bkg_dist,\n",
+ " sc_history=sc_orientation,\n",
+ " copy = False)\n",
+ "\n",
+ "\n",
+ "\n",
+ " esr = BinnedThreeMLExtendedSourceResponse(data = data,\n",
+ " precomputed_psr = dr,\n",
+ " \n",
+ " polarization_axis = dr.axes['Pol'] if 'Pol' in dr.axes.labels else None,\n",
+ " )\n",
+ "\n",
+ " ##====\n",
+ "\n",
+ "\n",
+ " response = BinnedThreeMLModelFolding(data = data, extended_source_response = esr)\n",
+ "\n",
+ " like_fun = PoissonLikelihood(data, response, bkg)\n",
+ "\n",
+ " cosi = ThreeMLPluginInterface('cosi',\n",
+ " like_fun,\n",
+ " response,\n",
+ " bkg)\n",
+ "\n",
+ " # Nuisance parameter guess, bounds, etc.\n",
+ " cosi.bkg_parameter['Background'] = Parameter(\"Background\", # background parameter\n",
+ " 1, # initial value of parameter\n",
+ " min_value=0, # minimum value of parameter\n",
+ " max_value=10, # maximum value of parameter\n",
+ " delta=0.05, # initial step used by fitting engine\n",
+ " unit = u.Hz\n",
+ " )\n",
+ " \n",
+ " # Set the source Model\n",
+ " cosi.set_model(model)\n",
+ "\n",
+ "\n",
+ " plugins = DataList(cosi) # If we had multiple instruments, we would do e.g. DataList(cosi, lat, hawc, ...)\n",
+ "\n",
+ " like = JointLikelihood(model, plugins, verbose = False)\n",
+ "\n",
+ " #do the fit\n",
+ " like.fit()\n",
+ "\n",
+ " #get L1\n",
+ " L1 = cosi.get_log_like()\n",
+ "\n",
+ " #Get L0\n",
+ " spectrum.F.value = 0 #null hypothesis (no signal)\n",
+ " L0 = cosi.get_log_like()\n",
+ " \n",
+ " #save LH ratio test\n",
+ " LHratiotest.append( -2 * (L0-L1) )\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "77f74ceb-cd5f-4c8d-8653-e40d2be0ecb0",
+ "metadata": {},
+ "source": [
+ "## Plot the LH ratio test\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "id": "02a9f721-b864-453a-8935-32e461b09830",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "COSI is 3 sigma sensitive to 3e-05 ph/cm2/s. You can continue to the next cell\n"
+ ]
+ }
+ ],
+ "source": [
+ "if np.median(LHratiotest) <= 9 :\n",
+ " print(f\"COSI is not sensitive to this model with a flux of {F.value} ph/cm2/s. Please try a lower flux\")\n",
+ "else :\n",
+ " print(f\"COSI is 3 sigma sensitive to {F.value} ph/cm2/s. You can continue to the next cell\")\n",
+ "\n",
+ "fig,ax = plt.subplots()\n",
+ "ax.hist(LHratiotest,bins=30)\n",
+ "ax.axvline(np.median(LHratiotest),label=f\"median {np.median(LHratiotest):.3f}\",color=\"r\",linestyle=\"--\")\n",
+ "ax.legend()\n",
+ "ax.set_xlabel(\"LH ratio test\")\n",
+ "ax.set_ylabel(\"counts\")\n",
+ "ax.set_title(f\"Model - flux {F.value} ph/cm2/s\")\n",
+ "plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "155e30d4-cbc2-4fc0-92bd-03d20339f1f0",
+ "metadata": {},
+ "source": [
+ "## Extrapolate the sensitivity to 2 years\n",
+ "\n",
+ "DC4 simulations only includes 3 months of orbit. To get the sensitivity after 2 years (nominal life time of COSI) as a first approximation we can scale the flux by $\\frac{1}{\\sqrt{T}}$ "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "id": "fbf1883a-1633-4986-9dcc-fd17d021e041",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "3 sigma sensitivity after 2 years of COSI observation : 1.0606601717798212e-05\n"
+ ]
+ }
+ ],
+ "source": [
+ "# 3 * 8 = 24 months = 2 years \n",
+ "\n",
+ "sensi_2y = F.value/np.sqrt(8)\n",
+ "\n",
+ "print(f\"3 sigma sensitivity after 2 years of COSI observation : {sensi_2y}\")\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "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.13.5"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/docs/tutorials/spectral_fits/Sensitivity_calculator/PointSource_Sensitivity.ipynb b/docs/tutorials/spectral_fits/Sensitivity_calculator/PointSource_Sensitivity.ipynb
new file mode 100644
index 000000000..3f641ff89
--- /dev/null
+++ b/docs/tutorials/spectral_fits/Sensitivity_calculator/PointSource_Sensitivity.ipynb
@@ -0,0 +1,4510 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "2148ff56-339e-4831-bcb3-03a36c4738ed",
+ "metadata": {},
+ "source": [
+ "# Point source sensitivity calculator\n",
+ "\n",
+ "This notebook show how to compute a point source sensitivity for a specific model. In the current status of cosipy, we are limited by the available responses, i.e at 511, 1157, 1173, 1333 and 1809 keV and a coarse continuum. Keep in mind that due to the coarseness of the current responses, the sensitivity might be underestimated. \n",
+ "\n",
+ "The collaboration is currently developping a neural network approach for the response to use with an unbinned analysis. This will allow us to fully exploit COSI power. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "2d780467-ec91-481b-90a8-353f9db61ac8",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "21:16:09 WARNING The naima package is not available. Models that depend on it will not be functions.py:43\n",
+ " available \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m21:16:09\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m The naima package is not available. Models that depend on it will not be \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=747474;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/functions/functions_1D/functions.py\u001b\\\u001b[2mfunctions.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=738472;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/functions/functions_1D/functions.py#43\u001b\\\u001b[2m43\u001b[0m\u001b]8;;\u001b\\\n",
+ "\u001b[38;5;46m \u001b[0m \u001b[1;38;5;251mavailable \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[2m \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " WARNING The GSL library or the pygsl wrapper cannot be loaded. Models that depend on it functions.py:65\n",
+ " will not be available. \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m \u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m The GSL library or the pygsl wrapper cannot be loaded. Models that depend on it \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=224155;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/functions/functions_1D/functions.py\u001b\\\u001b[2mfunctions.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=348766;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/functions/functions_1D/functions.py#65\u001b\\\u001b[2m65\u001b[0m\u001b]8;;\u001b\\\n",
+ "\u001b[38;5;46m \u001b[0m \u001b[1;38;5;251mwill not be available. \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[2m \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "21:16:10 WARNING The ebltable package is not available. Models that depend on it will not be absorption.py:33\n",
+ " available \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m21:16:10\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m The ebltable package is not available. Models that depend on it will not be \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=270393;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/functions/functions_1D/absorption.py\u001b\\\u001b[2mabsorption.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=706890;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/functions/functions_1D/absorption.py#33\u001b\\\u001b[2m33\u001b[0m\u001b]8;;\u001b\\\n",
+ "\u001b[38;5;46m \u001b[0m \u001b[1;38;5;251mavailable \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[2m \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "21:16:10 INFO Starting 3ML! __init__.py:44\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m21:16:10\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m Starting 3ML! \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=736423;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py\u001b\\\u001b[2m__init__.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=67732;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py#44\u001b\\\u001b[2m44\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " WARNING WARNINGs here are NOT errors __init__.py:45\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m \u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m WARNINGs here are \u001b[0m\u001b[1;31mNOT\u001b[0m\u001b[1;38;5;251m errors \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=351476;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py\u001b\\\u001b[2m__init__.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=146880;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py#45\u001b\\\u001b[2m45\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " WARNING but are inform you about optional packages that can be installed __init__.py:46\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m \u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m but are inform you about optional packages that can be installed \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=49621;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py\u001b\\\u001b[2m__init__.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=855362;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py#46\u001b\\\u001b[2m46\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " WARNING to disable these messages, turn off start_warning in your config file __init__.py:47\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m \u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m \u001b[0m\u001b[1;31m to disable these messages, turn off start_warning in your config file\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=659028;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py\u001b\\\u001b[2m__init__.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=405429;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py#47\u001b\\\u001b[2m47\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " WARNING no display variable set. using backend for graphics without display (agg) __init__.py:53\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m \u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m no display variable set. using backend for graphics without display \u001b[0m\u001b[1;38;5;251m(\u001b[0m\u001b[1;38;5;251magg\u001b[0m\u001b[1;38;5;251m)\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=531093;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py\u001b\\\u001b[2m__init__.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=601161;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py#53\u001b\\\u001b[2m53\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "21:16:11 WARNING ROOT minimizer not available minimization.py:1208\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m21:16:11\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m ROOT minimizer not available \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=748794;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/minimizer/minimization.py\u001b\\\u001b[2mminimization.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=428206;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/minimizer/minimization.py#1208\u001b\\\u001b[2m1208\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " WARNING Multinest minimizer not available minimization.py:1218\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m \u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m Multinest minimizer not available \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=411250;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/minimizer/minimization.py\u001b\\\u001b[2mminimization.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=833513;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/minimizer/minimization.py#1218\u001b\\\u001b[2m1218\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " WARNING PyGMO is not available minimization.py:1228\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m \u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m PyGMO is not available \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=159681;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/minimizer/minimization.py\u001b\\\u001b[2mminimization.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=911664;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/minimizer/minimization.py#1228\u001b\\\u001b[2m1228\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " WARNING Could not import plugin FermiLATLike.py. Do you have the relative instrument __init__.py:126\n",
+ " software installed and configured? \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m \u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m Could not import plugin FermiLATLike.py. Do you have the relative instrument \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=917805;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py\u001b\\\u001b[2m__init__.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=340721;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/__init__.py#126\u001b\\\u001b[2m126\u001b[0m\u001b]8;;\u001b\\\n",
+ "\u001b[38;5;46m \u001b[0m \u001b[1;38;5;251msoftware installed and configured? \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[2m \u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " WARNING No fermitools installed lat_transient_builder.py:44\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m \u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m No fermitools installed \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=282304;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/utils/data_builders/fermi/lat_transient_builder.py\u001b\\\u001b[2mlat_transient_builder.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=938855;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/utils/data_builders/fermi/lat_transient_builder.py#44\u001b\\\u001b[2m44\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "import os\n",
+ "import logging\n",
+ "import sys\n",
+ "\n",
+ "\n",
+ "\n",
+ "logger = logging.getLogger('cosipy')\n",
+ "logger.setLevel(logging.INFO)\n",
+ "logger.addHandler(logging.StreamHandler(sys.stdout))\n",
+ "\n",
+ "os.environ[\"OMP_NUM_THREADS\"] = \"1\"\n",
+ "os.environ[\"MKL_NUM_THREADS\"] = \"1\"\n",
+ "os.environ[\"NUMEXPR_NUM_THREADS\"] = \"1\"\n",
+ "\n",
+ "\n",
+ "from cosipy.spacecraftfile import SpacecraftHistory\n",
+ "from cosipy.response.FullDetectorResponse import FullDetectorResponse\n",
+ "from cosipy.util import fetch_wasabi_file\n",
+ "\n",
+ "from cosipy.statistics import PoissonLikelihood\n",
+ "from cosipy.background_estimation import FreeNormBinnedBackground\n",
+ "from cosipy.interfaces import ThreeMLPluginInterface\n",
+ "from cosipy.response import BinnedThreeMLModelFolding, BinnedInstrumentResponse, BinnedThreeMLPointSourceResponse\n",
+ "from cosipy.data_io import EmCDSBinnedData\n",
+ "from cosipy.source_injector import SourceInjector\n",
+ "from histpy import Histogram\n",
+ "\n",
+ "\n",
+ "from scoords import SpacecraftFrame\n",
+ "\n",
+ "from astropy.time import Time\n",
+ "import astropy.units as u\n",
+ "from astropy.coordinates import SkyCoord, Galactic\n",
+ "\n",
+ "import numpy as np\n",
+ "import matplotlib.pyplot as plt\n",
+ "\n",
+ "from threeML import *\n",
+ "from astromodels import *\n",
+ "\n",
+ "from pathlib import Path\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "dbe965ab-12fb-40a8-82a5-a4a19510b6e0",
+ "metadata": {},
+ "source": [
+ "# Download the data"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "6b1a4a9d-78cd-4f46-9329-baf31f2c6349",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "data_path = Path(\"\") # /path/to/files. Current dir by default"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "id": "d5b68117-177b-4553-b62e-361bd7d456cd",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Downloading cosi-pipeline-public/COSI-SMEX/develop/Data/Orientation/DC3_final_530km_3_month_with_slew_15sbins_GalacticEarth_SAA.fits\n"
+ ]
+ }
+ ],
+ "source": [
+ "#Download the Orientation file\n",
+ "fetch_wasabi_file('COSI-SMEX/develop/Data/Orientation/DC3_final_530km_3_month_with_slew_15sbins_GalacticEarth_SAA.fits', checksum = 'e86df2407eb052cf0c1db4a8e7598727')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "4ebbb5c4-d144-41af-8aa0-d48aac2b89d3",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Download the response\n",
+ "#Choose the response depending on your model\n",
+ "\n",
+ "#Model for a 511 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/develop/Data/Responses/Response511.o4.e509_513.s20881894470591.m2555.filtered.nonsparse.binnedimaging.imagingresponse.h5',checksum = 'd15cbd03b2cd3d50f3411cd6b8ee362e')\n",
+ "\n",
+ "#Model for a 1157 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Responses/Response44Ti.o4.e1154_1160.s9607532021290.m1215.filtered.nonsparse.binnedimaging.imagingresponse.h5',checksum = 'e965fdf8a7ee50cd6b300bd83778237b')\n",
+ "\n",
+ "#Model for a 1173 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Responses/Response60FeLow.o4.e1170_1176.s9552269354945.m1188.filtered.nonsparse.binnedimaging.imagingresponse.h5',checksum = '76ea57aef5c73d1471e77703935657f1')\n",
+ "\n",
+ "#Model for a 1333 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Responses/Response60FeHigh.o4.e1329_1336.s10201526728102.m1287.filtered.nonsparse.binnedimaging.imagingresponse.h5', checksum = 'b6fe847dd29570a991fc5316d39b3195')\n",
+ "\n",
+ "#Model for a 1809 keV line\n",
+ "fetch_wasabi_file('COSI-SMEX/DC4/Data/Responses/Response26Al.o4.e1805_1812.s10036231691364.m1045.filtered.nonsparse.binnedimaging.imagingresponse.h5',checksum = '4de7c15f95c62698ff139585f5f5cdd1')\n",
+ "\n",
+ "\n",
+ "#Model for an other line or continuum source\n",
+ "#fetch_wasabi_file('COSI-SMEX/develop/Data/Responses/ResponseContinuum.o3.e100_10000.b10log.s10396905069491.m2284.filtered.nonsparse.binnedimaging.imagingresponse.h5',checksum = '16fe005d3ab924ad98322b6579aabf2a')\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "8056e551-7058-48dd-b6b0-505391bd5153",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Download the background model \n",
+ "#Choose the file depending on your model\n",
+ "\n",
+ "#Model for a 511 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_511_binned_smoothed_fwhm_10.0deg.hdf5',checksum = '1b437be9b4d9e85a230dfe4f4d2ca67e')\n",
+ "\n",
+ "#Model for a 1157 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_Ti44_binned_smoothed_fwhm_10.0deg.hdf5',checksum = 'bd62bfde46628a6e68434a6c68c7167d')\n",
+ "\n",
+ "#Model for a 1173 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_Fe60_low_binned_smoothed_fwhm_10.0deg.hdf5',checksum = '57f972b0a1c2ece4626c85ced3cc050f')\n",
+ "\n",
+ "#Model for a 1333 keV line\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_Fe60_high_binned_smoothed_fwhm_10.0deg.hdf5',checksum = 'db56a9fd9d8fc37cb03fba5e907a80c3')\n",
+ "\n",
+ "#Model for a 1809 keV line\n",
+ "fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_Al26_binned_smoothed_fwhm_10.0deg.hdf5',checksum = 'bd6a32f8abee5b989b87149111487faa')\n",
+ "\n",
+ "\n",
+ "#Model for an other line or continuum source\n",
+ "#fetch_wasabi_file('COSI-SMEX/DC4/Data/Backgrounds/gal_DC4_bkg_continuum_binned_smoothed_fwhm_10.0deg.hdf5',checksum = 'b06599be5e32a53a6afd96a13e9ff37a')\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "cd9ed8aa-bb64-48cb-bce2-1845936b4faa",
+ "metadata": {},
+ "source": [
+ "# Define your source model\n",
+ "\n",
+ "For this example we are using a Gaussian but other functions can be used (see https://astromodels.readthedocs.io/en/latest/notebooks/function_list.html#Included-1D-Functions) \n",
+ "\n",
+ "Additionaly you can also provide your own spectrum template from a file. See Template (Table) Models in :\n",
+ "https://threeml.readthedocs.io/en/stable/notebooks/spectral_models.html\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "id": "20b2a4fa-3584-4918-84a5-ce38ba06b098",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Position in Galactic coord of the source\n",
+ "l = 184.56 \n",
+ "b = -5.78\n",
+ "\n",
+ "F = 3e-5 / u.cm / u.cm / u.s \n",
+ "mu = 1809*u.keV\n",
+ "sigma = 0.3*u.keV\n",
+ "spectrum = Gaussian()\n",
+ "spectrum.F.value = F.value\n",
+ "spectrum.F.unit = F.unit\n",
+ "spectrum.mu.value = mu.value\n",
+ "spectrum.mu.unit = mu.unit\n",
+ "spectrum.sigma.value = sigma.value\n",
+ "spectrum.sigma.unit = sigma.unit\n",
+ "\n",
+ "# Set spectral parameters for fitting:\n",
+ "spectrum.F.free = True\n",
+ "spectrum.mu.free = False\n",
+ "spectrum.sigma.free = False\n",
+ "\n",
+ "#set limit for the param\n",
+ "spectrum.F.min_value = 0\n",
+ "spectrum.F.max_value = 1\n",
+ "\n",
+ "\n",
+ "source = PointSource(\"source\", # Name of source (arbitrary, but needs to be unique)\n",
+ " l=l, # Longitude (deg)\n",
+ " b=b, # Latitude (deg)\n",
+ " spectral_shape=spectrum) # Spectral model\n",
+ "\n",
+ "model = Model(source) # Model with single source. If we had multiple sources, we would do Model(source1, source2, ...)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "d27be424-4525-476c-afc7-cb3610cbff98",
+ "metadata": {},
+ "source": [
+ "# Open the Response, Orientation and background files"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "id": "5e7d1a4b-13ca-400c-8357-b6a24992c93c",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#open the Response file\n",
+ "\n",
+ "#replace the background and response file by the one you want to use\n",
+ "responsefile = \"Response26Al.o4.e1805_1812.s10036231691364.m1045.filtered.nonsparse.binnedimaging.imagingresponse.h5\"\n",
+ "bkgfile = \"gal_DC4_bkg_Al26_binned_smoothed_fwhm_10.0deg.hdf5\"\n",
+ "sc_orientation_path = \"DC3_final_530km_3_month_with_slew_15sbins_GalacticEarth_SAA.fits\"\n",
+ "\n",
+ "dr = FullDetectorResponse.open(data_path / responsefile)\n",
+ "\n",
+ "#Create the point source injector \n",
+ "injector = SourceInjector(response_path=data_path / responsefile, response_frame = \"spacecraftframe\")\n",
+ "\n",
+ "#open the background model \n",
+ "bg_model = Histogram.open(data_path / bkgfile)\n",
+ "\n",
+ "#open the Orientation file\n",
+ "sc_orientation = SpacecraftHistory.open(data_path / sc_orientation_path)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "dcf349e9-4640-4c11-99ed-df9431ece3e7",
+ "metadata": {},
+ "source": [
+ "# Compute the sensitivity\n",
+ "\n",
+ "The Likelihood (LH) fit is ran hundred times (more would be better but depending on how fast it is you could increase this number).\n",
+ "Each time a new signal dataset is created by convolving the model with the response and applying some poisson statistic (also called the source injector). Similarly for the background, a dataset is created by taking a poisson sample of the background model.\n",
+ "\n",
+ "For each iteration the LH ratio test is computed : \n",
+ "\n",
+ "$$\n",
+ "\\text{LHtest} = -2 * (L_0 - L_1)\n",
+ "$$\n",
+ "\n",
+ "$L_0$ being the LH value for the background only hypothesis and $L_1$ for background+signal . Assuming the Wilk's theorem is applying, the LH ratio test should follow a $\\chi^2$ distribution with dof = nb of parameters. The median value of the LH ratio test distribution should tell us if COSI is sensitive or not to this flux value.\n",
+ "\n",
+ "For our example we have only one parameter we test : the signal strength . So for a 3 $\\sigma$ sensitivity we want to have the median superior or equal to 9.\n",
+ "\n",
+ "Keep in mind we are testing only 3 months of observations but we will scale the flux later to 2 years of observation if it is already sensitive after 3 months."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "id": "8d8cf924-67ba-4b67-b8fa-24b0f4ada9d9",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 0\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:28:13 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:28:13\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=701356;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=815002;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:28:13 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:28:13\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=405724;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=31944;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (3.10 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.206 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (3.10 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.206 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115497.5498985843 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115497.5498985843 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115497.5498985843\n",
+ "total 115497.5498985843"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 230999.09986227384 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 231019.34865448158 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 230999.09986227384\n",
+ "BIC 231019.34865448158"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 1\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:28:58 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:28:58\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=262470;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=295987;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:28:58 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:28:58\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=486764;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=994377;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (2.48 +/- 0.23) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.208 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (2.48 +/- 0.23) x 10^-5 1 / (s cm2)\n",
+ "Background (1.208 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.33 |
\n",
+ "| -0.33 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.33\n",
+ "-0.33 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115252.6117889455 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115252.6117889455 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115252.6117889455\n",
+ "total 115252.6117889455"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 230509.22364299625 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 230529.472435204 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 230509.22364299625\n",
+ "BIC 230529.472435204"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 2\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:29:41 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:29:41\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=780462;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=802309;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:29:41 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:29:41\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=847061;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=269341;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (2.92 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.208 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (2.92 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.208 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115575.47694670629 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115575.47694670629 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115575.47694670629\n",
+ "total 115575.47694670629"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 231154.9539585178 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 231175.20275072556 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 231154.9539585178\n",
+ "BIC 231175.20275072556"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 3\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:30:22 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:30:22\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=120677;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=15341;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:30:22 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:30:22\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=434562;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=876953;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (3.05 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.195 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (3.05 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.195 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115521.81674415742 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115521.81674415742 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115521.81674415742\n",
+ "total 115521.81674415742"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 231047.63355342008 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 231067.88234562782 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 231047.63355342008\n",
+ "BIC 231067.88234562782"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 4\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:31:04 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:31:04\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=181114;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=541360;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:31:04 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:31:04\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=305716;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=920416;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (3.08 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.197 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (3.08 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.197 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115020.99338241357 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115020.99338241357 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115020.99338241357\n",
+ "total 115020.99338241357"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 230045.98682993237 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 230066.2356221401 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 230045.98682993237\n",
+ "BIC 230066.2356221401"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 5\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:31:46 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:31:46\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=522269;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=121972;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:31:46 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:31:46\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=948791;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=275961;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (2.50 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.199 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (2.50 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.199 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115023.81827912811 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115023.81827912811 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115023.81827912811\n",
+ "total 115023.81827912811"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 230051.63662336147 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 230071.8854155692 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 230051.63662336147\n",
+ "BIC 230071.8854155692"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 6\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:32:28 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:32:28\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=180631;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=338639;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:32:28 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:32:28\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=461603;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=527045;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (2.92 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.201 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (2.92 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.201 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115456.61260147138 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115456.61260147138 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115456.61260147138\n",
+ "total 115456.61260147138"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 230917.225268048 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 230937.47406025574 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 230917.225268048\n",
+ "BIC 230937.47406025574"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 7\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:33:10 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:33:10\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=171432;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=412988;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:33:10 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:33:10\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=662902;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=694309;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (3.09 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.199 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (3.09 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.199 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115529.50454836372 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115529.50454836372 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115529.50454836372\n",
+ "total 115529.50454836372"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 231063.00916183268 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 231083.25795404043 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 231063.00916183268\n",
+ "BIC 231083.25795404043"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 8\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:33:52 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:33:52\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=872463;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=920200;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:33:52 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:33:52\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=338766;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=233276;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (2.88 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.209 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (2.88 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.209 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115856.26172249179 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115856.26172249179 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115856.26172249179\n",
+ "total 115856.26172249179"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 231716.52351008882 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 231736.77230229657 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 231716.52351008882\n",
+ "BIC 231736.77230229657"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 9\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:34:35 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:34:35\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=427216;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=467944;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:34:35 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:34:35\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=27428;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=448469;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (2.75 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.206 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (2.75 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.206 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115547.93606677087 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115547.93606677087 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115547.93606677087\n",
+ "total 115547.93606677087"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 231099.87219864698 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 231120.12099085472 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 231099.87219864698\n",
+ "BIC 231120.12099085472"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 10\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:35:17 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:35:17\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=210179;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=264782;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:35:17 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:35:17\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=122684;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=378554;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (3.34 +/- 0.25) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.199 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (3.34 +/- 0.25) x 10^-5 1 / (s cm2)\n",
+ "Background (1.199 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115421.88146860251 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115421.88146860251 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115421.88146860251\n",
+ "total 115421.88146860251"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 230847.76300231027 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 230868.011794518 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 230847.76300231027\n",
+ "BIC 230868.011794518"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 11\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:36:01 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:36:01\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=506751;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=148102;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:36:01 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:36:01\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=609749;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=552205;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (3.17 +/- 0.25) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.194 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (3.17 +/- 0.25) x 10^-5 1 / (s cm2)\n",
+ "Background (1.194 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.35 |
\n",
+ "| -0.35 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.35\n",
+ "-0.35 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 114894.91206004971 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 114894.91206004971 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 114894.91206004971\n",
+ "total 114894.91206004971"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 229793.82418520466 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 229814.0729774124 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 229793.82418520466\n",
+ "BIC 229814.0729774124"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 12\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:36:43 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:36:43\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=248605;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=229322;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:36:43 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:36:43\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=837414;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=47955;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (3.15 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.206 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (3.15 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.206 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115354.46943402829 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115354.46943402829 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115354.46943402829\n",
+ "total 115354.46943402829"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 230712.93893316181 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 230733.18772536956 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 230712.93893316181\n",
+ "BIC 230733.18772536956"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 13\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:37:25 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:37:25\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=963842;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=448791;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:37:25 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:37:25\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=897355;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=867455;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n",
+ "--> done (source name : source)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "Best fit values:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1;4;38;5;49mBest fit values:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " result | \n",
+ " unit | \n",
+ "
\n",
+ " \n",
+ " | parameter | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | source.spectrum.main.Gaussian.F | \n",
+ " (2.92 +/- 0.24) x 10^-5 | \n",
+ " 1 / (s cm2) | \n",
+ "
\n",
+ " \n",
+ " | Background | \n",
+ " (1.206 +/- 0.005) x 10^-2 | \n",
+ " Hz | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " result unit\n",
+ "parameter \n",
+ "source.spectrum.main.Gaussian.F (2.92 +/- 0.24) x 10^-5 1 / (s cm2)\n",
+ "Background (1.206 +/- 0.005) x 10^-2 Hz"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Correlation matrix:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mCorrelation matrix:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "| 1.00 | -0.34 |
\n",
+ "| -0.34 | 1.00 |
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 1.00 -0.34\n",
+ "-0.34 1.00"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of -log(likelihood) at the minimum:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of -\u001b[0m\u001b[1;4;38;5;49mlog\u001b[0m\u001b[1;4;38;5;49m(\u001b[0m\u001b[1;4;38;5;49mlikelihood\u001b[0m\u001b[1;4;38;5;49m)\u001b[0m\u001b[1;4;38;5;49m at the minimum:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " -log(likelihood) | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | cosi | \n",
+ " 115404.58125634972 | \n",
+ "
\n",
+ " \n",
+ " | total | \n",
+ " 115404.58125634972 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " -log(likelihood)\n",
+ "cosi 115404.58125634972\n",
+ "total 115404.58125634972"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "Values of statistical measures:\n",
+ "\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ "\u001b[1;4;38;5;49mValues of statistical measures:\u001b[0m\n",
+ "\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " statistical measures | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | AIC | \n",
+ " 230813.16257780467 | \n",
+ "
\n",
+ " \n",
+ " | BIC | \n",
+ " 230833.4113700124 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " statistical measures\n",
+ "AIC 230813.16257780467\n",
+ "BIC 230833.4113700124"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ITERATION 14\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:38:07 WARNING External parameter Background already exist in the model. Overwriting it... model.py:593\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:38:07\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;134mWARNING \u001b[0m \u001b[1;38;5;251m External parameter Background already exist in the model. Overwriting it\u001b[0m\u001b[1;33m...\u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=426710;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py\u001b\\\u001b[2mmodel.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=849028;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astromodels/core/model.py#593\u001b\\\u001b[2m593\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "22:38:07 INFO set the minimizer to minuit joint_likelihood.py:1017\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[38;5;46m22:38:07\u001b[0m\u001b[38;5;46m \u001b[0m\u001b[38;5;49mINFO \u001b[0m \u001b[1;38;5;251m set the minimizer to minuit \u001b[0m\u001b[1;38;5;251m \u001b[0m\u001b]8;id=666317;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py\u001b\\\u001b[2mjoint_likelihood.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=414449;file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py#1017\u001b\\\u001b[2m1017\u001b[0m\u001b]8;;\u001b\\\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "... Calculating point source response ...\n"
+ ]
+ },
+ {
+ "ename": "KeyboardInterrupt",
+ "evalue": "",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
+ "\u001b[31mKeyboardInterrupt\u001b[39m Traceback (most recent call last)",
+ "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[33]\u001b[39m\u001b[32m, line 78\u001b[39m\n\u001b[32m 75\u001b[39m like = JointLikelihood(model, plugins, verbose = \u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[32m 77\u001b[39m \u001b[38;5;66;03m#do the fit\u001b[39;00m\n\u001b[32m---> \u001b[39m\u001b[32m78\u001b[39m \u001b[43mlike\u001b[49m\u001b[43m.\u001b[49m\u001b[43mfit\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 80\u001b[39m \u001b[38;5;66;03m#get L1\u001b[39;00m\n\u001b[32m 81\u001b[39m L1 = cosi.get_log_like()\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py:346\u001b[39m, in \u001b[36mJointLikelihood.fit\u001b[39m\u001b[34m(self, quiet, compute_covariance, n_samples)\u001b[39m\n\u001b[32m 342\u001b[39m \u001b[38;5;66;03m# Perform the fit, but first flush stdout (so if we have verbose=True the\u001b[39;00m\n\u001b[32m 343\u001b[39m \u001b[38;5;66;03m# messages there will follow what is already in the buffer)\u001b[39;00m\n\u001b[32m 344\u001b[39m sys.stdout.flush()\n\u001b[32m--> \u001b[39m\u001b[32m346\u001b[39m xs, log_likelihood_minimum = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_minimizer\u001b[49m\u001b[43m.\u001b[49m\u001b[43mminimize\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 347\u001b[39m \u001b[43m \u001b[49m\u001b[43mcompute_covar\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcompute_covariance\u001b[49m\n\u001b[32m 348\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 350\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m log_likelihood_minimum == minimization.FIT_FAILED:\n\u001b[32m 351\u001b[39m log.error(\u001b[33m\"\u001b[39m\u001b[33mThe fit failed to converge.\u001b[39m\u001b[33m\"\u001b[39m)\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/minimizer/minimization.py:560\u001b[39m, in \u001b[36mMinimizer.minimize\u001b[39m\u001b[34m(self, compute_covar)\u001b[39m\n\u001b[32m 556\u001b[39m \u001b[38;5;66;03m# Gather the best fit values from the minimizer and the covariance matrix (if\u001b[39;00m\n\u001b[32m 557\u001b[39m \u001b[38;5;66;03m# provided)\u001b[39;00m\n\u001b[32m 559\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m560\u001b[39m internal_best_fit_values, function_minimum = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_minimize\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 562\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m FitFailed:\n\u001b[32m 563\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/minimizer/minuit_minimizer.py:187\u001b[39m, in \u001b[36mMinuitMinimizer._minimize\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 184\u001b[39m \u001b[38;5;66;03m# Try a maximum of 10 times and break as soon as the fit is ok\u001b[39;00m\n\u001b[32m 186\u001b[39m \u001b[38;5;28mself\u001b[39m.minuit.reset()\n\u001b[32m--> \u001b[39m\u001b[32m187\u001b[39m \u001b[38;5;28mself\u001b[39m._last_migrad_results = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mminuit\u001b[49m\u001b[43m.\u001b[49m\u001b[43mmigrad\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 189\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[32m9\u001b[39m):\n\u001b[32m 190\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.minuit.valid:\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/iminuit/minuit.py:852\u001b[39m, in \u001b[36mMinuit.migrad\u001b[39m\u001b[34m(self, ncall, iterate, use_simplex)\u001b[39m\n\u001b[32m 850\u001b[39m t = mutil._Timer(\u001b[38;5;28mself\u001b[39m._fmin)\n\u001b[32m 851\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m t:\n\u001b[32m--> \u001b[39m\u001b[32m852\u001b[39m fm = \u001b[43m_robust_low_level_fit\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 853\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_fcn\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 854\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_last_state\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 855\u001b[39m \u001b[43m \u001b[49m\u001b[43mreplace_none\u001b[49m\u001b[43m(\u001b[49m\u001b[43mncall\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[32;43m0\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 856\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_strategy\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 857\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_tolerance\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 858\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_precision\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 859\u001b[39m \u001b[43m \u001b[49m\u001b[43miterate\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 860\u001b[39m \u001b[43m \u001b[49m\u001b[43muse_simplex\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 861\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 863\u001b[39m \u001b[38;5;28mself\u001b[39m._last_state = fm.state\n\u001b[32m 865\u001b[39m \u001b[38;5;28mself\u001b[39m._fmin = mutil.FMin(\n\u001b[32m 866\u001b[39m fm,\n\u001b[32m 867\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mMigrad\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m (...)\u001b[39m\u001b[32m 874\u001b[39m t.value,\n\u001b[32m 875\u001b[39m )\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/iminuit/minuit.py:2863\u001b[39m, in \u001b[36m_robust_low_level_fit\u001b[39m\u001b[34m(fcn, state, ncall, strategy, tolerance, precision, iterate, use_simplex)\u001b[39m\n\u001b[32m 2861\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m precision \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m 2862\u001b[39m migrad.precision = precision\n\u001b[32m-> \u001b[39m\u001b[32m2863\u001b[39m fm = \u001b[43mmigrad\u001b[49m\u001b[43m(\u001b[49m\u001b[43mncall\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtolerance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 2864\u001b[39m strategy = MnStrategy(\u001b[32m2\u001b[39m)\n\u001b[32m 2865\u001b[39m migrad = MnMigrad(fcn, fm.state, strategy)\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py:70\u001b[39m, in \u001b[36m_WeakMinusLogLikeProxy.__call__\u001b[39m\u001b[34m(self, *trial_values)\u001b[39m\n\u001b[32m 67\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m jl \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m 68\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m minimization.FIT_FAILED\n\u001b[32m---> \u001b[39m\u001b[32m70\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mjl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mminus_log_like_profile\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43mtrial_values\u001b[49m\u001b[43m)\u001b[49m\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/threeML/classicMLE/joint_likelihood.py:955\u001b[39m, in \u001b[36mJointLikelihood.minus_log_like_profile\u001b[39m\u001b[34m(self, *trial_values)\u001b[39m\n\u001b[32m 953\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m dataset \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mlist\u001b[39m(\u001b[38;5;28mself\u001b[39m._data_list.values()):\n\u001b[32m 954\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m955\u001b[39m this_log_like = \u001b[43mdataset\u001b[49m\u001b[43m.\u001b[49m\u001b[43minner_fit\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 957\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m ModelAssertionViolation:\n\u001b[32m 958\u001b[39m \u001b[38;5;66;03m# This is a zone of the parameter space which is not allowed. Return\u001b[39;00m\n\u001b[32m 959\u001b[39m \u001b[38;5;66;03m# a big number for the likelihood so that the fit engine will avoid it\u001b[39;00m\n\u001b[32m 961\u001b[39m log.warning(\n\u001b[32m 962\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mFitting engine in forbidden space: \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[33m\"\u001b[39m % (trial_values,),\n\u001b[32m 963\u001b[39m )\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/cosipy/interfaces/threeml_plugin_interface.py:112\u001b[39m, in \u001b[36mThreeMLPluginInterface.inner_fit\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 106\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34minner_fit\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[32m 107\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 108\u001b[39m \u001b[33;03m Required for 3ML fit.\u001b[39;00m\n\u001b[32m 109\u001b[39m \n\u001b[32m 110\u001b[39m \u001b[33;03m Maybe in the future use fast norm fit to minimize the background normalization\u001b[39;00m\n\u001b[32m 111\u001b[39m \u001b[33;03m \"\"\"\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m112\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mget_log_like\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/cosipy/interfaces/threeml_plugin_interface.py:104\u001b[39m, in \u001b[36mThreeMLPluginInterface.get_log_like\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 100\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mget_log_like\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[32m 101\u001b[39m \u001b[38;5;66;03m# Update underlying background object in case the Parameter objects changed internally\u001b[39;00m\n\u001b[32m 102\u001b[39m \u001b[38;5;28mself\u001b[39m._update_bkg_parameters()\n\u001b[32m--> \u001b[39m\u001b[32m104\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_like\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_log_like\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/cosipy/statistics/likelihood_functions.py:108\u001b[39m, in \u001b[36mPoissonLikelihood.get_log_like\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 103\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mget_log_like\u001b[39m(\u001b[38;5;28mself\u001b[39m) -> \u001b[38;5;28mfloat\u001b[39m:\n\u001b[32m 104\u001b[39m \n\u001b[32m 105\u001b[39m \u001b[38;5;66;03m# Compute expectation including background\u001b[39;00m\n\u001b[32m 106\u001b[39m \u001b[38;5;66;03m# If we don't have background, we won't modify the expectation, so\u001b[39;00m\n\u001b[32m 107\u001b[39m \u001b[38;5;66;03m# it's safe to use the internal cache.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m108\u001b[39m expectation = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_response\u001b[49m\u001b[43m.\u001b[49m\u001b[43mexpectation\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcopy\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mhas_bkg\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 110\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.has_bkg:\n\u001b[32m 111\u001b[39m \u001b[38;5;66;03m# We won't modify the bkg expectation, so it's safe to use the internal cache\u001b[39;00m\n\u001b[32m 112\u001b[39m expectation += \u001b[38;5;28mself\u001b[39m._bkg.expectation(copy = \u001b[38;5;28;01mFalse\u001b[39;00m)\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/cosipy/response/threeml_response.py:191\u001b[39m, in \u001b[36mBinnedThreeMLModelFolding.expectation\u001b[39m\u001b[34m(self, copy)\u001b[39m\n\u001b[32m 189\u001b[39m \u001b[38;5;66;03m# Convolve all sources with the response\u001b[39;00m\n\u001b[32m 190\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m source_name,psr \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m._source_responses.items():\n\u001b[32m--> \u001b[39m\u001b[32m191\u001b[39m \u001b[38;5;28mself\u001b[39m._expectation += \u001b[43mpsr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mexpectation\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 193\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m copy:\n\u001b[32m 194\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._expectation.copy()\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/cosipy/response/threeml_point_source_response.py:196\u001b[39m, in \u001b[36mBinnedThreeMLPointSourceResponse.expectation\u001b[39m\u001b[34m(self, copy)\u001b[39m\n\u001b[32m 189\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 190\u001b[39m \u001b[38;5;66;03m# Inertial e..g. galactic\u001b[39;00m\n\u001b[32m 192\u001b[39m scatt_map = \u001b[38;5;28mself\u001b[39m._sc_ori.get_scatt_map(nside=\u001b[38;5;28mself\u001b[39m._nside,\n\u001b[32m 193\u001b[39m target_coord=coord,\n\u001b[32m 194\u001b[39m earth_occ=\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[32m--> \u001b[39m\u001b[32m196\u001b[39m \u001b[38;5;28mself\u001b[39m._psr = \u001b[43mPointSourceResponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mfrom_scatt_map\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcoord\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 197\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_data\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 198\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_response\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 199\u001b[39m \u001b[43m \u001b[49m\u001b[43mscatt_map\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 200\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_energy_axis\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 201\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_polarization_axis\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 203\u001b[39m logger.info(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m--> done (source name : \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m._source.name\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m)\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 205\u001b[39m \u001b[38;5;66;03m# Convolve with spectrum\u001b[39;00m\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/cosipy/response/PointSourceResponse.py:200\u001b[39m, in \u001b[36mPointSourceResponse.from_scatt_map\u001b[39m\u001b[34m(cls, coord, data, response, scatt_map, energy_axis, polarization_axis)\u001b[39m\n\u001b[32m 196\u001b[39m psr = Quantity(np.zeros(shape=axes.shape), unit = u.cm * u.cm * u.s)\n\u001b[32m 198\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m att, exposure \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(scatt_map.attitudes, scatt_map.weights):\n\u001b[32m--> \u001b[39m\u001b[32m200\u001b[39m \u001b[43mresponse\u001b[49m\u001b[43m.\u001b[49m\u001b[43mdifferential_effective_area\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcoord\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 201\u001b[39m \u001b[43m \u001b[49m\u001b[43menergy_axis\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcenters\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 202\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mpolarization_axis\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mis\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mpolarization_axis\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 203\u001b[39m \u001b[43m \u001b[49m\u001b[43mattitude\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43matt\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 204\u001b[39m \u001b[43m \u001b[49m\u001b[43mweight\u001b[49m\u001b[43m=\u001b[49m\u001b[43mexposure\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 205\u001b[39m \u001b[43m \u001b[49m\u001b[43mout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mpsr\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 206\u001b[39m \u001b[43m \u001b[49m\u001b[43madd_inplace\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[32m 208\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m PointSourceResponse(axes, contents = psr)\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/cosipy/response/instrument_response.py:122\u001b[39m, in \u001b[36mBinnedInstrumentResponse.differential_effective_area\u001b[39m\u001b[34m(self, direction, energy, polarization, attitude, time, weight, out, add_inplace)\u001b[39m\n\u001b[32m 119\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m attitude \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m 120\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\u001b[33m\"\u001b[39m\u001b[33mUser need to provide the attitude information in order to transform to spacecraft coordinates\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m--> \u001b[39m\u001b[32m122\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_differential_effective_area_inertial\u001b[49m\u001b[43m(\u001b[49m\u001b[43mattitude\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43maxes\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdirection\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpolarization\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mweight\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mout\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43madd_inplace\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 124\u001b[39m \u001b[38;5;66;03m# Is local\u001b[39;00m\n\u001b[32m 125\u001b[39m \n\u001b[32m 126\u001b[39m \u001b[38;5;66;03m# Check again remaining axes\u001b[39;00m\n\u001b[32m 127\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m._dr.measurement_axes[\u001b[33m\"\u001b[39m\u001b[33mPsiChi\u001b[39m\u001b[33m\"\u001b[39m] != \u001b[38;5;28mself\u001b[39m.axes[\u001b[33m\"\u001b[39m\u001b[33mPsiChi\u001b[39m\u001b[33m\"\u001b[39m]:\n\u001b[32m 128\u001b[39m \u001b[38;5;66;03m# Matches the v0.3 behaviour\u001b[39;00m\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/cosipy/response/instrument_response.py:255\u001b[39m, in \u001b[36mBinnedInstrumentResponse._differential_effective_area_inertial\u001b[39m\u001b[34m(self, attitude, axes, direction, polarization, weight, out, add_inplace)\u001b[39m\n\u001b[32m 251\u001b[39m phi = np.arccos(c_z)\n\u001b[32m 253\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m (phi, theta)\n\u001b[32m--> \u001b[39m\u001b[32m255\u001b[39m rot = \u001b[43mattitude\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtransform_to\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43micrs\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m)\u001b[49m.rot.inv().as_matrix()\n\u001b[32m 257\u001b[39m src_cart = direction.transform_to(\u001b[33m'\u001b[39m\u001b[33micrs\u001b[39m\u001b[33m'\u001b[39m).cartesian.xyz.value\n\u001b[32m 258\u001b[39m loc_src_colat, loc_src_lon = rotate_coords(src_cart, rot)\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/scoords/attitude.py:230\u001b[39m, in \u001b[36mAttitude.transform_to\u001b[39m\u001b[34m(self, frame)\u001b[39m\n\u001b[32m 226\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m deepcopy(\u001b[38;5;28mself\u001b[39m)\n\u001b[32m 228\u001b[39m axes = \u001b[38;5;28mself\u001b[39m.as_axes()\n\u001b[32m--> \u001b[39m\u001b[32m230\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mfrom_axes\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43maxes\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mframe\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43mframe\u001b[49m\u001b[43m)\u001b[49m\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/scoords/attitude.py:163\u001b[39m, in \u001b[36mAttitude.from_axes\u001b[39m\u001b[34m(cls, x, y, z, frame)\u001b[39m\n\u001b[32m 161\u001b[39m y = y.transform_to(frame).represent_as(\u001b[33m'\u001b[39m\u001b[33mcartesian\u001b[39m\u001b[33m'\u001b[39m)\n\u001b[32m 162\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m z \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m163\u001b[39m z = \u001b[43mz\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtransform_to\u001b[49m\u001b[43m(\u001b[49m\u001b[43mframe\u001b[49m\u001b[43m)\u001b[49m.represent_as(\u001b[33m'\u001b[39m\u001b[33mcartesian\u001b[39m\u001b[33m'\u001b[39m)\n\u001b[32m 165\u001b[39m \u001b[38;5;66;03m# Get the missing axis if needed\u001b[39;00m\n\u001b[32m 166\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m([i \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m [x,y,z] \u001b[38;5;28;01mif\u001b[39;00m i \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m]) > \u001b[32m1\u001b[39m:\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astropy/coordinates/sky_coordinate.py:551\u001b[39m, in \u001b[36mSkyCoord.transform_to\u001b[39m\u001b[34m(self, frame, merge_attributes)\u001b[39m\n\u001b[32m 547\u001b[39m generic_frame = GenericFrame(frame_kwargs)\n\u001b[32m 549\u001b[39m \u001b[38;5;66;03m# Do the transformation, returning a coordinate frame of the desired\u001b[39;00m\n\u001b[32m 550\u001b[39m \u001b[38;5;66;03m# final type (not generic).\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m551\u001b[39m new_coord = \u001b[43mtrans\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mframe\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mgeneric_frame\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 553\u001b[39m \u001b[38;5;66;03m# Finally make the new SkyCoord object from the `new_coord` and\u001b[39;00m\n\u001b[32m 554\u001b[39m \u001b[38;5;66;03m# remaining frame_kwargs that are not frame_attributes in `new_coord`.\u001b[39;00m\n\u001b[32m 555\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m attr \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mset\u001b[39m(new_coord.frame_attributes) & \u001b[38;5;28mset\u001b[39m(frame_kwargs.keys()):\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astropy/coordinates/transformations/composite.py:113\u001b[39m, in \u001b[36mCompositeTransform.__call__\u001b[39m\u001b[34m(self, fromcoord, toframe)\u001b[39m\n\u001b[32m 110\u001b[39m frattrs[inter_frame_attr_nm] = attr\n\u001b[32m 112\u001b[39m curr_toframe = t.tosys(**frattrs)\n\u001b[32m--> \u001b[39m\u001b[32m113\u001b[39m curr_coord = \u001b[43mt\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcurr_coord\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcurr_toframe\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 115\u001b[39m \u001b[38;5;66;03m# this is safe even in the case where self.transforms is empty, because\u001b[39;00m\n\u001b[32m 116\u001b[39m \u001b[38;5;66;03m# coordinate objects are immutable, so copying is not needed\u001b[39;00m\n\u001b[32m 117\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m curr_coord\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astropy/coordinates/transformations/affine.py:204\u001b[39m, in \u001b[36mBaseAffineTransform.__call__\u001b[39m\u001b[34m(self, fromcoord, toframe)\u001b[39m\n\u001b[32m 203\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__call__\u001b[39m(\u001b[38;5;28mself\u001b[39m, fromcoord, toframe):\n\u001b[32m--> \u001b[39m\u001b[32m204\u001b[39m params = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_affine_params\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfromcoord\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtoframe\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 205\u001b[39m newrep = \u001b[38;5;28mself\u001b[39m._apply_transform(fromcoord, *params)\n\u001b[32m 206\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m toframe.realize_frame(newrep)\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astropy/coordinates/transformations/affine.py:352\u001b[39m, in \u001b[36mDynamicMatrixTransform._affine_params\u001b[39m\u001b[34m(self, fromcoord, toframe)\u001b[39m\n\u001b[32m 351\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m_affine_params\u001b[39m(\u001b[38;5;28mself\u001b[39m, fromcoord, toframe):\n\u001b[32m--> \u001b[39m\u001b[32m352\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mmatrix_func\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfromcoord\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtoframe\u001b[49m\u001b[43m)\u001b[49m, \u001b[38;5;28;01mNone\u001b[39;00m\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astropy/coordinates/builtin_frames/icrs_fk5_transforms.py:44\u001b[39m, in \u001b[36mfk5_to_icrs\u001b[39m\u001b[34m(fk5coord, icrsframe)\u001b[39m\n\u001b[32m 40\u001b[39m \u001b[38;5;129m@frame_transform_graph\u001b[39m.transform(DynamicMatrixTransform, FK5, ICRS)\n\u001b[32m 41\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mfk5_to_icrs\u001b[39m(fk5coord, icrsframe):\n\u001b[32m 42\u001b[39m \u001b[38;5;66;03m# ICRS is by design very close to J2000 equinox\u001b[39;00m\n\u001b[32m 43\u001b[39m pmat = fk5coord._precession_matrix(fk5coord.equinox, EQUINOX_J2000)\n\u001b[32m---> \u001b[39m\u001b[32m44\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mmatrix_transpose\u001b[49m\u001b[43m(\u001b[49m\u001b[43m_ICRS_TO_FK5_J2000_MAT\u001b[49m\u001b[43m)\u001b[49m @ pmat\n",
+ "\u001b[36mFile \u001b[39m\u001b[32m~/software/COSItools/cosipy_DC4/Pyenv_DC4/lib/python3.13/site-packages/astropy/coordinates/matrix_utilities.py:18\u001b[39m, in \u001b[36mmatrix_transpose\u001b[39m\u001b[34m(matrix)\u001b[39m\n\u001b[32m 13\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mastropy\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mutils\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mdecorators\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m deprecated\n\u001b[32m 15\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01m.\u001b[39;00m\u001b[34;01mangles\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Angle\n\u001b[32m---> \u001b[39m\u001b[32m18\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mmatrix_transpose\u001b[39m(matrix):\n\u001b[32m 19\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"Transpose a matrix or stack of matrices by swapping the last two axes.\u001b[39;00m\n\u001b[32m 20\u001b[39m \n\u001b[32m 21\u001b[39m \u001b[33;03m This function mostly exists for readability; seeing ``.swapaxes(-2, -1)``\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 29\u001b[39m \n\u001b[32m 30\u001b[39m \u001b[33;03m \"\"\"\u001b[39;00m\n\u001b[32m 31\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m matrix.swapaxes(-\u001b[32m2\u001b[39m, -\u001b[32m1\u001b[39m)\n",
+ "\u001b[31mKeyboardInterrupt\u001b[39m: "
+ ]
+ }
+ ],
+ "source": [
+ "\n",
+ "# We start with 100 but higher would be better\n",
+ "# To adjust depending on how fast the LH fit is\n",
+ "# You can also run a script in parallel and save the likelihood ratio test\n",
+ "\n",
+ "nbiter = 10 #put this number to 100\n",
+ "\n",
+ "LHratiotest = []\n",
+ "\n",
+ "for i in range(nbiter) :\n",
+ "\n",
+ " print(f\"ITERATION {i}\")\n",
+ " \n",
+ " #create a signal dataset with the source injector\n",
+ " spectrum.F.value = F.value\n",
+ " signal = injector.inject_model(model = model, orientation = sc_orientation ,make_spectrum_plot = False ,data_save_path = None,fluctuate=True)\n",
+ "\n",
+ " \n",
+ " #create a bkg dataset from the bkg model\n",
+ " bkg_poissonsamp = Histogram(bg_model.axes)\n",
+ " bkg_poissonsamp[:] += np.random.poisson(lam = bg_model.to_dense()[:])\n",
+ "\n",
+ " # Set background parameter, which is used to fit the amplitude of the background, and instantiate the COSI 3ML plugin\n",
+ " # here we define only one bkg model but we could add more\n",
+ " bkg_dist = {\"Background\":bg_model.project('Em', 'Phi', 'PsiChi')}\n",
+ " \n",
+ " # Workaround to avoid inf values. Out bkg should be smooth, but currently it's not.\n",
+ " for bckfile in bkg_dist.keys() :\n",
+ " bkg_dist[bckfile] += sys.float_info.min\n",
+ "\n",
+ " #combine the data + the bck like we would get for real data\n",
+ " data = EmCDSBinnedData(signal.project('Em', 'Phi', 'PsiChi') \n",
+ " + bkg_poissonsamp.project('Em', 'Phi', 'PsiChi')\n",
+ " )\n",
+ " bkg = FreeNormBinnedBackground(bkg_dist,\n",
+ " sc_history=sc_orientation,\n",
+ " copy = False)\n",
+ "\n",
+ " instrument_response = BinnedInstrumentResponse(dr,data)\n",
+ "\n",
+ "\n",
+ " psr = BinnedThreeMLPointSourceResponse(data = data,\n",
+ " instrument_response = instrument_response,\n",
+ " sc_history=sc_orientation,\n",
+ " energy_axis = dr.axes['Ei'],\n",
+ " polarization_axis = dr.axes['Pol'] if 'Pol' in dr.axes.labels else None,\n",
+ " nside = 2*data.axes['PsiChi'].nside)\n",
+ "\n",
+ " ##====\n",
+ "\n",
+ "\n",
+ " response = BinnedThreeMLModelFolding(data = data, point_source_response = psr)\n",
+ "\n",
+ " like_fun = PoissonLikelihood(data, response, bkg)\n",
+ "\n",
+ " cosi = ThreeMLPluginInterface('cosi',\n",
+ " like_fun,\n",
+ " response,\n",
+ " bkg)\n",
+ "\n",
+ " # Nuisance parameter guess, bounds, etc.\n",
+ " cosi.bkg_parameter['Background'] = Parameter(\"Background\", # background parameter\n",
+ " 1, # initial value of parameter\n",
+ " min_value=0, # minimum value of parameter\n",
+ " max_value=10, # maximum value of parameter\n",
+ " delta=0.05, # initial step used by fitting engine\n",
+ " unit = u.Hz\n",
+ " )\n",
+ " \n",
+ " # Set the source Model\n",
+ " cosi.set_model(model)\n",
+ "\n",
+ "\n",
+ " plugins = DataList(cosi) # If we had multiple instruments, we would do e.g. DataList(cosi, lat, hawc, ...)\n",
+ "\n",
+ " like = JointLikelihood(model, plugins, verbose = False)\n",
+ "\n",
+ " #do the fit\n",
+ " like.fit()\n",
+ "\n",
+ " #get L1\n",
+ " L1 = cosi.get_log_like()\n",
+ "\n",
+ " #Get L0\n",
+ " spectrum.F.value = 0 #null hypothesis (no signal)\n",
+ " L0 = cosi.get_log_like()\n",
+ " \n",
+ " #save LH ratio test\n",
+ " LHratiotest.append( -2 * (L0-L1) )\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "77f74ceb-cd5f-4c8d-8653-e40d2be0ecb0",
+ "metadata": {},
+ "source": [
+ "## Plot the LH ratio test\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "id": "02a9f721-b864-453a-8935-32e461b09830",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "COSI is 3sigma sensitive to 3e-05 ph/cm2/s. You can continue to the next cell\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "Text(0.5, 1.0, 'Model - flux 3e-05 ph/cm2/s')"
+ ]
+ },
+ "execution_count": 36,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "if np.median(LHratiotest) <= 9 :\n",
+ " print(f\"COSI is not sensitive to this model with a flux of {F.value} ph/cm2/s. Please try a lower flux\")\n",
+ "else :\n",
+ " print(f\"COSI is 3sigma sensitive to {F.value} ph/cm2/s. You can continue to the next cell\")\n",
+ "\n",
+ "fig,ax = plt.subplots()\n",
+ "ax.hist(LHratiotest,bins=30)\n",
+ "ax.axvline(np.median(LHratiotest),label=f\"median {np.median(LHratiotest):.3f}\",color=\"r\",linestyle=\"--\")\n",
+ "ax.legend()\n",
+ "ax.set_xlabel(\"LH ratio test\")\n",
+ "ax.set_ylabel(\"counts\")\n",
+ "ax.set_title(f\"Model - flux {F.value} ph/cm2/s\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "155e30d4-cbc2-4fc0-92bd-03d20339f1f0",
+ "metadata": {},
+ "source": [
+ "## Extrapolate the sensitivity to 2 years\n",
+ "\n",
+ "DC4 simulations only includes 3 months of orbit. To get the sensitivity after 2 years (nominal life time of COSI) as a first approximation we can scale the flux by $\\frac{1}{\\sqrt{T}}$ "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 39,
+ "id": "fbf1883a-1633-4986-9dcc-fd17d021e041",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "3sigma sensitivity after 2 years of COSI observation : 1.0606601717798212e-05 1 / (s cm2)\n"
+ ]
+ }
+ ],
+ "source": [
+ "# 3 * 8 = 24 months = 2 years \n",
+ "\n",
+ "sensi_2y = F/np.sqrt(8)\n",
+ "\n",
+ "print(f\"3sigma sensitivity after 2 years of COSI observation : {sensi_2y}\")\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "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.11.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/tests/threeml/test_SpatialTemplate_2D_Healpix.py b/tests/threeml/test_SpatialTemplate_2D_Healpix.py
new file mode 100644
index 000000000..abdf03586
--- /dev/null
+++ b/tests/threeml/test_SpatialTemplate_2D_Healpix.py
@@ -0,0 +1,29 @@
+from cosipy.threeml.custom_functions import SpatialTemplate_2D_Healpix
+from mhealpy import HealpixMap
+import astropy.units as u
+import numpy as np
+
+def test_2DTemplateHealpix(tmp_path):
+
+ # Test template function with healpix map
+ skymap = HealpixMap(nside=8, scheme="ring", dtype=float, coordsys='G')
+ skymap[:] = 1
+
+ # normalise to the pixel area
+ area = skymap.pixarea().value
+ skymap[:] = skymap[:]/(np.sum(skymap)*area)
+
+ # write the fits file
+ skymap.write_map(tmp_path/"HealpixMap_test.fits", overwrite=True)
+
+ #test the init of the function
+ spatial_shape = SpatialTemplate_2D_Healpix(fits_file=tmp_path/"HealpixMap_test.fits")
+
+ #test evaluate
+ value = spatial_shape.evaluate(0*u.deg, 0*u.deg, spatial_shape.K.value, spatial_shape.hash.value)
+
+ #test boundaries
+ boundaries = spatial_shape.get_boundaries()
+
+ #test spatial integral
+ integral = spatial_shape.get_total_spatial_integral()