Example of rectangular selection

Once all the cells below have been executed, you will be able to press the Select button, drag a rectangle enclosing the sources you wish to select and see their names in the table at the right of the ipyaladin view.


In [9]:
from ipyaladin import Aladin
from ipywidgets import Layout, Box, widgets

aladin = Aladin(layout=Layout(width='50%'), target='M 1', fov=0.2)


button = widgets.Button(description="Select")
def on_button_clicked(b):
    aladin.rectangular_selection()

button.on_click(on_button_clicked)
table_info = widgets.HTML(layout=Layout(height='auto', overflow='auto'))


box_layout = Layout(display='flex',
                    flex_flow='row',
                    align_items='stretch',
                    width='100%',
                    position='relative',
                    overflow='hidden',
                    height='100vh',
                    margin='-100px 0 0 0',
                    padding='100px 0 0 0 '
                   )
box = Box(children=[aladin, button, table_info], layout=box_layout)
box


Execute the cell below before pressing the Select button.


In [7]:
from astroquery.simbad import Simbad
import astropy.units as u

table = Simbad.query_region("M 1", radius=0.1 * u.deg)
aladin.add_table(table)

def process_result(sources):
    s = '<table border="1">'
    s += '<tr><th>MAIN_ID</th><th>RA</th><th>DEC</th></tr>'
    for source in sources:
        s += '<tr><td>%s</td><td>%s</td><td>%s</td></tr>' % (source['data']['MAIN_ID'], source['data']['RA'], source['data']['DEC'])
    s += '</table>'
    table_info.value = s
    
aladin.add_listener('select', process_result)

In [3]:


In [4]:


In [ ]: