Adding tables to the view#

In this notebook, we add tables to the ipyaladin view.

[1]:
from ipyaladin import Aladin, CircleError, EllipseError
from astropy.table import QTable
import astropy.units as u
from astroquery.simbad import Simbad

Table from a database#

Let’s query the SIMBAD database around the Crab nebula.

[2]:
table = Simbad.query_region("Messier 1", radius=0.03 * u.deg)
table
[2]:
Table length=65
main_idradeccoo_err_majcoo_err_mincoo_err_anglecoo_wavelengthcoo_bibcode
degdegmasmasdeg
objectfloat64float64float32float32int16str1object
FHES J0534.5+220183.632759622.0203278------G2018ApJS..237...32A
PLCKERC -070 G184.55-05.7883.62522.016666666666666------F2016MNRAS.458.3619C
SCOPE G184.56-05.7883.63522.009999999999998------S2019MNRAS.485.2895E
SCOPE G184.56-05.7983.62922.012------S2019MNRAS.485.2895E
JCMTSF J053427.4+22022783.61422.042000000000005------S2019MNRAS.485.2895E
JCMTSF J053430.4+22015183.62822.034------S2019MNRAS.485.2895E
SCOPE G184.54-05.7783.63422.039------S2019MNRAS.485.2895E
SCOPE G184.55-05.7683.6522.032------S2019MNRAS.485.2895E
3FGL J0534.5+2201s83.629997253422.0200004578------2022ApJS..260...53A
........................
[LBC2011] 4083.6349166666666522.037533333333336------I2011ApJS..194...30L
[LBC2011] 3683.6450416666666622.033147222222222------I2011ApJS..194...30L
[LBC2011] 4983.6172522.036800000000003------I2011ApJS..194...30L
[LBC2011] 2783.6531249999999922.01733611111111------I2011ApJS..194...30L
[LBC2011] 3383.6479166666666522.031108333333332------I2011ApJS..194...30L
[LBC2011] 5183.6150000000000122.03098888888889------I2011ApJS..194...30L
[LBC2011] 5583.6369999999999922.01075------I2011ApJS..194...30L
[LBC2011] 4583.62987522.029730555555556------I2011ApJS..194...30L
V* CM Tau83.6331144560922.014487138340.07320.060690O2020yCat.1350....0G

Now we instantiate an ipyaladin view around the nebula.

[3]:
aladin = Aladin(fov=0.4, target="Messier 1")
aladin
[3]:

In add_table, the shape argument can take the values “square”, “circle”, “plus”, “cross”, “rhomb”, or “triangle” for the simple shapes.

The two specific classes of error shapes EllipseError and CircleError adapt the shapes drawn to the values of the errors around the coordinates.

SIMBAD gives errors as ellipses, so let’s use an EllipseError shape:

[4]:
aladin.add_table(
    table,
    shape=EllipseError(
        maj_axis="coo_err_maj",
        min_axis="coo_err_min",
        angle="coo_err_angle",
        default_shape="cross",
    ),
    color="lightskyblue",
    # source_size will only affect the sources which fallback to the default shape,
    # or the ones too small to be drawn
    source_size=20,
    name="SIMBAD query",
)

If you zoom in the view, you’ll remark that the sources which had error information appear as ellipses. If if there is no information in the error columns, then the sources appear with the fallback shape default_shape. default_shape should be one of the strings allowed in shape.

If the ellipse would be too small to be drawn in the widget, then it appears as a square, see the source 2MASS J05343561+2200372 located in 83.64842925852 +22.01034559457. If you zoom in close to this square, you’ll see the square turning into an ellipse when it is big enough to be drawn.

Displaying a QTable#

Let’s create a table from scratch and add it to the view. We will draw CircleError shapes this time.

[5]:
t = QTable(
    {
        "error": [0.005, 0.002, 0.003] * u.deg,
        "coo1": [83.63451584700, 83.61368056017, 83.58780251600] * u.deg,
        "coo2": [22.05652591227, 21.97517807639, 21.99277764451] * u.deg,
        "name": ["Source 1", "Source 2", "Source 3"],
        "parallax": [1.7703, 0.5112, 0.3735] * u.mas,
    },
    meta={"name": "my_sample_table"},
)

aladin.add_table(
    t,
    name=t.meta["name"],
    shape=CircleError(
        radius="error",
        probability_threshold=0.989,  # roughly 3 sigma
    ),
    color="pink",
    ra_field="coo1",
    dec_field="coo2",
)

Note that we used unconventional column names for the coordinates fields here. In this case, we can specify the column names where Aladin Lite should read the coordinates via ra_field and dec_field.

We used a very high probability threshold. This corresponds to roughly 3 sigma in the drawn circle.