Class: Aladin

Aladin(aladinDiv, requestedOptions)

new Aladin(aladinDiv, requestedOptions)

Creates an instance of the Aladin interactive sky atlas.
Parameters:
Name Type Description
aladinDiv string | HTMLElement The ID of the HTML element or the HTML element itself where the Aladin sky atlas will be rendered.
requestedOptions AladinOptions Options to customize the behavior and appearance of the Aladin atlas.
Source:
Throws:
Throws an error if aladinDiv is not provided or is invalid.
Type
Error
Example
// Usage example:
import { A } from 'aladin-lite';

let aladin = A.Aladin('#aladin-lite-div', { option1: 'value1', option2: 'value2' });

Members

removeLayer

Deprecated:
  • Old method name, use Aladin.prototype.removeOverlay instead.
Source:

removeLayers

Deprecated:
  • Old method name, use Aladin.prototype.removeOverlays instead.
Source:

setImageSurvey

Change the base layer of the view It internally calls Aladin.setBaseImageLayer with the url/ImageHiPS/ImageFITS given
Source:

Methods

addNewImageLayer(surveyopt)

Add a new HiPS layer to the view on top of the others
Parameters:
Name Type Attributes Default Description
survey string | ImageHiPS | ImageFITS <optional>
"CDS/P/DSS2/color" Can be:
  • 1. An url that refers to a HiPS.
  • 2. Or it can be a CDS ID that refers to a HiPS. One can found the list of IDs here
  • 3. It can also be an A.ImageHiPS HiPS object created from A.imageHiPS
By default, the Digital Sky Survey 2 survey will be displayed
Source:

addStatusBarMessage(options)

Append a message to the status bar with a specific duration
Parameters:
Name Type Description
options Object The message to display
Properties
Name Type Description
id string The id of the message, is useful for removing unlimited time messages
message string The message to display
duration string | number The duration of the message. Accepts a time in milliseconds or 'unlimited'
type string The type of the message. Can be 'loading', 'tooltip', 'info'
Source:
Example
aladin.addStatusBarMessage({
      duration: 10000,
      type: 'info',
      message: 'Aladin Lite v3.3 is out. New features available:<ul><li>New Button, Box objects</li><li>Polygonal, circular selection</li></ul>'
})

angularDist(x1, y1, x2, y2, frameopt) → {number}

Get the angular distance in degrees between two locations
Parameters:
Name Type Attributes Description
x1 number The x-coordinate of the first pixel coordinates.
y1 number The y-coordinate of the first pixel coordinates.
x2 number The x-coordinate of the second pixel coordinates.
y2 number The y-coordinate of the second pixel coordinates.
frame CooFrame <optional>
The frame in which we want to retrieve the coordinates. If not given, the frame chosen is the one from the view
Source:
Throws:
Throws an error if an issue occurs during the transformation.
Type
Error
Returns:
- The angular distance between the two pixel coordinates in degrees
Type
number

createImageSurvey(id, nameopt, url, cooFrameopt, maxOrderopt, optionsopt) → {ImageHiPS}

Parameters:
Name Type Attributes Description
id string Mandatory unique identifier for the survey.
name string <optional>
A convinient name for the survey, optional
url string Can be:
  • 1. An url that refers to a HiPS.
  • Or it can be a "CDS ID" that refers to a HiPS. One can found the list of IDs here
cooFrame string <optional>
Values accepted: 'equatorial', 'icrs', 'icrsd', 'j2000', 'gal', 'galactic'
maxOrder number <optional>
The maximum HEALPix order of the HiPS, i.e the HEALPix order of the most refined tile images of the HiPS.
options ImageHiPSOptions <optional>
Options describing the survey
Deprecated:
  • Creates and return an image survey (HiPS) object Please use A.imageHiPS instead for creating a new survey image
Source:
Returns:
A HiPS image object.
Type
ImageHiPS

displayFITS(url, optionsopt, successCallbackopt, errorCallbackopt, layeropt)

Display a FITS image in the Aladin Lite.
Parameters:
Name Type Attributes Default Description
url string The URL of the FITS image.
options ImageFITSOptions <optional>
Options to customize the display
successCallback function <optional>
<center the view on the FITS file> The callback function to be executed on a successful display. The callback gives the ra, dec, and fov of the image; By default, it centers the view on the FITS file loaded.
errorCallback function <optional>
The callback function to be executed if an error occurs during display.
layer string <optional>
"base" The name of the layer. If not specified, it will be replace the base layer.
Source:
Example
aladin.displayFITS(
    'https://fits.gsfc.nasa.gov/samples/FOCx38i0101t_c0f.fits', // url of the fits file
    {
        minCut: 5000,
        maxCut: 17000,
        colormap: 'viridis'
    },
    (ra, dec, fov, image) => {
        // ra, dec and fov are centered around the fits image
        image.setColormap("magma", {stretch: "asinh"});

        aladin.gotoRaDec(ra, dec);
        aladin.setFoV(fov);
    },
);

displayJPG(url, optionsopt, successCallbackopt, errorCallbackopt, layeropt)

Display a JPEG image in the Aladin Lite view.
Parameters:
Name Type Attributes Default Description
url string The URL of the JPEG image.
options Object <optional>
Options to customize the display. Can include the following properties:
Properties
Name Type Attributes Default Description
label string <optional>
"JPG/PNG image" A label for the displayed image.
order number <optional>
The desired HEALPix order format.
nocache boolean <optional>
True if you want to disable the cache
transparency number <optional>
1.0 Opacity of the image rendered in aladin lite. Between 0 and 1.
successCallback function <optional>
The callback function to be executed on a successful display. The callback gives the ra, dec, and fov of the image;
errorCallback function <optional>
The callback function to be executed if an error occurs during display.
layer string <optional>
"overlay" The name of the layer. If not specified, it will add a new overlay layer on top of the base.
Source:
Example
aladin.displayJPG(
 // the JPG to transform to HiPS
  'https://noirlab.edu/public/media/archives/images/large/noirlab1912a.jpg',
  {
      transparency: 0.6,
      label: 'NOIRLab image'
  },
  (ra, dec, fov) => {
     // your code here
  })
);

getBaseImageLayer() → {ImageHiPS|ImageFITS}

Get the base image layer object
Source:
Returns:
- Returns the image layer corresponding to the base layer
Type
ImageHiPS | ImageFITS

getFoVCorners(nbStepsopt, frameopt) → {Array.<Array.<number>>}

Gets a set of points along the current Field of View (FoV) corners.
Parameters:
Name Type Attributes Default Description
nbSteps number <optional>
1 The number of points to return along each side (the total number of points returned is 4 * nbSteps).
frame CooFrame <optional>
The frame in which the coo will be given. Default to the view frame.
Source:
Throws:
Throws an error if an issue occurs during the transformation.
Type
Error
Returns:
- A set of positions along the current FoV with the following format: [[ra1, dec1], [ra2, dec2], ..., [ra_n, dec_n]]. The positions will be given in degrees
Type
Array.<Array.<number>>

getFov() → {Array.<number>}

Gets the current Field of View (FoV) size in degrees as a 2-element array.
Source:
Returns:
- A 2-element array representing the current FoV size in degrees. The first element is the FoV width, and the second element is the FoV height.
Type
Array.<number>

getFrame() → {string}

Returns the current coordinate system: possible values are 'J2000', 'J2000d', and 'Galactic' .
Source:
Returns:
The current coordinate system: possible values are 'J2000', 'J2000d', and 'Galactic' .
Type
string
Example
const aladin = A.aladin('#aladin-lite-div', {cooFrame: 'galactic'});
let cooFrame = aladin.getFrame();
assert(cooFrame, 'galactic')

getOverlayImageLayer(layeropt) → {ImageHiPS|ImageFITS}

Get an image layer from a layer name
Parameters:
Name Type Attributes Default Description
layer string <optional>
"overlay" The name of the layer
Source:
Returns:
- The requested image layer.
Type
ImageHiPS | ImageFITS

getOverlays() → {Array.<MOC>|Array.<Catalog>|Array.<ProgressiveCat>|Array.<GraphicOverlay>}

Get list of overlays layers
Source:
Returns:
- Returns the ordered list of image layers. Items can be ImageHiPS or ImageFITS objects.
Type
Array.<MOC> | Array.<Catalog> | Array.<ProgressiveCat> | Array.<GraphicOverlay>

getParentDiv() → {HTMLElement}

Returns the HTML div element
Source:
Returns:
- The aladin lite div HTML element
Type
HTMLElement

getRaDec() → {Array.<number>}

Gets the current [Right Ascension, Declination] position of the center of the Aladin view. This method returns the celestial coordinates of the center of the Aladin view in the International Celestial Reference System (ICRS) or J2000 equatorial coordinates.
Source:
Returns:
- An array representing the [Right Ascension, Declination] coordinates in degrees. The first element is the Right Ascension (RA), and the second element is the Declination (Dec).
Type
Array.<number>

