Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aladin widget does not show coordinates #61

Closed
jpbrandtu opened this issue Jun 1, 2023 · 6 comments
Closed

Aladin widget does not show coordinates #61

jpbrandtu opened this issue Jun 1, 2023 · 6 comments
Labels

Comments

@jpbrandtu
Copy link

jpbrandtu commented Jun 1, 2023

Hi,

I am using Aladin widget in Python to show SN coordinates, but it does not work properly (the symbol indicating the coordinates does not appear, even when I provide them in the add_table function).
This is the code:

import pandas as pd
import numpy as np
from astropy.table import Table
from IPython.core.display import HTML
import ipyaladin as ipyal
from ipywidgets import Layout, Box, widgets

def start_aladin(survey="P/PanSTARRS/DR1/color-z-zg-g", layout_width=70, fov=0.025):
        aladin = ipyal.Aladin(survey=survey, layout=Layout(width='%s%%' % layout_width), fov=fov)
        info = widgets.HTML()
        box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%')
        box = Box(children=[aladin, info], layout=box_layout)
        display(box)
        return aladin, info

# start aladin widget
aladin, info = start_aladin()

aladin.target = "%f %f" % (124.487612, 33.766332)

table_cand = Table.from_pandas(pd.DataFrame(data={"ZTF_oid": ["ZTF20aatwyzg"], "RA": [124.487612], "DEC": [33.766332], "cat_name": ["ZTF"]}))
aladin.add_table(table_cand)
display(info, aladin)

And this is the output:

Screen Shot 2023-06-01 at 17 38 33

@ManonMarchand
Copy link
Member

Hello and thanks for opening this issue here 🙂

The function add_table only works to modify an existing widget. It should be called after the cell containing ipyaladin and the table appears in the above cell. See here :

image

(I clicked on the point to highlight it)

Does this answer your question? Or did I get you wrong?

@ManonMarchand
Copy link
Member

ManonMarchand commented Jun 5, 2023

Hi,
Is it ok with you if I close this issue? We will keep that in mind when writing the documentation 🙂

@ale-munozarancibia
Copy link

Hi @ManonMarchand,

Thanks for the reply! Is it therefore mandatory to use functions like add_table in a separate cell? I ask because until recently (maybe a month ago) I was able to run code like this from a separate library (thus everything was in a single cell) but now such code works only sometimes. For instance, sometimes when I set the aladin.target the widget is updated to the object coordinates, but other times it seems to ignore the command and only shows coordinates (0,0). Same happens to me with add_table, sometimes it shows the symbols and others it doesn't. Did something change recently?

If it helps, I include the code versions I'm using:

astropy==5.2.2
astropy-healpix==0.6
ipyaladin==0.2.1
ipykernel==6.22.0
ipython==8.12.0
jupyter==1.0.0
jupyter-console==6.6.3

Thanks in advance!

@ManonMarchand
Copy link
Member

Aaaah yes, indeed.

What we do internally is that we have a listener that adds the table to the widget when the boolean table_flag changes.

With this, it can happen that if you do everything in the same cell, the aladin view or the listener does not exist yet when the table is called. It seems to be a computer-dependent issue. A workaround is to call

aladin.table_flag = not aladin.table_flag 

in a next cell, but I'm aware that it does not solve your use case, very sorry 😦

Changing this behaviour requires some refactoring and won't be done right now (we're quite busy for the next 2 months) but I opened an issue for the v1 release #63

@ale-munozarancibia
Copy link

Thanks @ManonMarchand! I added some time.sleep(2)'s in between commands and that seems to help in my case

@bmatthieu3
Copy link
Collaborator

Hi @jpbrandtu - we recently changed ipyaladin for using anywidget. We will test it to see if things are getting better (I suppose this is because aladin lite instanciation is done async and maybe anywidget fix those types of errors). To be further tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants