<jupyter_start><jupyter_text>Imviz simple aperture photometryThis is a proof-of-concept showing how to use Imviz to perform simple aperture photometry using hand-drawn aperture on a single object.<jupyter_code>import warnings

from astropy.utils.data import download_file

from jdaviz import Imviz
with warnings.catch_warnings():
    warnings.simplefilter('ignore')  # Hide import warnings
    imviz = Imviz(verbosity='warning')  # Hide info messages<jupyter_output><empty_output><jupyter_text>We can load JWST images with ASDF and GWCS.<jupyter_code>jwf277w = download_file('https://stsci.box.com/shared/static/iao1zxtigyrhq7k3wtu5nchrxzlhj9kv.fits', cache=True)
jwf444w = download_file('https://stsci.box.com/shared/static/rey83o5wq6g7qd7xym6r1jq9wlsxaqnt.fits', cache=True)
my_cen = (1002, 1154)
my_radius = 20
my_zoom = 4

imviz.load_data(jwf277w, data_label='JWST_F277W')
imviz.load_data(jwf444w, data_label='JWST_F444W')<jupyter_output><empty_output><jupyter_text>Or we can load HST/ACS images with FITS WCS.<jupyter_code>acs_47tuc_1 = download_file('https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/jbqf03gjq_flc.fits', cache=True)
acs_47tuc_2 = download_file('https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/jbqf03h1q_flc.fits', cache=True)
my_cen = (1090, 1157)
my_radius = 10
my_zoom = 6

with warnings.catch_warnings():
    warnings.simplefilter('ignore')  # Hide FITS warnings
    imviz.load_data(acs_47tuc_1, data_label='acs_47tuc_1')
    imviz.load_data(acs_47tuc_2, data_label='acs_47tuc_2')

# These are dithered, so we re-link by WCS.
imviz.link_data(link_type='wcs')<jupyter_output><empty_output><jupyter_text>Or we can load plain Numpy array without WCS or unit.<jupyter_code>import numpy as np
from astropy.modeling.models import Gaussian2D

gm = Gaussian2D(100, 25, 25, 5, 5)
y, x = np.mgrid[0:51, 0:51]
arr = gm(x, y)
my_cen = (25, 25)
my_radius = 5
my_zoom = 'fit'

imviz.load_data(arr, data_label='my_gaussian')<jupyter_output><empty_output><jupyter_text>Display the app.<jupyter_code>imviz.app<jupyter_output><empty_output><jupyter_text>Now, we would zoom in on a star and draw an aperture.<jupyter_code>viewer = imviz.default_viewer
viewer.cuts = '95%'
viewer.center_on(my_cen)
viewer.zoom_level = my_zoom

# Click on image to finalize selection.
imviz._apply_interactive_region(
    'bqplot:circle', (my_cen[0] - my_radius, my_cen[1] - my_radius),
                     (my_cen[0] + my_radius, my_cen[1] + my_radius))<jupyter_output><empty_output><jupyter_text>Now, use the "Imviz Simple Aperture Photometry" plugin.Once photometry is done, we would do the following to extract the data from Imviz back to notebook for further processing.<jupyter_code>results = imviz.get_aperture_photometry_results()
results<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11170592433975732, 'fraction_numerical': 0.03890078515346181, 'mean_word_length': 6.474666666666667, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '471465', 'license': 'MIT', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1098, 'n_words': 210, 'path': 'notebooks/concepts/imviz_simple_aper_phot.ipynb', 'repo_name': 'check-spelling/jdaviz', 'size': '2802'}