getSize() → {Array.<number>}

Returns the size in pixels for the Aladin view
Source:
Returns:
- A 2-element array representing the current Aladin view size in pixels. The first element is the width, and the second element is the height.
Type
Array.<number>

getStackLayers() → {Array.<ImageHiPS>|Array.<ImageFITS>}

Get list of layers
Source:
Returns:
- Returns the ordered list of image layers. Items can be ImageHiPS or ImageFITS objects.
Type
Array.<ImageHiPS> | Array.<ImageFITS>

gotoObject(targetName, callbackOptionsopt)

Moves the Aladin instance to the specified astronomical object.
Parameters:
Name Type Attributes Description
targetName string The name or identifier of the astronomical object to move to.
callbackOptions Object <optional>
Optional callback options.
Properties
Name Type Attributes Description
success function <optional>
The callback function to execute on successful navigation.
error function <optional>
The callback function to execute on error during navigation.
Source:
Example
// Move to the astronomical object named 'M42' with callbacks
const aladinInstance = A.aladin('#aladin-lite-div');
aladinInstance.gotoObject('M42', {
  success: () => {
    console.log('Successfully moved to M42.');
  },
  error: (err) => {
    console.error('Error moving to M42:', err);
  }
});

gotoPosition(lon, lat, frameopt)

Moves the Aladin instance to the specified position.
Parameters:
Name Type Attributes Description
lon number longitude in degrees
lat number latitude in degrees
frame string <optional>
The name of the coordinate frame. Possible values: 'j2000d', 'j2000', 'gal', 'icrs'. The given string is case insensitive.
Source:
Example
// Move to position
const aladin = A.aladin('#aladin-lite-div');
aladin.gotoPosition(20, 10, "galactic");

gotoRaDec(ra, dec)

Moves the Aladin instance to the specified position given in ICRS frame
Parameters:
Name Type Description
ra number Right-ascension in degrees
dec number Declination in degrees
Source:
Example
const aladin = A.aladin('#aladin-lite-div');
aladin.gotoRaDec(20, 10);

newImageSurvey(id, optionsopt, successopt, erroropt) → {ImageHiPS}

Parameters:
Name Type Attributes Description
id string Can be:
  • 1. An url that refers to a HiPS.
  • Or it can be a "CDS ID" that refers to a HiPS. One can found the list of IDs here
options ImageHiPSOptions <optional>
Options for rendering the image
success function <optional>
A success callback
error function <optional>
A success callback
Deprecated:
  • Create a new layer from an url or CDS ID. Please use A.imageHiPS instead for creating a new survey image
Source:
Returns:
A FITS image object.
Type
ImageHiPS

on(what, myFunction)

Listen aladin for specific events
Parameters:
Name Type Description
what ListenerCallback e.g. objectHovered, select, zoomChanged, positionChanged
myFunction function a callback function. Note:
  • positionChanged and zoomChanged are throttled every 100ms.
  • positionChanged's callback gives an object having ra and dec keywords of the current position in ICRS frame. See the below example.
Source:
Example
// define function triggered when  a source is hovered
aladin.on('objectHovered', function(object, xyMouseCoords) {
    if (object) {
        msg = 'You hovered object ' + object.data.name + ' located at ' + object.ra + ', ' + object.dec + '; mouse coords - x: '
            + xyMouseCoords.x + ', y: ' + xyMouseCoords.y;
    }
    else {
        msg = 'No object hovered';
    }
    $('#infoDiv').html(msg);
});

aladin.on('objectHoveredStop', function(object, xyMouseCoords) {
    if (object) {
        msg = 'You stopped hove object ' + object.data.name + ' located at ' + object.ra + ', ' + object.dec + '; mouse coords - x: '
            + xyMouseCoords.x + ', y: ' + xyMouseCoords.y;
    }
    $('#infoDiv').html(msg);
});

// define function triggered when an object is clicked
var objClicked;
aladin.on('objectClicked', function(object, xyMouseCoords) {
    if (object) {
        objClicked = object;
        object.select();
        msg = 'You clicked object ' + object.data.name + ' located at ' + object.ra + ', ' + object.dec + '; mouse coords - x: '
            + xyMouseCoords.x + ', y: ' + xyMouseCoords.y;
    }
    else {
        objClicked.deselect();
        msg = 'You clicked in void';
    }
    $('#infoDiv').html(msg);
});

