Creating a Datapage

While we have seen how to fetch and plot lightcurves and images in previous tutorials, storing and analysing these separately can quickly become a tiresome process. This is where another feature of ATK comes in: Datapages. The datapage() tool allows for any bokeh plots (including those generated by ATK) to be neatly stacked together in a customisable grid.

We haven’t yet encountered all of the data structures that will be utilised in this tutorial, but it should still be fairly easy to follow since they all function in the same way.

We start by fetching all the data that we want in our datapage. We will start with an image:

from AstroToolkit.Datapages import buttons, datatable, datapage
from AstroToolkit.Tools import query

source=587316166180416640

image = query(
    kind="image",
    survey="panstarrs",
    source=source,
    overlays=["gaia", "galex"],
    check_exists="datapage_image",
).plot()

We can then fetch a Hertzsprung-Russell Diagram (HRD), a spectrum and a spectral energy distribution (SED):

hrd = query(kind="hrd", sources=source, check_exists="datapage_hrd").plot()

spectrum = query(
    kind="spectrum", survey="sdss", source=source, check_exists="datapage_spectrum"
).plot()

sed = query(kind="sed", source=source, check_exists="datapage_sed").plot(
    spectrum_overlay=spectrum
)

Here, we have passed the spectrum to our SED’s plot() method - another example of the differing capabilities of each data structure.

We can now fetch a light curve and use it to generate a power spectrum:

lightcurves = query(
    kind="lightcurve", survey="ztf", source=source, check_exists="datapage_lightcurve"
).plot(colours=["green", "red", "blue"])

powspec = query(
    kind="lightcurve", survey="ztf", source=source, check_exists="datapage_lightcurve"
).plot(kind="powspec")

Note that no additional (and in this case repeated) query is performed here when fetching a power spectrum - the data already exists. Finally, we can fetch some additional panels which are specifically designed for use in datapages. We start with Vizier and SIMBAD buttons, which open the source in Vizier/SIMBAD in the web browser when clicked:

buttons = buttons(source=source)

We can also create a datatable, which generates and populates a table with survey data:

metadata = datatable(
    source=source,
    entries=[
        {
            "kind": "atk_defaults",
            "surveys": [
                "gaia",
                "galex",
                "panstarrs",
                "skymapper",
                "sdss",
                "wise",
                "twomass",
            ],
        }
    ],
)

Here, we have used the package’s default entries for its supported data surveys for simplicity, but datatables can also be populated with data from any Vizier catalogue or with any other external data. See datatable() for a full description.

We then use the datapage() tool to generate our datapage from the above elements:

datapage = datapage(
    dimensions={"width": 6, "height": 6},
    panels=[
        {"name": "image", "figure": image, "width": 2, "height": 2},
        {"name": "hrd", "figure": hrd, "width": 2, "height": 2},
        {"name": "sed", "figure": sed, "width": 3, "height": 2},
        {"name": "buttons", "figure": buttons, "width": 2, "height": 2},
        {"name": "lightcurves", "figure": lightcurves, "width": 4, "height": 2},
        {"name": "powspec", "figure": powspec, "width": 3, "height": 2},
        {"name": "spectrum", "figure": spectrum, "width": 5, "height": 2},
        {"name": "metadata_table", "figure": metadata, "width": 7, "height": 2},
    ],
    layout=[
        ["image", "sed", "buttons"],
        ["hrd", "spectrum"],
        ["lightcurves", "powspec"],
        ["metadata_table"],
    ],
)

We start by specifying the total dimensions of the grid we wish to use (in this case 6x6). We then pass a list of data structures, giving them a label and specifying their individual dimensions within the grid. Here, we have used only elements provided by ATK, but any Bokeh figure may be used. Finally, we specify the layout of our grid row-by-row (columns are also supported, see datapage for a full description).

The datapage() tool returns a Datapage, which acts similarly to the other data structures that we have seen so far. We can hence show the resulting datapage as we would with any other data structure (although in this case providing a file name is required!):

datapage.showplot(f"{source}_datapage")

The resulting datapage is shown below - try out the interactive elements!


Note: The code used in this tutorial can be executed using:

from AstroToolkit.Examples import datapage_creation