Generating Datapages#

ATK supports the creation of datapages as a means of neatly combining plots into a single grid. To demonstrate this, some data must first be acquired:

from ATK import query

target = 587316166180416640

lc = query("lightcurve", survey="asassn", targets=target, path="datapage_lc.fits.gz")
pspec = lc.apply("pspec", fmin=0, fmax=60, samples=10000, inplace=False)
fold = lc.apply("fold", fmin=0, fmax=60, samples=10000, inplace=False)
image = query("image", survey="panstarrs", band="g", targets=target, overlays=["gaia","galex"], path="datapage_image.fits.gz")
spec = query("spectrum", survey="sdss", targets=target, path="datapage_spec.fits.gz")
sed = query("sed", targets=target, path="datapage_sed.fits.gz")
hrd = query("hrd", targets=target, path="datapage_hrd.fits.gz")
table = query("datatable", columns={"gaia": ["Gmag", "BPmag", "RPmag"], "galex": ["NUVmag", "FUVmag"]}, targets=target, radius=image.data[0].size)

The only other requirement is to define the datapage’s layout. This is done by defining a grid, with each cell in the grid being a DataSet:

layout = [[image, image, hrd,   hrd,   lc,    lc,    lc,    lc   ],
          [image, image, hrd,   hrd,   lc,    lc,    lc,    lc   ],
          [pspec, pspec, pspec, pspec, fold,  fold,  fold,  fold ],
          [pspec, pspec, pspec, pspec, fold,  fold,  fold,  fold ],
          [spec,  spec,  spec,  spec,  sed,   sed,   sed,   sed  ],
          [spec,  spec,  spec,  spec,  sed,   sed,   sed,   sed  ],
          [table, table, table, table, table, table, table, table],
          [table, table, table, table, table, table, table, table]]

The above example defines a datapage where the first row contains a 2x2 image in the top-left corner, followed by a 2x2 HRD and a 4x2 light curve, etc. Passing this to grid() returns a DataPages object, which contains one datapage per target in the input DataSet objects:

from ATK import grid

datapages = grid(layout)
datapages.show()
<1 DataPages>

.targets: 587316166180416640 | 141.185° 8.031° (icrs, 2016-01-01T00:00:00.000)
.figures: <Bokeh Figure>

Available Methods: .open(), .save(), .show()


Opening a Datapage#

The only remaining step is to open or save the datapage. Like everything in ATK, DataPages are designed to work with multiple targets. A datapage for a specific target can be opened by passing a Gaia source ID or Target to open().

For example, to open the above datapage:

datapages.open(target)
Bokeh Figure


Note

Since matching by SkyCoord is inexact, this is not supported by open() and save(). A Target should therefore be used for exact matching if a Source ID is not available (see here).



Saving Datapages To Local Files#

Saving and Opening#

To open a datapage and save it to local files, open() can be provided with a path:

target = 587316166180416640

datapages = ...

datapages.open(target, path="example_datapage.html")


Saving Without Opening#

Datapages can also be saved without opening them via save():

target = 587316166180416640

datapages.save(target, path="example_datapage.html")



Download this Tutorial

Total running time of the script: (0 minutes 8.249 seconds)

Gallery generated by Sphinx-Gallery