aladin.on("positionChanged", ({ra, dec}) => {
    console.log("positionChanged", ra, dec)
})

pix2world(x, y, frameopt) → {Array.<number>}

Transform pixel coordinates to world coordinates. The origin (0,0) of pixel coordinates is at the top-left corner of the Aladin Lite view.
Parameters:
Name Type Attributes Description
x number The x-coordinate in pixel coordinates.
y number The y-coordinate in pixel coordinates.
frame CooFrame <optional>
The frame in which we want to retrieve the coordinates. If not given, the frame chosen is the one from the view
Source:
Throws:
Throws an error if an issue occurs during the transformation.
Type
Error
Returns:
- An array representing the [Right Ascension, Declination] coordinates in degrees in the `frame`. If not specified, returns the coo in the frame of the current view.
Type
Array.<number>

removeImageLayer(layer)

Remove a specific layer
Parameters:
Name Type Description
layer string The name of the layer to remove
Source:

removeOverlay(layer)

Remove a overlay by its layer name
Parameters:
Name Type Description
layer string
Source:

removeOverlays()

Remove all the overlays (MOC, Overlay, ProgressiveCat, Catalog) from the view
Source:

select(modeopt, callbackopt)

Enters selection mode
Parameters:
Name Type Attributes Default Description
mode string <optional>
'rect' The mode of selection, can be either, 'rect', 'poly', or 'circle'
callback function <optional>
A function called once the selection has been done The callback accepts one parameter depending of the mode used:
- If mode='circle' that parameter is of type CircleSelection
- If mode='rect' that parameter is of type RectSelection
- If mode='poly' that parameter is of type PolygonSelection
Source:
Example
// Creates and add a MOC from the user polygonal selection
aladin.select('poly', p => {
   try {
       let ra = []
       let dec = []
       for (const v of p.vertices) {
           let [lon, lat] = aladin.pix2world(v.x, v.y);
           ra.push(lon)
           dec.push(lat)
       }

       let moc = A.MOCFromPolygon(
           {ra, dec},
           {name: 'poly', lineWidth: 3.0, color: 'pink'},
       );
       aladin.addMOC(moc)
   } catch(_) {
       alert('Selection covers a region out of the projection definition domain.');
   }
})

setBaseImageLayer(urlOrHiPSOrFITS)

Change the base layer of the view
Parameters:
Name Type Description
urlOrHiPSOrFITS string | ImageHiPS | ImageFITS Can be:
  • 1. An url that refers to a HiPS.
  • 2. Or it can be a CDS ID that refers to a HiPS. One can found the list of IDs here
  • 3. A ImageHiPS HiPS object created from A.imageHiPS
  • 4. A ImageFITS FITS image object
Source:

setCooGrid(options)

Sets the coordinate grid options for the Aladin Lite view. This method allows you to customize the appearance of the coordinate grid in the Aladin Lite view.
Parameters:
Name Type Description
options Object Options to customize the coordinate grid.
Properties
Name Type Attributes Description
color string <optional>
The color of the coordinate grid.
opacity number <optional>
The opacity of the coordinate grid (value between 0 and 1).
labelSize number <optional>
The size of the coordinate grid labels in pixels.
thickness number <optional>
The thickness of the coordinate grid lines.
enabled boolean <optional>
If true, the coordinate grid is enabled; otherwise, it is disabled.
Source:
Example
// Set the coordinate grid color to red
aladin.setCooGrid({ color: 'red' });

// Enable the coordinate grid
aladin.setCooGrid({ enabled: true });

setFoV(FoV)

Sets the field of view (FoV) of the Aladin instance to the specified angle in degrees.
Parameters:
Name Type Description
FoV number The angle of the field of view in degrees.
Source:
Example
let aladin = A.aladin('#aladin-lite-div');
aladin.setFoV(60);

setFoVRange(minFoV, maxFoV)

Restrict the FoV range between a min and a max value
Parameters:
Name Type Description
minFoV number in degrees when zoom in at max. If undefined, the zooming in is not limited
maxFoV number in degrees when zoom out at max. If undefined, the zooming out is not limited
Source:
Example
let aladin = A.aladin('#aladin-lite-div');
aladin.setFoVRange(30, 60);

setFrame(frame)

Sets the coordinate frame of the Aladin instance to the specified frame.
Parameters:
Name Type Description
frame string The name of the coordinate frame. Possible values: 'j2000d', 'j2000', 'gal', 'icrs'. The given string is case insensitive.
Source:
Example
// Set the coordinate frame to 'J2000'
const aladin = A.aladin('#aladin-lite-div');
aladin.setFrame('J2000');

