Retrieving data from the current widget’s view#
So far, we’ve seen how to send information (tables, MOCs, …) into the widget. The other way also works! This notebook contains a list of methods to extract diverse information about the current view. However, here are several information about retrieving data from the widget:
when the view is modified programmatically (i.e. not by clicking on the buttons), the update of its properties is done between cell execution. This means that you’ll see a
WidgetCommunicationError
when you try to modify the view and retrieve information about it in the same cell. Simply switch the property-reading to the next cell and everything will work as intended!if you generate different views of the same
Aladin()
instances – either by callingdisplay
multiple times, or by using theCreate new view for cell output
button in Jupyter, the information contained inwcs
andfov_xy
will always correspond to the most recently created view.
[1]:
from ipyaladin import Aladin
[2]:
aladin = Aladin(fov=5, height=600, target="M31")
aladin
[2]:
Getting the current WCS#
The World Coordinates System (WCS) describes the field of view, the projection, and it’s rotation. It is returned as an astropy.coordinates.WCS
object.
[3]:
aladin.wcs # Recover the current WCS
[3]:
WCS Keywords
Number of WCS axes: 2
CTYPE : 'RA---SIN' 'DEC--SIN'
CRVAL : 10.6847083 41.26875
CRPIX : 843.0 300.5
PC1_1 PC1_2 : 1.0 0.0
PC2_1 PC2_2 : 0.0 1.0
CDELT : -0.0029673590504451 0.002967359050445104
NAXIS : 1685 600
If you edit the view either by modifiing the widget through its interface, or programmatically:
[4]:
aladin.height = 800
aladin.survey = "CDS/P/PLANCK/R2/HFI/color"
aladin.target = "LMC"
aladin.frame = "Galactic"
aladin.fov = 50
The wcs is updated and you can print its new value in the next cell:
[5]:
aladin.wcs
[5]:
WCS Keywords
Number of WCS axes: 2
CTYPE : 'RA---SIN' 'DEC--SIN'
CRVAL : 80.89416999999995 -69.75611
CRPIX : 843.0 400.5
PC1_1 PC1_2 : 1.0 0.0
PC2_1 PC2_2 : 0.0 1.0
CDELT : -0.0029673590504451 0.002967359050445104
NAXIS : 1685 800
If you try to recover the value in the same cell, you’ll get a WidgetCommunicationError
error. This is because the calculation of the WCS is done by Aladin Lite between cell executions.
Getting the field of view#
The field of view is printed in the bottom left corner of the view. You can grab the two values with:
[6]:
aladin.fov_xy # Recover the current field of view for the x and y axis
[6]:
(<Angle 5. deg>, <Angle 2.37388724 deg>)