<jupyter_start><jupyter_text>Photometry verificationLets verify that from the simulation of the source we get back 4 sigmas using proper photometry methods. First we import the required packages.<jupyter_code>import os
from os.path import isfile
from sagsci.tools.utils import *
from sagsci.tools.photometry import *<jupyter_output><empty_output><jupyter_text>Let's define the simulation files and some parameters required to perform an aperture photometry analysis.<jupyter_code># observation and target
obs_crab = '../data/crab_test_sim.fits'
obs_crab = '../data/bkg000001.fits'

target = {'ra': 83.6331, 'dec': 22.0145}
pointing = {'ra': 83.6331, 'dec': 22.5145}

target = {'ra': 33.057, 'dec': -51.841}
pointing = {'ra': 33.557, 'dec': -51.841}


# configuration
erange = [0.03, 1]       # energy in teraelectronvolt (TeV)
trange = [0, 10]         # livetime in seconds (s)
radius = 0.2               # photometry region in degrees (deg)
spectral_index = -2.1     # slope of the power-law spectrum

# we need to add "radius" to the target dictionary 
target['rad'] = radius<jupyter_output><empty_output><jupyter_text>Now we initialise the Photometric class and perform the aperture photometry to retrive the counts and significance.<jupyter_code>phm = Photometrics({'events_filename': obs_crab})<jupyter_output><empty_output><jupyter_text>Firs we require to extract the off regions given the target and pointing of choice.<jupyter_code># remove duplicate files
offregionsfile = obs_crab.replace('.fits', '_off.reg')
if isfile(offregionsfile):
    os.remove(obs_crab.replace('.fits', '_off.reg'))
    
# compute regions
off_regions = phm.find_off_regions(algo='cross', src=target, pnt=pointing, rad=target['rad'], save=offregionsfile)<jupyter_output><empty_output><jupyter_text>Now we compute the on and off counts, the excess and the significance.<jupyter_code>on, off, alpha, excess, sigma, err_note = phm.counting(src=target, rad=target['rad'], off_regions=off_regions, e_min=erange[0], e_max=erange[1], t_min=trange[0], t_max=trange[1], draconian=False)<jupyter_output><empty_output><jupyter_text>Let's check the significance of the observation.<jupyter_code>on, off, excess, sigma<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11857529305680793, 'fraction_numerical': 0.029756537421100092, 'mean_word_length': 5.977987421383648, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '314177', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 795, 'n_tokens_neox': 723, 'n_words': 202, 'path': 'notebooks/5_photometry_verification.ipynb', 'repo_name': 'ambra-dipiano/studenti_computer_vision', 'size': '2218'}