setImageLayer(urlOrHiPSOrFITS)

Change the base layer of the view It internally calls Aladin.setBaseImageLayer with the url/ImageHiPS/ImageFITS given
Parameters:
Name Type Description
urlOrHiPSOrFITS string | ImageHiPS | ImageFITS Can be:
  • 1. An url that refers to a HiPS.
  • 2. Or it can be a CDS identifier that refers to a HiPS. One can found the list of IDs here
  • 3. A ImageHiPS HiPS object created from A.imageHiPS
  • 4. A ImageFITS FITS image object
Source:

setOverlayImageLayer(urlOrHiPSOrFITS, layeropt)

Add a new HiPS/FITS image layer in the view
Parameters:
Name Type Attributes Default Description
urlOrHiPSOrFITS string | ImageHiPS | ImageFITS Can be:
  • 1. An url that refers to a HiPS.
  • 2. Or it can be a CDS ID that refers to a HiPS. One can found the list of IDs here
  • 3. A ImageHiPS HiPS object created from A.imageHiPS
  • 4. A ImageFITS FITS image object
layer string <optional>
"overlay" A layer name. By default 'overlay' is chosen and it is destined to be plot on top the 'base' layer. If the layer is already present in the view, it will be replaced by the new HiPS/FITS image given here.
Source:

setProjection(projection)

Sets the projection of the Aladin instance to the specified type.
Parameters:
Name Type Description
projection string The type of projection to set. Possible values
"TAN" (Gnomonic projection)
"STG" (Stereographic projection)
"SIN" (Orthographic projection)
"ZEA" (Zenital equal-area projection)
"MER" (Mercator projection)
"AIT" (Hammer-Aitoff projection)
"MOL" (Mollweide projection)
Source:
Example
// Set the projection to 'orthographic'
let aladin = A.aladin('#aladin-lite-div');
aladin.setProjection('SIN');

world2pix(lon, lat, frameopt) → {Array.<number>}

Transform world coordinates to pixel coordinates in the view.
Parameters:
Name Type Attributes Description
lon number Londitude coordinate in degrees.
lat number Latitude coordinate in degrees.
frame CooFrame <optional>
If not specified, the frame used is ICRS
Source:
Throws:
Throws an error if an issue occurs during the transformation.
Type
Error
Returns:
- An array representing the [x, y] coordinates in pixel coordinates in the view.
Type
Array.<number>

(static) createImageFITS(url, nameopt, optionsopt, successopt, erroropt) → {ImageFITS}

Creates a FITS image object
Parameters:
Name Type Attributes Description
url string The url of the fits.
name string <optional>
A human readable name for that fits.
options ImageFITSOptions <optional>
Options for rendering the image
success function <optional>
A success callback
error function <optional>
A success callback
Deprecated:
Source:
Returns:
A FITS image object.
Type
ImageFITS

(static) createImageFITS(url, nameopt, optionsopt, successopt, erroropt) → {ImageFITS}

Parameters:
Name Type Attributes Description
url string The url of the fits.
name string <optional>
A human readable name for that fits.
options ImageFITSOptions <optional>
Options for rendering the image
success function <optional>
A success callback
error function <optional>
A success callback
Deprecated:
  • prefer use A.imageFITS instead Creates a FITS image object
Source:
Returns:
A FITS image object.
Type
ImageFITS

(static) createImageSurvey(id, nameopt, url, cooFrameopt, maxOrderopt, optionsopt) → {ImageHiPS}

Parameters:
Name Type Attributes Description
id string Mandatory unique identifier for the survey.
name string <optional>
A convinient name for the survey, optional
url string Can be:
  • 1. An url that refers to a HiPS.
  • Or it can be a "CDS ID" that refers to a HiPS. One can found the list of IDs here
cooFrame string <optional>
Values accepted: 'equatorial', 'icrs', 'icrsd', 'j2000', 'gal', 'galactic'
maxOrder number <optional>
The maximum HEALPix order of the HiPS, i.e the HEALPix order of the most refined tile images of the HiPS.
options ImageHiPSOptions <optional>
Options describing the survey
Deprecated:
  • Creates and return an image survey (HiPS) object. Please use A.imageHiPS instead for creating a new survey image
Source:
Returns:
A HiPS image object.
Type
ImageHiPS